mirror of https://github.com/stella-emu/stella.git
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:
parent
5c75ff1c15
commit
05c007cbae
|
@ -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 */
|
||||
|
|
|
@ -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,11 +110,9 @@ void DebuggerDialog::handleKeyDown(StellaKey key, StellaMod mod)
|
|||
doRewind();
|
||||
break;
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!handled)
|
||||
Dialog::handleKeyDown(key, mod);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -119,6 +119,8 @@ class PromptWidget : public Widget, public CommandSender
|
|||
bool _firstTime;
|
||||
bool _exitedEarly;
|
||||
|
||||
StellaMod _lastModPressed;
|
||||
|
||||
int compareHistory(const char *histLine);
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue