merged emulation and UI event mapping tabs

This commit is contained in:
thrust26 2021-04-30 19:10:52 +02:00
parent abc2d09b8e
commit eb873afc8b
11 changed files with 75 additions and 122 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -3898,16 +3898,13 @@
while in emulation mode, the left arrow could mean 'joystick 0 left', while in UI while in emulation mode, the left arrow could mean 'joystick 0 left', while in UI
mode it could mean 'move cursor left'. Emulation mode occurs whenever you're mode it could mean 'move cursor left'. Emulation mode occurs whenever you're
actually playing a game. UI mode occurs whenever a user interface is present actually playing a game. UI mode occurs whenever a user interface is present
(ROM launcher, debugger, settings menu, etc.). Because of these different modes, (ROM launcher, debugger, settings menu, etc.).
there are two separate mapping areas.
<p>To remap an event: <p>To remap an event:
<ol> <ol>
<li>Enter <b>Options Menu</b> and click the <b>Input Settings</b> button.</li> <li>Enter <b>Options Menu</b> and click the <b>Input Settings</b> button.</li>
<li>If you wish to remap emulation events, click the 'Emulation Events' tab. Here <li>Click the 'Event Mappings' tab. Here you can also filter the list of events by type.
you can also filter for the type of events. <li>Select the event you want to remap and click the 'Map' button.</li>
Otherwise, click the 'UI Events' tab for user interface events.</li>
<li>Select event you want to remap and click the 'Map' button.</li>
<li>Now define the input: <li>Now define the input:
<ul> <ul>
<li>Either press a key, a modifier key (Control, Shift...) or a modifier+key combination.</li> <li>Either press a key, a modifier key (Control, Shift...) or a modifier+key combination.</li>

View File

@ -2535,7 +2535,7 @@ StringList EventHandler::getActionList(const Event::EventSet& events, EventMode
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VariantList EventHandler::getComboList(EventMode /**/) const VariantList EventHandler::getComboList() const
{ {
// For now, this only works in emulation mode // For now, this only works in emulation mode
VariantList l; VariantList l;
@ -3436,8 +3436,3 @@ const Event::EventSet EventHandler::DebugEvents = {
Event::ToggleColorLoss, Event::ToggleColorLoss,
Event::ToggleJitter, Event::ToggleJitter,
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Event::EventSet EventHandler::EditEvents = {
};

View File

@ -175,7 +175,7 @@ class EventHandler
bool frying() const { return myFryingFlag; } bool frying() const { return myFryingFlag; }
StringList getActionList(Event::Group group) const; StringList getActionList(Event::Group group) const;
VariantList getComboList(EventMode mode) const; VariantList getComboList() const;
/** Used to access the list of events assigned to a specific combo event. */ /** Used to access the list of events assigned to a specific combo event. */
StringList getComboListForEvent(Event::Type event) const; StringList getComboListForEvent(Event::Type event) const;
@ -548,7 +548,6 @@ class EventHandler
static const Event::EventSet DevicesEvents; static const Event::EventSet DevicesEvents;
static const Event::EventSet ComboEvents; static const Event::EventSet ComboEvents;
static const Event::EventSet DebugEvents; static const Event::EventSet DebugEvents;
static const Event::EventSet EditEvents;
/** /**
The following methods take care of assigning action mappings. The following methods take care of assigning action mappings.

View File

@ -36,11 +36,9 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font, EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h, int x, int y, int w, int h)
EventMode mode)
: Widget(boss, font, x, y, w, h), : Widget(boss, font, x, y, w, h),
CommandSender(boss), CommandSender(boss)
myEventMode{mode}
{ {
const int lineHeight = boss->dialog().lineHeight(), const int lineHeight = boss->dialog().lineHeight(),
fontWidth = boss->dialog().fontWidth(), fontWidth = boss->dialog().fontWidth(),
@ -54,22 +52,21 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
const int listWidth = _w - buttonWidth - HBORDER * 2 - fontWidth; const int listWidth = _w - buttonWidth - HBORDER * 2 - fontWidth;
int listHeight = _h - (2 + ACTION_LINES) * lineHeight - VBORDER + 2; int listHeight = _h - (2 + ACTION_LINES) * lineHeight - VBORDER + 2;
if(mode == EventMode::kEmulationMode)
{
VariantList items; VariantList items;
items.clear(); items.clear();
VarList::push_back(items, "All", Event::Group::Emulation); VarList::push_back(items, "Emulation", Event::Group::Emulation);
VarList::push_back(items, "Miscellaneous", Event::Group::Misc); VarList::push_back(items, " Miscellaneous", Event::Group::Misc);
VarList::push_back(items, "Video & Audio", Event::Group::AudioVideo); VarList::push_back(items, " Video & Audio", Event::Group::AudioVideo);
VarList::push_back(items, "States", Event::Group::States); VarList::push_back(items, " States", Event::Group::States);
VarList::push_back(items, "Console", Event::Group::Console); VarList::push_back(items, " Console", Event::Group::Console);
VarList::push_back(items, "Joystick", Event::Group::Joystick); VarList::push_back(items, " Joystick", Event::Group::Joystick);
VarList::push_back(items, "Paddles", Event::Group::Paddles); VarList::push_back(items, " Paddles", Event::Group::Paddles);
VarList::push_back(items, "Keyboard", Event::Group::Keyboard); VarList::push_back(items, " Keyboard", Event::Group::Keyboard);
VarList::push_back(items, "Input Devices & Ports", Event::Group::Devices); VarList::push_back(items, " Input Devices & Ports", Event::Group::Devices);
VarList::push_back(items, "Combo", Event::Group::Combo); VarList::push_back(items, " Combo", Event::Group::Combo);
VarList::push_back(items, "Debug", Event::Group::Debug); VarList::push_back(items, " Debug", Event::Group::Debug);
VarList::push_back(items, "User Interface", Event::Group::Menu);
myFilterPopup = new PopUpWidget(boss, font, xpos, ypos, myFilterPopup = new PopUpWidget(boss, font, xpos, ypos,
listWidth - font.getStringWidth("Events ") - PopUpWidget::dropDownWidth(font), listWidth - font.getStringWidth("Events ") - PopUpWidget::dropDownWidth(font),
@ -78,7 +75,6 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
addFocusWidget(myFilterPopup); addFocusWidget(myFilterPopup);
ypos += lineHeight * 1.5; ypos += lineHeight * 1.5;
listHeight -= lineHeight * 1.5; listHeight -= lineHeight * 1.5;
}
myActionsList = new StringListWidget(boss, font, xpos, ypos, listWidth, listHeight); myActionsList = new StringListWidget(boss, font, xpos, ypos, listWidth, listHeight);
myActionsList->setTarget(this); myActionsList->setTarget(this);
@ -118,8 +114,6 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
myResetButton->setTarget(this); myResetButton->setTarget(this);
addFocusWidget(myResetButton); addFocusWidget(myResetButton);
if(mode == EventMode::kEmulationMode)
{
ypos += buttonHeight + VGAP * 2; ypos += buttonHeight + VGAP * 2;
myComboButton = new ButtonWidget(boss, font, xpos, ypos, myComboButton = new ButtonWidget(boss, font, xpos, ypos,
buttonWidth, buttonHeight, buttonWidth, buttonHeight,
@ -127,9 +121,8 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
myComboButton->setTarget(this); myComboButton->setTarget(this);
addFocusWidget(myComboButton); addFocusWidget(myComboButton);
VariantList combolist = instance().eventHandler().getComboList(mode); VariantList combolist = instance().eventHandler().getComboList();
myComboDialog = make_unique<ComboDialog>(boss, font, combolist); myComboDialog = make_unique<ComboDialog>(boss, font, combolist);
}
// Show message for currently selected event // Show message for currently selected event
xpos = HBORDER; xpos = HBORDER;
@ -149,9 +142,7 @@ void EventMappingWidget::loadConfig()
{ {
if(myFirstTime) if(myFirstTime)
{ {
if(myFilterPopup)
myFilterPopup->setSelectedIndex(0); myFilterPopup->setSelectedIndex(0);
myFirstTime = false; myFirstTime = false;
} }
@ -171,10 +162,11 @@ void EventMappingWidget::saveConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventMappingWidget::updateActions() void EventMappingWidget::updateActions()
{ {
if(myFilterPopup)
myEventGroup = Event::Group(myFilterPopup->getSelectedTag().toInt()); myEventGroup = Event::Group(myFilterPopup->getSelectedTag().toInt());
else myEventMode = myEventGroup == Event::Group::Menu
myEventGroup = Event::Group::Menu; ? myEventMode = EventMode::kMenuMode
: myEventMode = EventMode::kEmulationMode;
StringList actions = instance().eventHandler().getActionList(myEventGroup); StringList actions = instance().eventHandler().getActionList(myEventGroup);
myActionsList->setList(actions); myActionsList->setList(actions);
@ -294,13 +286,11 @@ void EventMappingWidget::enableButtons(bool state)
myCancelMapButton->setEnabled(!state); myCancelMapButton->setEnabled(!state);
myEraseButton->setEnabled(state); myEraseButton->setEnabled(state);
myResetButton->setEnabled(state); myResetButton->setEnabled(state);
if(myComboButton)
{
Event::Type e = Event::Type e =
instance().eventHandler().eventAtIndex(myActionSelected, myEventGroup); instance().eventHandler().eventAtIndex(myActionSelected, myEventGroup);
myComboButton->setEnabled(state && e >= Event::Combo1 && e <= Event::Combo16); myComboButton->setEnabled(state && e >= Event::Combo1 && e <= Event::Combo16);
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -39,8 +39,7 @@ class EventMappingWidget : public Widget, public CommandSender
public: public:
EventMappingWidget(GuiObject* boss, const GUI::Font& font, EventMappingWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h, int x, int y, int w, int h);
EventMode mode);
~EventMappingWidget() override = default; ~EventMappingWidget() override = default;
bool remapMode() { return myRemapStatus; } bool remapMode() { return myRemapStatus; }

View File

@ -64,30 +64,19 @@ InputDialog::InputDialog(OSystem& osystem, DialogContainer& parent,
_h -_th - VGAP - buttonHeight - VBORDER * 2); _h -_th - VGAP - buttonHeight - VBORDER * 2);
addTabWidget(myTab); addTabWidget(myTab);
// 1) Event mapper for emulation actions // 1) Event mapper
tabID = myTab->addTab(" Emul. Events ", TabWidget::AUTO_WIDTH); tabID = myTab->addTab(" Event Mappings ", TabWidget::AUTO_WIDTH);
myEmulEventMapper = new EventMappingWidget(myTab, _font, 2, 2, myEventMapper = new EventMappingWidget(myTab, _font, 2, 2,
myTab->getWidth(), myTab->getWidth(),
myTab->getHeight() - VGAP, myTab->getHeight() - VGAP);
EventMode::kEmulationMode); myTab->setParentWidget(tabID, myEventMapper);
myTab->setParentWidget(tabID, myEmulEventMapper); addToFocusList(myEventMapper->getFocusList(), myTab, tabID);
addToFocusList(myEmulEventMapper->getFocusList(), myTab, tabID);
myTab->parentWidget(tabID)->setHelpAnchor("Remapping"); myTab->parentWidget(tabID)->setHelpAnchor("Remapping");
// 2) Event mapper for UI actions // 2) Devices & ports
tabID = myTab->addTab(" UI Events ", TabWidget::AUTO_WIDTH);
myMenuEventMapper = new EventMappingWidget(myTab, _font, 2, 2,
myTab->getWidth(),
myTab->getHeight() - VGAP,
EventMode::kMenuMode);
myTab->setParentWidget(tabID, myMenuEventMapper);
addToFocusList(myMenuEventMapper->getFocusList(), myTab, tabID);
myTab->parentWidget(tabID)->setHelpAnchor("Remapping");
// 3) Devices & ports
addDevicePortTab(); addDevicePortTab();
// 4) Mouse // 3) Mouse
addMouseTab(); addMouseTab();
// Finalize the tabs, and activate the first tab // Finalize the tabs, and activate the first tab
@ -120,7 +109,7 @@ void InputDialog::addDevicePortTab()
WidgetArray wid; WidgetArray wid;
// Devices/ports // Devices/ports
tabID = myTab->addTab("Devices & Ports", TabWidget::AUTO_WIDTH); tabID = myTab->addTab(" Devices & Ports ", TabWidget::AUTO_WIDTH);
ypos = VBORDER; ypos = VBORDER;
lwidth = _font.getStringWidth("Digital paddle sensitivity "); lwidth = _font.getStringWidth("Digital paddle sensitivity ");
@ -497,14 +486,10 @@ void InputDialog::setDefaults()
switch(myTab->getActiveTab()) switch(myTab->getActiveTab())
{ {
case 0: // Emulation events case 0: // Emulation events
myEmulEventMapper->setDefaults(); myEventMapper->setDefaults();
break; break;
case 1: // UI events case 1: // Devices & Ports
myMenuEventMapper->setDefaults();
break;
case 2: // Devices & Ports
// Joystick deadzone // Joystick deadzone
myDeadzone->setValue(0); myDeadzone->setValue(0);
@ -537,7 +522,7 @@ void InputDialog::setDefaults()
myAVoxPort->setSelectedIndex(0); myAVoxPort->setSelectedIndex(0);
break; break;
case 3: // Mouse case 2: // Mouse
// Use mouse as a controller // Use mouse as a controller
myMouseControl->setSelected("analog"); myMouseControl->setSelected("analog");
@ -564,17 +549,15 @@ void InputDialog::setDefaults()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool InputDialog::repeatEnabled() bool InputDialog::repeatEnabled()
{ {
return !myEmulEventMapper->isRemapping() && !myMenuEventMapper->isRemapping(); return !myEventMapper->isRemapping();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated) void InputDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated)
{ {
// Remap key events in remap mode, otherwise pass to parent dialog // Remap key events in remap mode, otherwise pass to parent dialog
if (myEmulEventMapper->remapMode()) if (myEventMapper->remapMode())
myEmulEventMapper->handleKeyDown(key, mod); myEventMapper->handleKeyDown(key, mod);
else if (myMenuEventMapper->remapMode())
myMenuEventMapper->handleKeyDown(key, mod);
else else
Dialog::handleKeyDown(key, mod); Dialog::handleKeyDown(key, mod);
} }
@ -583,10 +566,8 @@ void InputDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated)
void InputDialog::handleKeyUp(StellaKey key, StellaMod mod) void InputDialog::handleKeyUp(StellaKey key, StellaMod mod)
{ {
// Remap key events in remap mode, otherwise pass to parent dialog // Remap key events in remap mode, otherwise pass to parent dialog
if (myEmulEventMapper->remapMode()) if (myEventMapper->remapMode())
myEmulEventMapper->handleKeyUp(key, mod); myEventMapper->handleKeyUp(key, mod);
else if (myMenuEventMapper->remapMode())
myMenuEventMapper->handleKeyUp(key, mod);
else else
Dialog::handleKeyUp(key, mod); Dialog::handleKeyUp(key, mod);
} }
@ -595,10 +576,8 @@ void InputDialog::handleKeyUp(StellaKey key, StellaMod mod)
void InputDialog::handleJoyDown(int stick, int button, bool longPress) void InputDialog::handleJoyDown(int stick, int button, bool longPress)
{ {
// Remap joystick buttons in remap mode, otherwise pass to parent dialog // Remap joystick buttons in remap mode, otherwise pass to parent dialog
if(myEmulEventMapper->remapMode()) if(myEventMapper->remapMode())
myEmulEventMapper->handleJoyDown(stick, button); myEventMapper->handleJoyDown(stick, button);
else if(myMenuEventMapper->remapMode())
myMenuEventMapper->handleJoyDown(stick, button);
else else
Dialog::handleJoyDown(stick, button); Dialog::handleJoyDown(stick, button);
} }
@ -607,10 +586,8 @@ void InputDialog::handleJoyDown(int stick, int button, bool longPress)
void InputDialog::handleJoyUp(int stick, int button) void InputDialog::handleJoyUp(int stick, int button)
{ {
// Remap joystick buttons in remap mode, otherwise pass to parent dialog // Remap joystick buttons in remap mode, otherwise pass to parent dialog
if (myEmulEventMapper->remapMode()) if (myEventMapper->remapMode())
myEmulEventMapper->handleJoyUp(stick, button); myEventMapper->handleJoyUp(stick, button);
else if (myMenuEventMapper->remapMode())
myMenuEventMapper->handleJoyUp(stick, button);
else else
Dialog::handleJoyUp(stick, button); Dialog::handleJoyUp(stick, button);
} }
@ -619,10 +596,8 @@ void InputDialog::handleJoyUp(int stick, int button)
void InputDialog::handleJoyAxis(int stick, JoyAxis axis, JoyDir adir, int button) void InputDialog::handleJoyAxis(int stick, JoyAxis axis, JoyDir adir, int button)
{ {
// Remap joystick axis in remap mode, otherwise pass to parent dialog // Remap joystick axis in remap mode, otherwise pass to parent dialog
if(myEmulEventMapper->remapMode()) if(myEventMapper->remapMode())
myEmulEventMapper->handleJoyAxis(stick, axis, adir, button); myEventMapper->handleJoyAxis(stick, axis, adir, button);
else if(myMenuEventMapper->remapMode())
myMenuEventMapper->handleJoyAxis(stick, axis, adir, button);
else else
Dialog::handleJoyAxis(stick, axis, adir, button); Dialog::handleJoyAxis(stick, axis, adir, button);
} }
@ -631,10 +606,8 @@ void InputDialog::handleJoyAxis(int stick, JoyAxis axis, JoyDir adir, int button
bool InputDialog::handleJoyHat(int stick, int hat, JoyHatDir hdir, int button) bool InputDialog::handleJoyHat(int stick, int hat, JoyHatDir hdir, int button)
{ {
// Remap joystick hat in remap mode, otherwise pass to parent dialog // Remap joystick hat in remap mode, otherwise pass to parent dialog
if(myEmulEventMapper->remapMode()) if(myEventMapper->remapMode())
return myEmulEventMapper->handleJoyHat(stick, hat, hdir, button); return myEventMapper->handleJoyHat(stick, hat, hdir, button);
else if(myMenuEventMapper->remapMode())
return myMenuEventMapper->handleJoyHat(stick, hat, hdir, button);
else else
return Dialog::handleJoyHat(stick, hat, hdir, button); return Dialog::handleJoyHat(stick, hat, hdir, button);
} }

View File

@ -89,8 +89,8 @@ class InputDialog : public Dialog
TabWidget* myTab{nullptr}; TabWidget* myTab{nullptr};
EventMappingWidget* myEmulEventMapper{nullptr}; EventMappingWidget* myEventMapper{nullptr};
EventMappingWidget* myMenuEventMapper{nullptr}; // EventMappingWidget* myMenuEventMapper{nullptr};
CheckboxWidget* mySAPort{nullptr}; CheckboxWidget* mySAPort{nullptr};