diff options
author | José Pekkarinen <jose.pekkarinen@nokia.com> | 2016-05-18 13:18:31 +0300 |
---|---|---|
committer | José Pekkarinen <jose.pekkarinen@nokia.com> | 2016-05-18 13:42:15 +0300 |
commit | 437fd90c0250dee670290f9b714253671a990160 (patch) | |
tree | b871786c360704244a07411c69fb58da9ead4a06 /qemu/roms/SLOF/lib/libusb/usb-hid.c | |
parent | 5bbd6fe9b8bab2a93e548c5a53b032d1939eec05 (diff) |
These changes are the raw update to qemu-2.6.
Collission happened in the following patches:
migration: do cleanup operation after completion(738df5b9)
Bug fix.(1750c932f86)
kvmclock: add a new function to update env->tsc.(b52baab2)
The code provided by the patches was already in the upstreamed
version.
Change-Id: I3cc11841a6a76ae20887b2e245710199e1ea7f9a
Signed-off-by: José Pekkarinen <jose.pekkarinen@nokia.com>
Diffstat (limited to 'qemu/roms/SLOF/lib/libusb/usb-hid.c')
-rw-r--r-- | qemu/roms/SLOF/lib/libusb/usb-hid.c | 85 |
1 files changed, 50 insertions, 35 deletions
diff --git a/qemu/roms/SLOF/lib/libusb/usb-hid.c b/qemu/roms/SLOF/lib/libusb/usb-hid.c index f0cab8a69..ac6616aba 100644 --- a/qemu/roms/SLOF/lib/libusb/usb-hid.c +++ b/qemu/roms/SLOF/lib/libusb/usb-hid.c @@ -28,6 +28,10 @@ #define HID_REQ_SET_IDLE 0x0A #define HID_REQ_SET_PROTOCOL 0x0B +//key position for latin letters +#define KEYP_LATIN_A 4 +#define KEYP_LATIN_Z 29 + //#define KEY_DEBUG /* HID SPEC - 7.2.6 Set_Protocol Request */ @@ -83,6 +87,8 @@ uint8_t set_leds; const uint8_t *key_std = NULL; const uint8_t *key_std_shift = NULL; +uint8_t ctrl; /* modifiers */ + /** * read character from Keyboard-Buffer * @@ -111,6 +117,16 @@ static void write_key(uint8_t key) } /** + * Checks if keypos is a latin key + * @param keypos + * @return - + */ +static bool is_latin(uint8_t keypos) +{ + return keypos >= KEYP_LATIN_A && keypos <= KEYP_LATIN_Z; +} + +/** * Convert keyboard usage-ID to ANSI-Code * * @param Ctrl=Modifier Byte @@ -120,22 +136,24 @@ static void write_key(uint8_t key) static void get_char(uint8_t ctrl, uint8_t keypos) { uint8_t ch; + bool caps = false; #ifdef KEY_DEBUG printf("pos %02X\n", keypos); #endif if (set_leds & LED_CAPS_LOCK) /* is CAPS Lock set ? */ - ctrl |= MODIFIER_SHIFT; /* simulate shift */ + caps = true; - if (ctrl == 0) { + /* caps is a shift only for latin chars */ + if ((!caps && ctrl == 0) || (caps && !is_latin(keypos))) { ch = key_std[keypos]; if (ch != 0) write_key(ch); return; } - if (ctrl & MODIFIER_SHIFT) { + if ((ctrl & MODIFIER_SHIFT) || caps) { ch = key_std_shift[keypos]; if (ch != 0) write_key(ch); @@ -187,36 +205,38 @@ static void check_key_code(uint8_t *buf) set_leds ^= LED_CAPS_LOCK; break; + case 0x36: /*Shift pressed*/ + ctrl |= MODIFIER_SHIFT; + break; + case 0xb6: /*Shift unpressed*/ + ctrl &= ~MODIFIER_SHIFT; + break; case 0x3a: /* F1 */ write_key(0x1b); write_key(0x5b); - write_key(0x31); - write_key(0x31); - write_key(0x7e); + write_key(0x4f); + write_key(0x50); break; case 0x3b: /* F2 */ write_key(0x1b); write_key(0x5b); - write_key(0x31); - write_key(0x32); - write_key(0x7e); + write_key(0x4f); + write_key(0x51); break; case 0x3c: write_key(0x1b); /* F3 */ write_key(0x5b); - write_key(0x31); - write_key(0x33); - write_key(0x7e); + write_key(0x4f); + write_key(0x52); break; case 0x3d: write_key(0x1b); /* F4 */ write_key(0x5b); - write_key(0x31); - write_key(0x34); - write_key(0x7e); + write_key(0x4f); + write_key(0x53); break; case 0x3e: @@ -254,7 +274,7 @@ static void check_key_code(uint8_t *buf) case 0x42: write_key(0x1b); /* F9 */ write_key(0x5b); - write_key(0x31); + write_key(0x32); write_key(0x30); write_key(0x7e); break; @@ -262,7 +282,7 @@ static void check_key_code(uint8_t *buf) case 0x43: write_key(0x1b); /* F10 */ write_key(0x5b); - write_key(0x31); + write_key(0x32); write_key(0x31); write_key(0x7e); break; @@ -270,7 +290,7 @@ static void check_key_code(uint8_t *buf) case 0x44: write_key(0x1b); /* F11 */ write_key(0x5b); - write_key(0x31); + write_key(0x32); write_key(0x33); write_key(0x7e); break; @@ -278,7 +298,7 @@ static void check_key_code(uint8_t *buf) case 0x45: write_key(0x1b); /* F12 */ write_key(0x5b); - write_key(0x31); + write_key(0x32); write_key(0x34); write_key(0x7e); break; @@ -290,36 +310,34 @@ static void check_key_code(uint8_t *buf) case 0x49: write_key(0x1b); /* INS */ write_key(0x5b); - write_key(0x31); + write_key(0x32); write_key(0x7e); break; case 0x4a: write_key(0x1b); /* HOME */ - write_key(0x5b); - write_key(0x32); - write_key(0x7e); + write_key(0x4f); + write_key(0x48); break; case 0x4b: write_key(0x1b); /* PgUp */ write_key(0x5b); - write_key(0x33); + write_key(0x35); write_key(0x7e); break; case 0x4c: write_key(0x1b); /* DEL */ write_key(0x5b); - write_key(0x34); + write_key(0x33); write_key(0x7e); break; case 0x4d: write_key(0x1b); /* END */ - write_key(0x5b); - write_key(0x35); - write_key(0x7e); + write_key(0x4f); + write_key(0x46); break; case 0x4e: @@ -443,11 +461,8 @@ unsigned char usb_key_available(void *dev) unsigned char usb_read_keyb(void *vdev) { - if (!vdev) - return false; - - while (usb_poll_key(vdev)) { - /* loop for all pending keys */ - } - return read_key(); + if (usb_key_available(vdev)) + return read_key(); + else + return 0; } |