add more default joystick button mapping

- open settings via joystick button in launcher and during emulation (4th button)
- open command menu and exit to launcher via joystick buttons during emulation (3rd and 5th button)
- cycle tabs via joystick 3rd and 4th buttons
This commit is contained in:
thrust26 2019-05-04 11:47:53 +02:00
parent a0ba4bc80f
commit 6a23b2f0b7
4 changed files with 93 additions and 61 deletions

View File

@ -11,36 +11,37 @@ Stella can be controlled via the console buttons or a joystick in left or
right port. right port.
Inside Launcher: Inside Launcher:
Joystick Button Action Joystick Button Action
-------------------------------------------------- ----------------------------------------------------
Up SAVE previous game Up SAVE previous game
Down RESET next game Down RESET next game
Left LOAD page up Left LOAD page up
Right MODE page down Right MODE page down
Button SKILL P1 start selected game Button 1 SKILL P1 start selected game
Button #2 SKILL P2 open Power-on options dialog Button 2 SKILL P2 open Power-on options dialog
- COLOR,B/W open Settings dialog Button 4 COLOR,B/W open Settings dialog
Inside a dialog: Inside a dialog:
Joystick Button Action Joystick Button Action
---------------------------------------------------- -----------------------------------------------------
Up SAVE change/increase current option Up SAVE change/increase current option
Down RESET change/decrease current option Down RESET change/decrease current option
Left LOAD previous dialog element Left LOAD previous dialog element
Right MODE next dialog element Right MODE next dialog element
Button SKILL P1 select Button 1 SKILL P1 select
Button #2 SKILL P2 cancel Button 2 SKILL P2 cancel
- 4:3,16:9 previous tab Button 3 4:3,16:9 previous tab
- FRY next tab Button 4 FRY next tab
During emulation: During emulation:
The joysticks work normal and all console buttons as labeled except of the The joysticks work normal and all console buttons as labeled except of the
following. following.
Button Action Joystick ´Button Action
---------------------------------- ----------------------------------------------
4:3,16:9 open the Command dialog Button 3 4:3,16:9 open the Command dialog
FRY return to Launcher Button 4 - open Settings dialog
Button 5 FRY return to Launcher
Note: If you have a keyboard attached via OTG all keys work as described in Note: If you have a keyboard attached via OTG all keys work as described in
the Stella User's Guide. the Stella User's Guide.

View File

@ -269,39 +269,66 @@ void PhysicalJoystickHandler::setStickDefaultMapping(int stick,
switch(mode) switch(mode)
{ {
case kEmulationMode: // Default emulation events case kEmulationMode: // Default emulation events
if(stick == 0) switch (stick)
{ {
// Left joystick left/right directions (assume joystick zero) case 0:
setDefaultAxis( 0, 0, 0, Event::JoystickZeroLeft ); case 2:
setDefaultAxis( 0, 0, 1, Event::JoystickZeroRight ); // Left joystick left/right directions (assume joystick zero or two)
// Left joystick up/down directions (assume joystick zero) setDefaultAxis(stick, 0, 0, Event::JoystickZeroLeft);
setDefaultAxis( 0, 1, 0, Event::JoystickZeroUp ); setDefaultAxis(stick, 0, 1, Event::JoystickZeroRight);
setDefaultAxis( 0, 1, 1, Event::JoystickZeroDown ); // Left joystick up/down directions (assume joystick zero or two)
// Left joystick (assume joystick zero, button zero) setDefaultAxis(stick, 1, 0, Event::JoystickZeroUp);
setDefaultBtn( 0, 0, Event::JoystickZeroFire ); setDefaultAxis(stick, 1, 1, Event::JoystickZeroDown);
// Left joystick left/right directions (assume joystick zero and hat 0) // Left joystick (assume joystick zero or two, buttons zero..two)
setDefaultHat( 0, 0, JoyHat::LEFT, Event::JoystickZeroLeft ); setDefaultBtn(stick, 0, Event::JoystickZeroFire);
setDefaultHat( 0, 0, JoyHat::RIGHT, Event::JoystickZeroRight ); setDefaultBtn(stick, 1, Event::JoystickZeroFire5);
// Left joystick up/down directions (assume joystick zero and hat 0) setDefaultBtn(stick, 2, Event::JoystickZeroFire9);
setDefaultHat( 0, 0, JoyHat::UP, Event::JoystickZeroUp ); // Left joystick left/right directions (assume joystick zero or two and hat 0)
setDefaultHat( 0, 0, JoyHat::DOWN, Event::JoystickZeroDown ); setDefaultHat(stick, 0, JoyHat::LEFT, Event::JoystickZeroLeft);
} setDefaultHat(stick, 0, JoyHat::RIGHT, Event::JoystickZeroRight);
else if(stick == 1) // Left joystick up/down directions (assume joystick zero or two and hat 0)
{ setDefaultHat(stick, 0, JoyHat::UP, Event::JoystickZeroUp);
// Right joystick left/right directions (assume joystick one) setDefaultHat(stick, 0, JoyHat::DOWN, Event::JoystickZeroDown);
setDefaultAxis( 1, 0, 0, Event::JoystickOneLeft ); // FIXME - use the R77 define in the final release
setDefaultAxis( 1, 0, 1, Event::JoystickOneRight ); // use the '1' define for testing
// Right joystick left/right directions (assume joystick one) #if defined(RETRON77)
setDefaultAxis( 1, 1, 0, Event::JoystickOneUp ); // #if 1
setDefaultAxis( 1, 1, 1, Event::JoystickOneDown ); // Left joystick (assume joystick zero or two, buttons two..four)
// Right joystick (assume joystick one, button zero) setDefaultBtn(stick, 2, Event::CmdMenuMode);
setDefaultBtn( 1, 0, Event::JoystickOneFire ); setDefaultBtn(stick, 3, Event::OptionsMenuMode);
// Right joystick left/right directions (assume joystick one and hat 0) setDefaultBtn(stick, 4, Event::LauncherMode);
setDefaultHat( 1, 0, JoyHat::LEFT, Event::JoystickOneLeft ); #endif
setDefaultHat( 1, 0, JoyHat::RIGHT, Event::JoystickOneRight ); break;
// Right joystick up/down directions (assume joystick one and hat 0) case 1:
setDefaultHat( 1, 0, JoyHat::UP, Event::JoystickOneUp ); case 3:
setDefaultHat( 1, 0, JoyHat::DOWN, Event::JoystickOneDown ); // Right joystick left/right directions (assume joystick one or three)
setDefaultAxis(stick, 0, 0, Event::JoystickOneLeft);
setDefaultAxis(stick, 0, 1, Event::JoystickOneRight);
// Right joystick left/right directions (assume joystick one or three)
setDefaultAxis(stick, 1, 0, Event::JoystickOneUp);
setDefaultAxis(stick, 1, 1, Event::JoystickOneDown);
// Right joystick (assume joystick one or three, buttons zero..two)
setDefaultBtn(stick, 0, Event::JoystickOneFire);
setDefaultBtn(stick, 1, Event::JoystickOneFire5);
setDefaultBtn(stick, 2, Event::JoystickOneFire9);
// Right joystick left/right directions (assume joystick one or three and hat 0)
setDefaultHat(stick, 0, JoyHat::LEFT, Event::JoystickOneLeft);
setDefaultHat(stick, 0, JoyHat::RIGHT, Event::JoystickOneRight);
// Right joystick up/down directions (assume joystick one or three and hat 0)
setDefaultHat(stick, 0, JoyHat::UP, Event::JoystickOneUp);
setDefaultHat(stick, 0, JoyHat::DOWN, Event::JoystickOneDown);
// FIXME - use the R77 define in the final release
// use the '1' define for testing
#if defined(RETRON77)
// #if 1
// Right joystick (assume joystick one or three, buttons two..four)
setDefaultBtn(stick, 2, Event::CmdMenuMode);
setDefaultBtn(stick, 3, Event::OptionsMenuMode);
setDefaultBtn(stick, 4, Event::LauncherMode);
#endif
break;
default:
break;
} }
break; break;
@ -311,9 +338,11 @@ void PhysicalJoystickHandler::setStickDefaultMapping(int stick,
setDefaultAxis( stick, 1, 0, Event::UIUp ); setDefaultAxis( stick, 1, 0, Event::UIUp );
setDefaultAxis( stick, 1, 1, Event::UIDown ); setDefaultAxis( stick, 1, 1, Event::UIDown );
// joystick (assume buttons zero and one) // joystick (assume buttons zero..three)
setDefaultBtn( stick, 0, Event::UISelect ); setDefaultBtn( stick, 0, Event::UISelect );
setDefaultBtn( stick, 1, Event::UICancel ); setDefaultBtn( stick, 1, Event::UICancel );
setDefaultBtn( stick, 2, Event::UITabPrev );
setDefaultBtn( stick, 3, Event::UITabNext );
setDefaultHat( stick, 0, JoyHat::LEFT, Event::UINavPrev ); setDefaultHat( stick, 0, JoyHat::LEFT, Event::UINavPrev );
setDefaultHat( stick, 0, JoyHat::RIGHT, Event::UINavNext ); setDefaultHat( stick, 0, JoyHat::RIGHT, Event::UINavNext );

View File

@ -458,8 +458,8 @@ void Dialog::handleKeyDown(StellaKey key, StellaMod mod)
} }
// FIXME - use the R77 define in the final release // FIXME - use the R77 define in the final release
// use the '1' define for testing // use the '1' define for testing
// #if defined(RETRON77) #if defined(RETRON77)
#if 1 // #if 1
// special keys used for R77 // special keys used for R77
else if (key == KBDK_F13) else if (key == KBDK_F13)
e = Event::UITabPrev; e = Event::UITabPrev;

View File

@ -498,11 +498,13 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::handleJoyDown(int stick, int button) void LauncherDialog::handleJoyDown(int stick, int button)
{ {
// open power-up options for 2nd button if not mapped otherwise // open power-up options and settings for 2nd and 4th button if not mapped otherwise
Event::Type e = instance().eventHandler().eventForJoyButton(stick, button, kMenuMode); Event::Type e = instance().eventHandler().eventForJoyButton(stick, button, kMenuMode);
if (button == 1 && (e == Event::UICancel || e == Event::NoType)) if (button == 1 && (e == Event::UICancel || e == Event::NoType))
myGlobalProps->open(); myGlobalProps->open();
if (button == 3 && e == Event::NoType)
openSettings();
else else
Dialog::handleJoyDown(stick, button); Dialog::handleJoyDown(stick, button);
} }