mirror of https://github.com/stella-emu/stella.git
More work on the remapping of menu/UI events infrastructure.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1101 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
e49e1f17e4
commit
ebf39cb52d
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: EventHandler.cxx,v 1.161 2006-05-04 17:45:24 stephena Exp $
|
||||
// $Id: EventHandler.cxx,v 1.162 2006-05-05 18:00:50 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
@ -1848,6 +1848,28 @@ inline bool EventHandler::eventIsAnalog(Event::Type event)
|
|||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
StringList EventHandler::getEmulationActions()
|
||||
{
|
||||
StringList l;
|
||||
|
||||
for(int i = 0; i < kActionListSize; ++i)
|
||||
l.push_back(EventHandler::ourActionList[i].action);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
StringList EventHandler::getMenuActions()
|
||||
{
|
||||
StringList l; // FIXME
|
||||
|
||||
// for(int i = 0; i < kActionListSize; ++i)
|
||||
// l.push_back(EventHandler::ourActionList[i].action);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Event::Type EventHandler::eventForKey(int key, EventMode mode)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: EventHandler.hxx,v 1.86 2006-05-04 17:45:24 stephena Exp $
|
||||
// $Id: EventHandler.hxx,v 1.87 2006-05-05 18:00:51 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef EVENTHANDLER_HXX
|
||||
|
@ -65,8 +65,8 @@ enum {
|
|||
};
|
||||
|
||||
enum EventMode {
|
||||
kEmulation,
|
||||
kMenuOverlay
|
||||
kEmulationMode,
|
||||
kMenuMode
|
||||
};
|
||||
|
||||
// Joystick related items
|
||||
|
@ -112,7 +112,7 @@ struct JoyMouse {
|
|||
mapping can take place.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: EventHandler.hxx,v 1.86 2006-05-04 17:45:24 stephena Exp $
|
||||
@version $Id: EventHandler.hxx,v 1.87 2006-05-05 18:00:51 stephena Exp $
|
||||
*/
|
||||
class EventHandler
|
||||
{
|
||||
|
@ -333,6 +333,9 @@ class EventHandler
|
|||
|
||||
inline SDL_Joystick* getJoystick(int i) { return ourJoysticks[i].stick; }
|
||||
|
||||
StringList getEmulationActions();
|
||||
StringList getMenuActions();
|
||||
|
||||
Event::Type eventForKey(int key, EventMode mode);
|
||||
Event::Type eventForJoyButton(int stick, int button, EventMode mode);
|
||||
Event::Type eventForJoyAxis(int stick, int axis, int value, EventMode mode);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Dialog.cxx,v 1.44 2006-05-04 17:45:25 stephena Exp $
|
||||
// $Id: Dialog.cxx,v 1.45 2006-05-05 18:00:51 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -313,7 +313,7 @@ void Dialog::handleKeyDown(int ascii, int keycode, int modifiers)
|
|||
// which must always be processed before any widget sees it.
|
||||
bool handled = false;
|
||||
if(e == Event::NoType)
|
||||
e = instance()->eventHandler().eventForKey(ascii, kMenuOverlay);
|
||||
e = instance()->eventHandler().eventForKey(ascii, kMenuMode);
|
||||
|
||||
switch(e)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: EventMappingWidget.cxx,v 1.15 2006-05-04 17:45:25 stephena Exp $
|
||||
// $Id: EventMappingWidget.cxx,v 1.16 2006-05-05 18:00:51 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -33,9 +33,11 @@
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
|
||||
int x, int y, int w, int h)
|
||||
int x, int y, int w, int h,
|
||||
const StringList& actions, EventMode mode)
|
||||
: Widget(boss, font, x, y, w, h),
|
||||
CommandSender(boss),
|
||||
myEventMode(mode),
|
||||
myActionSelected(-1),
|
||||
myRemapStatus(false),
|
||||
myFirstTime(true)
|
||||
|
@ -50,6 +52,7 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
|
|||
myActionsList->setTarget(this);
|
||||
myActionsList->setNumberingMode(kListNumberingOff);
|
||||
myActionsList->setEditable(false);
|
||||
myActionsList->setList(actions);
|
||||
addFocusWidget(myActionsList);
|
||||
|
||||
// Add remap, erase, cancel and default buttons
|
||||
|
@ -80,14 +83,6 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
|
|||
myKeyMapping = new StaticTextWidget(boss, font, xpos, ypos, _w - 20, fontHeight,
|
||||
"Action: ", kTextAlignLeft);
|
||||
myKeyMapping->setFlags(WIDGET_CLEARBG);
|
||||
|
||||
// Get actions names
|
||||
StringList l;
|
||||
|
||||
for(int i = 0; i < kActionListSize; ++i)
|
||||
l.push_back(EventHandler::ourActionList[i].action);
|
||||
|
||||
myActionsList->setList(l);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -98,7 +93,7 @@ EventMappingWidget::~EventMappingWidget()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventMappingWidget::loadConfig()
|
||||
{
|
||||
//cerr << "EventMappingWidget::loadConfig()\n";
|
||||
cerr << "EventMappingWidget::loadConfig() for " << myEventMode << endl;
|
||||
if(myFirstTime)
|
||||
{
|
||||
myActionsList->setSelected(0);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: EventMappingWidget.hxx,v 1.9 2006-05-04 17:45:25 stephena Exp $
|
||||
// $Id: EventMappingWidget.hxx,v 1.10 2006-05-05 18:00:51 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -42,7 +42,8 @@ class EventMappingWidget : public Widget, public CommandSender
|
|||
|
||||
public:
|
||||
EventMappingWidget(GuiObject* boss, const GUI::Font& font,
|
||||
int x, int y, int w, int h);
|
||||
int x, int y, int w, int h,
|
||||
const StringList& actions, EventMode mode);
|
||||
~EventMappingWidget();
|
||||
|
||||
bool handleKeyDown(int ascii, int keycode, int modifiers);
|
||||
|
@ -78,6 +79,10 @@ class EventMappingWidget : public Widget, public CommandSender
|
|||
void drawKeyMapping();
|
||||
|
||||
private:
|
||||
// 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;
|
||||
|
||||
// Indicates the event that is currently selected
|
||||
int myActionSelected;
|
||||
|
||||
|
|
|
@ -13,9 +13,12 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: InputDialog.cxx,v 1.14 2006-05-04 17:45:25 stephena Exp $
|
||||
// $Id: InputDialog.cxx,v 1.15 2006-05-05 18:00:51 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
// FIXME - this whole dialog should be a dialog of buttons instead of
|
||||
// a tabwidget. It would make things sooo much easier.
|
||||
|
||||
#include "OSystem.hxx"
|
||||
#include "Widget.hxx"
|
||||
#include "Array.hxx"
|
||||
|
@ -49,15 +52,27 @@ InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
|
|||
myTab = new TabWidget(this, font, xpos, ypos, _w - 2*xpos, _h - 24 - 2*ypos);
|
||||
addTabWidget(myTab);
|
||||
|
||||
// 1) Event mapper
|
||||
tabID = myTab->addTab("Event Mapping");
|
||||
myEventMapper = new EventMappingWidget(myTab, font, 2, 2,
|
||||
myTab->getWidth(),
|
||||
myTab->getHeight() - ypos);
|
||||
myTab->setParentWidget(tabID, myEventMapper);
|
||||
addToFocusList(myEventMapper->getFocusList(), tabID);
|
||||
// 1) Event mapper for emulation actions
|
||||
tabID = myTab->addTab("Emul. Events");
|
||||
const StringList& eactions = instance()->eventHandler().getEmulationActions();
|
||||
myEmulEventMapper = new EventMappingWidget(myTab, font, 2, 2,
|
||||
myTab->getWidth(),
|
||||
myTab->getHeight() - ypos,
|
||||
eactions, kEmulationMode);
|
||||
myTab->setParentWidget(tabID, myEmulEventMapper);
|
||||
addToFocusList(myEmulEventMapper->getFocusList(), tabID);
|
||||
|
||||
// 2) Virtual device support
|
||||
// 2) Event mapper for menu actions
|
||||
tabID = myTab->addTab("Menu Events");
|
||||
const StringList& mactions = instance()->eventHandler().getMenuActions();
|
||||
myMenuEventMapper = new EventMappingWidget(myTab, font, 2, 2,
|
||||
myTab->getWidth(),
|
||||
myTab->getHeight() - ypos,
|
||||
mactions, kMenuMode);
|
||||
myTab->setParentWidget(tabID, myMenuEventMapper);
|
||||
addToFocusList(myMenuEventMapper->getFocusList(), tabID);
|
||||
|
||||
// 3) Virtual device support
|
||||
addVDeviceTab(font);
|
||||
|
||||
// Finalize the tabs, and activate the first tab
|
||||
|
@ -93,7 +108,7 @@ void InputDialog::addVDeviceTab(const GUI::Font& font)
|
|||
WidgetArray wid;
|
||||
|
||||
// Virtual device/ports
|
||||
tabID = myTab->addTab("Virtual Devices");
|
||||
tabID = myTab->addTab("Virtual Devs");
|
||||
|
||||
// Stelladaptor mappings
|
||||
xpos = 5; ypos = 5;
|
||||
|
@ -194,7 +209,8 @@ void InputDialog::addVDeviceTab(const GUI::Font& font)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::loadConfig()
|
||||
{
|
||||
myEventMapper->loadConfig();
|
||||
myEmulEventMapper->loadConfig();
|
||||
myMenuEventMapper->loadConfig();
|
||||
|
||||
// Left & right ports
|
||||
const string& sa1 = instance()->settings().getString("sa1");
|
||||
|
@ -247,9 +263,11 @@ void InputDialog::saveConfig()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||
{
|
||||
// Remap key events in remap mode, otherwise pass to listwidget
|
||||
if(myEventMapper->remapMode())
|
||||
myEventMapper->handleKeyDown(ascii, keycode, modifiers);
|
||||
// Remap key events in remap mode, otherwise pass to parent dialog
|
||||
if(myEmulEventMapper->remapMode())
|
||||
myEmulEventMapper->handleKeyDown(ascii, keycode, modifiers);
|
||||
else if(myMenuEventMapper->remapMode())
|
||||
myMenuEventMapper->handleKeyDown(ascii, keycode, modifiers);
|
||||
else
|
||||
Dialog::handleKeyDown(ascii, keycode, modifiers);
|
||||
}
|
||||
|
@ -257,9 +275,11 @@ void InputDialog::handleKeyDown(int ascii, int keycode, int modifiers)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::handleJoyDown(int stick, int button)
|
||||
{
|
||||
// Remap joystick buttons in remap mode, otherwise pass to listwidget
|
||||
if(myEventMapper->remapMode())
|
||||
myEventMapper->handleJoyDown(stick, button);
|
||||
// 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);
|
||||
else
|
||||
Dialog::handleJoyDown(stick, button);
|
||||
}
|
||||
|
@ -267,9 +287,11 @@ void InputDialog::handleJoyDown(int stick, int button)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::handleJoyAxis(int stick, int axis, int value)
|
||||
{
|
||||
// Remap joystick axis in remap mode, otherwise pass to listwidget
|
||||
if(myEventMapper->remapMode())
|
||||
myEventMapper->handleJoyAxis(stick, axis, value);
|
||||
// Remap joystick axis in remap mode, otherwise pass to parent dialog
|
||||
if(myEmulEventMapper->remapMode())
|
||||
myEmulEventMapper->handleJoyAxis(stick, axis, value);
|
||||
else if(myMenuEventMapper->remapMode())
|
||||
myMenuEventMapper->handleJoyAxis(stick, axis, value);
|
||||
else
|
||||
Dialog::handleJoyAxis(stick, axis, value);
|
||||
}
|
||||
|
@ -277,9 +299,11 @@ void InputDialog::handleJoyAxis(int stick, int axis, int value)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool InputDialog::handleJoyHat(int stick, int hat, int value)
|
||||
{
|
||||
// Remap joystick hat in remap mode, otherwise pass to listwidget
|
||||
if(myEventMapper->remapMode())
|
||||
return myEventMapper->handleJoyHat(stick, hat, value);
|
||||
// Remap joystick hat in remap mode, otherwise pass to parent dialog
|
||||
if(myEmulEventMapper->remapMode())
|
||||
return myEmulEventMapper->handleJoyHat(stick, hat, value);
|
||||
else if(myMenuEventMapper->remapMode())
|
||||
return myMenuEventMapper->handleJoyHat(stick, hat, value);
|
||||
else
|
||||
return Dialog::handleJoyHat(stick, hat, value);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: InputDialog.hxx,v 1.8 2006-04-05 12:28:39 stephena Exp $
|
||||
// $Id: InputDialog.hxx,v 1.9 2006-05-05 18:00:51 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef INPUT_DIALOG_HXX
|
||||
|
@ -54,7 +54,8 @@ class InputDialog : public Dialog
|
|||
private:
|
||||
TabWidget* myTab;
|
||||
|
||||
EventMappingWidget* myEventMapper;
|
||||
EventMappingWidget* myEmulEventMapper;
|
||||
EventMappingWidget* myMenuEventMapper;
|
||||
|
||||
PopUpWidget* myLeftPort;
|
||||
PopUpWidget* myRightPort;
|
||||
|
@ -65,8 +66,6 @@ class InputDialog : public Dialog
|
|||
StaticTextWidget* myPaddleThresholdLabel;
|
||||
SliderWidget* myPaddleSpeed[4];
|
||||
StaticTextWidget* myPaddleLabel[4];
|
||||
|
||||
CheckBoxWidget* myJoyMouse;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: ListWidget.cxx,v 1.42 2006-05-04 17:45:25 stephena Exp $
|
||||
// $Id: ListWidget.cxx,v 1.43 2006-05-05 18:00:51 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -67,7 +67,8 @@ ListWidget::~ListWidget()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ListWidget::setSelected(int item)
|
||||
{
|
||||
assert(item >= -2 && item < (int)_list.size());
|
||||
if(item < -1 || item >= (int)_list.size())
|
||||
return;
|
||||
|
||||
if(isEnabled())
|
||||
{
|
||||
|
@ -85,7 +86,8 @@ void ListWidget::setSelected(int item)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ListWidget::setHighlighted(int item)
|
||||
{
|
||||
assert(item >= -1 && item < (int)_list.size());
|
||||
if(item < -1 || item >= (int)_list.size())
|
||||
return;
|
||||
|
||||
if(isEnabled())
|
||||
{
|
||||
|
@ -463,7 +465,6 @@ void ListWidget::endEditMode()
|
|||
void ListWidget::abortEditMode()
|
||||
{
|
||||
// Undo any changes made
|
||||
assert(_selectedItem >= 0);
|
||||
_editMode = false;
|
||||
|
||||
// Reset to normal data entry
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: PopUpWidget.cxx,v 1.25 2006-05-04 17:45:25 stephena Exp $
|
||||
// $Id: PopUpWidget.cxx,v 1.26 2006-05-05 18:00:51 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -141,12 +141,8 @@ void PopUpDialog::handleKeyDown(int ascii, int keycode, int modifiers)
|
|||
cancelSelection();
|
||||
break;
|
||||
default:
|
||||
{
|
||||
Event::Type e = instance()->eventHandler().eventForKey(ascii,
|
||||
kMenuOverlay);
|
||||
handleEvent(e);
|
||||
handleEvent(instance()->eventHandler().eventForKey(ascii, kMenuMode));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue