Mario Mastrodicasa
|
devi-hid and /dev/devi/keyboard0
|
Mario Mastrodicasa
02/27/2009 4:11 PM
post23143
|
devi-hid and /dev/devi/keyboard0
I hope this is the right place.
I have written this simple code in order to understand what I am able to capture from /dev/devi/keyboard0 using devi-hid
as a resource manager.
I have launched devi-hid as:
/usr/photon/bin/devi-hid -rP kbd keyboard /usr/photon/keyboard/it_IT_102.kdef
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/dcmd_input.h>
#include <devctl.h>
#include <string.h>
int main(int argc, char *argv[]) {
std::cout << "keyboard test data_len:"<< sizeof(struct _keyboard_packet) << std::endl;
int keyFD = open("/dev/devi/keyboard0", O_RDWR | O_NDELAY);
struct _keyboard_packet buf;
int index = 0, n;
while (1)
{
if ((n = read(keyFD, &buf, sizeof(buf))) > 0)
{
index++;
printf("KEY -> %d: char:%d modifiers:%x flags:%x key_cap:%x %c key_sym:%x %c key_scan:%x %c\n", index, n, buf.data
.modifiers, buf.data.flags, buf.data.key_cap, buf.data.key_cap, buf.data.key_sym, buf.data.key_sym, buf.data.key_scan,
buf.data.key_scan);
usleep(100000);
}
}
return EXIT_SUCCESS;
}
I have tried some tests but I cannot understand some things.
When I press a key I can read an entire "struct _keyboard_packet" from the fd. When release I receive another packet and
the information seems strange.
I cannot understand how interpret, in the correct manner, the field in the structure.
Reading the documenation I have found something in the photon KeyEvent, but, according to the documentation and seeing
the output of the test program, the means of modifiers and flags must be interpret in the opposite way.
When I press and release a key two event are produced; the output of the consecutive pressure of 'a' and 'shift + 'a' is
:
KEY -> 1: char:28 modifiers:7fc6d6c flags:0 key_cap:e1 á key_sym:61 a key_scan:61 a
KEY -> 2: char:28 modifiers:7fc6d6c flags:0 key_cap:1a0 key_sym:61 a key_scan:94 ”
KEY -> 3: char:28 modifiers:7fc6d6c flags:1 key_cap:e1 á key_sym:f0e2 â key_scan:f0e2 â
KEY -> 4: char:28 modifiers:7fc6d6c flags:1 key_cap:e1 á key_sym:61 a key_scan:41 A
KEY -> 5: char:28 modifiers:7fc6d6c flags:1 key_cap:1a0 key_sym:61 a key_scan:94 ”
KEY -> 6: char:28 modifiers:7fc6d6c flags:0 key_cap:1a0 key_sym:f0e2 â key_scan:bc ¼
Each row is produced on every key press/release event.
I don't understand what means the value of key_cap? It is associated, using some undocumented flag, to the kind of event
?
Key_sym is always the hardware button that have generated the event, but key_scan what means? In some situation (row 4)
is the right expected character, but the other row?
'flags' is a bitmask that tracks modifier button, while 'modifiers' is always the same, what means it's value?
Where I can find when a button is pressed or released? I must track all event in the past and make a sort of match
algorithm?
Thanks.
Mario.
|
|
|
Joel Pilon(deleted)
|
Re: devi-hid and /dev/devi/keyboard0
|
Joel Pilon(deleted)
02/27/2009 4:26 PM
post23144
|
Re: devi-hid and /dev/devi/keyboard0
The 6.4.0 version of devi-hid running in resource manager mode does not
provide the correct data from the /dev/devi/keyboardX interface.
A fixed version of devi-hid will be included in 6.4.1, should you want a
patch sooner you may need to contact QNX Sales and/or Support to get a
patch.
Cheers,
Joel
On Fri, 2009-02-27 at 16:11 -0500, Mario Mastrodicasa wrote:
> I hope this is the right place.
>
> I have written this simple code in order to understand what I am able to capture from /dev/devi/keyboard0 using devi-
hid as a resource manager.
> I have launched devi-hid as:
> /usr/photon/bin/devi-hid -rP kbd keyboard /usr/photon/keyboard/it_IT_102.kdef
>
> #include <cstdlib>
> #include <iostream>
> #include <stdio.h>
> #include <termios.h>
> #include <unistd.h>
> #include <fcntl.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <sys/dcmd_input.h>
> #include <devctl.h>
> #include <string.h>
>
> int main(int argc, char *argv[]) {
> std::cout << "keyboard test data_len:"<< sizeof(struct _keyboard_packet) << std::endl;
>
> int keyFD = open("/dev/devi/keyboard0", O_RDWR | O_NDELAY);
>
> struct _keyboard_packet buf;
> int index = 0, n;
>
> while (1)
> {
> if ((n = read(keyFD, &buf, sizeof(buf))) > 0)
> {
> index++;
> printf("KEY -> %d: char:%d modifiers:%x flags:%x key_cap:%x %c key_sym:%x %c key_scan:%x %c\n", index, n, buf.
data.modifiers, buf.data.flags, buf.data.key_cap, buf.data.key_cap, buf.data.key_sym, buf.data.key_sym, buf.data.
key_scan, buf.data.key_scan);
> usleep(100000);
> }
> }
>
>
> return EXIT_SUCCESS;
> }
>
> I have tried some tests but I cannot understand some things.
> When I press a key I can read an entire "struct _keyboard_packet" from the fd. When release I receive another packet
and the information seems strange.
> I cannot understand how interpret, in the correct manner, the field in the structure.
>
> Reading the documenation I have found something in the photon KeyEvent, but, according to the documentation and seeing
the output of the test program, the means of modifiers and flags must be interpret in the opposite way.
> When I press and release a key two event are produced; the output of the consecutive pressure of 'a' and 'shift + 'a'
is:
> KEY -> 1: char:28 modifiers:7fc6d6c flags:0 key_cap:e1 á key_sym:61 a key_scan:61 a
> KEY -> 2: char:28 modifiers:7fc6d6c flags:0 key_cap:1a0 key_sym:61 a key_scan:94 ”
> KEY -> 3: char:28 modifiers:7fc6d6c flags:1 key_cap:e1 á key_sym:f0e2 â key_scan:f0e2 â
> KEY -> 4: char:28 modifiers:7fc6d6c flags:1 key_cap:e1 á key_sym:61 a key_scan:41 A
> KEY -> 5: char:28 modifiers:7fc6d6c flags:1 key_cap:1a0 key_sym:61 a key_scan:94 ”
> KEY -> 6: char:28 modifiers:7fc6d6c flags:0 key_cap:1a0 key_sym:f0e2 â key_scan:bc ¼
>
> Each row is produced on every key press/release event.
> I don't understand what means the value of key_cap? It is associated, using some undocumented flag, to the kind of
event?
> Key_sym is always the hardware button that have generated the event, but key_scan what means? In some situation (row
4) is the right expected character, but the other row?
> 'flags' is a bitmask that tracks modifier button, while 'modifiers' is always the same, what means it's value?
> Where I can find when a button is pressed or released? I must track all event in the past and make a sort of match
algorithm?
>
> Thanks.
>
> Mario.
>
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post23143
|
|
|
Mario Mastrodicasa
|
Re: devi-hid and /dev/devi/keyboard0
|
Mario Mastrodicasa
03/02/2009 10:20 AM
post23202
|
Re: devi-hid and /dev/devi/keyboard0
OK, the server is broken when run as a resource manager. Waiting for the new version I would to know how I can
understand from struct _keyboard_packet:
1) when and which button is released;
2) when and which button is making a repeat;
This information can be read from the same field where I can understand if key_sym, key_cap, key_scan are valid?
Thanks,
Mario.
|
|
|
Joel Pilon(deleted)
|
Re: devi-hid and /dev/devi/keyboard0
|
Joel Pilon(deleted)
03/02/2009 10:27 AM
post23206
|
Re: devi-hid and /dev/devi/keyboard0
You can take a look at <sys/keycodes.h>, comments in the header file
tell you which fields the bit values are set for.
Cheers,
Joel
On Mon, 2009-03-02 at 10:20 -0500, Mario Mastrodicasa wrote:
> OK, the server is broken when run as a resource manager. Waiting for the new version I would to know how I can
understand from struct _keyboard_packet:
> 1) when and which button is released;
> 2) when and which button is making a repeat;
>
> This information can be read from the same field where I can understand if key_sym, key_cap, key_scan are valid?
>
> Thanks,
> Mario.
>
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post23202
>
|
|
|
Mario Mastrodicasa
|
Re: devi-hid and /dev/devi/keyboard0
|
Mario Mastrodicasa
03/02/2009 3:46 PM
post23266
|
Re: devi-hid and /dev/devi/keyboard0
I have used the value of photon/PkKeyDef.h, but they are the same.
So now my question is if devi-hid is able to manage extended functional key (F13...F20) present in some industrial PC.
They aren't mapped in sys/keycodes.h, but present in photon/PkKeyDef.h.
|
|
|
Augie Mattheiss
|
Re: devi-hid and /dev/devi/keyboard0
|
Augie Mattheiss
03/22/2009 9:44 AM
post24956
|
Re: devi-hid and /dev/devi/keyboard0
I tried this as I would like to poll my keyboard also. I am using 6.4 on an x86 with a PS/2 keyboard (/dev/kb) and I
don't see any change in the returned data with key presses. The supplied example of setting the Num Lock, Scroll Lock,
etc, and this works fine.
Should I expect Mario's example code to work in my environment or is there something else I can do to scan for keyboard
key presses?
Thanks,
Augie Mattheiss
|
|
|
|