mirror of https://github.com/stella-emu/stella.git
refactor 'ctrlcombo' into 'modcombo', suppresses all modifier key combinations
This commit is contained in:
parent
2dda6c24df
commit
354bb068fc
|
@ -18,6 +18,7 @@
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
KeyMap::KeyMap(void)
|
||||
: myModEnabled(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -50,14 +51,17 @@ Event::Type KeyMap::get(const Mapping& mapping) const
|
|||
{
|
||||
Mapping m = convertMod(mapping);
|
||||
|
||||
auto find = myMap.find(m);
|
||||
if (find != myMap.end())
|
||||
return find->second;
|
||||
if (myModEnabled)
|
||||
{
|
||||
auto find = myMap.find(m);
|
||||
if (find != myMap.end())
|
||||
return find->second;
|
||||
}
|
||||
|
||||
// mapping not found, try without modifiers
|
||||
m.mod = StellaMod(0);
|
||||
|
||||
find = myMap.find(m);
|
||||
auto find = myMap.find(m);
|
||||
if (find != myMap.end())
|
||||
return find->second;
|
||||
|
||||
|
|
|
@ -98,6 +98,8 @@ class KeyMap
|
|||
// void clear() { myMap.clear(); }
|
||||
size_t size() { return myMap.size(); }
|
||||
|
||||
bool& enableMod() { return myModEnabled; }
|
||||
|
||||
private:
|
||||
//** Convert modifiers */
|
||||
Mapping convertMod(const Mapping& mapping) const;
|
||||
|
@ -113,6 +115,12 @@ class KeyMap
|
|||
};
|
||||
|
||||
std::unordered_map<Mapping, Event::Type, KeyHash> myMap;
|
||||
|
||||
// Indicates whether the key-combos tied to a modifier key are
|
||||
// being used or not (e.g. Ctrl by default is the fire button,
|
||||
// pressing it with a movement key could inadvertantly activate
|
||||
// a Ctrl combo when it isn't wanted)
|
||||
bool myModEnabled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,8 +41,7 @@ PhysicalKeyboardHandler::PhysicalKeyboardHandler(
|
|||
: myOSystem(system),
|
||||
myHandler(handler),
|
||||
myEvent(event),
|
||||
myAltKeyCounter(0),
|
||||
myUseCtrlKeyFlag(myOSystem.settings().getBool("ctrlcombo"))
|
||||
myAltKeyCounter(0)
|
||||
{
|
||||
Int32 version = myOSystem.settings().getInt("event_ver");
|
||||
|
||||
|
@ -54,6 +53,7 @@ PhysicalKeyboardHandler::PhysicalKeyboardHandler(
|
|||
list = myOSystem.settings().getString("keymap_ui");
|
||||
myKeyMap.loadMapping(list, kMenuMode);
|
||||
}
|
||||
myKeyMap.enableMod() = myOSystem.settings().getBool("modcombo");
|
||||
|
||||
setDefaultMapping(Event::NoType, kEmulationMode, true);
|
||||
setDefaultMapping(Event::NoType, kMenuMode, true);
|
||||
|
@ -329,7 +329,6 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool pre
|
|||
// and don't pass the key on if we've already taken care of it
|
||||
if(handleAltEvent(key, mod, pressed))
|
||||
return;
|
||||
// TODO: myUseCtrlKeyFlag?
|
||||
|
||||
EventHandlerState estate = myHandler.state();
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ class PhysicalKeyboardHandler
|
|||
/** See comments on 'myAltKeyCounter' for more information. */
|
||||
uInt8& altKeyCount() { return myAltKeyCounter; }
|
||||
|
||||
/** See comments on 'myUseCtrlKeyFlag' for more information. */
|
||||
bool& useCtrlKey() { return myUseCtrlKeyFlag; }
|
||||
/** See comments on KeyMap.myModEnabled for more information. */
|
||||
bool& useModKeys() { return myKeyMap.enableMod(); }
|
||||
|
||||
private:
|
||||
bool handleAltEvent(StellaKey key, StellaMod mod, bool pressed);
|
||||
|
@ -88,12 +88,6 @@ class PhysicalKeyboardHandler
|
|||
// TODO - This may be a bug in SDL, and might be removed in the future
|
||||
// It only seems to be an issue in Linux
|
||||
uInt8 myAltKeyCounter;
|
||||
|
||||
// Indicates whether the key-combos tied to the Control key are
|
||||
// being used or not (since Ctrl by default is the fire button,
|
||||
// pressing it with a movement key could inadvertantly activate
|
||||
// a Ctrl combo when it isn't wanted)
|
||||
bool myUseCtrlKeyFlag;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -382,7 +382,7 @@ void EventHandler::handleEvent(Event::Type event, bool pressed)
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
case Event::Fry:
|
||||
if(myPKeyHandler->useCtrlKey()) myFryingFlag = pressed;
|
||||
/*if(myPKeyHandler->useModKeys())*/ myFryingFlag = pressed;
|
||||
return;
|
||||
|
||||
case Event::ReloadConsole:
|
||||
|
@ -1461,9 +1461,9 @@ void EventHandler::setState(EventHandlerState state)
|
|||
{
|
||||
myState = state;
|
||||
|
||||
// Normally, the usage of Control key is determined by 'ctrlcombo'
|
||||
// Normally, the usage of modifier keys is determined by 'modcombo'
|
||||
// For certain ROMs it may be forced off, whatever the setting
|
||||
myPKeyHandler->useCtrlKey() = myOSystem.settings().getBool("ctrlcombo");
|
||||
myPKeyHandler->useModKeys() = myOSystem.settings().getBool("modcombo");
|
||||
|
||||
// Only enable text input in GUI modes, since in emulation mode the
|
||||
// keyboard acts as one large joystick with many (single) buttons
|
||||
|
@ -1474,7 +1474,7 @@ void EventHandler::setState(EventHandlerState state)
|
|||
myOSystem.sound().mute(false);
|
||||
enableTextEvents(false);
|
||||
if(myOSystem.console().leftController().type() == Controller::Type::CompuMate)
|
||||
myPKeyHandler->useCtrlKey() = false;
|
||||
myPKeyHandler->useModKeys() = false;
|
||||
break;
|
||||
|
||||
case EventHandlerState::PAUSE:
|
||||
|
|
|
@ -98,7 +98,7 @@ Settings::Settings()
|
|||
setPermanent("msense", "10");
|
||||
setPermanent("tsense", "10");
|
||||
setPermanent("saport", "lr");
|
||||
setPermanent("ctrlcombo", "true");
|
||||
setPermanent("modcombo", "true");
|
||||
|
||||
// Snapshot options
|
||||
setPermanent("snapsavedir", "");
|
||||
|
@ -442,8 +442,8 @@ void Settings::usage() const
|
|||
<< " -tsense <1-20> Sensitivity of mouse emulated trackball movement\n"
|
||||
<< " -saport <lr|rl> How to assign virtual ports to multiple\n"
|
||||
<< " Stelladaptor/2600-daptors\n"
|
||||
<< " -ctrlcombo <1|0> Use key combos involving the Control key\n"
|
||||
<< " (Control-Q for quit may be disabled!)\n"
|
||||
<< " -modcombo <1|0> Enable modifer key combos\n"
|
||||
<< " (Control-Q for quit may not work when disabled!)\n"
|
||||
<< " -fastscbios <1|0> Disable Supercharger BIOS progress loading bars\n"
|
||||
<< " -threads <1|0> Whether to using multi-threading during\n"
|
||||
<< " emulation\n"
|
||||
|
|
|
@ -217,11 +217,11 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
|
|||
myGrabMouse->clearFlags(Widget::FLAG_ENABLED);
|
||||
#endif
|
||||
|
||||
// Enable/disable control key-combos
|
||||
// Enable/disable modifier key-combos
|
||||
ypos += lineHeight + VGAP;
|
||||
myCtrlCombo = new CheckboxWidget(myTab, font, HBORDER, ypos,
|
||||
"Use control key combos");
|
||||
wid.push_back(myCtrlCombo);
|
||||
myModCombo = new CheckboxWidget(myTab, font, HBORDER, ypos,
|
||||
"Use modifier key combos");
|
||||
wid.push_back(myModCombo);
|
||||
ypos += lineHeight + VGAP;
|
||||
|
||||
// Stelladaptor mappings
|
||||
|
@ -315,8 +315,8 @@ void InputDialog::loadConfig()
|
|||
// Grab mouse
|
||||
myGrabMouse->setState(instance().settings().getBool("grabmouse"));
|
||||
|
||||
// Enable/disable control key-combos
|
||||
myCtrlCombo->setState(instance().settings().getBool("ctrlcombo"));
|
||||
// Enable/disable modifier key-combos
|
||||
myModCombo->setState(instance().settings().getBool("modcombo"));
|
||||
|
||||
myTab->loadConfig();
|
||||
}
|
||||
|
@ -372,8 +372,8 @@ void InputDialog::saveConfig()
|
|||
instance().settings().setValue("grabmouse", myGrabMouse->getState());
|
||||
instance().frameBuffer().enableGrabMouse(myGrabMouse->getState());
|
||||
|
||||
// Enable/disable control key-combos
|
||||
instance().settings().setValue("ctrlcombo", myCtrlCombo->getState());
|
||||
// Enable/disable modifier key-combos
|
||||
instance().settings().setValue("modcombo", myModCombo->getState());
|
||||
|
||||
instance().eventHandler().saveKeyMapping();
|
||||
instance().eventHandler().saveJoyMapping();
|
||||
|
@ -433,8 +433,8 @@ void InputDialog::setDefaults()
|
|||
// Grab mouse
|
||||
myGrabMouse->setState(true);
|
||||
|
||||
// Enable/disable control key-combos
|
||||
myCtrlCombo->setState(true);
|
||||
// Enable/disable modifier key-combos
|
||||
myModCombo->setState(true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class InputDialog : public Dialog
|
|||
StaticTextWidget* myTrackBallLabel;
|
||||
CheckboxWidget* myAllowAll4;
|
||||
CheckboxWidget* myGrabMouse;
|
||||
CheckboxWidget* myCtrlCombo;
|
||||
CheckboxWidget* myModCombo;
|
||||
|
||||
ButtonWidget* myJoyDlgButton;
|
||||
ButtonWidget* myEraseEEPROMButton;
|
||||
|
|
Loading…
Reference in New Issue