Ticket #4759: 5_-_osystem_add_support_for_scroll_lock_sci_remove_hack (SVN).patch

File 5_-_osystem_add_support_for_scroll_lock_sci_remove_hack (SVN).patch, 3.3 KB (added by Templier, 14 years ago)

5 - Add support for Scroll lock as a modifier key and remove hack in SCI event code (SVN patch)

  • backends/platform/sdl/events.cpp

    bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) {  
    234234
    235235        SDLModToOSystemKeyFlags(SDL_GetModState(), event);
    236236
     237        // Handle scroll lock as a key modifier
     238        if (ev.key.keysym.sym == SDLK_SCROLLOCK)
     239                _scrollLock = !_scrollLock;
     240
     241        if (_scrollLock)
     242                event.kbd.flags |= Common::KBD_SCRL;
     243
    237244        // Alt-Return and Alt-Enter toggle full screen mode
    238245        if (event.kbd.hasFlags(Common::KBD_ALT) && (ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_KP_ENTER)) {
    239246                beginGFXTransaction();
    bool OSystem_SDL::handleKeyUp(SDL_Event &ev, Common::Event &event) {  
    326333
    327334        // Ctrl-Alt-<key> will change the GFX mode
    328335        SDLModToOSystemKeyFlags(SDL_GetModState(), event);
     336
     337        // Set the scroll lock sticky flag
     338        if (_scrollLock)
     339                event.kbd.flags |= Common::KBD_SCRL;
     340
    329341        if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
    330342                // Swallow these key up events
    331343                return false;
  • backends/platform/sdl/sdl.cpp

    OSystem_SDL::OSystem_SDL()  
    232232        _overlayscreen(0), _tmpscreen2(0),
    233233        _samplesPerSec(0),
    234234        _cdrom(0), _scalerProc(0), _modeChanged(false), _screenChangeCount(0), _dirtyChecksums(0),
     235        _scrollLock(false),
    235236        _mouseVisible(false), _mouseNeedsRedraw(false), _mouseData(0), _mouseSurface(0),
    236237        _mouseOrigSurface(0), _cursorTargetScale(1), _cursorPaletteDisabled(true),
    237238        _joystick(0),
  • engines/sci/event.cpp

    sciEvent SciEvent::getFromScummVM() {  
    120120                int modifiers = em->getModifierState();
    121121
    122122                // We add the modifier key status to buckybits
    123                 // SDL sends a keydown event if a modifier key is turned on and a keyup event if it's off
    124                 //
    125                 // FIXME: This code is semi-bogus. It only records the modifier key being *pressed*.
    126                 // It does not track correctly whether scrolllock. is active. To do that, we
    127                 // would have to record the fact that the modifier was pressed in global var,
    128                 // and also watch for Common::EVENT_KEYUP events.
    129                 // But this is still not quite good enough, because not all events might
    130                 // pass through here (e.g. the GUI might be running with its own event loop).
    131                 //
    132                 // The best solution likely would be to add code to the EventManager class
    133                 // for tracking which keys are pressed and which are not...
    134                 if (ev.type == Common::EVENT_KEYDOWN || ev.type == Common::EVENT_KEYUP) {
    135                         switch (ev.kbd.keycode) {
    136                         case Common::KEYCODE_SCROLLOCK:
    137                                 if (ev.type == Common::EVENT_KEYDOWN) {
    138                                         _modifierStates |= SCI_KEYMOD_SCRLOCK;
    139                                 } else {
    140                                         _modifierStates &= ~SCI_KEYMOD_SCRLOCK;
    141                                 }
    142                                 break;
    143                         default:
    144                                 break;
    145                         }
    146                 }
    147123                //TODO: SCI_EVM_INSERT
    148124
    149125                input.modifiers =
    sciEvent SciEvent::getFromScummVM() {  
    152128                    ((modifiers & Common::KBD_SHIFT) ? SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT : 0) |
    153129                    ((ev.kbd.flags & Common::KBD_NUM) ? SCI_KEYMOD_NUMLOCK : 0) |
    154130                    ((ev.kbd.flags & Common::KBD_CAPS) ? SCI_KEYMOD_CAPSLOCK : 0) |
     131                        ((ev.kbd.flags & Common::KBD_SCRL) ? SCI_KEYMOD_SCRLOCK : 0) |
    155132                        _modifierStates;
    156133
    157134                switch (ev.type) {