Changeset 24396 in vbox for trunk/src/VBox
- Timestamp:
- Nov 5, 2009 4:09:32 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/DevPS2.cpp
r23690 r24396 103 103 #define KBD_CMD_SET_LEDS 0xED /* Set keyboard leds */ 104 104 #define KBD_CMD_ECHO 0xEE 105 #define KBD_CMD_SCANCODE 0xF0 /* Get/set scancode set */ 105 106 #define KBD_CMD_GET_ID 0xF2 /* get keyboard ID */ 106 107 #define KBD_CMD_SET_RATE 0xF3 /* Set typematic rate */ … … 193 194 int32_t kbd_write_cmd; 194 195 int32_t scan_enabled; 196 int32_t translate; 197 int32_t scancode_set; /* 1=XT, 2=AT, 3=PS/2 */ 195 198 /* mouse state */ 196 199 int32_t mouse_write_cmd; … … 249 252 } KBDState; 250 253 254 /* Table to convert from PC scancodes to raw scancodes. */ 255 static const unsigned char ps2_raw_keycode[128] = { 256 0,118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85,102, 13, 257 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27, 258 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42, 259 50, 49, 58, 65, 73, 74, 89,124, 17, 41, 88, 5, 6, 4, 12, 3, 260 11, 2, 10, 1, 9,119,126,108,117,125,123,107,115,116,121,105, 261 114,122,112,113,127, 96, 97,120, 7, 15, 23, 31, 39, 47, 55, 63, 262 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87,111, 263 19, 25, 57, 81, 83, 92, 95, 98, 99,100,101,103,104,106,109,110 264 }; 265 251 266 #ifndef VBOX_DEVICE_STRUCT_TESTCASE 252 267 … … 332 347 { 333 348 KBDState *s = (KBDState*)opaque; 349 350 /* XXX: add support for scancode sets 1 and 3 */ 351 if (!s->translate && keycode < 0xe0 && s->scancode_set == 2) 352 { 353 if (keycode & 0x80) 354 kbd_queue(s, 0xf0, 0); 355 keycode = ps2_raw_keycode[keycode & 0x7f]; 356 } 334 357 kbd_queue(s, keycode, 0); 335 358 } … … 520 543 { 521 544 s->scan_enabled = 1; 545 s->scancode_set = 2; 522 546 } 523 547 … … 546 570 kbd_queue(s, KBD_REPLY_ACK, 0); 547 571 break; 572 case KBD_CMD_SCANCODE: 548 573 case KBD_CMD_SET_LEDS: 549 574 case KBD_CMD_SET_RATE: … … 571 596 } 572 597 break; 598 case KBD_CMD_SCANCODE: 599 #ifdef IN_RING3 600 if (val == 0) { 601 if (s->scancode_set == 1) 602 pc_kbd_put_keycode(s, 0x43); 603 else if (s->scancode_set == 2) 604 pc_kbd_put_keycode(s, 0x41); 605 else if (s->scancode_set == 3) 606 pc_kbd_put_keycode(s, 0x3f); 607 } else { 608 if (val >= 1 && val <= 3) 609 s->scancode_set = val; 610 kbd_queue(s, KBD_REPLY_ACK, 0); 611 } 612 #else 613 return VINF_IOM_HC_IOPORT_WRITE; 614 #endif 573 615 case KBD_CMD_SET_LEDS: 574 616 { … … 887 929 case KBD_CCMD_WRITE_MODE: 888 930 s->mode = val; 931 s->translate = (s->mode & KBD_MODE_KCC) == KBD_MODE_KCC; 889 932 kbd_update_irq(s); 890 933 break; … … 938 981 s->write_cmd = 0; 939 982 s->scan_enabled = 0; 983 s->translate = 0; 984 s->scancode_set = 2; 940 985 s->mouse_status = 0; 941 986 s->mouse_resolution = 0; … … 989 1034 qemu_put_8s(f, &s->mouse_buttons); 990 1035 1036 /* XXX: s->scancode_set isn't being saved, but we only really support set 2, 1037 * so no real harm done. 1038 */ 1039 991 1040 /* 992 1041 * We have to save the queues too. … … 1052 1101 s->mouse_event_queue.rptr = 0; 1053 1102 s->mouse_event_queue.wptr = 0; 1103 1104 /* Determine the translation state. */ 1105 s->translate = (s->mode & KBD_MODE_KCC) == KBD_MODE_KCC; 1106 s->scancode_set = 2; /* XXX: See comment in kbd_save(). */ 1054 1107 1055 1108 /*
Note:
See TracChangeset
for help on using the changeset viewer.