I'm analysing packets captured from a USB keyboard. I'm looking for a python library or dictionary that will convert the last 8 data bytes or even just the third byte which holds the Usage ID (of a single keypress) to an ASCII code (or to some other useful data structure which lets me quickly extract the character typed).
Here are a few example packets which represent 'g' and '{' keypresses (second one is '[' with Right Shift held down). (Note: only look at the last 8 bytes)
0000 1b 00 40 39 2d ac 89 b6 ff ff 00 00 00 00 09 00 ..@9-...........
0010 01 02 00 01 00 81 01 08 00 00 00 00 00 0a 00 00 ................
0020 00 00 00 ...
0000 1b 00 c0 e8 82 b4 89 b6 ff ff 00 00 00 00 09 00 ................
0010 01 02 00 01 00 81 01 08 00 00 00 00 00 00 00 00 ................
0020 00 00 00 ...
0000 1b 00 40 39 2d ac 89 b6 ff ff 00 00 00 00 09 00 ..@9-...........
0010 01 02 00 01 00 81 01 08 00 00 00 20 00 00 00 00 ........... ....
0020 00 00 00 ...
0000 1b 00 c0 e8 82 b4 89 b6 ff ff 00 00 00 00 09 00 ................
0010 01 02 00 01 00 81 01 08 00 00 00 20 00 2f 00 00 ........... ./..
0020 00 00 00 ...
For more information on the Usage ID, see page 53 of this document.
This question is related, but I'm specifically looking for an easy way to do this in python without having to create my own dictionary. Note that evdev
does not return the correct code.