X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=ppcskel.git;a=blobdiff_plain;f=usb%2Fdrivers%2Fclass%2Fhid.c;h=c8c9dfe1e2d10eb3d93a7f54df2a420e7f2c13fe;hp=fe5a17c2fecfa5e8600a452b1cb2ac8eeb2cae3b;hb=55d57a9ffdc8318dd652b1396f3ce8db6246820f;hpb=8c443e089d9f0202d06e0b5d656fd713b14fc9bc diff --git a/usb/drivers/class/hid.c b/usb/drivers/class/hid.c index fe5a17c..c8c9dfe 100644 --- a/usb/drivers/class/hid.c +++ b/usb/drivers/class/hid.c @@ -24,6 +24,28 @@ struct usb_driver hidkb = { .data = NULL }; +/* + * just using two very simple US layout code translation tables that + * are sufficient for providing a getc() C standard library call; + * the only non-printable character here in this table is ESCAPE which + * has index 0x29 and is zero + */ +unsigned char code_translation_table[2][57] = { + { /* unshifted */ + 0, 0, 0, 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', + '3', '4', '5', '6', '7', '8', '9', '0', '\n', 0, '\r','\t',' ', '-', '=', '[', + ']', '\\','\\',';', '\'','`', ',', '.', '/' + }, + { /* shifted */ + 0, 0, 0, 0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@', + '#', '$', '%', '^', '&', '*', '(', ')', '\n', 0, '\r','\t',' ', '_', '+', '{', + '}', '|', '|', ':', '\"','~', '<', '>', '?' + } +}; + + void usb_hidkb_init() { usb_register_driver(&hidkb); @@ -72,3 +94,10 @@ struct kbrep *usb_hidkb_getChars() { return ret; } +unsigned char usb_hidkb_get_char_from_keycode(u8 keycode, int shifted) +{ + unsigned char result = 0; + if (keycode < 57) + result = code_translation_table[!!shifted][keycode]; + return result; +}