Ticket #4759: 4 - sci_check_for_modifiers_instead_of_keyboard_events.patch

File 4 - sci_check_for_modifiers_instead_of_keyboard_events.patch, 2.2 KB (added by Templier, 14 years ago)

4 - Remove special handling of numlocks and capslocks key events in SCI (use flags instead)

  • engines/sci/event.cpp

     
    123123                // SDL sends a keydown event if a modifier key is turned on and a keyup event if it's off
    124124                //
    125125                // FIXME: This code is semi-bogus. It only records the modifier key being *pressed*.
    126                 // It does not track correctly whether capslock etc. is active. To do that, we
     126                // It does not track correctly whether scrolllock. is active. To do that, we
    127127                // would have to record the fact that the modifier was pressed in global var,
    128128                // and also watch for Common::EVENT_KEYUP events.
    129129                // But this is still not quite good enough, because not all events might
     
    133133                // for tracking which keys are pressed and which are not...
    134134                if (ev.type == Common::EVENT_KEYDOWN || ev.type == Common::EVENT_KEYUP) {
    135135                        switch (ev.kbd.keycode) {
    136                         case Common::KEYCODE_CAPSLOCK:
    137                                 if (ev.type == Common::EVENT_KEYDOWN) {
    138                                         _modifierStates |= SCI_KEYMOD_CAPSLOCK;
    139                                 } else {
    140                                         _modifierStates &= ~SCI_KEYMOD_CAPSLOCK;
    141                                 }
    142                                 break;
    143                         case Common::KEYCODE_NUMLOCK:
    144                                 if (ev.type == Common::EVENT_KEYDOWN) {
    145                                         _modifierStates |= SCI_KEYMOD_NUMLOCK;
    146                                 } else {
    147                                         _modifierStates &= ~SCI_KEYMOD_NUMLOCK;
    148                                 }
    149                                 break;
    150136                        case Common::KEYCODE_SCROLLOCK:
    151137                                if (ev.type == Common::EVENT_KEYDOWN) {
    152138                                        _modifierStates |= SCI_KEYMOD_SCRLOCK;
     
    164150                    ((modifiers & Common::KBD_ALT) ? SCI_KEYMOD_ALT : 0) |
    165151                    ((modifiers & Common::KBD_CTRL) ? SCI_KEYMOD_CTRL : 0) |
    166152                    ((modifiers & Common::KBD_SHIFT) ? SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT : 0) |
     153                    ((ev.kbd.flags & Common::KBD_NUM) ? SCI_KEYMOD_NUMLOCK : 0) |
     154                    ((ev.kbd.flags & Common::KBD_CAPS) ? SCI_KEYMOD_CAPSLOCK : 0) |
    167155                        _modifierStates;
    168156
    169157                switch (ev.type) {
     
    173161                        input.character = ev.kbd.ascii;
    174162
    175163                        // Debug console
    176                         if (ev.kbd.flags == Common::KBD_CTRL && ev.kbd.keycode == Common::KEYCODE_d) {
     164                        if (ev.kbd.hasFlags(Common::KBD_CTRL) && ev.kbd.keycode == Common::KEYCODE_d) {
    177165                                // Open debug console
    178166                                Console *con = g_sci->getSciDebugger();
    179167                                con->attach();