Discussion:
how to interpret /dev/input/event0
David Wu
2010-05-25 10:40:44 UTC
Permalink
I am trying to figure out what the keyboard driver receives in terms of raw
data.
When I do 'cat /dev/input/event0 | hexdump -C' and then press '1', I got

00000000 4b a7 fb 4b e9 93 05 00 04 00 04 00 1e 00 07 00
|K..K............|
00000010 4b a7 fb 4b 13 94 05 00 01 00 02 00 01 00 00 00
|K..K............|
00000020 4b a7 fb 4b 19 94 05 00 00 00 00 00 00 00 00 00
|K..K............|
00000030 4b a7 fb 4b cd 0a 07 00 04 00 04 00 1e 00 07 00
|K..K............|
00000040 4b a7 fb 4b f7 0a 07 00 01 00 02 00 00 00 00 00
|K..K............|
00000050 4b a7 fb 4b fc 0a 07 00 00 00 00 00 00 00 00 00
|K..K............|

event0 maps to my USB keyboard
I know 00000000 to 00000050 is the time stamp. I also know USB HID code for
'1' is 0x1e, However, I am having difficulty figure out the rest of it.
I think the data should relate to the input_event struct in input.h of the
kernel source.

struct input_event {
struct timeval time;
__u16 type;
__u16 code;
__s32 value;
};

Does anyone have more insight on this?
Lionel Widdifield
2010-05-25 19:42:02 UTC
Permalink
Post by David Wu
I am trying to figure out what the keyboard driver receives in terms of raw
data.
When I do 'cat /dev/input/event0 | hexdump -C' and then press '1', I got
00000000 4b a7 fb 4b e9 93 05 00 04 00 04 00 1e 00 07 00
00000010 4b a7 fb 4b 13 94 05 00 01 00 02 00 01 00 00 00
00000020 4b a7 fb 4b 19 94 05 00 00 00 00 00 00 00 00 00
00000030 4b a7 fb 4b cd 0a 07 00 04 00 04 00 1e 00 07 00
00000040 4b a7 fb 4b f7 0a 07 00 01 00 02 00 00 00 00 00
00000050 4b a7 fb 4b fc 0a 07 00 00 00 00 00 00 00 00 00
hexdump Bytecount | time stamp | type,code,value
00000000 | 4b a7 fb 4b e9 93 05 00 | 04 00 04 00 1e 00 07 00
Post by David Wu
event0 maps to my USB keyboard
I know 00000000 to 00000050 is the time stamp. I also know USB HID code for
'1' is 0x1e, However, I am having difficulty figure out the rest of it.
Helps when you know hexdump adds more output to your input
Post by David Wu
I think the data should relate to the input_event struct in input.h of the
kernel source.
struct input_event {
struct timeval time;
__u16 type;
__u16 code;
__s32 value;
};
04 00 04 00 1e 00 07 00

04 00 type u16 == 16bits 2 bytes
04 00 code u16
1e 00 07 00 value s32 4 bytes
--
Lionel Widdifield
pwillis
2010-05-26 04:01:34 UTC
Permalink
Post by David Wu
I am trying to figure out what the keyboard driver receives in terms of raw
data.
When I do 'cat /dev/input/event0 | hexdump -C' and then press '1', I got
00000000 4b a7 fb 4b e9 93 05 00 04 00 04 00 1e 00 07 00
|K..K............|
00000010 4b a7 fb 4b 13 94 05 00 01 00 02 00 01 00 00 00
|K..K............|
00000020 4b a7 fb 4b 19 94 05 00 00 00 00 00 00 00 00 00
|K..K............|
00000030 4b a7 fb 4b cd 0a 07 00 04 00 04 00 1e 00 07 00
|K..K............|
00000040 4b a7 fb 4b f7 0a 07 00 01 00 02 00 00 00 00 00
|K..K............|
00000050 4b a7 fb 4b fc 0a 07 00 00 00 00 00 00 00 00 00
|K..K............|
event0 maps to my USB keyboard
I know 00000000 to 00000050 is the time stamp. I also know USB HID code for
'1' is 0x1e, However, I am having difficulty figure out the rest of it.
I think the data should relate to the input_event struct in input.h of the
kernel source.
00000000 to 00000050 are the byte offset (hex) from the
beginning of the hex dump.
First line starts at zero, then line two at 16, three at 32,
four at 48, line five at 64, .... etc.

4ba7fb4b is the UNIX date in seconds since the epoch (tv_sec). The
next 4 bytes are usec (tv_usec). Then come:

- 2 bytes event type
- 2 bytes code,
- 4 bytes value.

Total record length = sizeof(struct input_event) = 16 bytes.

The system spits out 96 bytes for each keypress/release (state change).
A single state change produces 48 bytes.(3 separate input_events)

See: /usr/include/linux/input.h

You pressed key '1' you got:

01 00 02 00 nn nn nn nn

EV_KEY is event 0x01
KEY_1 is defined as 2


Hope that helps and happy hunting,


Peter
David Wu
2010-05-27 07:27:08 UTC
Permalink
Thnx Guys,

A bif of information, since event type 0x04 is EV_MSC, I think in my case of
USB keyboard, if emits out the HID scan code in the value portion.

Cheers,

David Wu
Post by pwillis
Post by David Wu
I am trying to figure out what the keyboard driver receives in terms of raw
data.
When I do 'cat /dev/input/event0 | hexdump -C' and then press '1', I got
00000000 4b a7 fb 4b e9 93 05 00 04 00 04 00 1e 00 07 00
|K..K............|
00000010 4b a7 fb 4b 13 94 05 00 01 00 02 00 01 00 00 00
|K..K............|
00000020 4b a7 fb 4b 19 94 05 00 00 00 00 00 00 00 00 00
|K..K............|
00000030 4b a7 fb 4b cd 0a 07 00 04 00 04 00 1e 00 07 00
|K..K............|
00000040 4b a7 fb 4b f7 0a 07 00 01 00 02 00 00 00 00 00
|K..K............|
00000050 4b a7 fb 4b fc 0a 07 00 00 00 00 00 00 00 00 00
|K..K............|
event0 maps to my USB keyboard
I know 00000000 to 00000050 is the time stamp. I also know USB HID code for
'1' is 0x1e, However, I am having difficulty figure out the rest of it.
I think the data should relate to the input_event struct in input.h of the
kernel source.
00000000 to 00000050 are the byte offset (hex) from the
beginning of the hex dump.
First line starts at zero, then line two at 16, three at 32,
four at 48, line five at 64, .... etc.
4ba7fb4b is the UNIX date in seconds since the epoch (tv_sec). The
- 2 bytes event type
- 2 bytes code,
- 4 bytes value.
Total record length = sizeof(struct input_event) = 16 bytes.
The system spits out 96 bytes for each keypress/release (state change).
A single state change produces 48 bytes.(3 separate input_events)
See: /usr/include/linux/input.h
01 00 02 00 nn nn nn nn
EV_KEY is event 0x01
KEY_1 is defined as 2
Hope that helps and happy hunting,
Peter
_______________________________________________
Discuss mailing list
http://ladybug.vlug.org/cgi-bin/mailman/listinfo/discuss
pwillis
2010-05-28 03:01:31 UTC
Permalink
Hello,

The EV_MSC is present even without USB keyboard.

These are the events, the device is already defined by
the link in /dev/input/<something>. It isn't telling you what
device because you already know that.

04 00 04 00 1e 00 07 00
EV_MSC MSC_SCAN <NOT REALLY A SCAN CODE....(?)>

0x02 from the EV_KEY event is the scan code for KEY_1 on a
standard PC-AT keyboard.

Even escaped the scan code should start with 0xE0 not 0x1E ...

Peter
Post by David Wu
Thnx Guys,
A bif of information, since event type 0x04 is EV_MSC, I think in my case of
USB keyboard, if emits out the HID scan code in the value portion.
Cheers,
David Wu
Post by pwillis
Post by David Wu
I am trying to figure out what the keyboard driver receives in terms of raw
data.
When I do 'cat /dev/input/event0 | hexdump -C' and then press '1', I got
00000000 4b a7 fb 4b e9 93 05 00 04 00 04 00 1e 00 07 00
|K..K............|
00000010 4b a7 fb 4b 13 94 05 00 01 00 02 00 01 00 00 00
|K..K............|
00000020 4b a7 fb 4b 19 94 05 00 00 00 00 00 00 00 00 00
|K..K............|
00000030 4b a7 fb 4b cd 0a 07 00 04 00 04 00 1e 00 07 00
|K..K............|
00000040 4b a7 fb 4b f7 0a 07 00 01 00 02 00 00 00 00 00
|K..K............|
00000050 4b a7 fb 4b fc 0a 07 00 00 00 00 00 00 00 00 00
|K..K............|
event0 maps to my USB keyboard
I know 00000000 to 00000050 is the time stamp. I also know USB HID code for
'1' is 0x1e, However, I am having difficulty figure out the rest of it.
I think the data should relate to the input_event struct in input.h of the
kernel source.
00000000 to 00000050 are the byte offset (hex) from the
beginning of the hex dump.
First line starts at zero, then line two at 16, three at 32,
four at 48, line five at 64, .... etc.
4ba7fb4b is the UNIX date in seconds since the epoch (tv_sec). The
- 2 bytes event type
- 2 bytes code,
- 4 bytes value.
Total record length = sizeof(struct input_event) = 16 bytes.
The system spits out 96 bytes for each keypress/release (state change).
A single state change produces 48 bytes.(3 separate input_events)
See: /usr/include/linux/input.h
01 00 02 00 nn nn nn nn
EV_KEY is event 0x01
KEY_1 is defined as 2
Hope that helps and happy hunting,
Peter
_______________________________________________
Discuss mailing list
http://ladybug.vlug.org/cgi-bin/mailman/listinfo/discuss
_______________________________________________
Discuss mailing list
http://ladybug.vlug.org/cgi-bin/mailman/listinfo/discuss
Loading...