From bf4b63cb1cd575a065ba755e865ad26df633adc4 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Mon, 31 Aug 2020 10:33:37 +0200 Subject: [PATCH] initial commit for QuadTari support (see #693) --- src/common/PKeyboardHandler.cxx | 17 +++++++++ src/emucore/Console.cxx | 13 ++++--- src/emucore/Control.cxx | 2 +- src/emucore/Control.hxx | 6 ++-- src/emucore/Event.hxx | 13 +++++-- src/emucore/EventHandler.cxx | 56 ++++++++++++++++++++++++++++++ src/emucore/EventHandler.hxx | 2 +- src/gui/GameInfoDialog.cxx | 2 +- src/windows/Stella.vcxproj | 2 ++ src/windows/Stella.vcxproj.filters | 6 ++++ 10 files changed, 107 insertions(+), 12 deletions(-) diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index 7532a1632..ab4f69906 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -658,6 +658,7 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultJoyst {Event::JoystickZeroFire9, KBDK_5}, {Event::JoystickZeroFire9, KBDK_RCTRL}, {Event::JoystickZeroFire9, KBDK_KP_3}, + {Event::JoystickOneUp, KBDK_Y}, {Event::JoystickOneDown, KBDK_H}, {Event::JoystickOneLeft, KBDK_G}, @@ -665,6 +666,22 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultJoyst {Event::JoystickOneFire, KBDK_F}, {Event::JoystickOneFire5, KBDK_6}, {Event::JoystickOneFire9, KBDK_7}, + + {Event::JoystickTwoUp, KBDK_UP, KBDM_SHIFT}, + {Event::JoystickTwoDown, KBDK_DOWN, KBDM_SHIFT}, + {Event::JoystickTwoLeft, KBDK_LEFT, KBDM_SHIFT}, + {Event::JoystickTwoRight, KBDK_RIGHT, KBDM_SHIFT}, + {Event::JoystickTwoUp, KBDK_KP_8, KBDM_SHIFT}, + {Event::JoystickTwoDown, KBDK_KP_2, KBDM_SHIFT}, + {Event::JoystickTwoLeft, KBDK_KP_4, KBDM_SHIFT}, + {Event::JoystickTwoRight, KBDK_KP_6, KBDM_SHIFT}, + {Event::JoystickTwoFire, KBDK_SPACE, KBDM_SHIFT}, + + {Event::JoystickThreeUp, KBDK_Y, KBDM_SHIFT}, + {Event::JoystickThreeDown, KBDK_H, KBDM_SHIFT}, + {Event::JoystickThreeLeft, KBDK_G, KBDM_SHIFT}, + {Event::JoystickThreeRight, KBDK_J, KBDM_SHIFT}, + {Event::JoystickThreeFire, KBDK_F, KBDM_SHIFT}, }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 9cb5c5087..98bb7e98c 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -35,6 +35,11 @@ #include "Genesis.hxx" #include "MindLink.hxx" #include "CompuMate.hxx" +#include "AmigaMouse.hxx" +#include "AtariMouse.hxx" +#include "TrakBall.hxx" +#include "Lightgun.hxx" +#include "QuadTari.hxx" #include "M6502.hxx" #include "M6532.hxx" #include "TIA.hxx" @@ -46,10 +51,6 @@ #include "Sound.hxx" #include "Switches.hxx" #include "System.hxx" -#include "AmigaMouse.hxx" -#include "AtariMouse.hxx" -#include "TrakBall.hxx" -#include "Lightgun.hxx" #include "FrameBuffer.hxx" #include "TIASurface.hxx" #include "OSystem.hxx" @@ -927,6 +928,10 @@ unique_ptr Console::getControllerPort(const Controller::Type type, controller = make_unique(port, myEvent, *mySystem, romMd5, myOSystem.frameBuffer()); break; + case Controller::Type::QuadTari: + controller = make_unique(port, myEvent, *mySystem); + break; + default: // What else can we do? // always create because it may have been changed by user dialog diff --git a/src/emucore/Control.cxx b/src/emucore/Control.cxx index 813063c04..0dfdc79d3 100644 --- a/src/emucore/Control.cxx +++ b/src/emucore/Control.cxx @@ -125,7 +125,7 @@ string Controller::getPropName(const Type type) "AMIGAMOUSE", "ATARIMOUSE", "ATARIVOX", "BOOSTERGRIP", "COMPUMATE", "DRIVING", "GENESIS", "JOYSTICK", "KEYBOARD", "KIDVID", "MINDLINK", "PADDLES", "PADDLES_IAXIS", "PADDLES_IAXDR", "SAVEKEY", "TRAKBALL", - "LIGHTGUN" + "LIGHTGUN", "QUADTARI" }; return PROP_NAMES[int(type)]; diff --git a/src/emucore/Control.hxx b/src/emucore/Control.hxx index 629a2afee..d1ed02b8b 100644 --- a/src/emucore/Control.hxx +++ b/src/emucore/Control.hxx @@ -94,7 +94,7 @@ class Controller : public Serializable AmigaMouse, AtariMouse, AtariVox, BoosterGrip, CompuMate, Driving, Genesis, Joystick, Keyboard, KidVid, MindLink, Paddles, PaddlesIAxis, PaddlesIAxDr, SaveKey, TrakBall, - Lightgun, + Lightgun, QuadTari, LastType }; @@ -178,12 +178,12 @@ class Controller : public Serializable Update the entire digital and analog pin state according to the events currently set. */ - virtual void update() = 0; + virtual void update() { }; /** Returns the name of this controller. */ - virtual string name() const = 0; + virtual string name() const { return ""; } /** Answers whether the controller is intrinsically an analog controller. diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index 197f7569f..bd4a7dae7 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -123,12 +123,17 @@ class Event ToggleFrameStats, ToggleSAPortOrder, ExitGame, SettingDecrease, SettingIncrease, PreviousSetting, NextSetting, ToggleAdaptRefresh, PreviousMultiCartRom, - // add new events from here to avoid that user remapped events get overwritten + // add new (after Version 4) events from here to avoid that user remapped events get overwritten PreviousSettingGroup, NextSettingGroup, TogglePlayBackMode, DecreaseAutoFire, IncreaseAutoFire, DecreaseSpeed, IncreaseSpeed, + JoystickTwoUp, JoystickTwoDown, JoystickTwoLeft, JoystickTwoRight, + JoystickTwoFire, + JoystickThreeUp, JoystickThreeDown, JoystickThreeLeft, JoystickThreeRight, + JoystickThreeFire, + LastType }; @@ -217,11 +222,15 @@ class Event static const Event::EventSet LeftJoystickEvents = { Event::JoystickZeroUp, Event::JoystickZeroDown, Event::JoystickZeroLeft, Event::JoystickZeroRight, Event::JoystickZeroFire, Event::JoystickZeroFire5, Event::JoystickZeroFire9, + Event::JoystickTwoUp, Event::JoystickTwoDown, Event::JoystickTwoLeft, Event::JoystickTwoRight, + Event::JoystickTwoFire }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static const Event::EventSet RightJoystickEvents = { Event::JoystickOneUp, Event::JoystickOneDown, Event::JoystickOneLeft, Event::JoystickOneRight, - Event::JoystickOneFire, Event::JoystickOneFire5, Event::JoystickOneFire9 + Event::JoystickOneFire, Event::JoystickOneFire5, Event::JoystickOneFire9, + Event::JoystickThreeUp, Event::JoystickThreeDown, Event::JoystickThreeLeft, Event::JoystickThreeRight, + Event::JoystickThreeFire }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index ed72579a6..5e3522624 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -620,6 +620,46 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) myEvent.set(Event::JoystickOneLeft, 0); break; + case Event::JoystickTwoUp: + if(!myAllowAllDirectionsFlag && pressed) + myEvent.set(Event::JoystickTwoDown, 0); + break; + + case Event::JoystickTwoDown: + if(!myAllowAllDirectionsFlag && pressed) + myEvent.set(Event::JoystickTwoUp, 0); + break; + + case Event::JoystickTwoLeft: + if(!myAllowAllDirectionsFlag && pressed) + myEvent.set(Event::JoystickTwoRight, 0); + break; + + case Event::JoystickTwoRight: + if(!myAllowAllDirectionsFlag && pressed) + myEvent.set(Event::JoystickTwoLeft, 0); + break; + + case Event::JoystickThreeUp: + if(!myAllowAllDirectionsFlag && pressed) + myEvent.set(Event::JoystickThreeDown, 0); + break; + + case Event::JoystickThreeDown: + if(!myAllowAllDirectionsFlag && pressed) + myEvent.set(Event::JoystickThreeUp, 0); + break; + + case Event::JoystickThreeLeft: + if(!myAllowAllDirectionsFlag && pressed) + myEvent.set(Event::JoystickThreeRight, 0); + break; + + case Event::JoystickThreeRight: + if(!myAllowAllDirectionsFlag && pressed) + myEvent.set(Event::JoystickThreeLeft, 0); + break; + /////////////////////////////////////////////////////////////////////////// // Audio & Video events (with global hotkeys) case Event::VolumeDecrease: @@ -2467,6 +2507,18 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { { { Event::JoystickOneFire5, "P1 Booster Top Booster Button", "" }, { Event::JoystickOneFire9, "P1 Booster Handle Grip Trigger", "" }, + { Event::JoystickTwoUp, "P2 Joystick Up", "" }, + { Event::JoystickTwoDown, "P2 Joystick Down", "" }, + { Event::JoystickTwoLeft, "P2 Joystick Left", "" }, + { Event::JoystickTwoRight, "P2 Joystick Right", "" }, + { Event::JoystickTwoFire, "P2 Joystick Fire", "" }, + + { Event::JoystickThreeUp, "P3 Joystick Up", "" }, + { Event::JoystickThreeDown, "P3 Joystick Down", "" }, + { Event::JoystickThreeLeft, "P3 Joystick Left", "" }, + { Event::JoystickThreeRight, "P3 Joystick Right", "" }, + { Event::JoystickThreeFire, "P3 Joystick Fire", "" }, + { Event::PaddleZeroAnalog, "Paddle 0 Analog", "" }, { Event::PaddleZeroIncrease, "Paddle 0 Turn Left", "" }, { Event::PaddleZeroDecrease, "Paddle 0 Turn Right", "" }, @@ -2711,6 +2763,10 @@ const Event::EventSet EventHandler::JoystickEvents = { Event::JoystickZeroFire, Event::JoystickZeroFire5, Event::JoystickZeroFire9, Event::JoystickOneUp, Event::JoystickOneDown, Event::JoystickOneLeft, Event::JoystickOneRight, Event::JoystickOneFire, Event::JoystickOneFire5, Event::JoystickOneFire9, + Event::JoystickTwoUp, Event::JoystickTwoDown, Event::JoystickTwoLeft, Event::JoystickTwoRight, + Event::JoystickTwoFire, + Event::JoystickThreeUp, Event::JoystickThreeDown, Event::JoystickThreeLeft, Event::JoystickThreeRight, + Event::JoystickThreeFire, }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index 4c7954c40..e1990a440 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -559,7 +559,7 @@ class EventHandler #else REFRESH_SIZE = 0, #endif - EMUL_ACTIONLIST_SIZE = 164 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE, + EMUL_ACTIONLIST_SIZE = 174 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE, MENU_ACTIONLIST_SIZE = 18 ; diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 6017c65d3..e960ab419 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -227,6 +227,7 @@ GameInfoDialog::GameInfoDialog( VarList::push_back(ctrls, "KidVid", "KIDVID"); VarList::push_back(ctrls, "Lightgun", "LIGHTGUN"); VarList::push_back(ctrls, "MindLink", "MINDLINK"); + VarList::push_back(ctrls, "QuadTari", "QUADTARI"); ypos = VBORDER; pwidth = font.getStringWidth("Paddles_IAxis"); @@ -771,7 +772,6 @@ void GameInfoDialog::updateControllerStates() myPaddleXCenter->setEnabled(enablePaddles); myPaddleYCenter->setEnabled(enablePaddles); - bool enableMouse = enablePaddles || BSPF::startsWithIgnoreCase(contrLeft, "Driving") || BSPF::startsWithIgnoreCase(contrRight, "Driving") || diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index b407d547a..71c5d6f30 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -746,6 +746,7 @@ + @@ -1775,6 +1776,7 @@ + diff --git a/src/windows/Stella.vcxproj.filters b/src/windows/Stella.vcxproj.filters index 5875efb8c..be6cc8424 100644 --- a/src/windows/Stella.vcxproj.filters +++ b/src/windows/Stella.vcxproj.filters @@ -1017,6 +1017,9 @@ Source Files\gui + + Source Files\emucore + @@ -2090,6 +2093,9 @@ Header Files\emucore + + Header Files\emucore +