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
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
(ROM launcher, debugger, settings menu, etc.). Because of these different modes,
there are two separate mapping areas.
(ROM launcher, debugger, settings menu, etc.).
<p>To remap an event:
<ol>
<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
you can also filter for the type of events.
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>Click the 'Event Mappings' tab. Here you can also filter the list of events by type.
<li>Select the event you want to remap and click the 'Map' button.</li>
<li>Now define the input:
<ul>
<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
VariantList l;
@ -3436,8 +3436,3 @@ const Event::EventSet EventHandler::DebugEvents = {
Event::ToggleColorLoss,
Event::ToggleJitter,
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Event::EventSet EventHandler::EditEvents = {
};

View File

@ -175,7 +175,7 @@ class EventHandler
bool frying() const { return myFryingFlag; }
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. */
StringList getComboListForEvent(Event::Type event) const;
@ -548,7 +548,6 @@ class EventHandler
static const Event::EventSet DevicesEvents;
static const Event::EventSet ComboEvents;
static const Event::EventSet DebugEvents;
static const Event::EventSet EditEvents;
/**
The following methods take care of assigning action mappings.

View File

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

View File

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

View File

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

View File

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