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 , 15 years ago) |
---|
-
engines/sci/event.cpp
123 123 // SDL sends a keydown event if a modifier key is turned on and a keyup event if it's off 124 124 // 125 125 // 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, we126 // It does not track correctly whether scrolllock. is active. To do that, we 127 127 // would have to record the fact that the modifier was pressed in global var, 128 128 // and also watch for Common::EVENT_KEYUP events. 129 129 // But this is still not quite good enough, because not all events might … … 133 133 // for tracking which keys are pressed and which are not... 134 134 if (ev.type == Common::EVENT_KEYDOWN || ev.type == Common::EVENT_KEYUP) { 135 135 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;150 136 case Common::KEYCODE_SCROLLOCK: 151 137 if (ev.type == Common::EVENT_KEYDOWN) { 152 138 _modifierStates |= SCI_KEYMOD_SCRLOCK; … … 164 150 ((modifiers & Common::KBD_ALT) ? SCI_KEYMOD_ALT : 0) | 165 151 ((modifiers & Common::KBD_CTRL) ? SCI_KEYMOD_CTRL : 0) | 166 152 ((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) | 167 155 _modifierStates; 168 156 169 157 switch (ev.type) { … … 173 161 input.character = ev.kbd.ascii; 174 162 175 163 // 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) { 177 165 // Open debug console 178 166 Console *con = g_sci->getSciDebugger(); 179 167 con->attach();