diff --git a/src/common/StellaKeys.hxx b/src/common/StellaKeys.hxx index b798265a4..0f49bb92c 100644 --- a/src/common/StellaKeys.hxx +++ b/src/common/StellaKeys.hxx @@ -35,7 +35,6 @@ */ // This comes directly from SDL_scancode.h - typedef enum { KBDK_UNKNOWN = 0, @@ -392,8 +391,26 @@ typedef enum for array bounds */ } StellaKey; -// Just pass SDLMod directly as int (placeholder for now) -// The underlying code doesn't need to know how it's implemented -typedef SDL_Keymod StellaMod; +// This comes directly from SDL_keycode.h +typedef enum +{ + KBDM_NONE = 0x0000, + KBDM_LSHIFT = 0x0001, + KBDM_RSHIFT = 0x0002, + KBDM_LCTRL = 0x0040, + KBDM_RCTRL = 0x0080, + KBDM_LALT = 0x0100, + KBDM_RALT = 0x0200, + KBDM_LGUI = 0x0400, + KBDM_RGUI = 0x0800, + KBDM_NUM = 0x1000, + KBDM_CAPS = 0x2000, + KBDM_MODE = 0x4000, + KBDM_RESERVED = 0x8000, + KBDM_CTRL = (KBDM_LCTRL|KBDM_RCTRL), + KBDM_SHIFT = (KBDM_LSHIFT|KBDM_RSHIFT), + KBDM_ALT = (KBDM_LALT|KBDM_RALT), + KBDM_GUI = (KBDM_LGUI|KBDM_RGUI) +} StellaMod; #endif /* StellaKeys */ diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index a32d4dae7..eafb54c68 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -89,8 +89,8 @@ void DebuggerDialog::loadConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::handleKeyDown(StellaKey key, StellaMod mod) { - bool handled = instance().eventHandler().kbdAlt(mod); - if(handled) + bool alt = instance().eventHandler().kbdAlt(mod); + if(alt) { switch(key) { @@ -110,12 +110,10 @@ void DebuggerDialog::handleKeyDown(StellaKey key, StellaMod mod) doRewind(); break; default: - handled = false; break; } } - if(!handled) - Dialog::handleKeyDown(key, mod); + Dialog::handleKeyDown(key, mod); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index 7036765c1..9302e9aac 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -42,7 +42,8 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font, CommandSender(boss), _makeDirty(false), _firstTime(true), - _exitedEarly(false) + _exitedEarly(false), + _lastModPressed(KBDM_NONE) { _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANTS_TAB | WIDGET_WANTS_RAWDATA; @@ -139,6 +140,11 @@ void PromptWidget::printPrompt() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool PromptWidget::handleText(char text) { + // FIXME - convert this class to inherit from EditableWidget + // Huge hack to test if ALT key was pressed in the last handleKeyDown call + if(instance().eventHandler().kbdAlt(_lastModPressed)) + return false; + for(int i = _promptEndPos - 1; i >= _currentPos; i--) buffer(i + 1) = buffer(i); _promptEndPos++; @@ -151,6 +157,11 @@ bool PromptWidget::handleText(char text) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod) { + // Ignore all alt-mod keys + _lastModPressed = mod; + if(instance().eventHandler().kbdAlt(mod)) + return true; + bool handled = true; bool dirty = false; @@ -419,6 +430,7 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod) } else if (instance().eventHandler().kbdAlt(mod)) { + // Placeholder only - this will never be reached } else handled = false; diff --git a/src/debugger/gui/PromptWidget.hxx b/src/debugger/gui/PromptWidget.hxx index 0a8f741dc..8f97777b5 100644 --- a/src/debugger/gui/PromptWidget.hxx +++ b/src/debugger/gui/PromptWidget.hxx @@ -119,6 +119,8 @@ class PromptWidget : public Widget, public CommandSender bool _firstTime; bool _exitedEarly; + StellaMod _lastModPressed; + int compareHistory(const char *histLine); }; diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 25701ab1c..ac95122cc 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -421,7 +421,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state) break; case KBDK_7: // Alt-7 changes scanline intensity for NTSC filtering - if(mod & KMOD_SHIFT) + if(mod & KBDM_SHIFT) myOSystem.frameBuffer().tiaSurface().setScanlineIntensity(-5); else myOSystem.frameBuffer().tiaSurface().setScanlineIntensity(+5); @@ -434,7 +434,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state) case KBDK_9: // Alt-9 selects various custom adjustables for NTSC filtering if(myOSystem.frameBuffer().tiaSurface().ntscEnabled()) { - if(mod & KMOD_SHIFT) + if(mod & KBDM_SHIFT) myOSystem.frameBuffer().showMessage( myOSystem.frameBuffer().tiaSurface().ntsc().setPreviousAdjustable()); else @@ -446,7 +446,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state) case KBDK_0: // Alt-0 changes custom adjustables for NTSC filtering if(myOSystem.frameBuffer().tiaSurface().ntscEnabled()) { - if(mod & KMOD_SHIFT) + if(mod & KBDM_SHIFT) myOSystem.frameBuffer().showMessage( myOSystem.frameBuffer().tiaSurface().ntsc().decreaseAdjustable()); else @@ -456,42 +456,42 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state) break; case KBDK_Z: - if(mod & KMOD_SHIFT) + if(mod & KBDM_SHIFT) myOSystem.console().toggleP0Collision(); else myOSystem.console().toggleP0Bit(); break; case KBDK_X: - if(mod & KMOD_SHIFT) + if(mod & KBDM_SHIFT) myOSystem.console().toggleP1Collision(); else myOSystem.console().toggleP1Bit(); break; case KBDK_C: - if(mod & KMOD_SHIFT) + if(mod & KBDM_SHIFT) myOSystem.console().toggleM0Collision(); else myOSystem.console().toggleM0Bit(); break; case KBDK_V: - if(mod & KMOD_SHIFT) + if(mod & KBDM_SHIFT) myOSystem.console().toggleM1Collision(); else myOSystem.console().toggleM1Bit(); break; case KBDK_B: - if(mod & KMOD_SHIFT) + if(mod & KBDM_SHIFT) myOSystem.console().toggleBLCollision(); else myOSystem.console().toggleBLBit(); break; case KBDK_N: - if(mod & KMOD_SHIFT) + if(mod & KBDM_SHIFT) myOSystem.console().togglePFCollision(); else myOSystem.console().togglePFBit(); @@ -506,7 +506,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state) break; case KBDK_PERIOD: - if(mod & KMOD_SHIFT) + if(mod & KBDM_SHIFT) myOSystem.console().toggleCollisions(); else myOSystem.console().toggleBits(); @@ -570,7 +570,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state) break; case KBDK_F: // (Shift) Ctrl-f toggles NTSC/PAL/SECAM mode - myOSystem.console().toggleFormat(mod & KMOD_SHIFT ? -1 : 1); + myOSystem.console().toggleFormat(mod & KBDM_SHIFT ? -1 : 1); break; case KBDK_G: // Ctrl-g (un)grabs mouse diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index fdf7534a6..b14fb9463 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -177,20 +177,20 @@ class EventHandler inline bool kbdAlt(int mod) const { #ifndef BSPF_MAC_OSX - return (mod & KMOD_ALT); + return (mod & KBDM_ALT); #else - return (mod & KMOD_MODE); + return (mod & KBDM_MODE); #endif } inline bool kbdControl(int mod) const { - return (mod & KMOD_CTRL) > 0; + return (mod & KBDM_CTRL); } inline bool kbdShift(int mod) const { - return (mod & KMOD_SHIFT); + return (mod & KBDM_SHIFT); } void enterMenuMode(State state);