VirtualBox

Changeset 24396 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 5, 2009 4:09:32 PM (15 years ago)
Author:
vboxsync
Message:

DevPS2: Added qemu code to emulate turning off scancode translation in controller (S8 keyboard fix); from http://git.savannah.gnu.org/cgit/qemu.git/tree/hw/ps2.c#n502

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Input/DevPS2.cpp

    r23690 r24396  
    103103#define KBD_CMD_SET_LEDS        0xED    /* Set keyboard leds */
    104104#define KBD_CMD_ECHO            0xEE
     105#define KBD_CMD_SCANCODE        0xF0    /* Get/set scancode set */
    105106#define KBD_CMD_GET_ID          0xF2    /* get keyboard ID */
    106107#define KBD_CMD_SET_RATE        0xF3    /* Set typematic rate */
     
    193194    int32_t kbd_write_cmd;
    194195    int32_t scan_enabled;
     196    int32_t translate;
     197    int32_t scancode_set;   /* 1=XT, 2=AT, 3=PS/2 */
    195198    /* mouse state */
    196199    int32_t mouse_write_cmd;
     
    249252} KBDState;
    250253
     254/* Table to convert from PC scancodes to raw scancodes.  */
     255static 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
    251266#ifndef VBOX_DEVICE_STRUCT_TESTCASE
    252267
     
    332347{
    333348    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    }
    334357    kbd_queue(s, keycode, 0);
    335358}
     
    520543{
    521544    s->scan_enabled = 1;
     545    s->scancode_set = 2;
    522546}
    523547
     
    546570            kbd_queue(s, KBD_REPLY_ACK, 0);
    547571            break;
     572        case KBD_CMD_SCANCODE:
    548573        case KBD_CMD_SET_LEDS:
    549574        case KBD_CMD_SET_RATE:
     
    571596        }
    572597        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
    573615    case KBD_CMD_SET_LEDS:
    574616        {
     
    887929    case KBD_CCMD_WRITE_MODE:
    888930        s->mode = val;
     931        s->translate = (s->mode & KBD_MODE_KCC) == KBD_MODE_KCC;
    889932        kbd_update_irq(s);
    890933        break;
     
    938981    s->write_cmd = 0;
    939982    s->scan_enabled = 0;
     983    s->translate = 0;
     984    s->scancode_set = 2;
    940985    s->mouse_status = 0;
    941986    s->mouse_resolution = 0;
     
    9891034    qemu_put_8s(f, &s->mouse_buttons);
    9901035
     1036    /* XXX: s->scancode_set isn't being saved, but we only really support set 2,
     1037     * so no real harm done.
     1038     */
     1039
    9911040    /*
    9921041     * We have to save the queues too.
     
    10521101    s->mouse_event_queue.rptr = 0;
    10531102    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(). */
    10541107
    10551108    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette