fix some joystick mapping bugs

update R77 readme with button combos
This commit is contained in:
Thomas Jentzsch 2019-08-12 16:26:35 +02:00
parent e236b0ce95
commit 3348495a55
7 changed files with 51 additions and 38 deletions

View File

@ -35,17 +35,19 @@ Inside Launcher:
Button 4 COLOR,B/W Open settings Button 4 COLOR,B/W Open settings
Inside a dialog: Inside a dialog:
Joystick Button Action Joystick Button Action
----------------------------------------------------- ------------------------------------------------------
Up SAVE Increase current setting Up SAVE Increase current setting
Down RESET Decrease current setting Down RESET Decrease current setting
Left LOAD Previous dialog element Left LOAD Previous dialog element
Right MODE Next dialog element Right MODE Next dialog element
Button 1 SKILL P1 Select element Button 1 SKILL P1 Select element
Button 2 SKILL P2 OK Button 2 SKILL P2 OK
Button 3 4:3,16:9 Previous tab Button 3 or 4:3,16:9 Previous tab
Button 4 FRY Next tab Button 1 + Left
Button 6 - Cancel Button 4 or FRY Next tab
Button 1 + Right
Button 6 - Cancel
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

@ -37,7 +37,7 @@ void JoyMap::add(const Event::Type event, const EventMode mode, const int button
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JoyMap::add(const Event::Type event, const EventMode mode, const int button, void JoyMap::add(const Event::Type event, const EventMode mode, const int button,
const int hat, const JoyHat hdir) const int hat, const JoyHat hdir)
{ {
add(event, JoyMapping(mode, button, hat, hdir)); add(event, JoyMapping(mode, button, hat, hdir));
@ -57,7 +57,7 @@ void JoyMap::erase(const EventMode mode, const int button,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JoyMap::erase(const EventMode mode, const int button, void JoyMap::erase(const EventMode mode, const int button,
const int hat, const JoyHat hdir) const int hat, const JoyHat hdir)
{ {
erase(JoyMapping(mode, button, hat, hdir)); erase(JoyMapping(mode, button, hat, hdir));
@ -90,7 +90,7 @@ Event::Type JoyMap::get(const EventMode mode, const int button,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type JoyMap::get(const EventMode mode, const int button, Event::Type JoyMap::get(const EventMode mode, const int button,
const int hat, const JoyHat hdir) const const int hat, const JoyHat hdir) const
{ {
return get(JoyMapping(mode, button, hat, hdir)); return get(JoyMapping(mode, button, hat, hdir));

View File

@ -232,7 +232,6 @@ void PhysicalJoystickHandler::mapStelladaptors(const string& saport)
myOSystem.settings().setValue("saport", saport); myOSystem.settings().setValue("saport", saport);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Depending on parameters, this method does the following: // Depending on parameters, this method does the following:
// 1. update all events with default (event == Event::NoType, updateDefault == true) // 1. update all events with default (event == Event::NoType, updateDefault == true)
@ -296,6 +295,10 @@ void PhysicalJoystickHandler::setStickDefaultMapping(int stick, Event::Type even
for (const auto& item : DefaultRightKeypadMapping) for (const auto& item : DefaultRightKeypadMapping)
setDefaultAction(j, item, event, kKeypadMode, updateDefaults); setDefaultAction(j, item, event, kKeypadMode, updateDefaults);
} }
for(const auto& item : DefaultCommonMapping)
setDefaultAction(j, item, event, kCommonMode, updateDefaults);
// update running emulation mapping too
enableEmulationMappings();
break; break;
case kMenuMode: case kMenuMode:
@ -562,14 +565,19 @@ bool PhysicalJoystickHandler::addJoyMapping(Event::Type event, EventMode mode, i
if (Event::isAnalog(event)) if (Event::isAnalog(event))
{ {
j->joyMap.add(event, evMode, button, axis, JoyDir::ANALOG); j->joyMap.add(event, evMode, button, axis, JoyDir::ANALOG);
// update running emulation mapping too
j->joyMap.add(event, kEmulationMode, button, axis, JoyDir::ANALOG);
} }
else else
{ {
// Otherwise, turn off the analog event(s) for this axis // Otherwise, turn off the analog event(s) for this axis
if (Event::isAnalog(j->joyMap.get(evMode, button, axis, JoyDir::ANALOG))) if (Event::isAnalog(j->joyMap.get(evMode, button, axis, JoyDir::ANALOG)))
j->joyMap.erase(evMode, button, axis, JoyDir::ANALOG); j->joyMap.erase(evMode, button, axis, JoyDir::ANALOG);
j->joyMap.add(event, evMode, button, axis, convertAxisValue(value)); j->joyMap.add(event, evMode, button, axis, convertAxisValue(value));
// update running emulation mapping too
if(Event::isAnalog(j->joyMap.get(kEmulationMode, button, axis, JoyDir::ANALOG)))
j->joyMap.erase(kEmulationMode, button, axis, JoyDir::ANALOG);
j->joyMap.add(event, kEmulationMode, button, axis, convertAxisValue(value));
} }
return true; return true;
} }
@ -587,6 +595,8 @@ bool PhysicalJoystickHandler::addJoyHatMapping(Event::Type event, EventMode mode
hat >= 0 && hat < j->numHats && dir != JoyHat::CENTER) hat >= 0 && hat < j->numHats && dir != JoyHat::CENTER)
{ {
j->joyMap.add(event, getEventMode(event, mode), button, hat, dir); j->joyMap.add(event, getEventMode(event, mode), button, hat, dir);
// update running emulation mapping too
j->joyMap.add(event, kEmulationMode, button, hat, dir);
return true; return true;
} }
return false; return false;
@ -673,7 +683,6 @@ void PhysicalJoystickHandler::handleBtnEvent(int stick, int button, bool pressed
{ {
j->buttonLast[stick] = pressed ? button : JOY_CTRL_NONE; j->buttonLast[stick] = pressed ? button : JOY_CTRL_NONE;
// Handle buttons which switch eventhandler state // Handle buttons which switch eventhandler state
if (pressed && myHandler.changeStateByEvent(j->joyMap.get(kEmulationMode, button))) if (pressed && myHandler.changeStateByEvent(j->joyMap.get(kEmulationMode, button)))
return; return;
@ -767,12 +776,6 @@ PhysicalJoystickHandler::EventMappingArray PhysicalJoystickHandler::DefaultLeftJ
{Event::JoystickZeroFire, 0}, {Event::JoystickZeroFire, 0},
{Event::JoystickZeroFire5, 1}, {Event::JoystickZeroFire5, 1},
{Event::JoystickZeroFire9, 2}, {Event::JoystickZeroFire9, 2},
#if defined(RETRON77)
// Left joystick (assume buttons two..four)
{Event::CmdMenuMode, 2),
{Event::OptionsMenuMode, 3),
{Event::ExitMode, 4),
#endif
// Left joystick left/right directions // Left joystick left/right directions
{Event::JoystickZeroLeft, JOY_CTRL_NONE, JoyAxis::X, JoyDir::NEG}, {Event::JoystickZeroLeft, JOY_CTRL_NONE, JoyAxis::X, JoyDir::NEG},
{Event::JoystickZeroRight, JOY_CTRL_NONE, JoyAxis::X, JoyDir::POS}, {Event::JoystickZeroRight, JOY_CTRL_NONE, JoyAxis::X, JoyDir::POS},
@ -793,15 +796,6 @@ PhysicalJoystickHandler::EventMappingArray PhysicalJoystickHandler::DefaultRight
{Event::JoystickOneFire, 0}, {Event::JoystickOneFire, 0},
{Event::JoystickOneFire5, 1}, {Event::JoystickOneFire5, 1},
{Event::JoystickOneFire9, 2}, {Event::JoystickOneFire9, 2},
#if defined(RETRON77)
// Right joystick (assume buttons two..eight)
{Event::CmdMenuMode, 2},
{Event::OptionsMenuMode, 3},
{Event::ExitMode, 4},
{Event::RewindPause, 5},
{Event::ConsoleSelect, 7},
{Event::ConsoleReset, 8},
#endif
// Right joystick left/right directions // Right joystick left/right directions
{Event::JoystickOneLeft, JOY_CTRL_NONE, JoyAxis::X, JoyDir::NEG}, {Event::JoystickOneLeft, JOY_CTRL_NONE, JoyAxis::X, JoyDir::NEG},
{Event::JoystickOneRight, JOY_CTRL_NONE, JoyAxis::X, JoyDir::POS}, {Event::JoystickOneRight, JOY_CTRL_NONE, JoyAxis::X, JoyDir::POS},
@ -872,6 +866,19 @@ PhysicalJoystickHandler::EventMappingArray PhysicalJoystickHandler::DefaultRight
{Event::KeyboardOnePound, 11}, {Event::KeyboardOnePound, 11},
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PhysicalJoystickHandler::EventMappingArray PhysicalJoystickHandler::DefaultCommonMapping = {
// valid for all joysticks
//#if defined(RETRON77)
{Event::CmdMenuMode, 2},
{Event::OptionsMenuMode, 3},
{Event::ExitMode, 4},
{Event::RewindPause, 5},
{Event::ConsoleSelect, 7},
{Event::ConsoleReset, 8},
//#endif
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PhysicalJoystickHandler::EventMappingArray PhysicalJoystickHandler::DefaultMenuMapping = { PhysicalJoystickHandler::EventMappingArray PhysicalJoystickHandler::DefaultMenuMapping = {
// valid for all joysticks // valid for all joysticks

View File

@ -171,6 +171,7 @@ class PhysicalJoystickHandler
// Controller menu and common emulation mappings // Controller menu and common emulation mappings
static EventMappingArray DefaultMenuMapping; static EventMappingArray DefaultMenuMapping;
static EventMappingArray DefaultCommonMapping;
// Controller specific mappings // Controller specific mappings
static EventMappingArray DefaultLeftJoystickMapping; static EventMappingArray DefaultLeftJoystickMapping;
static EventMappingArray DefaultRightJoystickMapping; static EventMappingArray DefaultRightJoystickMapping;

View File

@ -78,7 +78,7 @@ void PhysicalJoystick::initialize(int index, const string& desc,
string PhysicalJoystick::getMap() const string PhysicalJoystick::getMap() const
{ {
// The mapping structure (for remappable devices) is defined as follows: // The mapping structure (for remappable devices) is defined as follows:
// <NAME>'$'<MODE>['|'(<EVENT>':'<BUTTON>','<AXIS>','<VALUE>)|(<EVENT>':'<BUTTON>','<HAT>','<HATDIR>)] // <NAME>'>'<MODE>['|'(<EVENT>':'<BUTTON>','<AXIS>','<VALUE>)|(<EVENT>':'<BUTTON>','<HAT>','<HATDIR>)]
ostringstream joybuf; ostringstream joybuf;
@ -89,7 +89,6 @@ string PhysicalJoystick::getMap() const
joybuf << MODE_DELIM << int(kKeypadMode) << "|" << joyMap.saveMapping(kKeypadMode); joybuf << MODE_DELIM << int(kKeypadMode) << "|" << joyMap.saveMapping(kKeypadMode);
joybuf << MODE_DELIM << int(kCommonMode) << "|" << joyMap.saveMapping(kCommonMode); joybuf << MODE_DELIM << int(kCommonMode) << "|" << joyMap.saveMapping(kCommonMode);
return joybuf.str(); return joybuf.str();
} }

View File

@ -161,8 +161,11 @@ void EventMappingWidget::startRemapping()
myRemapStatus = true; myRemapStatus = true;
// Reset all previous events for determining correct axis/hat values // Reset all previous events for determining correct axis/hat values
myLastStick = myLastAxis = myLastHat = myLastValue = -1; myLastStick = -1;
myLastButton = JOY_CTRL_NONE; myLastButton = JOY_CTRL_NONE;
myLastAxis = int(JoyAxis::NONE);
myLastHat = -1;
myLastValue = int(JoyDir::NONE);
// Reset the previously aggregated key mappings // Reset the previously aggregated key mappings
myMod = myLastKey = 0; myMod = myLastKey = 0;
@ -217,8 +220,11 @@ void EventMappingWidget::stopRemapping()
cerr << "stopRemapping " << myRemapStatus << endl; cerr << "stopRemapping " << myRemapStatus << endl;
// Reset all previous events for determining correct axis/hat values // Reset all previous events for determining correct axis/hat values
myLastStick = myLastAxis = myLastHat = myLastValue = -1; myLastStick = -1;
myLastButton = JOY_CTRL_NONE; myLastButton = JOY_CTRL_NONE;
myLastAxis = int(JoyAxis::NONE);
myLastHat = -1;
myLastValue = int(JoyDir::NONE);
// And re-enable all the widgets // And re-enable all the widgets
enableButtons(true); enableButtons(true);

View File

@ -65,7 +65,6 @@ StellaSettingsDialog::StellaSettingsDialog(OSystem& osystem, DialogContainer& pa
xpos += INDENT; xpos += INDENT;
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
addUIOptions(wid, xpos, ypos, font); addUIOptions(wid, xpos, ypos, font);
ypos += VGAP * 4; ypos += VGAP * 4;
addVideoOptions(wid, xpos, ypos, font); addVideoOptions(wid, xpos, ypos, font);
@ -390,7 +389,6 @@ void StellaSettingsDialog::handleOverscanChange()
myTVOverscan->setValueUnit("%"); myTVOverscan->setValueUnit("%");
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaSettingsDialog::switchSettingsMode() void StellaSettingsDialog::switchSettingsMode()
{ {