Finally, we have CVS access back!!

Finalized remapping of GUI/menu events, and added an interface to change
these mappings from 'Input Settings'.

Fixed bug with taking snapshots having a previously overlaid message
being part of the image.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1102 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-05-15 12:24:09 +00:00
parent ebf39cb52d
commit 893716abcd
8 changed files with 477 additions and 352 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Event.hxx,v 1.20 2006-05-04 17:45:24 stephena Exp $ // $Id: Event.hxx,v 1.21 2006-05-15 12:24:09 stephena Exp $
//============================================================================ //============================================================================
#ifndef EVENT_HXX #ifndef EVENT_HXX
@ -26,7 +26,7 @@ class EventStreamer;
/** /**
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Event.hxx,v 1.20 2006-05-04 17:45:24 stephena Exp $ @version $Id: Event.hxx,v 1.21 2006-05-15 12:24:09 stephena Exp $
*/ */
class Event class Event
{ {
@ -81,7 +81,7 @@ class Event
VolumeDecrease, VolumeIncrease, VolumeDecrease, VolumeIncrease,
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown, UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect, UISelect, UIPrevDir, UINavPrev, UINavNext, UITabPrev, UITabNext,
LastType LastType
}; };

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventHandler.cxx,v 1.162 2006-05-05 18:00:50 stephena Exp $ // $Id: EventHandler.cxx,v 1.163 2006-05-15 12:24:09 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -72,7 +72,7 @@ EventHandler::EventHandler(OSystem* osystem)
myPaddleMode(0), myPaddleMode(0),
myPaddleThreshold(0) myPaddleThreshold(0)
{ {
int i, j, k; int i, j, k, m;
// Add this eventhandler object to the OSystem // Add this eventhandler object to the OSystem
myOSystem->attach(this); myOSystem->attach(this);
@ -86,26 +86,30 @@ EventHandler::EventHandler(OSystem* osystem)
// Erase the key mapping array // Erase the key mapping array
for(i = 0; i < SDLK_LAST; ++i) for(i = 0; i < SDLK_LAST; ++i)
{ {
myKeyTable[i] = Event::NoType;
ourSDLMapping[i] = ""; ourSDLMapping[i] = "";
for(m = 0; m < kNumModes; ++m)
myKeyTable[i][m] = Event::NoType;
} }
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
// Erase the joystick button mapping array // Erase the joystick button mapping array
for(m = 0; m < kNumModes; ++m)
for(i = 0; i < kNumJoysticks; ++i) for(i = 0; i < kNumJoysticks; ++i)
for(j = 0; j < kNumJoyButtons; ++j) for(j = 0; j < kNumJoyButtons; ++j)
myJoyTable[i][j] = Event::NoType; myJoyTable[i][j][m] = Event::NoType;
// Erase the joystick axis mapping array // Erase the joystick axis mapping array
for(m = 0; m < kNumModes; ++m)
for(i = 0; i < kNumJoysticks; ++i) for(i = 0; i < kNumJoysticks; ++i)
for(j = 0; j < kNumJoyAxis; ++j) for(j = 0; j < kNumJoyAxis; ++j)
myJoyAxisTable[i][j][0] = myJoyAxisTable[i][j][1] = Event::NoType; myJoyAxisTable[i][j][0][m] = myJoyAxisTable[i][j][1][m] = Event::NoType;
// Erase the joystick hat mapping array // Erase the joystick hat mapping array
for(m = 0; m < kNumModes; ++m)
for(i = 0; i < kNumJoysticks; ++i) for(i = 0; i < kNumJoysticks; ++i)
for(j = 0; j < kNumJoyHats; ++j) for(j = 0; j < kNumJoyHats; ++j)
for(k = 0; k < 4; ++k) for(k = 0; k < 4; ++k)
myJoyHatTable[i][j][k] = Event::NoType; myJoyHatTable[i][j][k][m] = Event::NoType;
#endif #endif
// Erase the Message array // Erase the Message array
@ -127,7 +131,8 @@ EventHandler::EventHandler(OSystem* osystem)
setJoymap(); setJoymap();
setJoyAxisMap(); setJoyAxisMap();
setJoyHatMap(); setJoyHatMap();
setActionMappings(); setActionMappings(kEmulationMode);
setActionMappings(kMenuMode);
myGrabMouseFlag = myOSystem->settings().getBool("grabmouse"); myGrabMouseFlag = myOSystem->settings().getBool("grabmouse");
@ -208,8 +213,6 @@ void EventHandler::refreshDisplay(bool forceUpdate)
if(forceUpdate) if(forceUpdate)
myOSystem->frameBuffer().update(); myOSystem->frameBuffer().update();
// cerr << " ==> State change = " << myState << endl;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -608,12 +611,12 @@ void EventHandler::poll(uInt32 time)
// Handle keys which switch eventhandler state // Handle keys which switch eventhandler state
// Arrange the logic to take advantage of short-circuit evaluation // Arrange the logic to take advantage of short-circuit evaluation
if(!(kbdControl(mod) || kbdShift(mod) || kbdAlt(mod)) && if(!(kbdControl(mod) || kbdShift(mod) || kbdAlt(mod)) &&
state && eventStateChange(myKeyTable[key])) state && eventStateChange(myKeyTable[key][kEmulationMode]))
return; return;
// Otherwise, let the event handler deal with it // Otherwise, let the event handler deal with it
if(myState == S_EMULATE) if(myState == S_EMULATE)
handleEvent(myKeyTable[key], state); handleEvent(myKeyTable[key][kEmulationMode], state);
else if(myOverlay != NULL) else if(myOverlay != NULL)
{ {
// Make sure the unicode field is valid // Make sure the unicode field is valid
@ -916,12 +919,12 @@ void EventHandler::handleMouseButtonEvent(SDL_Event& event, int state)
void EventHandler::handleJoyEvent(int stick, int button, int state) void EventHandler::handleJoyEvent(int stick, int button, int state)
{ {
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
if(state && eventStateChange(myJoyTable[stick][button])) if(state && eventStateChange(myJoyTable[stick][button][kEmulationMode]))
return; return;
// Determine which mode we're in, then send the event to the appropriate place // Determine which mode we're in, then send the event to the appropriate place
if(myState == S_EMULATE) if(myState == S_EMULATE)
handleEvent(myJoyTable[stick][button], state); handleEvent(myJoyTable[stick][button][kEmulationMode], state);
else if(myOverlay != NULL) else if(myOverlay != NULL)
myOverlay->handleJoyEvent(stick, button, state); myOverlay->handleJoyEvent(stick, button, state);
#endif #endif
@ -932,8 +935,8 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value)
{ {
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
// Every axis event has two associated values, negative and positive // Every axis event has two associated values, negative and positive
Event::Type eventAxisNeg = myJoyAxisTable[stick][axis][0]; Event::Type eventAxisNeg = myJoyAxisTable[stick][axis][0][kEmulationMode];
Event::Type eventAxisPos = myJoyAxisTable[stick][axis][1]; Event::Type eventAxisPos = myJoyAxisTable[stick][axis][1][kEmulationMode];
// Check for analog events, which are handled differently // Check for analog events, which are handled differently
switch((int)eventAxisNeg) switch((int)eventAxisNeg)
@ -980,13 +983,13 @@ void EventHandler::handleJoyHatEvent(int stick, int hat, int value)
{ {
// Turn off all associated events, since we don't know exactly // Turn off all associated events, since we don't know exactly
// which one was previously activated. // which one was previously activated.
handleEvent(myJoyHatTable[stick][hat][0], 0); handleEvent(myJoyHatTable[stick][hat][0][kEmulationMode], 0);
handleEvent(myJoyHatTable[stick][hat][1], 0); handleEvent(myJoyHatTable[stick][hat][1][kEmulationMode], 0);
handleEvent(myJoyHatTable[stick][hat][2], 0); handleEvent(myJoyHatTable[stick][hat][2][kEmulationMode], 0);
handleEvent(myJoyHatTable[stick][hat][3], 0); handleEvent(myJoyHatTable[stick][hat][3][kEmulationMode], 0);
} }
else else
handleEvent(myJoyHatTable[stick][hat][value], 1); handleEvent(myJoyHatTable[stick][hat][value][kEmulationMode], 1);
} }
else if(myOverlay != NULL) else if(myOverlay != NULL)
myOverlay->handleJoyHatEvent(stick, hat, value); myOverlay->handleJoyHatEvent(stick, hat, value);
@ -1215,8 +1218,6 @@ bool EventHandler::eventStateChange(Event::Type type)
{ {
if(myState == S_EMULATE) if(myState == S_EMULATE)
enterMenuMode(S_MENU); enterMenuMode(S_MENU);
// else if(myState == S_MENU) // FIXME - maybe 'tab' should only enter, not exit
// leaveMenuMode();
else else
handled = false; handled = false;
} }
@ -1275,22 +1276,40 @@ void EventHandler::createMouseButtonEvent(int x, int y, int state)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setActionMappings() void EventHandler::setActionMappings(EventMode mode)
{ {
int listsize = 0;
ActionList* list = NULL;
switch(mode)
{
case kEmulationMode:
listsize = kEmulActionListSize;
list = ourEmulActionList;
break;
case kMenuMode:
listsize = kMenuActionListSize;
list = ourMenuActionList;
break;
default:
return;
break;
}
int i, j, stick, button, axis, hat, dir; int i, j, stick, button, axis, hat, dir;
ostringstream buf; ostringstream buf;
// Fill the ActionList with the current key and joystick mappings // Fill the ActionList with the current key and joystick mappings
for(i = 0; i < kActionListSize; ++i) for(i = 0; i < listsize; ++i)
{ {
Event::Type event = ourActionList[i].event; Event::Type event = list[i].event;
if(ourActionList[i].key) if(list[i].key)
free(ourActionList[i].key); free(list[i].key);
ourActionList[i].key = strdup("None"); list[i].key = strdup("None");
string key = ""; string key = "";
for(j = 0; j < SDLK_LAST; ++j) // key mapping for(j = 0; j < SDLK_LAST; ++j) // key mapping
{ {
if(myKeyTable[j] == event) if(myKeyTable[j][mode] == event)
{ {
if(key == "") if(key == "")
key = key + ourSDLMapping[j]; key = key + ourSDLMapping[j];
@ -1304,7 +1323,7 @@ void EventHandler::setActionMappings()
{ {
for(button = 0; button < kNumJoyButtons; ++button) for(button = 0; button < kNumJoyButtons; ++button)
{ {
if(myJoyTable[stick][button] == event) if(myJoyTable[stick][button][mode] == event)
{ {
buf.str(""); buf.str("");
buf << "J" << stick << " B" << button; buf << "J" << stick << " B" << button;
@ -1322,7 +1341,7 @@ void EventHandler::setActionMappings()
{ {
for(dir = 0; dir < 2; ++dir) for(dir = 0; dir < 2; ++dir)
{ {
if(myJoyAxisTable[stick][axis][dir] == event) if(myJoyAxisTable[stick][axis][dir][mode] == event)
{ {
buf.str(""); buf.str("");
buf << "J" << stick << " axis " << axis; buf << "J" << stick << " axis " << axis;
@ -1351,7 +1370,7 @@ void EventHandler::setActionMappings()
{ {
for(dir = 0; dir < 4; ++dir) for(dir = 0; dir < 4; ++dir)
{ {
if(myJoyHatTable[stick][hat][dir] == event) if(myJoyHatTable[stick][hat][dir][mode] == event)
{ {
buf.str(""); buf.str("");
buf << "J" << stick << " hat " << hat; buf << "J" << stick << " hat " << hat;
@ -1389,9 +1408,9 @@ void EventHandler::setActionMappings()
if(key != "") if(key != "")
{ {
if(ourActionList[i].key) if(list[i].key)
free(ourActionList[i].key); free(list[i].key);
ourActionList[i].key = strdup(key.c_str()); list[i].key = strdup(key.c_str());
} }
} }
} }
@ -1402,14 +1421,19 @@ void EventHandler::setKeymap()
string list = myOSystem->settings().getString("keymap"); string list = myOSystem->settings().getString("keymap");
IntArray map; IntArray map;
if(isValidList(list, map, SDLK_LAST)) if(isValidList(list, map, SDLK_LAST * kNumModes))
{ {
// Fill the keymap table with events // Fill the keymap table with events
for(Int32 i = 0; i < SDLK_LAST; ++i) IntArray::const_iterator event = map.begin();
myKeyTable[i] = (Event::Type) map[i]; for(int mode = 0; mode < kNumModes; ++mode)
for(int i = 0; i < SDLK_LAST; ++i)
myKeyTable[i][mode] = (Event::Type) *event++;
} }
else else
setDefaultKeymap(); {
setDefaultKeymap(kEmulationMode);
setDefaultKeymap(kMenuMode);
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1419,16 +1443,20 @@ void EventHandler::setJoymap()
string list = myOSystem->settings().getString("joymap"); string list = myOSystem->settings().getString("joymap");
IntArray map; IntArray map;
if(isValidList(list, map, kNumJoysticks*kNumJoyButtons)) if(isValidList(list, map, kNumJoysticks*kNumJoyButtons*kNumModes))
{ {
// Fill the joymap table with events // Fill the joymap table with events
int idx = 0; IntArray::const_iterator event = map.begin();
for(int mode = 0; mode < kNumModes; ++mode)
for(int i = 0; i < kNumJoysticks; ++i) for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyButtons; ++j) for(int j = 0; j < kNumJoyButtons; ++j)
myJoyTable[i][j] = (Event::Type) map[idx++]; myJoyTable[i][j][mode] = (Event::Type) *event++;
} }
else else
setDefaultJoymap(); {
setDefaultJoymap(kEmulationMode);
setDefaultJoymap(kMenuMode);
}
#endif #endif
} }
@ -1439,17 +1467,21 @@ void EventHandler::setJoyAxisMap()
string list = myOSystem->settings().getString("joyaxismap"); string list = myOSystem->settings().getString("joyaxismap");
IntArray map; IntArray map;
if(isValidList(list, map, kNumJoysticks*kNumJoyAxis*2)) if(isValidList(list, map, kNumJoysticks*kNumJoyAxis*2*kNumModes))
{ {
// Fill the joyaxismap table with events // Fill the joyaxismap table with events
int idx = 0; IntArray::const_iterator event = map.begin();
for(int mode = 0; mode < kNumModes; ++mode)
for(int i = 0; i < kNumJoysticks; ++i) for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyAxis; ++j) for(int j = 0; j < kNumJoyAxis; ++j)
for(int k = 0; k < 2; ++k) for(int k = 0; k < 2; ++k)
myJoyAxisTable[i][j][k] = (Event::Type) map[idx++]; myJoyAxisTable[i][j][k][mode] = (Event::Type) *event++;
} }
else else
setDefaultJoyAxisMap(); {
setDefaultJoyAxisMap(kEmulationMode);
setDefaultJoyAxisMap(kMenuMode);
}
#endif #endif
} }
@ -1460,54 +1492,60 @@ void EventHandler::setJoyHatMap()
string list = myOSystem->settings().getString("joyhatmap"); string list = myOSystem->settings().getString("joyhatmap");
IntArray map; IntArray map;
if(isValidList(list, map, kNumJoysticks*kNumJoyHats*4)) if(isValidList(list, map, kNumJoysticks*kNumJoyHats*4*kNumModes))
{ {
// Fill the joyhatmap table with events // Fill the joyhatmap table with events
int idx = 0; IntArray::const_iterator event = map.begin();
for(int mode = 0; mode < kNumModes; ++mode)
for(int i = 0; i < kNumJoysticks; ++i) for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyHats; ++j) for(int j = 0; j < kNumJoyHats; ++j)
for(int k = 0; k < 4; ++k) for(int k = 0; k < 4; ++k)
myJoyHatTable[i][j][k] = (Event::Type) map[idx++]; myJoyHatTable[i][j][k][mode] = (Event::Type) *event++;
} }
else else
setDefaultJoyHatMap(); {
setDefaultJoyHatMap(kEmulationMode);
setDefaultJoyHatMap(kMenuMode);
}
#endif #endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::addKeyMapping(Event::Type event, int key) bool EventHandler::addKeyMapping(Event::Type event, EventMode mode, int key)
{ {
// These keys cannot be remapped. // These keys cannot be remapped.
if(key == SDLK_TAB || eventIsAnalog(event)) if(key == SDLK_TAB || eventIsAnalog(event))
return false; return false;
else else
{ {
myKeyTable[key] = event; myKeyTable[key][mode] = event;
saveKeyMapping(); saveKeyMapping();
setActionMappings(); setActionMappings(mode);
return true; return true;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultJoyMapping(Event::Type event, int stick, int button) void EventHandler::setDefaultJoyMapping(Event::Type event, EventMode mode,
int stick, int button)
{ {
if(stick >= 0 && stick < kNumJoysticks && if(stick >= 0 && stick < kNumJoysticks &&
button >= 0 && button < kNumJoyButtons && button >= 0 && button < kNumJoyButtons &&
event >= 0 && event < Event::LastType) event >= 0 && event < Event::LastType)
myJoyTable[stick][button] = event; myJoyTable[stick][button][mode] = event;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::addJoyMapping(Event::Type event, int stick, int button) bool EventHandler::addJoyMapping(Event::Type event, EventMode mode,
int stick, int button)
{ {
if(!eventIsAnalog(event)) if(!eventIsAnalog(event))
{ {
setDefaultJoyMapping(event, stick, button); setDefaultJoyMapping(event, mode, stick, button);
saveJoyMapping(); saveJoyMapping();
setActionMappings(); setActionMappings(mode);
return true; return true;
} }
else else
@ -1515,8 +1553,8 @@ bool EventHandler::addJoyMapping(Event::Type event, int stick, int button)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultJoyAxisMapping(Event::Type event, int stick, void EventHandler::setDefaultJoyAxisMapping(Event::Type event, EventMode mode,
int axis, int value) int stick, int axis, int value)
{ {
if(stick >= 0 && stick < kNumJoysticks && if(stick >= 0 && stick < kNumJoysticks &&
axis >= 0 && axis < kNumJoyAxis && axis >= 0 && axis < kNumJoyAxis &&
@ -1525,35 +1563,36 @@ void EventHandler::setDefaultJoyAxisMapping(Event::Type event, int stick,
// This confusing code is because each axis has two associated values, // This confusing code is because each axis has two associated values,
// but analog events only affect one of the axis. // but analog events only affect one of the axis.
if(eventIsAnalog(event)) if(eventIsAnalog(event))
myJoyAxisTable[stick][axis][0] = myJoyAxisTable[stick][axis][1] = event; myJoyAxisTable[stick][axis][0][mode] =
myJoyAxisTable[stick][axis][1][mode] = event;
else else
{ {
// Otherwise, turn off the analog event(s) for this axis // Otherwise, turn off the analog event(s) for this axis
if(eventIsAnalog(myJoyAxisTable[stick][axis][0])) if(eventIsAnalog(myJoyAxisTable[stick][axis][0][mode]))
myJoyAxisTable[stick][axis][0] = Event::NoType; myJoyAxisTable[stick][axis][0][mode] = Event::NoType;
if(eventIsAnalog(myJoyAxisTable[stick][axis][1])) if(eventIsAnalog(myJoyAxisTable[stick][axis][1][mode]))
myJoyAxisTable[stick][axis][1] = Event::NoType; myJoyAxisTable[stick][axis][1][mode] = Event::NoType;
myJoyAxisTable[stick][axis][(value > 0)] = event; myJoyAxisTable[stick][axis][(value > 0)][mode] = event;
} }
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::addJoyAxisMapping(Event::Type event, int stick, int axis, bool EventHandler::addJoyAxisMapping(Event::Type event, EventMode mode,
int value) int stick, int axis, int value)
{ {
setDefaultJoyAxisMapping(event, stick, axis, value); setDefaultJoyAxisMapping(event, mode, stick, axis, value);
saveJoyAxisMapping(); saveJoyAxisMapping();
setActionMappings(); setActionMappings(mode);
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultJoyHatMapping(Event::Type event, int stick, void EventHandler::setDefaultJoyHatMapping(Event::Type event, EventMode mode,
int hat, int value) int stick, int hat, int value)
{ {
if(stick >= 0 && stick < kNumJoysticks && if(stick >= 0 && stick < kNumJoysticks &&
hat >= 0 && hat < kNumJoyHats && hat >= 0 && hat < kNumJoyHats &&
@ -1565,22 +1604,22 @@ void EventHandler::setDefaultJoyHatMapping(Event::Type event, int stick,
case kJHatDown: case kJHatDown:
case kJHatLeft: case kJHatLeft:
case kJHatRight: case kJHatRight:
myJoyHatTable[stick][hat][value] = event; myJoyHatTable[stick][hat][value][mode] = event;
break; break;
} }
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::addJoyHatMapping(Event::Type event, int stick, int hat, bool EventHandler::addJoyHatMapping(Event::Type event, EventMode mode,
int value) int stick, int hat, int value)
{ {
if(!eventIsAnalog(event)) if(!eventIsAnalog(event))
{ {
setDefaultJoyHatMapping(event, stick, hat, value); setDefaultJoyHatMapping(event, mode, stick, hat, value);
saveJoyHatMapping(); saveJoyHatMapping();
setActionMappings(); setActionMappings(mode);
return true; return true;
} }
else else
@ -1588,168 +1627,192 @@ bool EventHandler::addJoyHatMapping(Event::Type event, int stick, int hat,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::eraseMapping(Event::Type event) void EventHandler::eraseMapping(Event::Type event, EventMode mode)
{ {
int i, j, k; int i, j, k;
// Erase the KeyEvent arrays // Erase the KeyEvent arrays
for(i = 0; i < SDLK_LAST; ++i) for(i = 0; i < SDLK_LAST; ++i)
if(myKeyTable[i] == event && i != SDLK_TAB) if(myKeyTable[i][mode] == event && i != SDLK_TAB)
myKeyTable[i] = Event::NoType; myKeyTable[i][mode] = Event::NoType;
saveKeyMapping(); saveKeyMapping();
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
// Erase the JoyEvent array // Erase the JoyEvent array
for(i = 0; i < kNumJoysticks; ++i) for(i = 0; i < kNumJoysticks; ++i)
for(j = 0; j < kNumJoyButtons; ++j) for(j = 0; j < kNumJoyButtons; ++j)
if(myJoyTable[i][j] == event) if(myJoyTable[i][j][mode] == event)
myJoyTable[i][j] = Event::NoType; myJoyTable[i][j][mode] = Event::NoType;
saveJoyMapping(); saveJoyMapping();
// Erase the JoyAxisEvent array // Erase the JoyAxisEvent array
for(i = 0; i < kNumJoysticks; ++i) for(i = 0; i < kNumJoysticks; ++i)
for(j = 0; j < kNumJoyAxis; ++j) for(j = 0; j < kNumJoyAxis; ++j)
for(k = 0; k < 2; ++k) for(k = 0; k < 2; ++k)
if(myJoyAxisTable[i][j][k] == event) if(myJoyAxisTable[i][j][k][mode] == event)
myJoyAxisTable[i][j][k] = Event::NoType; myJoyAxisTable[i][j][k][mode] = Event::NoType;
saveJoyAxisMapping(); saveJoyAxisMapping();
// Erase the JoyHatEvent array // Erase the JoyHatEvent array
for(i = 0; i < kNumJoysticks; ++i) for(i = 0; i < kNumJoysticks; ++i)
for(j = 0; j < kNumJoyHats; ++j) for(j = 0; j < kNumJoyHats; ++j)
for(k = 0; k < 4; ++k) for(k = 0; k < 4; ++k)
if(myJoyHatTable[i][j][k] == event) if(myJoyHatTable[i][j][k][mode] == event)
myJoyHatTable[i][j][k] = Event::NoType; myJoyHatTable[i][j][k][mode] = Event::NoType;
saveJoyHatMapping(); saveJoyHatMapping();
#endif #endif
setActionMappings(); setActionMappings(mode);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultMapping() void EventHandler::setDefaultMapping(EventMode mode)
{ {
setDefaultKeymap(); setDefaultKeymap(mode);
setDefaultJoymap(); setDefaultJoymap(mode);
setDefaultJoyAxisMap(); setDefaultJoyAxisMap(mode);
setDefaultJoyHatMap(); setDefaultJoyHatMap(mode);
setActionMappings(); setActionMappings(mode);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultKeymap() void EventHandler::setDefaultKeymap(EventMode mode)
{ {
switch(mode)
{
case kEmulationMode:
// Erase all mappings // Erase all mappings
for(Int32 i = 0; i < SDLK_LAST; ++i) for(int i = 0; i < SDLK_LAST; ++i)
myKeyTable[i] = Event::NoType; myKeyTable[i][mode] = Event::NoType;
myKeyTable[ SDLK_1 ] = Event::KeyboardZero1; myKeyTable[ SDLK_1 ][mode] = Event::KeyboardZero1;
myKeyTable[ SDLK_2 ] = Event::KeyboardZero2; myKeyTable[ SDLK_2 ][mode] = Event::KeyboardZero2;
myKeyTable[ SDLK_3 ] = Event::KeyboardZero3; myKeyTable[ SDLK_3 ][mode] = Event::KeyboardZero3;
myKeyTable[ SDLK_q ] = Event::KeyboardZero4; myKeyTable[ SDLK_q ][mode] = Event::KeyboardZero4;
myKeyTable[ SDLK_w ] = Event::KeyboardZero5; myKeyTable[ SDLK_w ][mode] = Event::KeyboardZero5;
myKeyTable[ SDLK_e ] = Event::KeyboardZero6; myKeyTable[ SDLK_e ][mode] = Event::KeyboardZero6;
myKeyTable[ SDLK_a ] = Event::KeyboardZero7; myKeyTable[ SDLK_a ][mode] = Event::KeyboardZero7;
myKeyTable[ SDLK_s ] = Event::KeyboardZero8; myKeyTable[ SDLK_s ][mode] = Event::KeyboardZero8;
myKeyTable[ SDLK_d ] = Event::KeyboardZero9; myKeyTable[ SDLK_d ][mode] = Event::KeyboardZero9;
myKeyTable[ SDLK_z ] = Event::KeyboardZeroStar; myKeyTable[ SDLK_z ][mode] = Event::KeyboardZeroStar;
myKeyTable[ SDLK_x ] = Event::KeyboardZero0; myKeyTable[ SDLK_x ][mode] = Event::KeyboardZero0;
myKeyTable[ SDLK_c ] = Event::KeyboardZeroPound; myKeyTable[ SDLK_c ][mode] = Event::KeyboardZeroPound;
myKeyTable[ SDLK_8 ] = Event::KeyboardOne1; myKeyTable[ SDLK_8 ][mode] = Event::KeyboardOne1;
myKeyTable[ SDLK_9 ] = Event::KeyboardOne2; myKeyTable[ SDLK_9 ][mode] = Event::KeyboardOne2;
myKeyTable[ SDLK_0 ] = Event::KeyboardOne3; myKeyTable[ SDLK_0 ][mode] = Event::KeyboardOne3;
myKeyTable[ SDLK_i ] = Event::KeyboardOne4; myKeyTable[ SDLK_i ][mode] = Event::KeyboardOne4;
myKeyTable[ SDLK_o ] = Event::KeyboardOne5; myKeyTable[ SDLK_o ][mode] = Event::KeyboardOne5;
myKeyTable[ SDLK_p ] = Event::KeyboardOne6; myKeyTable[ SDLK_p ][mode] = Event::KeyboardOne6;
myKeyTable[ SDLK_k ] = Event::KeyboardOne7; myKeyTable[ SDLK_k ][mode] = Event::KeyboardOne7;
myKeyTable[ SDLK_l ] = Event::KeyboardOne8; myKeyTable[ SDLK_l ][mode] = Event::KeyboardOne8;
myKeyTable[ SDLK_SEMICOLON ] = Event::KeyboardOne9; myKeyTable[ SDLK_SEMICOLON ][mode] = Event::KeyboardOne9;
myKeyTable[ SDLK_COMMA ] = Event::KeyboardOneStar; myKeyTable[ SDLK_COMMA ][mode] = Event::KeyboardOneStar;
myKeyTable[ SDLK_PERIOD ] = Event::KeyboardOne0; myKeyTable[ SDLK_PERIOD ][mode] = Event::KeyboardOne0;
myKeyTable[ SDLK_SLASH ] = Event::KeyboardOnePound; myKeyTable[ SDLK_SLASH ][mode] = Event::KeyboardOnePound;
myKeyTable[ SDLK_UP ] = Event::JoystickZeroUp; myKeyTable[ SDLK_UP ][mode] = Event::JoystickZeroUp;
myKeyTable[ SDLK_DOWN ] = Event::JoystickZeroDown; myKeyTable[ SDLK_DOWN ][mode] = Event::JoystickZeroDown;
myKeyTable[ SDLK_LEFT ] = Event::JoystickZeroLeft; myKeyTable[ SDLK_LEFT ][mode] = Event::JoystickZeroLeft;
myKeyTable[ SDLK_RIGHT ] = Event::JoystickZeroRight; myKeyTable[ SDLK_RIGHT ][mode] = Event::JoystickZeroRight;
myKeyTable[ SDLK_SPACE ] = Event::JoystickZeroFire; myKeyTable[ SDLK_SPACE ][mode] = Event::JoystickZeroFire;
myKeyTable[ SDLK_LCTRL ] = Event::JoystickZeroFire; myKeyTable[ SDLK_LCTRL ][mode] = Event::JoystickZeroFire;
myKeyTable[ SDLK_4 ] = Event::BoosterGripZeroTrigger; myKeyTable[ SDLK_4 ][mode] = Event::BoosterGripZeroTrigger;
myKeyTable[ SDLK_5 ] = Event::BoosterGripZeroBooster; myKeyTable[ SDLK_5 ][mode] = Event::BoosterGripZeroBooster;
myKeyTable[ SDLK_y ] = Event::JoystickOneUp; myKeyTable[ SDLK_y ][mode] = Event::JoystickOneUp;
myKeyTable[ SDLK_h ] = Event::JoystickOneDown; myKeyTable[ SDLK_h ][mode] = Event::JoystickOneDown;
myKeyTable[ SDLK_g ] = Event::JoystickOneLeft; myKeyTable[ SDLK_g ][mode] = Event::JoystickOneLeft;
myKeyTable[ SDLK_j ] = Event::JoystickOneRight; myKeyTable[ SDLK_j ][mode] = Event::JoystickOneRight;
myKeyTable[ SDLK_f ] = Event::JoystickOneFire; myKeyTable[ SDLK_f ][mode] = Event::JoystickOneFire;
myKeyTable[ SDLK_6 ] = Event::BoosterGripOneTrigger; myKeyTable[ SDLK_6 ][mode] = Event::BoosterGripOneTrigger;
myKeyTable[ SDLK_7 ] = Event::BoosterGripOneBooster; myKeyTable[ SDLK_7 ][mode] = Event::BoosterGripOneBooster;
myKeyTable[ SDLK_INSERT ] = Event::DrivingZeroCounterClockwise; myKeyTable[ SDLK_INSERT ][mode] = Event::DrivingZeroCounterClockwise;
myKeyTable[ SDLK_PAGEUP ] = Event::DrivingZeroClockwise; myKeyTable[ SDLK_PAGEUP ][mode] = Event::DrivingZeroClockwise;
myKeyTable[ SDLK_HOME ] = Event::DrivingZeroFire; myKeyTable[ SDLK_HOME ][mode] = Event::DrivingZeroFire;
myKeyTable[ SDLK_DELETE ] = Event::DrivingOneCounterClockwise; myKeyTable[ SDLK_DELETE ][mode] = Event::DrivingOneCounterClockwise;
myKeyTable[ SDLK_PAGEDOWN ] = Event::DrivingOneClockwise; myKeyTable[ SDLK_PAGEDOWN ][mode] = Event::DrivingOneClockwise;
myKeyTable[ SDLK_END ] = Event::DrivingOneFire; myKeyTable[ SDLK_END ][mode] = Event::DrivingOneFire;
myKeyTable[ SDLK_F1 ] = Event::ConsoleSelect; myKeyTable[ SDLK_F1 ][mode] = Event::ConsoleSelect;
myKeyTable[ SDLK_F2 ] = Event::ConsoleReset; myKeyTable[ SDLK_F2 ][mode] = Event::ConsoleReset;
myKeyTable[ SDLK_F3 ] = Event::ConsoleColor; myKeyTable[ SDLK_F3 ][mode] = Event::ConsoleColor;
myKeyTable[ SDLK_F4 ] = Event::ConsoleBlackWhite; myKeyTable[ SDLK_F4 ][mode] = Event::ConsoleBlackWhite;
myKeyTable[ SDLK_F5 ] = Event::ConsoleLeftDifficultyA; myKeyTable[ SDLK_F5 ][mode] = Event::ConsoleLeftDifficultyA;
myKeyTable[ SDLK_F6 ] = Event::ConsoleLeftDifficultyB; myKeyTable[ SDLK_F6 ][mode] = Event::ConsoleLeftDifficultyB;
myKeyTable[ SDLK_F7 ] = Event::ConsoleRightDifficultyA; myKeyTable[ SDLK_F7 ][mode] = Event::ConsoleRightDifficultyA;
myKeyTable[ SDLK_F8 ] = Event::ConsoleRightDifficultyB; myKeyTable[ SDLK_F8 ][mode] = Event::ConsoleRightDifficultyB;
myKeyTable[ SDLK_F9 ] = Event::SaveState; myKeyTable[ SDLK_F9 ][mode] = Event::SaveState;
myKeyTable[ SDLK_F10 ] = Event::ChangeState; myKeyTable[ SDLK_F10 ][mode] = Event::ChangeState;
myKeyTable[ SDLK_F11 ] = Event::LoadState; myKeyTable[ SDLK_F11 ][mode] = Event::LoadState;
myKeyTable[ SDLK_F12 ] = Event::TakeSnapshot; myKeyTable[ SDLK_F12 ][mode] = Event::TakeSnapshot;
myKeyTable[ SDLK_PAUSE ] = Event::Pause; myKeyTable[ SDLK_PAUSE ][mode] = Event::Pause;
myKeyTable[ SDLK_BACKSPACE ] = Event::Fry; myKeyTable[ SDLK_BACKSPACE ][mode] = Event::Fry;
myKeyTable[ SDLK_TAB ] = Event::MenuMode; myKeyTable[ SDLK_TAB ][mode] = Event::MenuMode;
myKeyTable[ SDLK_BACKSLASH ] = Event::CmdMenuMode; myKeyTable[ SDLK_BACKSLASH ][mode] = Event::CmdMenuMode;
myKeyTable[ SDLK_BACKQUOTE ] = Event::DebuggerMode; myKeyTable[ SDLK_BACKQUOTE ][mode] = Event::DebuggerMode;
myKeyTable[ SDLK_ESCAPE ] = Event::LauncherMode; myKeyTable[ SDLK_ESCAPE ][mode] = Event::LauncherMode;
break;
case kMenuMode:
myKeyTable[ SDLK_UP ][mode] = Event::UIUp;
myKeyTable[ SDLK_DOWN ][mode] = Event::UIDown;
myKeyTable[ SDLK_LEFT ][mode] = Event::UILeft;
myKeyTable[ SDLK_RIGHT ][mode] = Event::UIRight;
myKeyTable[ SDLK_HOME ][mode] = Event::UIHome;
myKeyTable[ SDLK_END ][mode] = Event::UIEnd;
myKeyTable[ SDLK_PAGEUP ][mode] = Event::UIPgUp;
myKeyTable[ SDLK_PAGEDOWN ][mode] = Event::UIPgDown;
myKeyTable[ SDLK_RETURN ][mode] = Event::UISelect;
myKeyTable[ SDLK_BACKSPACE ][mode] = Event::UIPrevDir;
break;
default:
return;
break;
}
saveKeyMapping(); saveKeyMapping();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultJoymap() void EventHandler::setDefaultJoymap(EventMode mode)
{ {
// Erase all mappings // Erase all mappings
for(int i = 0; i < kNumJoysticks; ++i) for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyButtons; ++j) for(int j = 0; j < kNumJoyButtons; ++j)
myJoyTable[i][j] = Event::NoType; myJoyTable[i][j][mode] = Event::NoType;
myOSystem->setDefaultJoymap(); myOSystem->setDefaultJoymap();
saveJoyMapping(); saveJoyMapping();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultJoyAxisMap() void EventHandler::setDefaultJoyAxisMap(EventMode mode)
{ {
// Erase all mappings // Erase all mappings
for(int i = 0; i < kNumJoysticks; ++i) for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyAxis; ++j) for(int j = 0; j < kNumJoyAxis; ++j)
for(int k = 0; k < 2; ++k) for(int k = 0; k < 2; ++k)
myJoyAxisTable[i][j][k] = Event::NoType; myJoyAxisTable[i][j][k][mode] = Event::NoType;
myOSystem->setDefaultJoyAxisMap(); myOSystem->setDefaultJoyAxisMap();
saveJoyAxisMapping(); saveJoyAxisMapping();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultJoyHatMap() void EventHandler::setDefaultJoyHatMap(EventMode mode)
{ {
// Erase all mappings // Erase all mappings
for(int i = 0; i < kNumJoysticks; ++i) for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyHats; ++j) for(int j = 0; j < kNumJoyHats; ++j)
for(int k = 0; k < 4; ++k) for(int k = 0; k < 4; ++k)
myJoyHatTable[i][j][k] = Event::NoType; myJoyHatTable[i][j][k][mode] = Event::NoType;
myOSystem->setDefaultJoyHatMap(); myOSystem->setDefaultJoyHatMap();
saveJoyHatMapping(); saveJoyHatMapping();
@ -1762,8 +1825,9 @@ void EventHandler::saveKeyMapping()
// Prepend the event count, so we can check it on next load // Prepend the event count, so we can check it on next load
ostringstream keybuf; ostringstream keybuf;
keybuf << Event::LastType << ":"; keybuf << Event::LastType << ":";
for(uInt32 i = 0; i < SDLK_LAST; ++i) for(int mode = 0; mode < kNumModes; ++mode)
keybuf << myKeyTable[i] << ":"; for(int i = 0; i < SDLK_LAST; ++i)
keybuf << myKeyTable[i][mode] << ":";
myOSystem->settings().setString("keymap", keybuf.str()); myOSystem->settings().setString("keymap", keybuf.str());
} }
@ -1775,9 +1839,10 @@ void EventHandler::saveJoyMapping()
// Prepend the event count, so we can check it on next load // Prepend the event count, so we can check it on next load
ostringstream buf; ostringstream buf;
buf << Event::LastType << ":"; buf << Event::LastType << ":";
for(int mode = 0; mode < kNumModes; ++mode)
for(int i = 0; i < kNumJoysticks; ++i) for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyButtons; ++j) for(int j = 0; j < kNumJoyButtons; ++j)
buf << myJoyTable[i][j] << ":"; buf << myJoyTable[i][j][mode] << ":";
myOSystem->settings().setString("joymap", buf.str()); myOSystem->settings().setString("joymap", buf.str());
} }
@ -1789,10 +1854,11 @@ void EventHandler::saveJoyAxisMapping()
// Prepend the event count, so we can check it on next load // Prepend the event count, so we can check it on next load
ostringstream buf; ostringstream buf;
buf << Event::LastType << ":"; buf << Event::LastType << ":";
for(int mode = 0; mode < kNumModes; ++mode)
for(int i = 0; i < kNumJoysticks; ++i) for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyAxis; ++j) for(int j = 0; j < kNumJoyAxis; ++j)
for(int k = 0; k < 2; ++k) for(int k = 0; k < 2; ++k)
buf << myJoyAxisTable[i][j][k] << ":"; buf << myJoyAxisTable[i][j][k][mode] << ":";
myOSystem->settings().setString("joyaxismap", buf.str()); myOSystem->settings().setString("joyaxismap", buf.str());
} }
@ -1804,10 +1870,11 @@ void EventHandler::saveJoyHatMapping()
// Prepend the event count, so we can check it on next load // Prepend the event count, so we can check it on next load
ostringstream buf; ostringstream buf;
buf << Event::LastType << ":"; buf << Event::LastType << ":";
for(int mode = 0; mode < kNumModes; ++mode)
for(int i = 0; i < kNumJoysticks; ++i) for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyHats; ++j) for(int j = 0; j < kNumJoyHats; ++j)
for(int k = 0; k < 4; ++k) for(int k = 0; k < 4; ++k)
buf << myJoyHatTable[i][j][k] << ":"; buf << myJoyHatTable[i][j][k][mode] << ":";
myOSystem->settings().setString("joyhatmap", buf.str()); myOSystem->settings().setString("joyhatmap", buf.str());
} }
@ -1849,98 +1916,94 @@ inline bool EventHandler::eventIsAnalog(Event::Type event)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StringList EventHandler::getEmulationActions() StringList EventHandler::getActionList(EventMode mode)
{ {
StringList l; StringList l;
for(int i = 0; i < kActionListSize; ++i) switch(mode)
l.push_back(EventHandler::ourActionList[i].action);
return l;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StringList EventHandler::getMenuActions()
{ {
StringList l; // FIXME case kEmulationMode:
for(int i = 0; i < kEmulActionListSize; ++i)
// for(int i = 0; i < kActionListSize; ++i) l.push_back(EventHandler::ourEmulActionList[i].action);
// l.push_back(EventHandler::ourActionList[i].action);
return l;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type EventHandler::eventForKey(int key, EventMode mode)
{
// FIXME - eventually make this a one-line inliner in the header
Event::Type e = Event::NoType;
// FIXME - eventually this will return the mapped events for
// keys either for emulation mode or UI mode. For now, it always
// assumes UI mode, and generates the key statically.
if(key < 0 || key >= SDLK_LAST)
return e;
switch(key)
{
case '\n': // enter/return
case '\r':
e = Event::UISelect;
break; break;
case 256+17: // cursor up case kMenuMode:
e = Event::UIUp; for(int i = 0; i < kMenuActionListSize; ++i)
break; l.push_back(EventHandler::ourMenuActionList[i].action);
case 256+18: // cursor down
e = Event::UIDown;
break;
case 256+20: // cursor left
e = Event::UILeft;
break;
case 256+19: // cursor right
e = Event::UIRight;
break;
case 256+24: // Page Up:
e = Event::UIPgUp;
break;
case 256+25: // Page Down
e = Event::UIPgDown;
break;
case 256+22: // Home
e = Event::UIHome;
break;
case 256+23: // End
e = Event::UIEnd;
break; break;
default: default:
break; break;
} }
return e; // ... myKeyTable[key];
return l;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type EventHandler::eventForJoyButton(int stick, int button, Event::Type EventHandler::eventAtIndex(int idx, EventMode mode)
EventMode mode)
{ {
// FIXME - do a lookup switch(mode)
{
case kEmulationMode:
if(idx < 0 || idx >= kEmulActionListSize)
return Event::NoType; return Event::NoType;
else
return ourEmulActionList[idx].event;
break;
case kMenuMode:
if(idx < 0 || idx >= kMenuActionListSize)
return Event::NoType;
else
return ourMenuActionList[idx].event;
break;
default:
return Event::NoType;
break;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type EventHandler::eventForJoyAxis(int stick, int axis, int value, string EventHandler::actionAtIndex(int idx, EventMode mode)
EventMode mode)
{ {
// FIXME - do a lookup switch(mode)
return Event::NoType; {
case kEmulationMode:
if(idx < 0 || idx >= kEmulActionListSize)
return EmptyString;
else
return ourEmulActionList[idx].action;
break;
case kMenuMode:
if(idx < 0 || idx >= kMenuActionListSize)
return EmptyString;
else
return ourMenuActionList[idx].action;
break;
default:
return EmptyString;
break;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type EventHandler::eventForJoyHat(int stick, int hat, int value, string EventHandler::keyAtIndex(int idx, EventMode mode)
EventMode mode)
{ {
// FIXME - do a lookup switch(mode)
return Event::NoType; {
case kEmulationMode:
if(idx < 0 || idx >= kEmulActionListSize)
return EmptyString;
else
return ourEmulActionList[idx].key;
break;
case kMenuMode:
if(idx < 0 || idx >= kMenuActionListSize)
return EmptyString;
else
return ourMenuActionList[idx].key;
break;
default:
return EmptyString;
break;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -2090,7 +2153,7 @@ void EventHandler::takeSnapshot()
filename = sspath + ".png"; filename = sspath + ".png";
// Now create a Snapshot object and save the PNG // Now create a Snapshot object and save the PNG
myOSystem->eventHandler().refreshDisplay(true); // force an immediate update refreshDisplay(true); // force an immediate update
Snapshot snapshot(myOSystem->frameBuffer()); Snapshot snapshot(myOSystem->frameBuffer());
string result = snapshot.savePNG(filename); string result = snapshot.savePNG(filename);
myOSystem->frameBuffer().showMessage(result); myOSystem->frameBuffer().showMessage(result);
@ -2497,7 +2560,7 @@ void EventHandler::setSDLMappings()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ActionList EventHandler::ourActionList[kActionListSize] = { ActionList EventHandler::ourEmulActionList[kEmulActionListSize] = {
{ Event::ConsoleSelect, "Select", 0 }, { Event::ConsoleSelect, "Select", 0 },
{ Event::ConsoleReset, "Reset", 0 }, { Event::ConsoleReset, "Reset", 0 },
{ Event::ConsoleColor, "Color TV", 0 }, { Event::ConsoleColor, "Color TV", 0 },
@ -2593,6 +2656,27 @@ ActionList EventHandler::ourActionList[kActionListSize] = {
{ Event::KeyboardOnePound, "P2 Keyboard #", 0 } { Event::KeyboardOnePound, "P2 Keyboard #", 0 }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ActionList EventHandler::ourMenuActionList[kMenuActionListSize] = {
{ Event::UIUp, "Move Up", 0 },
{ Event::UIDown, "Move Down", 0 },
{ Event::UILeft, "Move Left", 0 },
{ Event::UIRight, "Move Right", 0 },
{ Event::UIHome, "Home", 0 },
{ Event::UIEnd, "End", 0 },
{ Event::UIPgUp, "Page Up", 0 },
{ Event::UIPgDown, "Page Down", 0 },
{ Event::UISelect, "Select item", 0 },
{ Event::UIPrevDir, "Previous Directory", 0 },
{ Event::UINavPrev, "Previous object", 0 },
{ Event::UINavNext, "Next object", 0 },
{ Event::UITabPrev, "Previous tabgroup", 0 },
{ Event::UITabNext, "Next tabgroup", 0 }
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Event::Type EventHandler::Paddle_Resistance[4] = { const Event::Type EventHandler::Paddle_Resistance[4] = {
Event::PaddleZeroResistance, Event::PaddleOneResistance, Event::PaddleZeroResistance, Event::PaddleOneResistance,

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventHandler.hxx,v 1.87 2006-05-05 18:00:51 stephena Exp $ // $Id: EventHandler.hxx,v 1.88 2006-05-15 12:24:09 stephena Exp $
//============================================================================ //============================================================================
#ifndef EVENTHANDLER_HXX #ifndef EVENTHANDLER_HXX
@ -61,12 +61,14 @@ struct ActionList {
}; };
enum { enum {
kActionListSize = 81 kEmulActionListSize = 81,
kMenuActionListSize = 14
}; };
enum EventMode { enum EventMode {
kEmulationMode, kEmulationMode = 0, // make sure these are set correctly,
kMenuMode kMenuMode = 1, // since they'll be used as array indices
kNumModes = 2
}; };
// Joystick related items // Joystick related items
@ -112,12 +114,10 @@ struct JoyMouse {
mapping can take place. mapping can take place.
@author Stephen Anthony @author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.87 2006-05-05 18:00:51 stephena Exp $ @version $Id: EventHandler.hxx,v 1.88 2006-05-15 12:24:09 stephena Exp $
*/ */
class EventHandler class EventHandler
{ {
friend class EventMappingWidget;
public: public:
/** /**
Create a new event handler object Create a new event handler object
@ -166,30 +166,36 @@ class EventHandler
Set the default action for a joystick button to the given event Set the default action for a joystick button to the given event
@param event The event we are assigning @param event The event we are assigning
@param mode The mode where this event is active
@param stick The joystick number @param stick The joystick number
@param button The joystick button @param button The joystick button
*/ */
void setDefaultJoyMapping(Event::Type event, int stick, int button); void setDefaultJoyMapping(Event::Type event, EventMode mode,
int stick, int button);
/** /**
Set the default for a joystick axis to the given event Set the default for a joystick axis to the given event
@param event The event we are assigning @param event The event we are assigning
@param mode The mode where this event is active
@param stick The joystick number @param stick The joystick number
@param axis The joystick axis @param axis The joystick axis
@param value The value on the given axis @param value The value on the given axis
*/ */
void setDefaultJoyAxisMapping(Event::Type event, int stick, int axis, int value); void setDefaultJoyAxisMapping(Event::Type event, EventMode mode,
int stick, int axis, int value);
/** /**
Set the default for a joystick hat to the given event Set the default for a joystick hat to the given event
@param event The event we are assigning @param event The event we are assigning
@param mode The mode where this event is active
@param stick The joystick number @param stick The joystick number
@param axis The joystick axis @param axis The joystick axis
@param value The value on the given axis @param value The value on the given axis
*/ */
void setDefaultJoyHatMapping(Event::Type event, int stick, int hat, int value); void setDefaultJoyHatMapping(Event::Type event, EventMode mode,
int stick, int hat, int value);
/** /**
Returns the current state of the EventHandler Returns the current state of the EventHandler
@ -333,67 +339,83 @@ class EventHandler
inline SDL_Joystick* getJoystick(int i) { return ourJoysticks[i].stick; } inline SDL_Joystick* getJoystick(int i) { return ourJoysticks[i].stick; }
StringList getEmulationActions(); StringList getActionList(EventMode mode);
StringList getMenuActions();
Event::Type eventForKey(int key, EventMode mode); inline Event::Type eventForKey(int key, EventMode mode)
Event::Type eventForJoyButton(int stick, int button, EventMode mode); { return myKeyTable[key][mode]; }
Event::Type eventForJoyAxis(int stick, int axis, int value, EventMode mode); inline Event::Type eventForJoyButton(int stick, int button, EventMode mode)
Event::Type eventForJoyHat(int stick, int hat, int value, EventMode mode); { return myJoyTable[stick][button][mode]; }
inline Event::Type eventForJoyAxis(int stick, int axis, int value, EventMode mode)
{ return myJoyAxisTable[stick][axis][(value > 0)][mode]; }
inline Event::Type eventForJoyHat(int stick, int hat, int value, EventMode mode)
{ return myJoyHatTable[stick][hat][value][mode]; }
Event::Type eventAtIndex(int idx, EventMode mode);
string actionAtIndex(int idx, EventMode mode);
string keyAtIndex(int idx, EventMode mode);
private:
/** /**
Bind a key to an event/action and regenerate the mapping array(s) Bind a key to an event/action and regenerate the mapping array(s)
@param event The event we are remapping @param event The event we are remapping
@param mode The mode where this event is active
@param key The key to bind to this event @param key The key to bind to this event
*/ */
bool addKeyMapping(Event::Type event, int key); bool addKeyMapping(Event::Type event, EventMode mode, int key);
/** /**
Bind a joystick button to an event/action and regenerate the Bind a joystick button to an event/action and regenerate the
mapping array(s) mapping array(s)
@param event The event we are remapping @param event The event we are remapping
@param mode The mode where this event is active
@param stick The joystick number @param stick The joystick number
@param button The joystick button @param button The joystick button
*/ */
bool addJoyMapping(Event::Type event, int stick, int button); bool addJoyMapping(Event::Type event, EventMode mode, int stick, int button);
/** /**
Bind a joystick axis direction to an event/action and regenerate Bind a joystick axis direction to an event/action and regenerate
the mapping array(s) the mapping array(s)
@param event The event we are remapping @param event The event we are remapping
@param mode The mode where this event is active
@param stick The joystick number @param stick The joystick number
@param axis The joystick axis @param axis The joystick axis
@param value The value on the given axis @param value The value on the given axis
*/ */
bool addJoyAxisMapping(Event::Type event, int stick, int axis, int value); bool addJoyAxisMapping(Event::Type event, EventMode mode,
int stick, int axis, int value);
/** /**
Bind a joystick hat direction to an event/action and regenerate Bind a joystick hat direction to an event/action and regenerate
the mapping array(s) the mapping array(s)
@param event The event we are remapping @param event The event we are remapping
@param mode The mode where this event is active
@param stick The joystick number @param stick The joystick number
@param axis The joystick hat @param axis The joystick hat
@param value The value on the given hat @param value The value on the given hat
*/ */
bool addJoyHatMapping(Event::Type event, int stick, int hat, int value); bool addJoyHatMapping(Event::Type event, EventMode mode,
int stick, int hat, int value);
/** /**
Erase the specified mapping Erase the specified mapping
@event The event for which we erase all mappings @event The event for which we erase all mappings
@param mode The mode where this event is active
*/ */
void eraseMapping(Event::Type event); void eraseMapping(Event::Type event, EventMode mode);
/** /**
Resets the event mappings to default values Resets the event mappings to default values
*/
void setDefaultMapping();
@param mode The mode for which the defaults are set
*/
void setDefaultMapping(EventMode mode);
private:
/** /**
Send a mouse motion event to the handler. Send a mouse motion event to the handler.
@ -446,16 +468,16 @@ class EventHandler
/** /**
The following methods take care of assigning action mappings. The following methods take care of assigning action mappings.
*/ */
void setActionMappings(); void setActionMappings(EventMode mode);
void setSDLMappings(); void setSDLMappings();
void setKeymap(); void setKeymap();
void setJoymap(); void setJoymap();
void setJoyAxisMap(); void setJoyAxisMap();
void setJoyHatMap(); void setJoyHatMap();
void setDefaultKeymap(); void setDefaultKeymap(EventMode mode);
void setDefaultJoymap(); void setDefaultJoymap(EventMode mode);
void setDefaultJoyAxisMap(); void setDefaultJoyAxisMap(EventMode mode);
void setDefaultJoyHatMap(); void setDefaultJoyHatMap(EventMode mode);
void saveKeyMapping(); void saveKeyMapping();
void saveJoyMapping(); void saveJoyMapping();
void saveJoyAxisMapping(); void saveJoyAxisMapping();
@ -510,16 +532,16 @@ class EventHandler
DialogContainer* myOverlay; DialogContainer* myOverlay;
// Array of key events, indexed by SDLKey // Array of key events, indexed by SDLKey
Event::Type myKeyTable[SDLK_LAST]; Event::Type myKeyTable[SDLK_LAST][kNumModes];
// Array of joystick button events // Array of joystick button events
Event::Type myJoyTable[kNumJoysticks][kNumJoyButtons]; Event::Type myJoyTable[kNumJoysticks][kNumJoyButtons][kNumModes];
// Array of joystick axis events // Array of joystick axis events
Event::Type myJoyAxisTable[kNumJoysticks][kNumJoyAxis][2]; Event::Type myJoyAxisTable[kNumJoysticks][kNumJoyAxis][2][kNumModes];
// Array of joystick hat events (we don't record diagonals) // Array of joystick hat events (we don't record diagonals)
Event::Type myJoyHatTable[kNumJoysticks][kNumJoyHats][4]; Event::Type myJoyHatTable[kNumJoysticks][kNumJoyHats][4][kNumModes];
// Array of messages for each Event // Array of messages for each Event
string ourMessageTable[Event::LastType]; string ourMessageTable[Event::LastType];
@ -566,8 +588,9 @@ class EventHandler
// Type of device on each controller port (based on ROM properties) // Type of device on each controller port (based on ROM properties)
Controller::Type myController[2]; Controller::Type myController[2];
// Holds static strings for the remap menu // Holds static strings for the remap menu (emulation and menu events)
static ActionList ourActionList[kActionListSize]; static ActionList ourEmulActionList[kEmulActionListSize];
static ActionList ourMenuActionList[kMenuActionListSize];
// Lookup table for paddle resistance events // Lookup table for paddle resistance events
static const Event::Type Paddle_Resistance[4]; static const Event::Type Paddle_Resistance[4];

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.cxx,v 1.86 2006-05-04 17:45:24 stephena Exp $ // $Id: FrameBuffer.cxx,v 1.87 2006-05-15 12:24:09 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -331,6 +331,13 @@ void FrameBuffer::pause(bool status)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::refresh()
{
theRedrawTIAIndicator = true;
myMessage.counter = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::setPalette(const uInt32* palette) void FrameBuffer::setPalette(const uInt32* palette)
{ {

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.hxx,v 1.69 2006-03-25 00:34:17 stephena Exp $ // $Id: FrameBuffer.hxx,v 1.70 2006-05-15 12:24:09 stephena Exp $
//============================================================================ //============================================================================
#ifndef FRAMEBUFFER_HXX #ifndef FRAMEBUFFER_HXX
@ -82,7 +82,7 @@ enum {
All GUI elements (ala ScummVM) are drawn here as well. All GUI elements (ala ScummVM) are drawn here as well.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.69 2006-03-25 00:34:17 stephena Exp $ @version $Id: FrameBuffer.hxx,v 1.70 2006-05-15 12:24:09 stephena Exp $
*/ */
class FrameBuffer class FrameBuffer
{ {
@ -172,7 +172,7 @@ class FrameBuffer
Indicates that the TIA area is dirty, and certain areas need Indicates that the TIA area is dirty, and certain areas need
to be redrawn. to be redrawn.
*/ */
void refresh() { theRedrawTIAIndicator = true; } void refresh();
/** /**
Toggles between fullscreen and window mode. Toggles between fullscreen and window mode.

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystem.cxx,v 1.68 2006-03-27 12:52:19 stephena Exp $ // $Id: OSystem.cxx,v 1.69 2006-05-15 12:24:09 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -453,36 +453,42 @@ bool OSystem::openROM(const string& rom, string& md5, uInt8** image, int* size)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setDefaultJoymap() void OSystem::setDefaultJoymap()
{ {
// Left joystick (assume joystick zero, button zero) EventMode mode;
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroFire, 0, 0);
mode = kEmulationMode; // Default emulation events
// Left joystick (assume joystick zero, button zero)
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroFire, mode, 0, 0);
// Right joystick (assume joystick one, button zero) // Right joystick (assume joystick one, button zero)
myEventHandler->setDefaultJoyMapping(Event::JoystickOneFire, 1, 0); myEventHandler->setDefaultJoyMapping(Event::JoystickOneFire, mode, 1, 0);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setDefaultJoyAxisMap() void OSystem::setDefaultJoyAxisMap()
{ {
EventMode mode;
mode = kEmulationMode; // Default emulation events
// Left joystick left/right directions (assume joystick zero) // Left joystick left/right directions (assume joystick zero)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroLeft, 0, 0, 0); myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroLeft, mode, 0, 0, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroRight, 0, 0, 1); myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroRight, mode, 0, 0, 1);
// Left joystick up/down directions (assume joystick zero) // Left joystick up/down directions (assume joystick zero)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroUp, 0, 1, 0); myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroUp, mode, 0, 1, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroDown, 0, 1, 1); myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroDown, mode, 0, 1, 1);
// Right joystick left/right directions (assume joystick one) // Right joystick left/right directions (assume joystick one)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneLeft, 1, 0, 0); myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneLeft, mode, 1, 0, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneRight, 1, 0, 1); myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneRight, mode, 1, 0, 1);
// Right joystick left/right directions (assume joystick one) // Right joystick left/right directions (assume joystick one)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneUp, 1, 1, 0); myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneUp, mode, 1, 1, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneDown, 1, 1, 1); myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneDown, mode, 1, 1, 1);
mode = kMenuMode; // Default menu/UI events
// FIXME - add UI events
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setDefaultJoyHatMap() void OSystem::setDefaultJoyHatMap()
{ {
// FIXME - add emul and UI events
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventMappingWidget.cxx,v 1.16 2006-05-05 18:00:51 stephena Exp $ // $Id: EventMappingWidget.cxx,v 1.17 2006-05-15 12:24:09 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -42,7 +42,6 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
myRemapStatus(false), myRemapStatus(false),
myFirstTime(true) myFirstTime(true)
{ {
// FIXME
const int fontHeight = font.getFontHeight(), const int fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight(); lineHeight = font.getLineHeight();
int xpos = 5, ypos = 5; int xpos = 5, ypos = 5;
@ -93,7 +92,6 @@ EventMappingWidget::~EventMappingWidget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventMappingWidget::loadConfig() void EventMappingWidget::loadConfig()
{ {
cerr << "EventMappingWidget::loadConfig() for " << myEventMode << endl;
if(myFirstTime) if(myFirstTime)
{ {
myActionsList->setSelected(0); myActionsList->setSelected(0);
@ -129,7 +127,7 @@ void EventMappingWidget::startRemapping()
// And show a message indicating which key is being remapped // And show a message indicating which key is being remapped
ostringstream buf; ostringstream buf;
buf << "Select action for '" buf << "Select action for '"
<< EventHandler::ourActionList[ myActionSelected ].action << instance()->eventHandler().actionAtIndex(myActionSelected, myEventMode)
<< "' event"; << "' event";
myKeyMapping->setColor(kTextColorEm); myKeyMapping->setColor(kTextColorEm);
myKeyMapping->setLabel(buf.str()); myKeyMapping->setLabel(buf.str());
@ -145,8 +143,9 @@ void EventMappingWidget::eraseRemapping()
if(myActionSelected < 0) if(myActionSelected < 0)
return; return;
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event; Event::Type event =
instance()->eventHandler().eraseMapping(event); instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
instance()->eventHandler().eraseMapping(event, myEventMode);
drawKeyMapping(); drawKeyMapping();
} }
@ -182,7 +181,8 @@ void EventMappingWidget::drawKeyMapping()
if(myActionSelected >= 0) if(myActionSelected >= 0)
{ {
ostringstream buf; ostringstream buf;
buf << "Action: " << EventHandler::ourActionList[ myActionSelected ].key; buf << "Action: "
<< instance()->eventHandler().keyAtIndex(myActionSelected, myEventMode);
myKeyMapping->setColor(kTextColor); myKeyMapping->setColor(kTextColor);
myKeyMapping->setLabel(buf.str()); myKeyMapping->setLabel(buf.str());
} }
@ -194,8 +194,9 @@ bool EventMappingWidget::handleKeyDown(int ascii, int keycode, int modifiers)
// Remap keys in remap mode // Remap keys in remap mode
if(myRemapStatus && myActionSelected >= 0) if(myRemapStatus && myActionSelected >= 0)
{ {
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event; Event::Type event =
if(instance()->eventHandler().addKeyMapping(event, keycode)) instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addKeyMapping(event, myEventMode, keycode))
stopRemapping(); stopRemapping();
} }
return true; return true;
@ -207,8 +208,9 @@ void EventMappingWidget::handleJoyDown(int stick, int button)
// Remap joystick buttons in remap mode // Remap joystick buttons in remap mode
if(myRemapStatus && myActionSelected >= 0) if(myRemapStatus && myActionSelected >= 0)
{ {
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event; Event::Type event =
if(instance()->eventHandler().addJoyMapping(event, stick, button)) instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addJoyMapping(event, myEventMode, stick, button))
stopRemapping(); stopRemapping();
} }
} }
@ -219,8 +221,10 @@ void EventMappingWidget::handleJoyAxis(int stick, int axis, int value)
// Remap joystick axes in remap mode // Remap joystick axes in remap mode
if(myRemapStatus && myActionSelected >= 0) if(myRemapStatus && myActionSelected >= 0)
{ {
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event; Event::Type event =
if(instance()->eventHandler().addJoyAxisMapping(event, stick, axis, value)) instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addJoyAxisMapping(event, myEventMode,
stick, axis, value))
stopRemapping(); stopRemapping();
} }
} }
@ -233,8 +237,10 @@ bool EventMappingWidget::handleJoyHat(int stick, int hat, int value)
// Remap joystick hats in remap mode // Remap joystick hats in remap mode
if(myRemapStatus && myActionSelected >= 0) if(myRemapStatus && myActionSelected >= 0)
{ {
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event; Event::Type event =
if(instance()->eventHandler().addJoyHatMapping(event, stick, hat, value)) instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addJoyHatMapping(event, myEventMode,
stick, hat, value))
{ {
stopRemapping(); stopRemapping();
result = true; result = true;
@ -284,7 +290,7 @@ void EventMappingWidget::handleCommand(CommandSender* sender, int cmd,
break; break;
case kDefaultsCmd: case kDefaultsCmd:
instance()->eventHandler().setDefaultMapping(); instance()->eventHandler().setDefaultMapping(myEventMode);
drawKeyMapping(); drawKeyMapping();
break; break;
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: InputDialog.cxx,v 1.15 2006-05-05 18:00:51 stephena Exp $ // $Id: InputDialog.cxx,v 1.16 2006-05-15 12:24:09 stephena Exp $
//============================================================================ //============================================================================
// FIXME - this whole dialog should be a dialog of buttons instead of // FIXME - this whole dialog should be a dialog of buttons instead of
@ -54,7 +54,7 @@ InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
// 1) Event mapper for emulation actions // 1) Event mapper for emulation actions
tabID = myTab->addTab("Emul. Events"); tabID = myTab->addTab("Emul. Events");
const StringList& eactions = instance()->eventHandler().getEmulationActions(); const StringList& eactions = instance()->eventHandler().getActionList(kEmulationMode);
myEmulEventMapper = new EventMappingWidget(myTab, font, 2, 2, myEmulEventMapper = new EventMappingWidget(myTab, font, 2, 2,
myTab->getWidth(), myTab->getWidth(),
myTab->getHeight() - ypos, myTab->getHeight() - ypos,
@ -64,7 +64,7 @@ InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
// 2) Event mapper for menu actions // 2) Event mapper for menu actions
tabID = myTab->addTab("Menu Events"); tabID = myTab->addTab("Menu Events");
const StringList& mactions = instance()->eventHandler().getMenuActions(); const StringList& mactions = instance()->eventHandler().getActionList(kMenuMode);
myMenuEventMapper = new EventMappingWidget(myTab, font, 2, 2, myMenuEventMapper = new EventMappingWidget(myTab, font, 2, 2,
myTab->getWidth(), myTab->getWidth(),
myTab->getHeight() - ypos, myTab->getHeight() - ypos,
@ -209,9 +209,6 @@ void InputDialog::addVDeviceTab(const GUI::Font& font)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::loadConfig() void InputDialog::loadConfig()
{ {
myEmulEventMapper->loadConfig();
myMenuEventMapper->loadConfig();
// Left & right ports // Left & right ports
const string& sa1 = instance()->settings().getString("sa1"); const string& sa1 = instance()->settings().getString("sa1");
int lport = sa1 == "right" ? 2 : 1; int lport = sa1 == "right" ? 2 : 1;
@ -237,6 +234,8 @@ void InputDialog::loadConfig()
myPaddleLabel[2]->setLabel(instance()->settings().getString("p3speed")); myPaddleLabel[2]->setLabel(instance()->settings().getString("p3speed"));
myPaddleSpeed[3]->setValue(instance()->settings().getInt("p4speed")); myPaddleSpeed[3]->setValue(instance()->settings().getInt("p4speed"));
myPaddleLabel[3]->setLabel(instance()->settings().getString("p4speed")); myPaddleLabel[3]->setLabel(instance()->settings().getString("p4speed"));
myTab->loadConfig();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -