diff --git a/Changes.txt b/Changes.txt index 91db129b3..0eaffdd36 100644 --- a/Changes.txt +++ b/Changes.txt @@ -22,6 +22,11 @@ * Fixed bug with 'Medieval Mayhem' ROMs; the paddle range was set too low, and as a result the number of players couldn't be selected. + * Fixed bug when using more than two input controllers with the same + name; each controller after the second one was named the same as the + second one. This caused the joystick mappings to be lost, since there + was only information about two controllers being saved. + * Updated internal ROM properties database to ROM-Hunter version 11 (thanks go to RomHunter for his tireless research in this area). Related to this, updated the snapshot collection. diff --git a/src/common/EventHandlerSDL2.cxx b/src/common/EventHandlerSDL2.cxx index 727f6e1ba..dcde1a134 100644 --- a/src/common/EventHandlerSDL2.cxx +++ b/src/common/EventHandlerSDL2.cxx @@ -196,11 +196,11 @@ EventHandlerSDL2::JoystickSDL2::JoystickSDL2(int idx) myStick = SDL_JoystickOpen(idx); if(myStick) { - // There still seems to be some issue with certain controllers not being - // recognized. In this case, SDL names the controller as "XInput Controller". - // This would be fine except it also appends " #x", where x seems to vary. - // Obviously this wreaks havoc with the idea that a joystick will always - // have the same name. So we truncate the number. + // In Windows, all XBox controllers using the XInput API seem to name + // the controller as "XInput Controller". This would be fine, except + // it also appends " #x", where x seems to vary. Obviously this wreaks + // havoc with the idea that a joystick will always have the same name. + // So we truncate the number. const char* sdlname = SDL_JoystickName(myStick); const string& desc = BSPF_startsWithIgnoreCase(sdlname, "XInput Controller") ? "XInput Controller" : sdlname; diff --git a/src/emucore/EventJoyHandler.cxx b/src/emucore/EventJoyHandler.cxx index a08847b4b..2ccc32c0e 100644 --- a/src/emucore/EventJoyHandler.cxx +++ b/src/emucore/EventJoyHandler.cxx @@ -317,13 +317,9 @@ bool EventHandler::JoystickHandler::add(StellaJoystick* stick) // we append ' #x', where 'x' increases consecutively int count = 0; for(const auto& i: myDatabase) - { if(BSPF_startsWithIgnoreCase(i.first, stick->name) && i.second.joy) - { ++count; - break; - } - } + if(count > 0) { ostringstream name;