Hi, I need to develop a custom usb keyboard driver for my c++ program. I need to read data from keyboard and print it on the screen. The program will look like a simple text editor (vi). I was trying to 'cat' data from /dev/input/event0, but returns only garbage, there's no pattern for the received bytes. Have anyone any idea of how to read data from a usb keyboard? Is there any protocol to do that? Thanks in advance.
custom usb keyboard driver
kernel/Documentation/input/input.txt chapter 5: 5. Event interface ~~~~~~~~~~~~~~~~~~ Should you want to add event device support into any application (X, gpm, svgalib ...) I <vojtech@ucw.cz> will be happy to provide you any help I can. Here goes a description of the current state of things, which is going to be extended, but not changed incompatibly as time goes: You can use blocking and nonblocking reads, also select() on the /dev/input/eventX devices, and you'll always get a whole number of input events on a read. Their layout is: struct input_event { struct timeval time; unsigned short type; unsigned short code; unsigned int value; }; 'time' is the timestamp, it returns the time at which the event happened. Type is for example EV_REL for relative moment, EV_KEY for a keypress or release. More types are defined in include/linux/input.h. 'code' is event code, for example REL_X or KEY_BACKSPACE, again a complete list is in include/linux/input.h. 'value' is the value the event carries. Either a relative change for EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for release, 1 for keypress and 2 for autorepeat.
Hi open-nandra, Thanks for your response! It's everything on the kernel documentation, unfortunately I never read it... :P I'll do some tests and later I'll post the results. Thanks again.