fix mapping for side independent modifiers (press both + key)

This commit is contained in:
thrust26 2019-05-28 18:29:18 +02:00
parent d1df80b41d
commit d9ba5bedd7
5 changed files with 38 additions and 3 deletions

View File

@ -1542,7 +1542,6 @@ EventHandler::ActionList EventHandler::ourEmulActionList[EMUL_ACTIONLIST_SIZE] =
{ Event::DecreaseFormat, "Decrease display format", "", false },
{ Event::IncreaseFormat, "Increase display format", "", false },
{ Event::TogglePalette, "Switch palette (Standard/Z26/User)", "", false },
{ Event::ToggleColorLoss, "Toggle PAL color-loss effect", "", false },
#ifdef PNG_SUPPORT
{ Event::ToggleContSnapshots, "Save cont. PNG snapsh. (as defined)", "", false },
{ Event::ToggleContSnapshotsFrame,"Save cont. PNG snapsh. (every frame)", "", false },
@ -1662,6 +1661,7 @@ EventHandler::ActionList EventHandler::ourEmulActionList[EMUL_ACTIONLIST_SIZE] =
{ Event::ToggleFixedColors, "Toggle TIA 'Fixed Debug Colors' mode", "", false },
{ Event::ToggleBits, "Toggle all TIA objects", "", false },
{ Event::ToggleCollisions, "Toggle all TIA collisions", "", false },
{ Event::ToggleColorLoss, "Toggle PAL color-loss effect", "", false },
{ Event::ToggleJitter, "Toggle TV 'Jitter' effect", "", false }
};

View File

@ -165,6 +165,9 @@ void EventMappingWidget::startRemapping()
// Reset all previous events for determining correct axis/hat values
myLastStick = myLastAxis = myLastHat = myLastValue = -1;
// Reset the previously aggregated key mappings
myMod = myKey = 0;
// Disable all other widgets while in remap mode, except enable 'Cancel'
enableButtons(false);
@ -254,14 +257,27 @@ void EventMappingWidget::enableButtons(bool state)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventMappingWidget::handleKeyUp(StellaKey key, StellaMod mod)
bool EventMappingWidget::handleKeyDown(StellaKey key, StellaMod mod)
{
// Remap keys in remap mode
if (myRemapStatus && myActionSelected >= 0)
{
myKey = key;
myMod |= mod;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventMappingWidget::handleKeyUp(StellaKey key, StellaMod mod)
{
// Remap keys in remap mode
if (myRemapStatus && myActionSelected >= 0
&& (mod & (KBDM_ALT | KBDM_CTRL | KBDM_SHIFT)) == 0)
{
Event::Type event =
instance().eventHandler().eventAtIndex(myActionSelected, myEventMode);
if (instance().eventHandler().addKeyMapping(event, myEventMode, key, mod))
if (instance().eventHandler().addKeyMapping(event, myEventMode, StellaKey(myKey), StellaMod(myMod)))
stopRemapping();
}
return true;

View File

@ -57,6 +57,7 @@ class EventMappingWidget : public Widget, public CommandSender
kComboCmd = 'cmbo'
};
bool handleKeyDown(StellaKey key, StellaMod mod) override;
bool handleKeyUp(StellaKey key, StellaMod mod) override;
void handleJoyDown(int stick, int button) override;
void handleJoyAxis(int stick, int axis, int value) override;
@ -104,6 +105,11 @@ class EventMappingWidget : public Widget, public CommandSender
// As a result, we need to keep track of their old values
int myLastStick, myLastAxis, myLastHat, myLastValue;
// Aggregates the modifier flags of the mapping
int myMod;
// Saves the last *pressed* key
int myKey;
bool myFirstTime;
private:

View File

@ -444,6 +444,18 @@ void InputDialog::setDefaults()
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::handleKeyDown(StellaKey key, StellaMod mod)
{
// Remap key events in remap mode, otherwise pass to parent dialog
if (myEmulEventMapper->remapMode())
myEmulEventMapper->handleKeyDown(key, mod);
else if (myMenuEventMapper->remapMode())
myMenuEventMapper->handleKeyDown(key, mod);
else
Dialog::handleKeyDown(key, mod);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::handleKeyUp(StellaKey key, StellaMod mod)
{

View File

@ -43,6 +43,7 @@ class InputDialog : public Dialog
virtual ~InputDialog();
private:
void handleKeyDown(StellaKey key, StellaMod mod) override;
void handleKeyUp(StellaKey key, StellaMod mod) override;
void handleJoyDown(int stick, int button) override;
void handleJoyAxis(int stick, int axis, int value) override;