diff --git a/src/common/EventHandlerSDL2.cxx b/src/common/EventHandlerSDL2.cxx index 200298d37..cbe39dc12 100644 --- a/src/common/EventHandlerSDL2.cxx +++ b/src/common/EventHandlerSDL2.cxx @@ -94,6 +94,7 @@ void EventHandlerSDL2::pollEvent() case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { + // ToDo: check support of more buttons and double-click switch(myEvent.button.button) { case SDL_BUTTON_LEFT: diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index ad9bded9b..fdf01cb6d 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -133,9 +133,6 @@ Console::Console(OSystem& osystem, unique_ptr& cart, // This must be done before the debugger is initialized const string& md5 = myProperties.get(PropType::Cart_MD5); setControllers(md5); - // now that we know the controllers, enable the event mappings - myOSystem.eventHandler().enableEmulationKeyMappings(); - myOSystem.eventHandler().enableEmulationJoyMappings(); // Mute audio and clear framebuffer while autodetection runs myOSystem.sound().mute(1); @@ -814,7 +811,7 @@ void Console::setControllers(const string& rommd5) string right = myProperties.get(PropType::Controller_Right); uInt32 size = 0; const uInt8* image = myCart->getImage(size); - const bool swappedPorts = myProperties.get(PropType::Console_SwapPorts) != "NO"; + const bool swappedPorts = myProperties.get(PropType::Console_SwapPorts) == "YES"; // Try to detect controllers if(image != nullptr || size != 0) @@ -842,23 +839,27 @@ void Console::setControllers(const string& rommd5) } myTIA->bindToControllers(); + + // now that we know the controllers, enable the event mappings + myOSystem.eventHandler().enableEmulationKeyMappings(); + myOSystem.eventHandler().enableEmulationJoyMappings(); + + myOSystem.eventHandler().setMouseControllerMode(myOSystem.settings().getString("usemouse")); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unique_ptr Console::getControllerPort(const string& rommd5, const string& controllerName, Controller::Jack port) { - unique_ptr controller = std::move(myLeftControl); + unique_ptr controller; // = std::move(myLeftControl); // TJ: why was this there? myOSystem.eventHandler().defineKeyControllerMappings(controllerName, port); myOSystem.eventHandler().defineJoyControllerMappings(controllerName, port); if(controllerName == "JOYSTICK") { - // Already created in c'tor - // We save some time by not looking at all the other types - if(!controller) - controller = make_unique(port, myEvent, *mySystem); + // always create because it may have been changed by user dialog + controller = make_unique(port, myEvent, *mySystem); } else if(controllerName == "BOOSTERGRIP") { diff --git a/src/emucore/Console.hxx b/src/emucore/Console.hxx index 0486274f9..01cca4f54 100644 --- a/src/emucore/Console.hxx +++ b/src/emucore/Console.hxx @@ -81,6 +81,12 @@ class Console : public Serializable, public ConsoleIO virtual ~Console(); public: + + /** + Sets the left and right controllers for the console. + */ + void setControllers(const string& rommd5); + /** Get the controller plugged into the specified jack @@ -330,11 +336,6 @@ class Console : public Serializable, public ConsoleIO */ void createAudioQueue(); - /** - Adds the left and right controllers to the console. - */ - void setControllers(const string& rommd5); - /** Selects the left or right controller depending on ROM properties */ diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 285007388..9317e6c87 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -67,7 +67,7 @@ GameInfoDialog::GameInfoDialog( // Set real dimensions setSize(53 * fontWidth + 8, - 8 * (lineHeight + VGAP) + 2 * (infoLineHeight + VGAP) + VBORDER * 2 + _th + + 8 * (lineHeight + VGAP) + 1 * (infoLineHeight + VGAP) + VBORDER * 2 + _th + buttonHeight + fontHeight + ifont.getLineHeight() + 20, max_w, max_h); @@ -191,7 +191,7 @@ GameInfoDialog::GameInfoDialog( ////////////////////////////////////////////////////////////////////////////// // 3) Controller properties wid.clear(); - tabID = myTab->addTab("Controller"); + tabID = myTab->addTab("Controllers"); ctrls.clear(); VarList::push_back(ctrls, "Auto-detect", "AUTO"); @@ -286,11 +286,6 @@ GameInfoDialog::GameInfoDialog( myMouseRange->setTickmarkIntervals(4); wid.push_back(myMouseRange); - // Add message concerning usage - ypos = myTab->getHeight() - 5 - fontHeight - ifont.getFontHeight() - 10; - new StaticTextWidget(myTab, ifont, xpos, ypos, - "(*) Changes to properties require a ROM reload"); - // Add items for tab 2 addToFocusList(wid, myTab, tabID); @@ -614,6 +609,9 @@ void GameInfoDialog::saveConfig() instance().console().switches().setTvColor(myTVTypeGroup->getSelected() == 0); instance().console().switches().setLeftDifficultyA(myLeftDiffGroup->getSelected() == 0); instance().console().switches().setRightDifficultyA(myRightDiffGroup->getSelected() == 0); + + // update 'Controllers' tab settings immediately + instance().console().setControllers(myGameProperties.get(PropType::Cart_MD5)); } } @@ -658,9 +656,12 @@ void GameInfoDialog::updateControllerStates() // Compumate bankswitching scheme doesn't allow to select controllers bool enableSelectControl = myBSType->getSelectedTag() != "CM"; - + // Enable Swap Paddles checkbox only for paddle games bool enableSwapPaddles = BSPF::startsWithIgnoreCase(contrLeft, "PADDLES") || - BSPF::startsWithIgnoreCase(contrRight, "PADDLES"); + BSPF::startsWithIgnoreCase(contrRight, "PADDLES") || + BSPF::startsWithIgnoreCase(myLeftPortDetected->getLabel(), "Paddles") || + BSPF::startsWithIgnoreCase(myRightPortDetected->getLabel(), "Paddles"); + if(instance().hasConsole()) { const Controller& lport = instance().console().leftController();