Made StellaMod an actual enum, rather than simply typedef'ing

to SDL mod.

Added a hack/fix for Alt-key combos being printed in the debugger
prompt (ie, when stepping though a frame with Alt-f, the 'f' character
was shown in the prompt).  This will be fixed when PromptWidget
becomes an EditableWidget (not for the 4.0 release).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2922 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-06-13 19:34:35 +00:00
parent 5c75ff1c15
commit 05c007cbae
6 changed files with 54 additions and 25 deletions

View File

@ -35,7 +35,6 @@
*/ */
// This comes directly from SDL_scancode.h // This comes directly from SDL_scancode.h
typedef enum typedef enum
{ {
KBDK_UNKNOWN = 0, KBDK_UNKNOWN = 0,
@ -392,8 +391,26 @@ typedef enum
for array bounds */ for array bounds */
} StellaKey; } StellaKey;
// Just pass SDLMod directly as int (placeholder for now) // This comes directly from SDL_keycode.h
// The underlying code doesn't need to know how it's implemented typedef enum
typedef SDL_Keymod StellaMod; {
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 */ #endif /* StellaKeys */

View File

@ -89,8 +89,8 @@ void DebuggerDialog::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::handleKeyDown(StellaKey key, StellaMod mod) void DebuggerDialog::handleKeyDown(StellaKey key, StellaMod mod)
{ {
bool handled = instance().eventHandler().kbdAlt(mod); bool alt = instance().eventHandler().kbdAlt(mod);
if(handled) if(alt)
{ {
switch(key) switch(key)
{ {
@ -110,12 +110,10 @@ void DebuggerDialog::handleKeyDown(StellaKey key, StellaMod mod)
doRewind(); doRewind();
break; break;
default: default:
handled = false;
break; break;
} }
} }
if(!handled) Dialog::handleKeyDown(key, mod);
Dialog::handleKeyDown(key, mod);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -42,7 +42,8 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font,
CommandSender(boss), CommandSender(boss),
_makeDirty(false), _makeDirty(false),
_firstTime(true), _firstTime(true),
_exitedEarly(false) _exitedEarly(false),
_lastModPressed(KBDM_NONE)
{ {
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
WIDGET_WANTS_TAB | WIDGET_WANTS_RAWDATA; WIDGET_WANTS_TAB | WIDGET_WANTS_RAWDATA;
@ -139,6 +140,11 @@ void PromptWidget::printPrompt()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PromptWidget::handleText(char text) 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--) for(int i = _promptEndPos - 1; i >= _currentPos; i--)
buffer(i + 1) = buffer(i); buffer(i + 1) = buffer(i);
_promptEndPos++; _promptEndPos++;
@ -151,6 +157,11 @@ bool PromptWidget::handleText(char text)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod) 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 handled = true;
bool dirty = false; bool dirty = false;
@ -419,6 +430,7 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
} }
else if (instance().eventHandler().kbdAlt(mod)) else if (instance().eventHandler().kbdAlt(mod))
{ {
// Placeholder only - this will never be reached
} }
else else
handled = false; handled = false;

View File

@ -119,6 +119,8 @@ class PromptWidget : public Widget, public CommandSender
bool _firstTime; bool _firstTime;
bool _exitedEarly; bool _exitedEarly;
StellaMod _lastModPressed;
int compareHistory(const char *histLine); int compareHistory(const char *histLine);
}; };

View File

@ -421,7 +421,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
break; break;
case KBDK_7: // Alt-7 changes scanline intensity for NTSC filtering case KBDK_7: // Alt-7 changes scanline intensity for NTSC filtering
if(mod & KMOD_SHIFT) if(mod & KBDM_SHIFT)
myOSystem.frameBuffer().tiaSurface().setScanlineIntensity(-5); myOSystem.frameBuffer().tiaSurface().setScanlineIntensity(-5);
else else
myOSystem.frameBuffer().tiaSurface().setScanlineIntensity(+5); 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 case KBDK_9: // Alt-9 selects various custom adjustables for NTSC filtering
if(myOSystem.frameBuffer().tiaSurface().ntscEnabled()) if(myOSystem.frameBuffer().tiaSurface().ntscEnabled())
{ {
if(mod & KMOD_SHIFT) if(mod & KBDM_SHIFT)
myOSystem.frameBuffer().showMessage( myOSystem.frameBuffer().showMessage(
myOSystem.frameBuffer().tiaSurface().ntsc().setPreviousAdjustable()); myOSystem.frameBuffer().tiaSurface().ntsc().setPreviousAdjustable());
else 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 case KBDK_0: // Alt-0 changes custom adjustables for NTSC filtering
if(myOSystem.frameBuffer().tiaSurface().ntscEnabled()) if(myOSystem.frameBuffer().tiaSurface().ntscEnabled())
{ {
if(mod & KMOD_SHIFT) if(mod & KBDM_SHIFT)
myOSystem.frameBuffer().showMessage( myOSystem.frameBuffer().showMessage(
myOSystem.frameBuffer().tiaSurface().ntsc().decreaseAdjustable()); myOSystem.frameBuffer().tiaSurface().ntsc().decreaseAdjustable());
else else
@ -456,42 +456,42 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
break; break;
case KBDK_Z: case KBDK_Z:
if(mod & KMOD_SHIFT) if(mod & KBDM_SHIFT)
myOSystem.console().toggleP0Collision(); myOSystem.console().toggleP0Collision();
else else
myOSystem.console().toggleP0Bit(); myOSystem.console().toggleP0Bit();
break; break;
case KBDK_X: case KBDK_X:
if(mod & KMOD_SHIFT) if(mod & KBDM_SHIFT)
myOSystem.console().toggleP1Collision(); myOSystem.console().toggleP1Collision();
else else
myOSystem.console().toggleP1Bit(); myOSystem.console().toggleP1Bit();
break; break;
case KBDK_C: case KBDK_C:
if(mod & KMOD_SHIFT) if(mod & KBDM_SHIFT)
myOSystem.console().toggleM0Collision(); myOSystem.console().toggleM0Collision();
else else
myOSystem.console().toggleM0Bit(); myOSystem.console().toggleM0Bit();
break; break;
case KBDK_V: case KBDK_V:
if(mod & KMOD_SHIFT) if(mod & KBDM_SHIFT)
myOSystem.console().toggleM1Collision(); myOSystem.console().toggleM1Collision();
else else
myOSystem.console().toggleM1Bit(); myOSystem.console().toggleM1Bit();
break; break;
case KBDK_B: case KBDK_B:
if(mod & KMOD_SHIFT) if(mod & KBDM_SHIFT)
myOSystem.console().toggleBLCollision(); myOSystem.console().toggleBLCollision();
else else
myOSystem.console().toggleBLBit(); myOSystem.console().toggleBLBit();
break; break;
case KBDK_N: case KBDK_N:
if(mod & KMOD_SHIFT) if(mod & KBDM_SHIFT)
myOSystem.console().togglePFCollision(); myOSystem.console().togglePFCollision();
else else
myOSystem.console().togglePFBit(); myOSystem.console().togglePFBit();
@ -506,7 +506,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
break; break;
case KBDK_PERIOD: case KBDK_PERIOD:
if(mod & KMOD_SHIFT) if(mod & KBDM_SHIFT)
myOSystem.console().toggleCollisions(); myOSystem.console().toggleCollisions();
else else
myOSystem.console().toggleBits(); myOSystem.console().toggleBits();
@ -570,7 +570,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
break; break;
case KBDK_F: // (Shift) Ctrl-f toggles NTSC/PAL/SECAM mode 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; break;
case KBDK_G: // Ctrl-g (un)grabs mouse case KBDK_G: // Ctrl-g (un)grabs mouse

View File

@ -177,20 +177,20 @@ class EventHandler
inline bool kbdAlt(int mod) const inline bool kbdAlt(int mod) const
{ {
#ifndef BSPF_MAC_OSX #ifndef BSPF_MAC_OSX
return (mod & KMOD_ALT); return (mod & KBDM_ALT);
#else #else
return (mod & KMOD_MODE); return (mod & KBDM_MODE);
#endif #endif
} }
inline bool kbdControl(int mod) const inline bool kbdControl(int mod) const
{ {
return (mod & KMOD_CTRL) > 0; return (mod & KBDM_CTRL);
} }
inline bool kbdShift(int mod) const inline bool kbdShift(int mod) const
{ {
return (mod & KMOD_SHIFT); return (mod & KBDM_SHIFT);
} }
void enterMenuMode(State state); void enterMenuMode(State state);