Remove 'combo' events and associated remapping.

This commit is contained in:
Stephen Anthony 2018-04-11 13:04:29 -02:30
parent d798a007d0
commit eb591cb096
11 changed files with 5 additions and 455 deletions

View File

@ -61,9 +61,6 @@ class Event
KeyboardOne7, KeyboardOne8, KeyboardOne9,
KeyboardOneStar, KeyboardOne0, KeyboardOnePound,
Combo1, Combo2, Combo3, Combo4, Combo5, Combo6, Combo7, Combo8,
Combo9, Combo10, Combo11, Combo12, Combo13, Combo14, Combo15, Combo16,
SALeftAxis0Value, SALeftAxis1Value,
SARightAxis0Value, SARightAxis1Value,

View File

@ -71,11 +71,6 @@ EventHandler::EventHandler(OSystem& osystem)
// Create joystick handler (to handle all physical joystick functionality)
myPJoyHandler = make_unique<PhysicalJoystickHandler>(osystem, *this, myEvent);
// Erase the 'combo' array
for(int i = 0; i < kComboSize; ++i)
for(int j = 0; j < kEventsPerCombo; ++j)
myComboTable[i][j] = Event::NoType;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -88,7 +83,6 @@ void EventHandler::initialize()
{
// Make sure the event/action mappings are correctly set,
// and fill the ActionList structure with valid values
setComboMap();
setActionMappings(kEmulationMode);
setActionMappings(kMenuMode);
@ -403,31 +397,6 @@ void EventHandler::handleEvent(Event::Type event, Int32 state)
}
return;
////////////////////////////////////////////////////////////////////////
// A combo event is simply multiple calls to handleEvent, once for
// each event it contains
case Event::Combo1:
case Event::Combo2:
case Event::Combo3:
case Event::Combo4:
case Event::Combo5:
case Event::Combo6:
case Event::Combo7:
case Event::Combo8:
case Event::Combo9:
case Event::Combo10:
case Event::Combo11:
case Event::Combo12:
case Event::Combo13:
case Event::Combo14:
case Event::Combo15:
case Event::Combo16:
for(int i = 0, combo = event - Event::Combo1; i < kEventsPerCombo; ++i)
if(myComboTable[combo][i] != Event::NoType)
handleEvent(myComboTable[combo][i], state);
return;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// Events which relate to switches()
case Event::ConsoleColor:
@ -712,56 +681,6 @@ void EventHandler::setActionMappings(EventMode mode)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setComboMap()
{
// Since istringstream swallows whitespace, we have to make the
// delimiters be spaces
string list = myOSystem.settings().getString("combomap");
replace(list.begin(), list.end(), ':', ' ');
istringstream buf(list);
// Erase the 'combo' array
auto ERASE_ALL = [&]() {
for(int i = 0; i < kComboSize; ++i)
for(int j = 0; j < kEventsPerCombo; ++j)
myComboTable[i][j] = Event::NoType;
};
// Get combo count, which should be the first int in the list
// If it isn't, then we treat the entire list as invalid
if(!buf.good())
ERASE_ALL();
else
{
string key;
buf >> key;
if(atoi(key.c_str()) == kComboSize)
{
// Fill the combomap table with events for as long as they exist
int combocount = 0;
while(buf >> key && combocount < kComboSize)
{
// Each event in a comboevent is separated by a comma
replace(key.begin(), key.end(), ',', ' ');
istringstream buf2(key);
int eventcount = 0;
while(buf2 >> key && eventcount < kEventsPerCombo)
{
myComboTable[combocount][eventcount] = Event::Type(atoi(key.c_str()));
++eventcount;
}
++combocount;
}
}
else
ERASE_ALL();
}
saveComboMapping();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::removePhysicalJoystickFromDatabase(const string& name)
{
@ -879,23 +798,6 @@ void EventHandler::saveJoyMapping()
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::saveComboMapping()
{
// Iterate through the combomap table and create a colon-separated list
// For each combo event, create a comma-separated list of its events
// Prepend the event count, so we can check it on next load
ostringstream buf;
buf << kComboSize;
for(int i = 0; i < kComboSize; ++i)
{
buf << ":" << myComboTable[i][0];
for(int j = 1; j < kEventsPerCombo; ++j)
buf << "," << myComboTable[i][j];
}
myOSystem.settings().setValue("combomap", buf.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StringList EventHandler::getActionList(EventMode mode) const
{
@ -916,74 +818,6 @@ StringList EventHandler::getActionList(EventMode mode) const
return l;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VariantList EventHandler::getComboList(EventMode /**/) const
{
// For now, this only works in emulation mode
VariantList l;
ostringstream buf;
VarList::push_back(l, "None", "-1");
for(uInt32 i = 0; i < kEmulActionListSize; ++i)
{
if(EventHandler::ourEmulActionList[i].allow_combo)
{
buf << i;
VarList::push_back(l, EventHandler::ourEmulActionList[i].action, buf.str());
buf.str("");
}
}
return l;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StringList EventHandler::getComboListForEvent(Event::Type event) const
{
StringList l;
ostringstream buf;
if(event >= Event::Combo1 && event <= Event::Combo16)
{
int combo = event - Event::Combo1;
for(uInt32 i = 0; i < kEventsPerCombo; ++i)
{
Event::Type e = myComboTable[combo][i];
for(uInt32 j = 0; j < kEmulActionListSize; ++j)
{
if(EventHandler::ourEmulActionList[j].event == e &&
EventHandler::ourEmulActionList[j].allow_combo)
{
buf << j;
l.push_back(buf.str());
buf.str("");
}
}
// Make sure entries are 1-to-1, using '-1' to indicate Event::NoType
if(i == l.size())
l.push_back("-1");
}
}
return l;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setComboListForEvent(Event::Type event, const StringList& events)
{
if(event >= Event::Combo1 && event <= Event::Combo16)
{
assert(events.size() == 8);
int combo = event - Event::Combo1;
for(int i = 0; i < 8; ++i)
{
int idx = atoi(events[i].c_str());
if(idx >=0 && idx < kEmulActionListSize)
myComboTable[combo][i] = EventHandler::ourEmulActionList[idx].event;
else
myComboTable[combo][i] = Event::NoType;
}
saveComboMapping();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type EventHandler::eventAtIndex(int idx, EventMode mode) const
{
@ -1308,24 +1142,7 @@ EventHandler::ActionList EventHandler::ourEmulActionList[kEmulActionListSize] =
{ Event::KeyboardOne9, "P1 Keyboard 9", "", true },
{ Event::KeyboardOneStar, "P1 Keyboard *", "", true },
{ Event::KeyboardOne0, "P1 Keyboard 0", "", true },
{ Event::KeyboardOnePound, "P1 Keyboard #", "", true },
{ Event::Combo1, "Combo 1", "", false },
{ Event::Combo2, "Combo 2", "", false },
{ Event::Combo3, "Combo 3", "", false },
{ Event::Combo4, "Combo 4", "", false },
{ Event::Combo5, "Combo 5", "", false },
{ Event::Combo6, "Combo 6", "", false },
{ Event::Combo7, "Combo 7", "", false },
{ Event::Combo8, "Combo 8", "", false },
{ Event::Combo9, "Combo 9", "", false },
{ Event::Combo10, "Combo 10", "", false },
{ Event::Combo11, "Combo 11", "", false },
{ Event::Combo12, "Combo 12", "", false },
{ Event::Combo13, "Combo 13", "", false },
{ Event::Combo14, "Combo 14", "", false },
{ Event::Combo15, "Combo 15", "", false },
{ Event::Combo16, "Combo 16", "", false }
{ Event::KeyboardOnePound, "P1 Keyboard #", "", true }
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -151,11 +151,6 @@ class EventHandler
bool frying() const { return myFryingFlag; }
StringList getActionList(EventMode mode) const;
VariantList getComboList(EventMode mode) const;
/** Used to access the list of events assigned to a specific combo event. */
StringList getComboListForEvent(Event::Type event) const;
void setComboListForEvent(Event::Type event, const StringList& events);
/** Convert keys and physical joystick events into Stella events. */
Event::Type eventForKey(StellaKey key, EventMode mode) const {
@ -249,11 +244,6 @@ class EventHandler
*/
void setDefaultMapping(Event::Type event, EventMode mode);
/**
Sets the combo event mappings to those in the 'combomap' setting
*/
void setComboMap();
/**
Joystick emulates 'impossible' directions (ie, left & right
at the same time).
@ -361,9 +351,7 @@ class EventHandler
private:
enum {
kComboSize = 16,
kEventsPerCombo = 8,
kEmulActionListSize = 80 + kComboSize,
kEmulActionListSize = 80,
kMenuActionListSize = 14
};
@ -375,7 +363,6 @@ class EventHandler
void setDefaultJoymap(Event::Type, EventMode mode);
void saveKeyMapping();
void saveJoyMapping();
void saveComboMapping();
private:
// Structure used for action menu items
@ -402,9 +389,6 @@ class EventHandler
// all possible controller modes
unique_ptr<MouseControl> myMouseControl;
// The event(s) assigned to each combination event
Event::Type myComboTable[kComboSize][kEventsPerCombo];
// Indicates the current state of the system (ie, which mode is current)
EventHandlerState myState;

View File

@ -77,7 +77,6 @@ Settings::Settings(OSystem& osystem)
// Input event options
setInternal("keymap", "");
setInternal("joymap", "");
setInternal("combomap", "");
setInternal("joydeadzone", "13");
setInternal("joyallow4", "false");
setInternal("usemouse", "analog");

View File

@ -1,143 +0,0 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2018 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "bspf.hxx"
#include "Control.hxx"
#include "Dialog.hxx"
#include "EventHandler.hxx"
#include "OSystem.hxx"
#include "EditTextWidget.hxx"
#include "PopUpWidget.hxx"
#include "Widget.hxx"
#include "Font.hxx"
#include "ComboDialog.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font,
const VariantList& combolist)
: Dialog(boss->instance(), boss->parent(), font, ""),
myComboEvent(Event::NoType)
{
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth();
int xpos, ypos;
WidgetArray wid;
// Set real dimensions
_w = 35 * fontWidth + 10;
_h = 10 * (lineHeight + 4) + 10 + _th;
xpos = 10;
ypos = 10 + _th;
// Get maximum width of popupwidget
int pwidth = 0;
for(const auto& s: combolist)
pwidth = std::max(font.getStringWidth(s.first), pwidth);
// Add event popup for 8 events
auto ADD_EVENT_POPUP = [&](int idx, const string& label)
{
myEvents[idx] = new PopUpWidget(this, font, xpos, ypos,
pwidth, lineHeight, combolist, label);
wid.push_back(myEvents[idx]);
ypos += lineHeight + 4;
};
xpos = 10;
myEvents[0] = nullptr; ADD_EVENT_POPUP(0, "Event 1 ");
myEvents[1] = nullptr; ADD_EVENT_POPUP(1, "Event 2 ");
myEvents[2] = nullptr; ADD_EVENT_POPUP(2, "Event 3 ");
myEvents[3] = nullptr; ADD_EVENT_POPUP(3, "Event 4 ");
myEvents[4] = nullptr; ADD_EVENT_POPUP(4, "Event 5 ");
myEvents[5] = nullptr; ADD_EVENT_POPUP(5, "Event 6 ");
myEvents[6] = nullptr; ADD_EVENT_POPUP(6, "Event 7 ");
myEvents[7] = nullptr; ADD_EVENT_POPUP(7, "Event 8 ");
// Add Defaults, OK and Cancel buttons
addDefaultsOKCancelBGroup(wid, font);
addToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ComboDialog::show(Event::Type event, const string& name)
{
// Make sure the event is allowed
if(event >= Event::Combo1 && event <= Event::Combo16)
{
myComboEvent = event;
setTitle("Add events for " + name);
open();
}
else
myComboEvent = Event::NoType;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ComboDialog::loadConfig()
{
StringList events = instance().eventHandler().getComboListForEvent(myComboEvent);
uInt32 size = std::min(uInt32(events.size()), 8u);
for(uInt32 i = 0; i < size; ++i)
myEvents[i]->setSelected("", events[i]);
// Fill any remaining items to 'None'
if(size < 8)
for(uInt32 i = size; i < 8; ++i)
myEvents[i]->setSelected("None", "-1");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ComboDialog::saveConfig()
{
StringList events;
for(int i = 0; i < 8; ++i)
events.push_back(myEvents[i]->getSelectedTag().toString());
instance().eventHandler().setComboListForEvent(myComboEvent, events);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ComboDialog::setDefaults()
{
for(int i = 0; i < 8; ++i)
myEvents[i]->setSelected("None", "-1");
_dirty = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ComboDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id)
{
switch(cmd)
{
case GuiObject::kOKCmd:
saveConfig();
close();
break;
case GuiObject::kDefaultsCmd:
setDefaults();
break;
default:
Dialog::handleCommand(sender, cmd, data, 0);
break;
}
}

View File

@ -1,59 +0,0 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2018 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef COMBO_DIALOG_HXX
#define COMBO_DIALOG_HXX
class PopUpWidget;
class EditTextWidget;
class StaticTextWidget;
class OSystem;
#include "Dialog.hxx"
#include "bspf.hxx"
class ComboDialog : public Dialog
{
public:
ComboDialog(GuiObject* boss, const GUI::Font& font, const VariantList& combolist);
virtual ~ComboDialog() = default;
/** Place the dialog onscreen and center it */
void show(Event::Type event, const string& name);
private:
void loadConfig() override;
void saveConfig() override;
void setDefaults() override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
private:
Event::Type myComboEvent;
PopUpWidget* myEvents[8];
private:
// Following constructors and assignment operators not supported
ComboDialog() = delete;
ComboDialog(const ComboDialog&) = delete;
ComboDialog(ComboDialog&&) = delete;
ComboDialog& operator=(const ComboDialog&) = delete;
ComboDialog& operator=(ComboDialog&&) = delete;
};
#endif

View File

@ -26,7 +26,6 @@
#include "StringListWidget.hxx"
#include "Widget.hxx"
#include "Font.hxx"
#include "ComboDialog.hxx"
#include "Variant.hxx"
#include "EventMappingWidget.hxx"
@ -36,7 +35,6 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
const StringList& actions, EventMode mode)
: Widget(boss, font, x, y, w, h),
CommandSender(boss),
myComboDialog(nullptr),
myEventMode(mode),
myActionSelected(-1),
myRemapStatus(false),
@ -92,21 +90,6 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
myResetButton->setTarget(this);
addFocusWidget(myResetButton);
if(mode == kEmulationMode)
{
ypos += lineHeight + 20;
myComboButton = new ButtonWidget(boss, font, xpos, ypos,
buttonWidth, buttonHeight,
"Combo" + ELLIPSIS, kComboCmd);
myComboButton->setTarget(this);
addFocusWidget(myComboButton);
VariantList combolist = instance().eventHandler().getComboList(mode);
myComboDialog = new ComboDialog(boss, font, combolist);
}
else
myComboButton = nullptr;
// Show message for currently selected event
//xpos = HBORDER; ypos = VBORDER + myActionsList->getHeight() + 8;
xpos = x; ypos = y + myActionsList->getHeight() + 8;
@ -244,13 +227,6 @@ void EventMappingWidget::enableButtons(bool state)
myCancelMapButton->setEnabled(!state);
myEraseButton->setEnabled(state);
myResetButton->setEnabled(state);
if(myComboButton)
{
Event::Type e =
instance().eventHandler().eventAtIndex(myActionSelected, myEventMode);
myComboButton->setEnabled(state && e >= Event::Combo1 && e <= Event::Combo16);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -389,12 +365,5 @@ void EventMappingWidget::handleCommand(CommandSender* sender, int cmd,
case kResetCmd:
resetRemapping();
break;
case kComboCmd:
if(myComboDialog)
myComboDialog->show(
instance().eventHandler().eventAtIndex(myActionSelected, myEventMode),
instance().eventHandler().actionAtIndex(myActionSelected, myEventMode));
break;
}
}

View File

@ -26,7 +26,6 @@ class StaticTextWidget;
class StringListWidget;
class PopUpWidget;
class GuiObject;
class ComboDialog;
class InputDialog;
#include "Widget.hxx"
@ -55,8 +54,7 @@ class EventMappingWidget : public Widget, public CommandSender
kStartMapCmd = 'map ',
kStopMapCmd = 'smap',
kEraseCmd = 'eras',
kResetCmd = 'rest',
kComboCmd = 'cmbo'
kResetCmd = 'rest'
};
bool handleKeyDown(StellaKey key, StellaMod mod) override;
@ -82,12 +80,9 @@ class EventMappingWidget : public Widget, public CommandSender
ButtonWidget* myCancelMapButton;
ButtonWidget* myEraseButton;
ButtonWidget* myResetButton;
ButtonWidget* myComboButton;
StringListWidget* myActionsList;
EditTextWidget* myKeyMapping;
ComboDialog* myComboDialog;
// Since this widget can be used for different collections of events,
// we need to specify exactly which group of events we are remapping
EventMode myEventMode;

View File

@ -6,7 +6,6 @@ MODULE_OBJS := \
src/gui/BrowserDialog.o \
src/gui/CheckListWidget.o \
src/gui/ColorWidget.o \
src/gui/ComboDialog.o \
src/gui/CommandDialog.o \
src/gui/CommandMenu.o \
src/gui/ConfigPathDialog.o \

View File

@ -445,7 +445,6 @@
<ClCompile Include="..\gui\AudioDialog.cxx" />
<ClCompile Include="..\gui\BrowserDialog.cxx" />
<ClCompile Include="..\gui\CheckListWidget.cxx" />
<ClCompile Include="..\gui\ComboDialog.cxx" />
<ClCompile Include="..\gui\CommandDialog.cxx" />
<ClCompile Include="..\gui\CommandMenu.cxx" />
<ClCompile Include="..\gui\ContextMenu.cxx" />
@ -772,7 +771,6 @@
<ClInclude Include="..\gui\AudioDialog.hxx" />
<ClInclude Include="..\gui\BrowserDialog.hxx" />
<ClInclude Include="..\gui\CheckListWidget.hxx" />
<ClInclude Include="..\gui\ComboDialog.hxx" />
<ClInclude Include="..\gui\Command.hxx" />
<ClInclude Include="..\gui\CommandDialog.hxx" />
<ClInclude Include="..\gui\CommandMenu.hxx" />
@ -836,4 +834,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -342,9 +342,6 @@
<ClCompile Include="..\gui\CheckListWidget.cxx">
<Filter>Source Files\gui</Filter>
</ClCompile>
<ClCompile Include="..\gui\ComboDialog.cxx">
<Filter>Source Files\gui</Filter>
</ClCompile>
<ClCompile Include="..\gui\CommandDialog.cxx">
<Filter>Source Files\gui</Filter>
</ClCompile>
@ -1229,9 +1226,6 @@
<ClInclude Include="..\gui\CheckListWidget.hxx">
<Filter>Header Files\gui</Filter>
</ClInclude>
<ClInclude Include="..\gui\ComboDialog.hxx">
<Filter>Header Files\gui</Filter>
</ClInclude>
<ClInclude Include="..\gui\Command.hxx">
<Filter>Header Files\gui</Filter>
</ClInclude>
@ -1856,4 +1850,4 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
</Project>