Some cleanups to the event mapping UI and associated functionality:

1)  Added a 'Reset' button to the UI, which resets (to defaults)
the currently selected item.  This is more fine-grained than the actual
'Defaults' button, which resets *all* events.

2)  Rearranged some buttons and resized UI.  There is now a main 'Defaults'
button on the bottom of the dialog, which applies to the currently selected
tab.  This also allows to set defaults for Virtual Devs, which didn't have
such functionality previously.

3)  Added a 'Combo' button to the Emulation events tab.  It doesn't do
anything yet, but eventually will allow to assign events to the 'combo'
events.

ContextMenu/PopupWidget now supports the scroll button on a mouse when
in scroll mode.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2084 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2010-08-03 21:04:58 +00:00
parent 6fbd57d63b
commit 044e1aa151
11 changed files with 399 additions and 207 deletions

View File

@ -1247,6 +1247,10 @@ void EventHandler::setActionMappings(EventMode mode)
#else #else
prepend = "Cmd Q"; prepend = "Cmd Q";
#endif #endif
else if(event == Event::UINavNext)
prepend = "TAB";
else if(event == Event::UINavPrev)
prepend = "Shift-TAB";
// else if ... // else if ...
if(key == "") if(key == "")
@ -1278,8 +1282,8 @@ void EventHandler::setKeymap()
} }
else else
{ {
setDefaultKeymap(kEmulationMode); setDefaultKeymap(Event::NoType, kEmulationMode);
setDefaultKeymap(kMenuMode); setDefaultKeymap(Event::NoType, kMenuMode);
} }
} }
@ -1301,8 +1305,8 @@ void EventHandler::setJoymap()
} }
else else
{ {
setDefaultJoymap(kEmulationMode); setDefaultJoymap(Event::NoType, kEmulationMode);
setDefaultJoymap(kMenuMode); setDefaultJoymap(Event::NoType, kMenuMode);
} }
#endif #endif
} }
@ -1326,8 +1330,8 @@ void EventHandler::setJoyAxisMap()
} }
else else
{ {
setDefaultJoyAxisMap(kEmulationMode); setDefaultJoyAxisMap(Event::NoType, kEmulationMode);
setDefaultJoyAxisMap(kMenuMode); setDefaultJoyAxisMap(Event::NoType, kMenuMode);
} }
#endif #endif
} }
@ -1351,8 +1355,8 @@ void EventHandler::setJoyHatMap()
} }
else else
{ {
setDefaultJoyHatMap(kEmulationMode); setDefaultJoyHatMap(Event::NoType, kEmulationMode);
setDefaultJoyHatMap(kMenuMode); setDefaultJoyHatMap(Event::NoType, kMenuMode);
} }
#endif #endif
} }
@ -1547,104 +1551,115 @@ void EventHandler::eraseMapping(Event::Type event, EventMode mode)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultMapping(EventMode mode) void EventHandler::setDefaultMapping(Event::Type event, EventMode mode)
{ {
setDefaultKeymap(mode); setDefaultKeymap(event, mode);
setDefaultJoymap(mode); setDefaultJoymap(event, mode);
setDefaultJoyAxisMap(mode); setDefaultJoyAxisMap(event, mode);
setDefaultJoyHatMap(mode); setDefaultJoyHatMap(event, mode);
setActionMappings(mode); setActionMappings(mode);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultKeymap(EventMode mode) void EventHandler::setDefaultKeymap(Event::Type event, EventMode mode)
{ {
// Erase all mappings #define SET_DEFAULT_KEY(sdk_key, sdk_mode, sdk_event, sdk_cmp_event) \
for(int i = 0; i < SDLK_LAST; ++i) if(eraseAll || sdk_cmp_event == sdk_event) \
myKeyTable[i][mode] = Event::NoType; myKeyTable[sdk_key][sdk_mode] = sdk_event;
// If event is 'NoType', erase and reset all mappings
// Otherwise, only reset the given event
bool eraseAll = (event == Event::NoType);
if(eraseAll)
{
// Erase all mappings
for(int i = 0; i < SDLK_LAST; ++i)
myKeyTable[i][mode] = Event::NoType;
}
switch(mode) switch(mode)
{ {
case kEmulationMode: case kEmulationMode:
myKeyTable[ SDLK_1 ][mode] = Event::KeyboardZero1; SET_DEFAULT_KEY(SDLK_1, mode, Event::KeyboardZero1, event);
myKeyTable[ SDLK_2 ][mode] = Event::KeyboardZero2; SET_DEFAULT_KEY(SDLK_2, mode, Event::KeyboardZero2, event);
myKeyTable[ SDLK_3 ][mode] = Event::KeyboardZero3; SET_DEFAULT_KEY(SDLK_3, mode, Event::KeyboardZero3, event);
myKeyTable[ SDLK_q ][mode] = Event::KeyboardZero4; SET_DEFAULT_KEY(SDLK_q, mode, Event::KeyboardZero4, event);
myKeyTable[ SDLK_w ][mode] = Event::KeyboardZero5; SET_DEFAULT_KEY(SDLK_w, mode, Event::KeyboardZero5, event);
myKeyTable[ SDLK_e ][mode] = Event::KeyboardZero6; SET_DEFAULT_KEY(SDLK_e, mode, Event::KeyboardZero6, event);
myKeyTable[ SDLK_a ][mode] = Event::KeyboardZero7; SET_DEFAULT_KEY(SDLK_a, mode, Event::KeyboardZero7, event);
myKeyTable[ SDLK_s ][mode] = Event::KeyboardZero8; SET_DEFAULT_KEY(SDLK_s, mode, Event::KeyboardZero8, event);
myKeyTable[ SDLK_d ][mode] = Event::KeyboardZero9; SET_DEFAULT_KEY(SDLK_d, mode, Event::KeyboardZero9, event);
myKeyTable[ SDLK_z ][mode] = Event::KeyboardZeroStar; SET_DEFAULT_KEY(SDLK_z, mode, Event::KeyboardZeroStar, event);
myKeyTable[ SDLK_x ][mode] = Event::KeyboardZero0; SET_DEFAULT_KEY(SDLK_x, mode, Event::KeyboardZero0, event);
myKeyTable[ SDLK_c ][mode] = Event::KeyboardZeroPound; SET_DEFAULT_KEY(SDLK_c, mode, Event::KeyboardZeroPound, event);
myKeyTable[ SDLK_8 ][mode] = Event::KeyboardOne1; SET_DEFAULT_KEY(SDLK_8, mode, Event::KeyboardOne1, event);
myKeyTable[ SDLK_9 ][mode] = Event::KeyboardOne2; SET_DEFAULT_KEY(SDLK_9, mode, Event::KeyboardOne2, event);
myKeyTable[ SDLK_0 ][mode] = Event::KeyboardOne3; SET_DEFAULT_KEY(SDLK_0, mode, Event::KeyboardOne3, event);
myKeyTable[ SDLK_i ][mode] = Event::KeyboardOne4; SET_DEFAULT_KEY(SDLK_i, mode, Event::KeyboardOne4, event);
myKeyTable[ SDLK_o ][mode] = Event::KeyboardOne5; SET_DEFAULT_KEY(SDLK_o, mode, Event::KeyboardOne5, event);
myKeyTable[ SDLK_p ][mode] = Event::KeyboardOne6; SET_DEFAULT_KEY(SDLK_p, mode, Event::KeyboardOne6, event);
myKeyTable[ SDLK_k ][mode] = Event::KeyboardOne7; SET_DEFAULT_KEY(SDLK_k, mode, Event::KeyboardOne7, event);
myKeyTable[ SDLK_l ][mode] = Event::KeyboardOne8; SET_DEFAULT_KEY(SDLK_l, mode, Event::KeyboardOne8, event);
myKeyTable[ SDLK_SEMICOLON ][mode] = Event::KeyboardOne9; SET_DEFAULT_KEY(SDLK_SEMICOLON, mode, Event::KeyboardOne9, event);
myKeyTable[ SDLK_COMMA ][mode] = Event::KeyboardOneStar; SET_DEFAULT_KEY(SDLK_COMMA, mode, Event::KeyboardOneStar, event);
myKeyTable[ SDLK_PERIOD ][mode] = Event::KeyboardOne0; SET_DEFAULT_KEY(SDLK_PERIOD, mode, Event::KeyboardOne0, event);
myKeyTable[ SDLK_SLASH ][mode] = Event::KeyboardOnePound; SET_DEFAULT_KEY(SDLK_SLASH, mode, Event::KeyboardOnePound, event);
myKeyTable[ SDLK_UP ][mode] = Event::JoystickZeroUp; SET_DEFAULT_KEY(SDLK_UP, mode, Event::JoystickZeroUp, event);
myKeyTable[ SDLK_DOWN ][mode] = Event::JoystickZeroDown; SET_DEFAULT_KEY(SDLK_DOWN, mode, Event::JoystickZeroDown, event);
myKeyTable[ SDLK_LEFT ][mode] = Event::JoystickZeroLeft; SET_DEFAULT_KEY(SDLK_LEFT, mode, Event::JoystickZeroLeft, event);
myKeyTable[ SDLK_RIGHT ][mode] = Event::JoystickZeroRight; SET_DEFAULT_KEY(SDLK_RIGHT, mode, Event::JoystickZeroRight, event);
myKeyTable[ SDLK_SPACE ][mode] = Event::JoystickZeroFire1; SET_DEFAULT_KEY(SDLK_SPACE, mode, Event::JoystickZeroFire1, event);
myKeyTable[ SDLK_LCTRL ][mode] = Event::JoystickZeroFire1; SET_DEFAULT_KEY(SDLK_LCTRL, mode, Event::JoystickZeroFire1, event);
myKeyTable[ SDLK_4 ][mode] = Event::JoystickZeroFire2; SET_DEFAULT_KEY(SDLK_4, mode, Event::JoystickZeroFire2, event);
myKeyTable[ SDLK_5 ][mode] = Event::JoystickZeroFire3; SET_DEFAULT_KEY(SDLK_5, mode, Event::JoystickZeroFire3, event);
myKeyTable[ SDLK_y ][mode] = Event::JoystickOneUp; SET_DEFAULT_KEY(SDLK_y, mode, Event::JoystickOneUp, event);
myKeyTable[ SDLK_h ][mode] = Event::JoystickOneDown; SET_DEFAULT_KEY(SDLK_h, mode, Event::JoystickOneDown, event);
myKeyTable[ SDLK_g ][mode] = Event::JoystickOneLeft; SET_DEFAULT_KEY(SDLK_g, mode, Event::JoystickOneLeft, event);
myKeyTable[ SDLK_j ][mode] = Event::JoystickOneRight; SET_DEFAULT_KEY(SDLK_j, mode, Event::JoystickOneRight, event);
myKeyTable[ SDLK_f ][mode] = Event::JoystickOneFire1; SET_DEFAULT_KEY(SDLK_f, mode, Event::JoystickOneFire1, event);
myKeyTable[ SDLK_6 ][mode] = Event::JoystickOneFire2; SET_DEFAULT_KEY(SDLK_6, mode, Event::JoystickOneFire2, event);
myKeyTable[ SDLK_7 ][mode] = Event::JoystickOneFire3; SET_DEFAULT_KEY(SDLK_7, mode, Event::JoystickOneFire3, event);
myKeyTable[ SDLK_F1 ][mode] = Event::ConsoleSelect;
myKeyTable[ SDLK_F2 ][mode] = Event::ConsoleReset; SET_DEFAULT_KEY(SDLK_F1, mode, Event::ConsoleSelect, event);
myKeyTable[ SDLK_F3 ][mode] = Event::ConsoleColor; SET_DEFAULT_KEY(SDLK_F2, mode, Event::ConsoleReset, event);
myKeyTable[ SDLK_F4 ][mode] = Event::ConsoleBlackWhite; SET_DEFAULT_KEY(SDLK_F3, mode, Event::ConsoleColor, event);
myKeyTable[ SDLK_F5 ][mode] = Event::ConsoleLeftDifficultyA; SET_DEFAULT_KEY(SDLK_F4, mode, Event::ConsoleBlackWhite, event);
myKeyTable[ SDLK_F6 ][mode] = Event::ConsoleLeftDifficultyB; SET_DEFAULT_KEY(SDLK_F5, mode, Event::ConsoleLeftDifficultyA, event);
myKeyTable[ SDLK_F7 ][mode] = Event::ConsoleRightDifficultyA; SET_DEFAULT_KEY(SDLK_F6, mode, Event::ConsoleLeftDifficultyB, event);
myKeyTable[ SDLK_F8 ][mode] = Event::ConsoleRightDifficultyB; SET_DEFAULT_KEY(SDLK_F7, mode, Event::ConsoleRightDifficultyA, event);
myKeyTable[ SDLK_F9 ][mode] = Event::SaveState; SET_DEFAULT_KEY(SDLK_F8, mode, Event::ConsoleRightDifficultyB, event);
myKeyTable[ SDLK_F10 ][mode] = Event::ChangeState; SET_DEFAULT_KEY(SDLK_F9, mode, Event::SaveState, event);
myKeyTable[ SDLK_F11 ][mode] = Event::LoadState; SET_DEFAULT_KEY(SDLK_F10, mode, Event::ChangeState, event);
myKeyTable[ SDLK_F12 ][mode] = Event::TakeSnapshot; SET_DEFAULT_KEY(SDLK_F11, mode, Event::LoadState, event);
myKeyTable[ SDLK_BACKSPACE ][mode] = Event::Fry; SET_DEFAULT_KEY(SDLK_F12, mode, Event::TakeSnapshot, event);
myKeyTable[ SDLK_PAUSE ][mode] = Event::PauseMode; SET_DEFAULT_KEY(SDLK_BACKSPACE, mode, Event::Fry, event);
myKeyTable[ SDLK_TAB ][mode] = Event::MenuMode; SET_DEFAULT_KEY(SDLK_PAUSE, mode, Event::PauseMode, event);
myKeyTable[ SDLK_BACKSLASH ][mode] = Event::CmdMenuMode; SET_DEFAULT_KEY(SDLK_TAB, mode, Event::MenuMode, event);
myKeyTable[ SDLK_BACKQUOTE ][mode] = Event::DebuggerMode; SET_DEFAULT_KEY(SDLK_BACKSLASH, mode, Event::CmdMenuMode, event);
myKeyTable[ SDLK_ESCAPE ][mode] = Event::LauncherMode; SET_DEFAULT_KEY(SDLK_BACKQUOTE, mode, Event::DebuggerMode, event);
SET_DEFAULT_KEY(SDLK_ESCAPE, mode, Event::LauncherMode, event);
break; break;
case kMenuMode: case kMenuMode:
myKeyTable[ SDLK_UP ][mode] = Event::UIUp; SET_DEFAULT_KEY(SDLK_UP, mode, Event::UIUp, event);
myKeyTable[ SDLK_DOWN ][mode] = Event::UIDown; SET_DEFAULT_KEY(SDLK_DOWN, mode, Event::UIDown, event);
myKeyTable[ SDLK_LEFT ][mode] = Event::UILeft; SET_DEFAULT_KEY(SDLK_LEFT, mode, Event::UILeft, event);
myKeyTable[ SDLK_RIGHT ][mode] = Event::UIRight; SET_DEFAULT_KEY(SDLK_RIGHT, mode, Event::UIRight, event);
myKeyTable[ SDLK_HOME ][mode] = Event::UIHome; SET_DEFAULT_KEY(SDLK_HOME, mode, Event::UIHome, event);
myKeyTable[ SDLK_END ][mode] = Event::UIEnd; SET_DEFAULT_KEY(SDLK_END, mode, Event::UIEnd, event);
myKeyTable[ SDLK_PAGEUP ][mode] = Event::UIPgUp; SET_DEFAULT_KEY(SDLK_PAGEUP, mode, Event::UIPgUp, event);
myKeyTable[ SDLK_PAGEDOWN ][mode] = Event::UIPgDown; SET_DEFAULT_KEY(SDLK_PAGEDOWN, mode, Event::UIPgDown, event);
myKeyTable[ SDLK_RETURN ][mode] = Event::UISelect; SET_DEFAULT_KEY(SDLK_RETURN, mode, Event::UISelect, event);
myKeyTable[ SDLK_ESCAPE ][mode] = Event::UICancel; SET_DEFAULT_KEY(SDLK_ESCAPE, mode, Event::UICancel, event);
myKeyTable[ SDLK_BACKSPACE ][mode] = Event::UIPrevDir; SET_DEFAULT_KEY(SDLK_BACKSPACE, mode, Event::UIPrevDir, event);
break; break;
default: default:
@ -1656,40 +1671,55 @@ void EventHandler::setDefaultKeymap(EventMode mode)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultJoymap(EventMode mode) void EventHandler::setDefaultJoymap(Event::Type event, EventMode mode)
{ {
// Erase all mappings // If event is 'NoType', erase and reset all mappings
for(int i = 0; i < kNumJoysticks; ++i) // Otherwise, only reset the given event
for(int j = 0; j < kNumJoyButtons; ++j) if(event == Event::NoType)
myJoyTable[i][j][mode] = Event::NoType; {
// Erase all mappings
for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyButtons; ++j)
myJoyTable[i][j][mode] = Event::NoType;
}
myOSystem->setDefaultJoymap(); myOSystem->setDefaultJoymap(event, mode);
saveJoyMapping(); saveJoyMapping();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultJoyAxisMap(EventMode mode) void EventHandler::setDefaultJoyAxisMap(Event::Type event, EventMode mode)
{ {
// Erase all mappings // If event is 'NoType', erase and reset all mappings
for(int i = 0; i < kNumJoysticks; ++i) // Otherwise, only reset the given event
for(int j = 0; j < kNumJoyAxis; ++j) if(event == Event::NoType)
for(int k = 0; k < 2; ++k) {
myJoyAxisTable[i][j][k][mode] = Event::NoType; // Erase all mappings
for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyAxis; ++j)
for(int k = 0; k < 2; ++k)
myJoyAxisTable[i][j][k][mode] = Event::NoType;
}
myOSystem->setDefaultJoyAxisMap(); myOSystem->setDefaultJoyAxisMap(event, mode);
saveJoyAxisMapping(); saveJoyAxisMapping();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultJoyHatMap(EventMode mode) void EventHandler::setDefaultJoyHatMap(Event::Type event, EventMode mode)
{ {
// Erase all mappings // If event is 'NoType', erase and reset all mappings
for(int i = 0; i < kNumJoysticks; ++i) // Otherwise, only reset the given event
for(int j = 0; j < kNumJoyHats; ++j) if(event == Event::NoType)
for(int k = 0; k < 4; ++k) {
myJoyHatTable[i][j][k][mode] = Event::NoType; // Erase all mappings
for(int i = 0; i < kNumJoysticks; ++i)
for(int j = 0; j < kNumJoyHats; ++j)
for(int k = 0; k < 4; ++k)
myJoyHatTable[i][j][k][mode] = Event::NoType;
}
myOSystem->setDefaultJoyHatMap(); myOSystem->setDefaultJoyHatMap(event, mode);
saveJoyHatMapping(); saveJoyHatMapping();
} }

View File

@ -304,7 +304,7 @@ class EventHandler
/** /**
Erase the specified mapping Erase the specified mapping
@event The event for which we erase all mappings @param event The event for which we erase all mappings
@param mode The mode where this event is active @param mode The mode where this event is active
*/ */
void eraseMapping(Event::Type event, EventMode mode); void eraseMapping(Event::Type event, EventMode mode);
@ -312,9 +312,10 @@ class EventHandler
/** /**
Resets the event mappings to default values Resets the event mappings to default values
@param event The event which to (re)set (Event::NoType resets all)
@param mode The mode for which the defaults are set @param mode The mode for which the defaults are set
*/ */
void setDefaultMapping(EventMode mode); void setDefaultMapping(Event::Type event, EventMode mode);
/** /**
Sets the combo event mappings to those in the 'combomap' setting Sets the combo event mappings to those in the 'combomap' setting
@ -356,10 +357,10 @@ class EventHandler
void setJoymap(); void setJoymap();
void setJoyAxisMap(); void setJoyAxisMap();
void setJoyHatMap(); void setJoyHatMap();
void setDefaultKeymap(EventMode mode); void setDefaultKeymap(Event::Type, EventMode mode);
void setDefaultJoymap(EventMode mode); void setDefaultJoymap(Event::Type, EventMode mode);
void setDefaultJoyAxisMap(EventMode mode); void setDefaultJoyAxisMap(Event::Type, EventMode mode);
void setDefaultJoyHatMap(EventMode mode); void setDefaultJoyHatMap(Event::Type, EventMode mode);
void saveKeyMapping(); void saveKeyMapping();
void saveJoyMapping(); void saveJoyMapping();
void saveJoyAxisMapping(); void saveJoyAxisMapping();

View File

@ -862,67 +862,100 @@ void OSystem::resetLoopTiming()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setDefaultJoymap() void OSystem::setDefaultJoymap(Event::Type event, EventMode mode)
{ {
EventMode mode; #define SET_DEFAULT_BTN(sdb_event, sdb_mode, sdb_stick, sdb_button, sdb_cmp_event) \
if(eraseAll || sdb_cmp_event == sdb_event) \
myEventHandler->setDefaultJoyMapping(sdb_event, sdb_mode, sdb_stick, sdb_button);
mode = kEmulationMode; // Default emulation events bool eraseAll = (event == Event::NoType);
// Left joystick (assume joystick zero, button zero) switch(mode)
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroFire1, mode, 0, 0); {
// Right joystick (assume joystick one, button zero) case kEmulationMode: // Default emulation events
myEventHandler->setDefaultJoyMapping(Event::JoystickOneFire1, mode, 1, 0); // Left joystick (assume joystick zero, button zero)
SET_DEFAULT_BTN(Event::JoystickZeroFire1, mode, 0, 0, event);
// Right joystick (assume joystick one, button zero)
SET_DEFAULT_BTN(Event::JoystickOneFire1, mode, 1, 0, event);
break;
mode = kMenuMode; // Default menu/UI events case kMenuMode: // Default menu/UI events
// Left joystick (assume joystick zero, button zero) // Left joystick (assume joystick zero, button zero)
myEventHandler->setDefaultJoyMapping(Event::UISelect, mode, 0, 0); SET_DEFAULT_BTN(Event::UISelect, mode, 0, 0, event);
// Right joystick (assume joystick one, button zero) // Right joystick (assume joystick one, button zero)
myEventHandler->setDefaultJoyMapping(Event::UISelect, mode, 1, 0); SET_DEFAULT_BTN(Event::UISelect, mode, 1, 0, event);
break;
default:
break;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setDefaultJoyAxisMap() void OSystem::setDefaultJoyAxisMap(Event::Type event, EventMode mode)
{ {
EventMode mode; #define SET_DEFAULT_AXIS(sda_event, sda_mode, sda_stick, sda_axis, sda_val, sda_cmp_event) \
if(eraseAll || sda_cmp_event == sda_event) \
myEventHandler->setDefaultJoyAxisMapping(sda_event, sda_mode, sda_stick, sda_axis, sda_val);
mode = kEmulationMode; // Default emulation events bool eraseAll = (event == Event::NoType);
// Left joystick left/right directions (assume joystick zero) switch(mode)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroLeft, mode, 0, 0, 0); {
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroRight, mode, 0, 0, 1); case kEmulationMode: // Default emulation events
// Left joystick up/down directions (assume joystick zero) // Left joystick left/right directions (assume joystick zero)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroUp, mode, 0, 1, 0); SET_DEFAULT_AXIS(Event::JoystickZeroLeft, mode, 0, 0, 0, event);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroDown, mode, 0, 1, 1); SET_DEFAULT_AXIS(Event::JoystickZeroRight, mode, 0, 0, 1, event);
// Right joystick left/right directions (assume joystick one) // Left joystick up/down directions (assume joystick zero)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneLeft, mode, 1, 0, 0); SET_DEFAULT_AXIS(Event::JoystickZeroUp, mode, 0, 1, 0, event);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneRight, mode, 1, 0, 1); SET_DEFAULT_AXIS(Event::JoystickZeroDown, mode, 0, 1, 1, event);
// Right joystick left/right directions (assume joystick one) // Right joystick left/right directions (assume joystick one)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneUp, mode, 1, 1, 0); SET_DEFAULT_AXIS(Event::JoystickOneLeft, mode, 1, 0, 0, event);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneDown, mode, 1, 1, 1); SET_DEFAULT_AXIS(Event::JoystickOneRight, mode, 1, 0, 1, event);
// Right joystick left/right directions (assume joystick one)
SET_DEFAULT_AXIS(Event::JoystickOneUp, mode, 1, 1, 0, event);
SET_DEFAULT_AXIS(Event::JoystickOneDown, mode, 1, 1, 1, event);
break;
mode = kMenuMode; // Default menu/UI events case kMenuMode: // Default menu/UI events
myEventHandler->setDefaultJoyAxisMapping(Event::UILeft, mode, 0, 0, 0); SET_DEFAULT_AXIS(Event::UILeft, mode, 0, 0, 0, event);
myEventHandler->setDefaultJoyAxisMapping(Event::UIRight, mode, 0, 0, 1); SET_DEFAULT_AXIS(Event::UIRight, mode, 0, 0, 1, event);
myEventHandler->setDefaultJoyAxisMapping(Event::UIUp, mode, 0, 1, 0); SET_DEFAULT_AXIS(Event::UIUp, mode, 0, 1, 0, event);
myEventHandler->setDefaultJoyAxisMapping(Event::UIDown, mode, 0, 1, 1); SET_DEFAULT_AXIS(Event::UIDown, mode, 0, 1, 1, event);
break;
default:
break;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setDefaultJoyHatMap() void OSystem::setDefaultJoyHatMap(Event::Type event, EventMode mode)
{ {
EventMode mode; #define SET_DEFAULT_HAT(sdh_event, sdh_mode, sdh_stick, sdh_hat, sdh_dir, sdh_cmp_event) \
if(eraseAll || sdh_cmp_event == sdh_event) \
myEventHandler->setDefaultJoyHatMapping(sdh_event, sdh_mode, sdh_stick, sdh_hat, sdh_dir);
mode = kEmulationMode; // Default emulation events bool eraseAll = (event == Event::NoType);
// Left joystick left/right directions (assume joystick zero and hat 0) switch(mode)
myEventHandler->setDefaultJoyHatMapping(Event::JoystickZeroLeft, mode, 0, 0, EVENT_HATLEFT); {
myEventHandler->setDefaultJoyHatMapping(Event::JoystickZeroRight, mode, 0, 0, EVENT_HATRIGHT); case kEmulationMode: // Default emulation events
// Left joystick up/down directions (assume joystick zero and hat 0) // Left joystick left/right directions (assume joystick zero and hat 0)
myEventHandler->setDefaultJoyHatMapping(Event::JoystickZeroUp, mode, 0, 0, EVENT_HATUP); SET_DEFAULT_HAT(Event::JoystickZeroLeft, mode, 0, 0, EVENT_HATLEFT, event);
myEventHandler->setDefaultJoyHatMapping(Event::JoystickZeroDown, mode, 0, 0, EVENT_HATDOWN); SET_DEFAULT_HAT(Event::JoystickZeroRight, mode, 0, 0, EVENT_HATRIGHT, event);
// Left joystick up/down directions (assume joystick zero and hat 0)
SET_DEFAULT_HAT(Event::JoystickZeroUp, mode, 0, 0, EVENT_HATUP, event);
SET_DEFAULT_HAT(Event::JoystickZeroDown, mode, 0, 0, EVENT_HATDOWN, event);
break;
mode = kMenuMode; // Default menu/UI events case kMenuMode: // Default menu/UI events
myEventHandler->setDefaultJoyHatMapping(Event::UILeft, mode, 0, 0, EVENT_HATLEFT); SET_DEFAULT_HAT(Event::UILeft, mode, 0, 0, EVENT_HATLEFT, event);
myEventHandler->setDefaultJoyHatMapping(Event::UIRight, mode, 0, 0, EVENT_HATRIGHT); SET_DEFAULT_HAT(Event::UIRight, mode, 0, 0, EVENT_HATRIGHT, event);
myEventHandler->setDefaultJoyHatMapping(Event::UIUp, mode, 0, 0, EVENT_HATUP); SET_DEFAULT_HAT(Event::UIUp, mode, 0, 0, EVENT_HATUP, event);
myEventHandler->setDefaultJoyHatMapping(Event::UIDown, mode, 0, 0, EVENT_HATDOWN); SET_DEFAULT_HAT(Event::UIDown, mode, 0, 0, EVENT_HATDOWN, event);
break;
default:
break;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -403,20 +403,29 @@ class OSystem
/** /**
This method determines the default mapping of joystick buttons to This method determines the default mapping of joystick buttons to
Stella events for a specific system/platform. Stella events for a specific system/platform.
@param event The event which to (re)set (Event::NoType resets all)
@param mode The mode for which the defaults are set
*/ */
virtual void setDefaultJoymap(); virtual void setDefaultJoymap(Event::Type event, EventMode mode);
/** /**
This method determines the default mapping of joystick axis to This method determines the default mapping of joystick axis to
Stella events for a specific system/platform. Stella events for a specific system/platform.
@param event The event which to (re)set (Event::NoType resets all)
@param mode The mode for which the defaults are set
*/ */
virtual void setDefaultJoyAxisMap(); virtual void setDefaultJoyAxisMap(Event::Type event, EventMode mode);
/** /**
This method determines the default mapping of joystick hats to This method determines the default mapping of joystick hats to
Stella events for a specific system/platform. Stella events for a specific system/platform.
@param event The event which to (re)set (Event::NoType resets all)
@param mode The mode for which the defaults are set
*/ */
virtual void setDefaultJoyHatMap(); virtual void setDefaultJoyHatMap(Event::Type event, EventMode mode);
/** /**
This method creates events from platform-specific hardware. This method creates events from platform-specific hardware.

View File

@ -111,7 +111,7 @@ void ContextMenu::recalc(const GUI::Rect& image)
{ {
// Now is the time to adjust the height // Now is the time to adjust the height
// If it's higher than the screen, we need to scroll through // If it's higher than the screen, we need to scroll through
int maxentries = BSPF_min(16, (image.height() - 4) / _rowHeight); int maxentries = BSPF_min(18, (image.height() - 4) / _rowHeight);
if((int)_entries.size() > maxentries) if((int)_entries.size() > maxentries)
{ {
// We show two less than the max, so we have room for two scroll buttons // We show two less than the max, so we have room for two scroll buttons
@ -228,6 +228,19 @@ bool ContextMenu::handleMouseClicks(int x, int y, int button)
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::handleMouseWheel(int x, int y, int direction)
{
// Wheel events are only relevant in scroll mode
if(_showScroll)
{
if(direction < 0)
return scrollUp();
else if(direction > 0)
return scrollDown();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::handleKeyDown(int ascii, int keycode, int modifiers) void ContextMenu::handleKeyDown(int ascii, int keycode, int modifiers)
{ {

View File

@ -77,6 +77,7 @@ class ContextMenu : public Dialog, public CommandSender
void handleMouseDown(int x, int y, int button, int clickCount); void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseMoved(int x, int y, int button); void handleMouseMoved(int x, int y, int button);
bool handleMouseClicks(int x, int y, int button); bool handleMouseClicks(int x, int y, int button);
void handleMouseWheel(int x, int y, int direction);
void handleKeyDown(int ascii, int keycode, int modifiers); // Scroll through entries with arrow keys etc void handleKeyDown(int ascii, int keycode, int modifiers); // Scroll through entries with arrow keys etc
void handleJoyDown(int stick, int button); void handleJoyDown(int stick, int button);
void handleJoyAxis(int stick, int axis, int value); void handleJoyAxis(int stick, int axis, int value);

View File

@ -27,6 +27,7 @@
#include "EventHandler.hxx" #include "EventHandler.hxx"
#include "Event.hxx" #include "Event.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#include "EditTextWidget.hxx"
#include "StringListWidget.hxx" #include "StringListWidget.hxx"
#include "Widget.hxx" #include "Widget.hxx"
@ -64,12 +65,7 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
"Map", kStartMapCmd); "Map", kStartMapCmd);
myMapButton->setTarget(this); myMapButton->setTarget(this);
addFocusWidget(myMapButton); addFocusWidget(myMapButton);
ypos += lineHeight + 10;
myEraseButton = new ButtonWidget(boss, font, xpos, ypos,
buttonWidth, buttonHeight,
"Erase", kEraseCmd);
myEraseButton->setTarget(this);
addFocusWidget(myEraseButton);
ypos += lineHeight + 10; ypos += lineHeight + 10;
myCancelMapButton = new ButtonWidget(boss, font, xpos, ypos, myCancelMapButton = new ButtonWidget(boss, font, xpos, ypos,
buttonWidth, buttonHeight, buttonWidth, buttonHeight,
@ -77,18 +73,42 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
myCancelMapButton->setTarget(this); myCancelMapButton->setTarget(this);
myCancelMapButton->clearFlags(WIDGET_ENABLED); myCancelMapButton->clearFlags(WIDGET_ENABLED);
addFocusWidget(myCancelMapButton); addFocusWidget(myCancelMapButton);
ypos += lineHeight + 30;
myDefaultsButton = new ButtonWidget(boss, font, xpos, ypos, ypos += lineHeight + 20;
buttonWidth, buttonHeight, myEraseButton = new ButtonWidget(boss, font, xpos, ypos,
"Defaults", kDefaultsCmd); buttonWidth, buttonHeight,
myDefaultsButton->setTarget(this); "Erase", kEraseCmd);
addFocusWidget(myDefaultsButton); myEraseButton->setTarget(this);
addFocusWidget(myEraseButton);
ypos += lineHeight + 10;
myResetButton = new ButtonWidget(boss, font, xpos, ypos,
buttonWidth, buttonHeight,
"Reset", kResetCmd);
myResetButton->setTarget(this);
addFocusWidget(myResetButton);
if(mode == kEmulationMode)
{
ypos += lineHeight + 20;
myComboButton = new ButtonWidget(boss, font, xpos, ypos,
buttonWidth, buttonHeight,
"Combo", kComboCmd);
myComboButton->setTarget(this);
addFocusWidget(myComboButton);
}
// Show message for currently selected event // Show message for currently selected event
xpos = 10; ypos = 5 + myActionsList->getHeight() + 3; xpos = 10; ypos = 5 + myActionsList->getHeight() + 5;
myKeyMapping = new StaticTextWidget(boss, font, xpos, ypos, _w - 20, fontHeight, StaticTextWidget* t;
"Action: ", kTextAlignLeft); t = new StaticTextWidget(boss, font, xpos, ypos, font.getStringWidth("Action:"),
myKeyMapping->setFlags(WIDGET_CLEARBG); fontHeight, "Action:", kTextAlignLeft);
t->setFlags(WIDGET_CLEARBG);
myKeyMapping = new EditTextWidget(boss, font, xpos + t->getWidth() + 5, ypos,
_w - xpos - t->getWidth() - 15, lineHeight, "");
myKeyMapping->setEditable(false);
myKeyMapping->clearFlags(WIDGET_RETAIN_FOCUS);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -107,7 +127,8 @@ void EventMappingWidget::loadConfig()
// Make sure remapping is turned off, just in case the user didn't properly // Make sure remapping is turned off, just in case the user didn't properly
// exit last time // exit last time
stopRemapping(); if(myRemapStatus)
stopRemapping();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -115,6 +136,13 @@ void EventMappingWidget::saveConfig()
{ {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventMappingWidget::setDefaults()
{
instance().eventHandler().setDefaultMapping(Event::NoType, myEventMode);
drawKeyMapping();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventMappingWidget::startRemapping() void EventMappingWidget::startRemapping()
{ {
@ -131,16 +159,16 @@ void EventMappingWidget::startRemapping()
myActionsList->setEnabled(false); myActionsList->setEnabled(false);
myMapButton->setEnabled(false); myMapButton->setEnabled(false);
myEraseButton->setEnabled(false); myEraseButton->setEnabled(false);
myDefaultsButton->setEnabled(false);
myCancelMapButton->setEnabled(true); myCancelMapButton->setEnabled(true);
myResetButton->setEnabled(false);
// 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 '"
<< instance().eventHandler().actionAtIndex(myActionSelected, myEventMode) << instance().eventHandler().actionAtIndex(myActionSelected, myEventMode)
<< "' event"; << "' event";
myKeyMapping->setTextColor(kTextColorEm); myKeyMapping->setTextColor(kTextColorEm);
myKeyMapping->setLabel(buf.str()); myKeyMapping->setEditString(buf.str());
// Make sure that this widget receives all raw data, before any // Make sure that this widget receives all raw data, before any
// pre-processing occurs // pre-processing occurs
@ -160,6 +188,19 @@ void EventMappingWidget::eraseRemapping()
drawKeyMapping(); drawKeyMapping();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventMappingWidget::resetRemapping()
{
if(myActionSelected < 0)
return;
Event::Type event =
instance().eventHandler().eventAtIndex(myActionSelected, myEventMode);
instance().eventHandler().setDefaultMapping(event, myEventMode);
drawKeyMapping();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventMappingWidget::stopRemapping() void EventMappingWidget::stopRemapping()
{ {
@ -173,8 +214,8 @@ void EventMappingWidget::stopRemapping()
myActionsList->setEnabled(true); myActionsList->setEnabled(true);
myMapButton->setEnabled(false); myMapButton->setEnabled(false);
myEraseButton->setEnabled(false); myEraseButton->setEnabled(false);
myDefaultsButton->setEnabled(true);
myCancelMapButton->setEnabled(false); myCancelMapButton->setEnabled(false);
myResetButton->setEnabled(true);
// Make sure the list widget is in a known state // Make sure the list widget is in a known state
if(myActionSelected >= 0) if(myActionSelected >= 0)
@ -194,10 +235,9 @@ void EventMappingWidget::drawKeyMapping()
if(myActionSelected >= 0) if(myActionSelected >= 0)
{ {
ostringstream buf; ostringstream buf;
buf << "Action: " buf << instance().eventHandler().keyAtIndex(myActionSelected, myEventMode);
<< instance().eventHandler().keyAtIndex(myActionSelected, myEventMode);
myKeyMapping->setTextColor(kTextColor); myKeyMapping->setTextColor(kTextColor);
myKeyMapping->setLabel(buf.str()); myKeyMapping->setEditString(buf.str());
} }
} }
@ -311,6 +351,7 @@ void EventMappingWidget::handleCommand(CommandSender* sender, int cmd,
myMapButton->setEnabled(true); myMapButton->setEnabled(true);
myEraseButton->setEnabled(true); myEraseButton->setEnabled(true);
myCancelMapButton->setEnabled(false); myCancelMapButton->setEnabled(false);
myResetButton->setEnabled(true);
} }
break; break;
@ -328,17 +369,20 @@ void EventMappingWidget::handleCommand(CommandSender* sender, int cmd,
startRemapping(); startRemapping();
break; break;
case kEraseCmd:
eraseRemapping();
break;
case kStopMapCmd: case kStopMapCmd:
stopRemapping(); stopRemapping();
break; break;
case kDefaultsCmd: case kEraseCmd:
instance().eventHandler().setDefaultMapping(myEventMode); eraseRemapping();
drawKeyMapping(); break;
case kResetCmd:
resetRemapping();
break;
case kComboCmd:
cerr << "combo\n";
break; break;
} }
} }

View File

@ -26,6 +26,7 @@
class DialogContainer; class DialogContainer;
class CommandSender; class CommandSender;
class ButtonWidget; class ButtonWidget;
class EditTextWidget;
class StaticTextWidget; class StaticTextWidget;
class StringListWidget; class StringListWidget;
class PopUpWidget; class PopUpWidget;
@ -54,25 +55,22 @@ class EventMappingWidget : public Widget, public CommandSender
bool remapMode() { return myRemapStatus; } bool remapMode() { return myRemapStatus; }
protected: void setDefaults();
ButtonWidget* myMapButton;
ButtonWidget* myCancelMapButton;
ButtonWidget* myEraseButton;
ButtonWidget* myDefaultsButton;
StringListWidget* myActionsList;
StaticTextWidget* myKeyMapping;
private: private:
enum { enum {
kStartMapCmd = 'map ', kStartMapCmd = 'map ',
kStopMapCmd = 'smap',
kEraseCmd = 'eras', kEraseCmd = 'eras',
kStopMapCmd = 'smap' kResetCmd = 'rest',
kComboCmd = 'cmbo'
}; };
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
void startRemapping(); void startRemapping();
void eraseRemapping(); void eraseRemapping();
void resetRemapping();
void stopRemapping(); void stopRemapping();
void loadConfig(); void loadConfig();
void saveConfig(); void saveConfig();
@ -80,6 +78,14 @@ class EventMappingWidget : public Widget, public CommandSender
void drawKeyMapping(); void drawKeyMapping();
private: private:
ButtonWidget* myMapButton;
ButtonWidget* myCancelMapButton;
ButtonWidget* myEraseButton;
ButtonWidget* myResetButton;
ButtonWidget* myComboButton;
StringListWidget* myActionsList;
EditTextWidget* myKeyMapping;
// Since this widget can be used for different collections of events, // Since this widget can be used for different collections of events,
// we need to specify exactly which group of events we are remapping // we need to specify exactly which group of events we are remapping
EventMode myEventMode; EventMode myEventMode;
@ -91,7 +97,7 @@ class EventMappingWidget : public Widget, public CommandSender
// In this mode, the next event received is remapped to some action // In this mode, the next event received is remapped to some action
bool myRemapStatus; bool myRemapStatus;
// Joystick axes and hats can be more problematic that ordinary buttons // Joystick axes and hats can be more problematic than ordinary buttons
// or keys, in that there can be 'drift' in the values // or keys, in that there can be 'drift' in the values
// Therefore, we map these events when they've been 'released', rather // Therefore, we map these events when they've been 'released', rather
// than on their first occurrence (aka, when they're 'pressed') // than on their first occurrence (aka, when they're 'pressed')

View File

@ -36,19 +36,20 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent, InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
const GUI::Font& font) const GUI::Font& font, int max_w, int max_h)
: Dialog(osystem, parent, 0, 0, 0, 0) : Dialog(osystem, parent, 0, 0, 0, 0)
{ {
const int lineHeight = font.getLineHeight(), const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(), fontWidth = font.getMaxCharWidth(),
buttonWidth = font.getStringWidth("Defaults") + 20,
buttonHeight = font.getLineHeight() + 4; buttonHeight = font.getLineHeight() + 4;
const int vBorder = 4; const int vBorder = 4;
int xpos, ypos, tabID; int xpos, ypos, tabID;
WidgetArray wid; WidgetArray wid;
// Set real dimensions // Set real dimensions
_w = 42 * fontWidth + 10; _w = BSPF_min(48 * fontWidth + 10, max_w);
_h = 12 * (lineHeight + 4) + 10; _h = BSPF_min(12 * (lineHeight + 4) + 10, max_h);
// The tab widget // The tab widget
xpos = 2; ypos = vBorder; xpos = 2; ypos = vBorder;
@ -84,8 +85,12 @@ InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
myTab->activateTabs(); myTab->activateTabs();
myTab->setActiveTab(0); myTab->setActiveTab(0);
// Add OK and Cancel buttons // Add Defaults, OK and Cancel buttons
wid.clear(); wid.clear();
ButtonWidget* b;
b = new ButtonWidget(this, font, 10, _h - buttonHeight - 10,
buttonWidth, buttonHeight, "Defaults", kDefaultsCmd);
wid.push_back(b);
addOKCancelBGroup(wid, font); addOKCancelBGroup(wid, font);
addBGroupToFocusList(wid); addBGroupToFocusList(wid);
} }
@ -241,6 +246,51 @@ void InputDialog::saveConfig()
instance().eventHandler().allowAllDirections(allowall4); instance().eventHandler().allowAllDirections(allowall4);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::setDefaults()
{
switch(myTab->getActiveTab())
{
case 0: // Emulation events
myEmulEventMapper->setDefaults();
break;
case 1: // UI events
myMenuEventMapper->setDefaults();
break;
case 2: // Virtual devices
{
// Left & right ports
myLeftPort->setSelected("left", "left");
myRightPort->setSelected("right", "right");
// Joystick deadzone
myDeadzone->setValue(0);
myDeadzoneLabel->setValue(3200);
// Mouse/paddle enabled
myMouseEnabled->setState(true);
// Paddle speed
myPaddleSpeed->setValue(6);
myPaddleLabel->setLabel("6");
// AtariVox serial port
myAVoxPort->setEditString("");
// Allow all 4 joystick directions
myAllowAll4->setState(false);
break;
}
default:
break;
}
_dirty = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::handleKeyDown(int ascii, int keycode, int modifiers) void InputDialog::handleKeyDown(int ascii, int keycode, int modifiers)
{ {
@ -305,6 +355,10 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
close(); close();
break; break;
case kDefaultsCmd:
setDefaults();
break;
case kLeftChanged: case kLeftChanged:
myRightPort->setSelected( myRightPort->setSelected(
myLeftPort->getSelected() == 1 ? 0 : 1); myLeftPort->getSelected() == 1 ? 0 : 1);

View File

@ -37,7 +37,7 @@ class InputDialog : public Dialog
{ {
public: public:
InputDialog(OSystem* osystem, DialogContainer* parent, InputDialog(OSystem* osystem, DialogContainer* parent,
const GUI::Font& font); const GUI::Font& font, int max_w, int max_h);
~InputDialog(); ~InputDialog();
protected: protected:
@ -49,6 +49,7 @@ class InputDialog : public Dialog
void loadConfig(); void loadConfig();
void saveConfig(); void saveConfig();
void setDefaults();
private: private:
void addVDeviceTab(const GUI::Font& font); void addVDeviceTab(const GUI::Font& font);

View File

@ -119,7 +119,7 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent,
// Now create all the dialogs attached to each menu button // Now create all the dialogs attached to each menu button
myVideoDialog = new VideoDialog(osystem, parent, font, max_w, max_h); myVideoDialog = new VideoDialog(osystem, parent, font, max_w, max_h);
myAudioDialog = new AudioDialog(osystem, parent, font); myAudioDialog = new AudioDialog(osystem, parent, font);
myInputDialog = new InputDialog(osystem, parent, font); myInputDialog = new InputDialog(osystem, parent, font, max_w, max_h);
myUIDialog = new UIDialog(osystem, parent, font); myUIDialog = new UIDialog(osystem, parent, font);
myFileSnapDialog = new FileSnapDialog(osystem, parent, font, boss, max_w, max_h); myFileSnapDialog = new FileSnapDialog(osystem, parent, font, boss, max_w, max_h);
myRomAuditDialog = new RomAuditDialog(osystem, parent, font, max_w, max_h); myRomAuditDialog = new RomAuditDialog(osystem, parent, font, max_w, max_h);