diff --git a/Changes.txt b/Changes.txt index 16e7a10a1..33da1ce90 100644 --- a/Changes.txt +++ b/Changes.txt @@ -16,16 +16,18 @@ * Updated the CompuMate keyboard handler to recognize more keys on an actual keyboard, instead of having to remember the weird combinations - used on the original CompuMate keyboard. + used on the original CompuMate keyboard (although those original keys + will continue to work). - * Added emulation for MindLink controller; the Bionic Breakthrough - ROM now works. + * Added emulation for MindLink controller using the mouse; the 'Bionic + Breakthrough' and 'Telepathy' ROMs now work. * Updated FA2 bankswitch scheme (Star Castle) to emulate load/save high score functionality to the Harmony cart flash RAM. - * Updated internal database for 'Juno First' ROMs; they will now use - an AtariVox/SaveKey when possible. + * Several updates to the internal properties database: + - 'Juno First' ROMs now use an AtariVox/SaveKey when possible + - 'Astroblast' ROMs now use the paddles by default * Updated included PNG library to latest stable version. diff --git a/src/common/MouseControl.cxx b/src/common/MouseControl.cxx index 4a682723a..db8209d53 100644 --- a/src/common/MouseControl.cxx +++ b/src/common/MouseControl.cxx @@ -30,53 +30,117 @@ MouseControl::MouseControl(Console& console, const string& mode) myRightController(console.controller(Controller::Right)), myCurrentModeNum(0) { - if(BSPF_equalsIgnoreCase(mode, "never")) + if(BSPF_equalsIgnoreCase(mode, "none")) { myModeList.push_back(MouseMode("Mouse input is disabled")); return; } else if(!BSPF_equalsIgnoreCase(mode, "auto") && mode.length() == 2 && - mode[0] >= '0' && mode[0] <= '5' && - mode[1] >= '0' && mode[1] <= '5') + mode[0] >= '0' && mode[0] <= '8' && + mode[1] >= '0' && mode[1] <= '8') { Axis xaxis = (Axis) ((int)mode[0] - '0'); Axis yaxis = (Axis) ((int)mode[1] - '0'); ostringstream msg; msg << "Mouse X-axis is "; + Controller::Type xtype = Controller::Joystick, ytype = Controller::Joystick; + int xid = -1, yid = -1; switch(xaxis) { + case NoControl: + msg << "not used"; + break; case Paddle0: - msg << "Paddle 0"; break; + xtype = Controller::Paddles; + xid = 0; + msg << "Paddle 0"; + break; case Paddle1: - msg << "Paddle 1"; break; + xtype = Controller::Paddles; + xid = 1; + msg << "Paddle 1"; + break; case Paddle2: - msg << "Paddle 2"; break; + xtype = Controller::Paddles; + xid = 2; + msg << "Paddle 2"; + break; case Paddle3: - msg << "Paddle 3"; break; + xtype = Controller::Paddles; + xid = 3; + msg << "Paddle 3"; + break; case Driving0: - msg << "Driving 0"; break; + xtype = Controller::Driving; + xid = 0; + msg << "Driving 0"; + break; case Driving1: - msg << "Driving 1"; break; - default: break; + xtype = Controller::Driving; + xid = 1; + msg << "Driving 1"; + break; + case MindLink0: + xtype = Controller::MindLink; + xid = 0; + msg << "MindLink 0"; + break; + case MindLink1: + xtype = Controller::MindLink; + xid = 1; + msg << "MindLink 1"; + break; + default: break; } msg << ", Y-axis is "; switch(yaxis) { + case NoControl: + msg << "not used"; + break; case Paddle0: - msg << "Paddle 0"; break; + ytype = Controller::Paddles; + yid = 0; + msg << "Paddle 0"; + break; case Paddle1: - msg << "Paddle 1"; break; + ytype = Controller::Paddles; + yid = 1; + msg << "Paddle 1"; + break; case Paddle2: - msg << "Paddle 2"; break; + ytype = Controller::Paddles; + yid = 2; + msg << "Paddle 2"; + break; case Paddle3: - msg << "Paddle 3"; break; + ytype = Controller::Paddles; + yid = 3; + msg << "Paddle 3"; + break; case Driving0: - msg << "Driving 0"; break; + ytype = Controller::Driving; + yid = 0; + msg << "Driving 0"; + break; case Driving1: - msg << "Driving 1"; break; - default: break; + ytype = Controller::Driving; + yid = 1; + msg << "Driving 1"; + break; + case MindLink0: + ytype = Controller::MindLink; + yid = 0; + msg << "MindLink 0"; + break; + case MindLink1: + ytype = Controller::MindLink; + yid = 1; + msg << "MindLink 1"; + break; + default: break; } - myModeList.push_back(MouseMode(xaxis, yaxis, -1, msg.str())); + myModeList.push_back(MouseMode(xtype, xid, ytype, yid, msg.str())); } // Now consider the possible modes for the mouse based on the left @@ -96,6 +160,11 @@ MouseControl::MouseControl(Console& console, const string& mode) // If the mouse isn't used at all, we still need one item in the list if(myModeList.size() == 0) myModeList.push_back(MouseMode("Mouse not used for current controllers")); + +#if 0 + for(unsigned int i = 0; i < myModeList.size(); ++i) + cerr << myModeList[i] << endl; +#endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -109,8 +178,8 @@ const string& MouseControl::next() const MouseMode& mode = myModeList[myCurrentModeNum]; myCurrentModeNum = (myCurrentModeNum + 1) % myModeList.size(); - myLeftController.setMouseControl(mode.xaxis, mode.yaxis, mode.controlID); - myRightController.setMouseControl(mode.xaxis, mode.yaxis, mode.controlID); + myLeftController.setMouseControl(mode.xtype, mode.xid, mode.ytype, mode.yid); + myRightController.setMouseControl(mode.xtype, mode.xid, mode.ytype, mode.yid); return mode.message; } @@ -118,69 +187,56 @@ const string& MouseControl::next() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void MouseControl::addLeftControllerModes(bool noswap) { - switch(myLeftController.type()) + if(controllerSupportsMouse(myLeftController)) { - case Controller::Joystick: - case Controller::BoosterGrip: - case Controller::Genesis: - case Controller::Driving: - case Controller::TrackBall22: - case Controller::TrackBall80: - case Controller::AmigaMouse: -// case Controller::Mindlink: + if(myLeftController.type() == Controller::Paddles) + { + if(noswap) addPaddleModes(0, 1, 0, 1); + else addPaddleModes(2, 3, 0, 1); + } + else { ostringstream msg; msg << "Mouse is left " << myLeftController.name() << " controller"; - myModeList.push_back(MouseMode(Automatic, Automatic, noswap ? 0 : 1, msg.str())); - break; + Controller::Type type = myLeftController.type(); + int id = noswap ? 0 : 1; + myModeList.push_back(MouseMode(type, id, type, id, msg.str())); } - case Controller::Paddles: - if(noswap) addPaddleModes(0, 1, 0, 1); - else addPaddleModes(2, 3, 0, 1); - break; - default: - break; } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void MouseControl::addRightControllerModes(bool noswap) { - switch(myRightController.type()) + if(controllerSupportsMouse(myRightController)) { - case Controller::Joystick: - case Controller::BoosterGrip: - case Controller::Genesis: - case Controller::Driving: - case Controller::TrackBall22: - case Controller::TrackBall80: - case Controller::AmigaMouse: -// case Controller::Mindlink: + if(myRightController.type() == Controller::Paddles) + { + if(noswap) addPaddleModes(2, 3, 2, 3); + else addPaddleModes(0, 1, 2, 3); + } + else { ostringstream msg; msg << "Mouse is right " << myRightController.name() << " controller"; - myModeList.push_back(MouseMode(Automatic, Automatic, noswap ? 1 : 0, msg.str())); - break; + Controller::Type type = myRightController.type(); + int id = noswap ? 1 : 0; + myModeList.push_back(MouseMode(type, id, type, id, msg.str())); } - case Controller::Paddles: - if(noswap) addPaddleModes(2, 3, 2, 3); - else addPaddleModes(0, 1, 2, 3); - break; - default: - break; } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void MouseControl::addPaddleModes(int lport, int rport, int lname, int rname) { + Controller::Type type = Controller::Paddles; ostringstream msg; msg << "Mouse is Paddle " << lname << " controller"; - MouseMode mode0(Automatic, Automatic, lport, msg.str()); + MouseMode mode0(type, lport, type, lport, msg.str()); msg.str(""); msg << "Mouse is Paddle " << rname << " controller"; - MouseMode mode1(Automatic, Automatic, rport, msg.str()); + MouseMode mode1(type, rport, type, rport, msg.str()); if(BSPF_equalsIgnoreCase(myProps.get(Controller_SwapPaddles), "NO")) { @@ -193,3 +249,13 @@ void MouseControl::addPaddleModes(int lport, int rport, int lname, int rname) myModeList.push_back(mode0); } } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool MouseControl::controllerSupportsMouse(Controller& controller) +{ + // Test whether the controller uses the mouse at all + // We can pass in dummy values here, since the controllers will be + // initialized by a call to next() once the system is up and running + return controller.setMouseControl( + Controller::Joystick, -1, Controller::Joystick, -1); +} diff --git a/src/common/MouseControl.hxx b/src/common/MouseControl.hxx index db717d1c7..1b2f20d5c 100644 --- a/src/common/MouseControl.hxx +++ b/src/common/MouseControl.hxx @@ -21,11 +21,11 @@ #define MOUSE_CONTROL_HXX class Console; -class Controller; class Properties; #include "bspf.hxx" #include "Array.hxx" +#include "Control.hxx" /** The mouse can control various virtual 'controllers' in many different @@ -47,7 +47,8 @@ class MouseControl enum Axis { Paddle0 = 0, Paddle1, Paddle2, Paddle3, - Driving0, Driving1, Automatic, NoControl + Driving0, Driving1, MindLink0, MindLink1, + NoControl }; public: @@ -76,6 +77,7 @@ class MouseControl void addLeftControllerModes(bool noswap); void addRightControllerModes(bool noswap); void addPaddleModes(int lport, int rport, int lname, int rname); + bool controllerSupportsMouse(Controller& controller); private: const Properties& myProps; @@ -83,29 +85,30 @@ class MouseControl Controller& myRightController; struct MouseMode { - Axis xaxis, yaxis; - int controlID; + Controller::Type xtype, ytype; + int xid, yid; string message; - MouseMode() - : xaxis(NoControl), - yaxis(NoControl), - controlID(-1), - message("") { } - MouseMode(const string& msg) - : xaxis(NoControl), - yaxis(NoControl), - controlID(-1), + MouseMode(const string& msg = "") + : xtype(Controller::Joystick), + ytype(Controller::Joystick), + xid(-1), + yid(-1), message(msg) { } - MouseMode(Axis x, Axis y, int id, const string& msg) - : xaxis(x), - yaxis(y), - controlID(id), + MouseMode(Controller::Type xtype, int xid, + Controller::Type ytype, int yid, + const string& msg) + : xtype(xtype), + ytype(ytype), + xid(xid), + yid(yid), message(msg) { } + friend ostream& operator<<(ostream& os, const MouseMode& mm) { - os << "xaxis=" << mm.xaxis << ", yaxis=" << mm.yaxis - << ", id=" << mm.controlID << ", msg=" << mm.message; + os << "xtype=" << mm.xtype << ", xid=" << mm.xid + << ", ytype=" << mm.ytype << ", yid=" << mm.yid + << ", msg=" << mm.message; return os; } }; diff --git a/src/emucore/Booster.cxx b/src/emucore/Booster.cxx index eee00e0d2..053bb3ea7 100644 --- a/src/emucore/Booster.cxx +++ b/src/emucore/Booster.cxx @@ -129,16 +129,21 @@ void BoosterGrip::update() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void BoosterGrip::setMouseControl( - MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID) +bool BoosterGrip::setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid) { - // In 'automatic' mode, both axes on the mouse map to a single normal booster - if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic) + // Currently, the booster-grip takes full control of the mouse, using both + // axes for its two degrees of movement, and the left/right buttons for + // fire and booster, respectively + if(xtype == Controller::BoosterGrip && ytype == Controller::BoosterGrip && + xid == yid) { - myControlID = ((myJack == Left && ctrlID == 0) || - (myJack == Right && ctrlID == 1) - ) ? ctrlID : -1; + myControlID = ((myJack == Left && xid == 0) || + (myJack == Right && xid == 1) + ) ? xid : -1; } - else // Otherwise, boosters are not used in 'non-auto' mode + else myControlID = -1; + + return true; } diff --git a/src/emucore/Booster.hxx b/src/emucore/Booster.hxx index d96f26cc4..ca30871dc 100644 --- a/src/emucore/Booster.hxx +++ b/src/emucore/Booster.hxx @@ -58,20 +58,21 @@ class BoosterGrip : public Controller /** Determines how this controller will treat values received from the X/Y axis and left/right buttons of the mouse. Since not all controllers - use the mouse, it's up to the specific class to decide how to use this data. - - If either of the axis is set to 'Automatic', then we automatically - use the ctrlID for the control type. + use the mouse the same way (or at all), it's up to the specific class to + decide how to use this data. In the current implementation, the left button is tied to the X axis, and the right one tied to the Y axis. - @param xaxis How the controller should use x-axis data - @param yaxis How the controller should use y-axis data - @param ctrlID The controller ID to use axis 'auto' mode + @param xtype The controller to use for x-axis data + @param xid The controller ID to use for x-axis data (-1 for no id) + @param ytype The controller to use for y-axis data + @param yid The controller ID to use for y-axis data (-1 for no id) + + @return Whether the controller supports using the mouse */ - void setMouseControl( - MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1); + bool setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid); private: // Pre-compute the events we care about based on given port @@ -80,7 +81,7 @@ class BoosterGrip : public Controller myFireEvent, myBoosterEvent, myTriggerEvent, myXAxisValue, myYAxisValue; - // Controller to emulate in mouse axis 'automatic' mode + // Controller to emulate in normal mouse axis mode int myControlID; }; diff --git a/src/emucore/Control.hxx b/src/emucore/Control.hxx index cb9984740..63463058f 100644 --- a/src/emucore/Control.hxx +++ b/src/emucore/Control.hxx @@ -26,7 +26,6 @@ class System; #include "Serializable.hxx" #include "bspf.hxx" -#include "MouseControl.hxx" /** A controller is a device that plugs into either the left or right @@ -181,20 +180,22 @@ class Controller : public Serializable /** Determines how this controller will treat values received from the X/Y axis and left/right buttons of the mouse. Since not all controllers - use the mouse, it's up to the specific class to decide how to use this data. - - If either of the axis is set to 'Automatic', then we automatically - use the ctrlID for the control type. + use the mouse the same way (or at all), it's up to the specific class to + decide how to use this data. In the current implementation, the left button is tied to the X axis, and the right one tied to the Y axis. - @param xaxis How the controller should use x-axis data - @param yaxis How the controller should use y-axis data - @param ctrlID The controller ID to use axis 'auto' mode + @param xtype The controller to use for x-axis data + @param xid The controller ID to use for x-axis data (-1 for no id) + @param ytype The controller to use for y-axis data + @param yid The controller ID to use for y-axis data (-1 for no id) + + @return Whether the controller supports using the mouse */ - virtual void setMouseControl( - MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1) { }; + virtual bool setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid) + { return false; } /** Returns the name of this controller. diff --git a/src/emucore/DefProps.hxx b/src/emucore/DefProps.hxx index ac5c203f8..8200a881e 100644 --- a/src/emucore/DefProps.hxx +++ b/src/emucore/DefProps.hxx @@ -331,7 +331,7 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = { { "16e04823887c547dc24bc70dff693df4", "Atari", "CX26163P", "Tennis (32 in 1) (1988) (Atari) (PAL)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "16f494f20af5dc803bc35939ef924020", "Mark De Smet", "", "Video Simon (Mark De Smet)", "", "New Release", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "16fbb36a6124567405a235821e8f69ee", "", "", "Star Fire (28-11-2002) (MP)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, - { "170e7589a48739cfb9cc782cbb0fe25a", "M Network, Hal Finney - INTV", "MT5666", "Astroblast (1982) (M Network) [fixed]", "", "Uncommon", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, + { "170e7589a48739cfb9cc782cbb0fe25a", "M Network, Hal Finney - INTV", "MT5666", "Astroblast (1982) (M Network) [fixed]", "Can also use left joystick", "Uncommon", "", "", "", "", "", "", "PADDLES", "", "YES", "", "", "", "", "", "" }, { "171cd6b55267573e6a9c2921fb720794", "Kurt Howe", "", "Adventure 34 (Kurt Howe) (Hack)", "Hack of Adventure", "Hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "1733772165d7b886a94e2b4ed0f74ccd", "", "", "Boring Journey Escape (Hack)", "Hack of Journey - Escape", "Hack", "", "", "", "", "", "", "", "", "", "", "", "", "230", "", "" }, { "1738b2e3f25ab3eef3cecb95e1d0d957", "", "", "Hangman Monkey Biglist1 (Hack)", "Hack of Hangman", "Hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, @@ -829,7 +829,7 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = { { "3d48b8b586a09bdbf49f1a016bf4d29a", "Video Game Cartridge - Ariola", "TP-606", "Hole Hunter (Video Game Cartridge)", "AKA Topy", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "3d6fc7a19be76d808aa233415cb583fc", "CCE", "C-833", "Target Practice (1983) (CCE)", "AKA Carnival", "", "", "", "", "", "", "", "", "", "", "", "", "26", "214", "", "" }, { "3d7749fb9c2f91a276dfe494495234c5", "Jone Yuan Telephonic Enterprise Co", "", "Checkers (Jone Yuan)", "2600 Screen Search Console", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, - { "3d7aad37c55692814211c8b590a0334c", "Atari, Dan Oliver", "", "Telepathy (1983) (Atari) (Prototype)", "", "Prototype", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, + { "3d7aad37c55692814211c8b590a0334c", "Atari, Dan Oliver", "", "Telepathy (1983) (Atari) (Prototype)", "Uses both left joystick and right Mindlink controllers (press Fire on respective controller to begin)", "Prototype", "", "", "", "", "", "", "", "MINDLINK", "", "78", "", "", "", "", "" }, { "3d8a2d6493123a53ade45e3e2c5cafa0", "Atari, Jim Huether - Sears", "CX2629 - 6-99843, 49-75118", "Sky Diver (1979) (Atari) (4K)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "3d934bb980e2e63e1ead3e7756928ccd", "Activision, Steve Cartwright - Ariola", "EAX-017, EAX-017-04I - 711 017-720", "MegaMania (1982) (Activision) (PAL)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "3d9c2fccf8b11630762ff00811c19277", "", "", "Challenge of.... Nexar, The (Unknown) (PAL)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, @@ -954,7 +954,7 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = { { "469473ff6fed8cc8d65f3c334f963aab", "Atari, Bruce Poehlman, Gary Stark", "", "Dune (07-10-1984) (Atari) (Prototype)", "", "Prototype", "", "", "", "", "", "", "", "", "", "", "", "23", "", "YES", "" }, { "46c021a3e9e2fd00919ca3dd1a6b76d8", "Atari, Jim Huether - Sears", "CX2629 - 6-99843, 49-75118", "Sky Diver (1979) (Atari)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "46c43fdcbce8fde3a91ebeafc05b7cbd", "", "", "Invaders Demo (PAL) (2001) (Eckhard Stolberg)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, - { "46e9428848c9ea71a4d8f91ff81ac9cc", "Telegames", "", "Astroblast (1989) (Telegames) (PAL)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, + { "46e9428848c9ea71a4d8f91ff81ac9cc", "Telegames", "", "Astroblast (1989) (Telegames) (PAL)", "Can also use left joystick", "", "", "", "", "", "", "", "PADDLES", "", "YES", "", "", "", "", "", "" }, { "4702d8d9b48a332724af198aeac9e469", "Atari, Jerome Domurat, Steve Woita", "CX2699", "Taz (1983) (Atari) [a]", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "470878b9917ea0348d64b5750af149aa", "Atari, Suki Lee - Sears", "CX2658 - 49-75128", "Math Gran Prix (1982) (Atari)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "47464694e9cce07fdbfd096605bf39d4", "Activision, Dan Kitchen", "EAK-050-04", "Double Dragon (1989) (Activision) (PAL) [a]", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, @@ -1540,7 +1540,7 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = { { "74f623833429d35341b7a84bc09793c0", "Zellers", "", "Radar (Zellers)", "AKA Exocet", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "75028162bfc4cc8e74b04e320f9e6a3f", "Atari, Greg Easter, Mimi Nyden", "CX26107", "Snow White and the Seven Dwarfs (02-09-1983) (Atari) (Prototype)", "", "Prototype", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "7511c34518a9a124ea773f5b0b5c9a48", "", "", "Donkey Kong (208 in 1) (Unknown) (PAL)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, - { "75169c08b56e4e6c36681e599c4d8cc5", "M Network, Hal Finney - INTV", "MT5666", "Astroblast (1982) (M Network)", "", "Uncommon", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, + { "75169c08b56e4e6c36681e599c4d8cc5", "M Network, Hal Finney - INTV", "MT5666", "Astroblast (1982) (M Network)", "Can also use left joystick", "Uncommon", "", "", "", "", "", "", "PADDLES", "", "YES", "", "", "", "", "", "" }, { "753375d183c713cfa0aa7298d1f3067b", "Arcadia Corporation, Steve Hales, Stephen Harland Landrum", "AR-4102", "Suicide Mission (1982) (Arcadia) [a]", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "" }, { "7550b821ee56fb5833dca2be88622d5a", "", "", "Multiple Moving Objects Demo (B. Watson)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "75511bb694662301c9e71df645f4b5a7", "Activision, Bob Whitehead - Ariola", "EAG-011, PAG-011 - 711 011-715", "Stampede (1981) (Activision) (PAL)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, @@ -2581,7 +2581,7 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = { { "cbc373fbcb1653b4c56bfabba33ea50d", "CCE", "", "Super Voleyball (CCE)", "AKA RealSports Volleyball", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "cbced209dd0575a27212d3eee6aee3bc", "Apollo - Games by Apollo, Ed Salvo, Byron Parks", "AP-2003", "Racquetball (1981) (Apollo)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "" }, { "cbd981a23c592fb9ab979223bb368cd5", "Atari, Carla Meninsky - Sears", "CX2660 - 49-75187", "Star Raiders (1982) (Atari)", "Uses Joystick (left) and Keypad (right) Controllers", "", "", "", "", "", "", "", "", "KEYBOARD", "", "", "", "", "", "", "" }, - { "cbe5a166550a8129a5e6d374901dffad", "Atari, Carla Meninsky - Sears", "CX2610 - 49-75127", "Warlords (1981) (Atari)", "Uses the Paddle Controllers", "", "", "", "", "", "", "", "PADDLES", "PADDLES", "", "01", "", "", "", "", "" }, + { "cbe5a166550a8129a5e6d374901dffad", "Atari, Carla Meninsky - Sears", "CX2610 - 49-75127", "Warlords (1981) (Atari)", "Uses the Paddle Controllers", "", "", "", "", "", "", "", "PADDLES", "PADDLES", "", "", "", "", "", "", "" }, { "cbeafd37f15e0dddb0540dbe15c545a4", "", "", "Black and White Fast Scolling Demo (PD)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "cc03c68b8348b62331964d7a3dbec381", "Jone Yuan Telephonic Enterprise Co", "", "Marauder (Jone Yuan)", "2600 Screen Search Console", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "cc12581e079cd18330a89902625b8347", "Dave Neuman", "", "Space Battle (PAL)", "", "Homebrew", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, diff --git a/src/emucore/Driving.cxx b/src/emucore/Driving.cxx index 1afd4b6d6..ab842d3c3 100644 --- a/src/emucore/Driving.cxx +++ b/src/emucore/Driving.cxx @@ -136,31 +136,34 @@ void Driving::update() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Driving::setMouseControl( - MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID) +bool Driving::setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid) { - // In 'automatic' mode, only the X-axis is used - if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic) + // When the mouse emulates a single driving controller, only the X-axis is + // used, and both mouse buttons map to the same 'fire' event + if(xtype == Controller::Driving && ytype == Controller::Driving && xid == yid) { - myControlID = ((myJack == Left && ctrlID == 0) || - (myJack == Right && ctrlID == 1) - ) ? ctrlID : -1; + myControlID = ((myJack == Left && xid == 0) || + (myJack == Right && xid == 1) + ) ? xid : -1; myControlIDX = myControlIDY = -1; } else { - // The following is somewhat complex, but we need to pre-process as much - // as possible, so that ::update() can run quickly + // Otherwise, each axis can be mapped to a separate driving controller, + // and the buttons map to separate (corresponding) controllers myControlID = -1; if(myJack == Left) { - myControlIDX = xaxis == MouseControl::Driving0 ? 0 : -1; - myControlIDY = yaxis == MouseControl::Driving0 ? 0 : -1; + myControlIDX = (xtype == Controller::Driving && xid == 0) ? 0 : -1; + myControlIDY = (ytype == Controller::Driving && yid == 0) ? 0 : -1; } else // myJack == Right { - myControlIDX = xaxis == MouseControl::Driving1 ? 1 : -1; - myControlIDY = yaxis == MouseControl::Driving1 ? 1 : -1; + myControlIDX = (xtype == Controller::Driving && xid == 1) ? 1 : -1; + myControlIDY = (ytype == Controller::Driving && yid == 1) ? 1 : -1; } } + + return true; } diff --git a/src/emucore/Driving.hxx b/src/emucore/Driving.hxx index 296be350f..44750394b 100644 --- a/src/emucore/Driving.hxx +++ b/src/emucore/Driving.hxx @@ -58,20 +58,21 @@ class Driving : public Controller /** Determines how this controller will treat values received from the X/Y axis and left/right buttons of the mouse. Since not all controllers - use the mouse, it's up to the specific class to decide how to use this data. - - If either of the axis is set to 'Automatic', then we automatically - use the ctrlID for the control type. + use the mouse the same way (or at all), it's up to the specific class to + decide how to use this data. In the current implementation, the left button is tied to the X axis, and the right one tied to the Y axis. - @param xaxis How the controller should use x-axis data - @param yaxis How the controller should use y-axis data - @param ctrlID The controller ID to use axis 'auto' mode + @param xtype The controller to use for x-axis data + @param xid The controller ID to use for x-axis data (-1 for no id) + @param ytype The controller to use for y-axis data + @param yid The controller ID to use for y-axis data (-1 for no id) + + @return Whether the controller supports using the mouse */ - void setMouseControl( - MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1); + bool setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid); private: // Counter to iterate through the gray codes @@ -89,10 +90,10 @@ class Driving : public Controller Event::Type myCWEvent, myCCWEvent, myFireEvent, myXAxisValue, myYAxisValue, myAxisMouseMotion; - // Controller to emulate in mouse axis 'automatic' mode + // Controller to emulate in normal mouse axis mode int myControlID; - // Controller to emulate in mouse axis 'specific' mode + // Controllers to emulate in 'specific' mouse axis mode int myControlIDX, myControlIDY; }; diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index b53d3c54f..186ab65a8 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -518,10 +518,7 @@ void EventHandler::poll(uInt64 time) { case KBDK_0: // Ctrl-0 switches between mouse control modes if(myMouseControl) - { - const string& message = myMouseControl->next(); - myOSystem->frameBuffer().showMessage(message); - } + myOSystem->frameBuffer().showMessage(myMouseControl->next()); break; case KBDK_1: // Ctrl-1 swaps Stelladaptor/2600-daptor ports @@ -1964,13 +1961,14 @@ void EventHandler::takeSnapshot(uInt32 number) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void EventHandler::setMouseControllerMode(const string& mode) +void EventHandler::setMouseControllerMode(bool enable) { - delete myMouseControl; myMouseControl = NULL; if(&myOSystem->console()) { - const string& control = mode == "rom" ? - myOSystem->console().properties().get(Controller_MouseAxis) : mode; + delete myMouseControl; myMouseControl = NULL; + + const string& control = enable ? + myOSystem->console().properties().get(Controller_MouseAxis) : "none"; myMouseControl = new MouseControl(myOSystem->console(), control); myMouseControl->next(); // set first available mode diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index eb6882987..89934cf3a 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -157,12 +157,12 @@ class EventHandler void quit() { handleEvent(Event::Quit, 1); } /** - Sets the mouse axes and buttons to act as controller 'mode', where - the mode is defined from the Controller::MouseAxisControl enum + Sets the mouse axes and buttons to act as the controller specified in + the ROM properties, otherwise disable mouse control completely - @param mode The controller which the mouse axes should emulate + @param enable Whether to use the mouse to emulate controllers */ - void setMouseControllerMode(const string& mode); + void setMouseControllerMode(bool enable); /** Set the number of seconds between taking a snapshot in diff --git a/src/emucore/Genesis.cxx b/src/emucore/Genesis.cxx index 3ddf78ee1..9a29a06ef 100644 --- a/src/emucore/Genesis.cxx +++ b/src/emucore/Genesis.cxx @@ -105,16 +105,20 @@ void Genesis::update() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Genesis::setMouseControl( - MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID) +bool Genesis::setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid) { - // In 'automatic' mode, both axes on the mouse map to a single Genesis - if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic) + // Currently, the Genesis controller takes full control of the mouse, using + // both axes for its two degrees of movement, and the left/right buttons for + // 'B' and 'C', respectively + if(xtype == Controller::Genesis && ytype == Controller::Genesis && xid == yid) { - myControlID = ((myJack == Left && ctrlID == 0) || - (myJack == Right && ctrlID == 1) - ) ? ctrlID : -1; + myControlID = ((myJack == Left && xid == 0) || + (myJack == Right && xid == 1) + ) ? xid : -1; } - else // Otherwise, Genesis controllers are not used in 'non-auto' mode + else myControlID = -1; + + return true; } diff --git a/src/emucore/Genesis.hxx b/src/emucore/Genesis.hxx index c80a9ca60..239aa9a3b 100644 --- a/src/emucore/Genesis.hxx +++ b/src/emucore/Genesis.hxx @@ -59,20 +59,21 @@ class Genesis : public Controller /** Determines how this controller will treat values received from the X/Y axis and left/right buttons of the mouse. Since not all controllers - use the mouse, it's up to the specific class to decide how to use this data. - - If either of the axis is set to 'Automatic', then we automatically - use the ctrlID for the control type. + use the mouse the same way (or at all), it's up to the specific class to + decide how to use this data. In the current implementation, the left button is tied to the X axis, and the right one tied to the Y axis. - @param xaxis How the controller should use x-axis data - @param yaxis How the controller should use y-axis data - @param ctrlID The controller ID to use axis 'auto' mode + @param xtype The controller to use for x-axis data + @param xid The controller ID to use for x-axis data (-1 for no id) + @param ytype The controller to use for y-axis data + @param yid The controller ID to use for y-axis data (-1 for no id) + + @return Whether the controller supports using the mouse */ - void setMouseControl( - MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1); + bool setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid); private: // Pre-compute the events we care about based on given port @@ -80,7 +81,7 @@ class Genesis : public Controller Event::Type myUpEvent, myDownEvent, myLeftEvent, myRightEvent, myFire1Event, myFire2Event; - // Controller to emulate in mouse axis 'automatic' mode + // Controller to emulate in normal mouse axis mode int myControlID; }; diff --git a/src/emucore/Joystick.cxx b/src/emucore/Joystick.cxx index 43d25a18b..1f6ad8eb0 100644 --- a/src/emucore/Joystick.cxx +++ b/src/emucore/Joystick.cxx @@ -120,18 +120,22 @@ void Joystick::update() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Joystick::setMouseControl( - MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID) +bool Joystick::setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid) { - // In 'automatic' mode, both axes on the mouse map to a single normal joystick - if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic) + // Currently, the joystick takes full control of the mouse, using both + // axes for its two degrees of movement, and both mouse buttons for the + // single joystick button + if(xtype == Controller::Joystick && ytype == Controller::Joystick && xid == yid) { - myControlID = ((myJack == Left && ctrlID == 0) || - (myJack == Right && ctrlID == 1) - ) ? ctrlID : -1; + myControlID = ((myJack == Left && xid == 0) || + (myJack == Right && xid == 1) + ) ? xid : -1; } - else // Otherwise, joysticks are not used in 'non-auto' mode + else myControlID = -1; + + return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Joystick.hxx b/src/emucore/Joystick.hxx index 8e4d03b5e..49800e369 100644 --- a/src/emucore/Joystick.hxx +++ b/src/emucore/Joystick.hxx @@ -57,20 +57,21 @@ class Joystick : public Controller /** Determines how this controller will treat values received from the X/Y axis and left/right buttons of the mouse. Since not all controllers - use the mouse, it's up to the specific class to decide how to use this data. - - If either of the axis is set to 'Automatic', then we automatically - use the ctrlID for the control type. + use the mouse the same way (or at all), it's up to the specific class to + decide how to use this data. In the current implementation, the left button is tied to the X axis, and the right one tied to the Y axis. - @param xaxis How the controller should use x-axis data - @param yaxis How the controller should use y-axis data - @param ctrlID The controller ID to use axis 'auto' mode + @param xtype The controller to use for x-axis data + @param xid The controller ID to use for x-axis data (-1 for no id) + @param ytype The controller to use for y-axis data + @param yid The controller ID to use for y-axis data (-1 for no id) + + @return Whether the controller supports using the mouse */ - void setMouseControl( - MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1); + bool setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid); /** Sets the deadzone amount for real analog joysticks. @@ -86,7 +87,7 @@ class Joystick : public Controller Event::Type myUpEvent, myDownEvent, myLeftEvent, myRightEvent, myXAxisValue, myYAxisValue, myFireEvent; - // Controller to emulate in mouse axis 'automatic' mode + // Controller to emulate in normal mouse axis mode int myControlID; static int _DEAD_ZONE; diff --git a/src/emucore/MindLink.cxx b/src/emucore/MindLink.cxx index 4eeab5acb..75fcd587d 100644 --- a/src/emucore/MindLink.cxx +++ b/src/emucore/MindLink.cxx @@ -24,7 +24,8 @@ MindLink::MindLink(Jack jack, const Event& event, const System& system) : Controller(jack, event, system, Controller::MindLink), myMindlinkPos(0x2800), - myMindlinkShift(1) + myMindlinkShift(1), + myMouseEnabled(false) { myDigitalPinState[One] = true; myDigitalPinState[Two] = true; @@ -48,6 +49,9 @@ void MindLink::update() myDigitalPinState[Three] = myDigitalPinState[Four] = true; + if(!myMouseEnabled) + return; + myMindlinkPos = (myMindlinkPos & 0x3fffffff) + (myEvent.get(Event::MouseAxisXValue) << 3); if(myMindlinkPos < 0x2800) @@ -75,3 +79,16 @@ void MindLink::nextMindlinkBit() myMindlinkShift <<= 1; } } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool MindLink::setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid) +{ + // Currently, the mindlink takes full control of the mouse, but only ever + // uses the x-axis, and both mouse buttons for the single mindlink button + // As well, there's no separate setting for x and y axis, so any + // combination of Controller and id is valid + myMouseEnabled = (xtype == myType || ytype == myType) && + (xid != -1 || yid != -1); + return true; +} diff --git a/src/emucore/MindLink.hxx b/src/emucore/MindLink.hxx index c070ad301..8847f98ee 100644 --- a/src/emucore/MindLink.hxx +++ b/src/emucore/MindLink.hxx @@ -81,6 +81,25 @@ class MindLink : public Controller */ void update(); + /** + Determines how this controller will treat values received from the + X/Y axis and left/right buttons of the mouse. Since not all controllers + use the mouse the same way (or at all), it's up to the specific class to + decide how to use this data. + + In the current implementation, the left button is tied to the X axis, + and the right one tied to the Y axis. + + @param xtype The controller to use for x-axis data + @param xid The controller ID to use for x-axis data (-1 for no id) + @param ytype The controller to use for y-axis data + @param yid The controller ID to use for y-axis data (-1 for no id) + + @return Whether the controller supports using the mouse + */ + bool setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid); + private: void nextMindlinkBit(); @@ -91,6 +110,9 @@ class MindLink : public Controller // Which bit to transfer next int myMindlinkShift; + + // Whether to use the mouse to emulate this controller + int myMouseEnabled; }; #endif diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 9c2e15298..b6d8d8635 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -531,7 +531,7 @@ bool OSystem::createConsole(const string& romfile, const string& md5sum) ////////////////////////////////////////////////////////////////////////// myConsole->initializeAudio(); myEventHandler->reset(EventHandler::S_EMULATE); - myEventHandler->setMouseControllerMode(mySettings->getString("mcontrol")); + myEventHandler->setMouseControllerMode(mySettings->getBool("usemouse")); if(createFrameBuffer() != kSuccess) // Takes care of initializeVideo() { logMessage("ERROR: Couldn't create framebuffer for console\n", 0); diff --git a/src/emucore/Paddles.cxx b/src/emucore/Paddles.cxx index fb4e9f880..3bf9c3bd0 100644 --- a/src/emucore/Paddles.cxx +++ b/src/emucore/Paddles.cxx @@ -383,17 +383,17 @@ void Paddles::update() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Paddles::setMouseControl( - MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID) +bool Paddles::setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid) { // In 'automatic' mode, both axes on the mouse map to a single paddle, // and the paddle axis and direction settings are taken into account // This overrides any other mode - if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic) + if(xtype == Controller::Paddles && ytype == Controller::Paddles && xid == yid) { - myMPaddleID = ((myJack == Left && (ctrlID == 0 || ctrlID == 1)) || - (myJack == Right && (ctrlID == 2 || ctrlID == 3)) - ) ? ctrlID & 0x01 : -1; + myMPaddleID = ((myJack == Left && (xid == 0 || xid == 1)) || + (myJack == Right && (xid == 2 || xid == 3)) + ) ? xid & 0x01 : -1; myMPaddleIDX = myMPaddleIDY = -1; } else @@ -401,37 +401,19 @@ void Paddles::setMouseControl( // The following is somewhat complex, but we need to pre-process as much // as possible, so that ::update() can run quickly myMPaddleID = -1; - if(myJack == Left) + if(myJack == Left && xtype == Controller::Paddles) { - switch(xaxis) - { - case MouseControl::Paddle0: myMPaddleIDX = 0; break; - case MouseControl::Paddle1: myMPaddleIDX = 1; break; - default: myMPaddleIDX = -1; break; - } - switch(yaxis) - { - case MouseControl::Paddle0: myMPaddleIDY = 0; break; - case MouseControl::Paddle1: myMPaddleIDY = 1; break; - default: myMPaddleIDY = -1; break; - } + myMPaddleIDX = (xid == 0 || xid == 1) ? xid & 0x01 : -1; + myMPaddleIDY = (yid == 0 || yid == 1) ? yid & 0x01 : -1; } - else // myJack == Right + else if(myJack == Right && ytype == Controller::Paddles) { - switch(xaxis) - { - case MouseControl::Paddle2: myMPaddleIDX = 0; break; - case MouseControl::Paddle3: myMPaddleIDX = 1; break; - default: myMPaddleIDX = -1; break; - } - switch(yaxis) - { - case MouseControl::Paddle2: myMPaddleIDY = 0; break; - case MouseControl::Paddle3: myMPaddleIDY = 1; break; - default: myMPaddleIDY = -1; break; - } + myMPaddleIDX = (xid == 2 || xid == 3) ? xid & 0x01 : -1; + myMPaddleIDY = (yid == 2 || yid == 3) ? yid & 0x01 : -1; } } + + return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Paddles.hxx b/src/emucore/Paddles.hxx index a9af5c29f..44e267860 100644 --- a/src/emucore/Paddles.hxx +++ b/src/emucore/Paddles.hxx @@ -64,20 +64,21 @@ class Paddles : public Controller /** Determines how this controller will treat values received from the X/Y axis and left/right buttons of the mouse. Since not all controllers - use the mouse, it's up to the specific class to decide how to use this data. - - If either of the axis is set to 'Automatic', then we automatically - use the ctrlID for the control type. + use the mouse the same way (or at all), it's up to the specific class to + decide how to use this data. In the current implementation, the left button is tied to the X axis, and the right one tied to the Y axis. - @param xaxis How the controller should use x-axis data - @param yaxis How the controller should use y-axis data - @param ctrlID The controller ID to use axis 'auto' mode + @param xtype The controller to use for x-axis data + @param xid The controller ID to use for x-axis data (-1 for no id) + @param ytype The controller to use for y-axis data + @param yid The controller ID to use for y-axis data (-1 for no id) + + @return Whether the controller supports using the mouse */ - void setMouseControl( - MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1); + bool setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid); /** Sets the sensitivity for digital emulation of paddle movement. diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 8305d9e59..2bc914e9c 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -76,7 +76,7 @@ Settings::Settings(OSystem* osystem) setInternal("combomap", ""); setInternal("joydeadzone", "13"); setInternal("joyallow4", "false"); - setInternal("mcontrol", "auto"); + setInternal("usemouse", "true"); setInternal("dsense", "5"); setInternal("msense", "7"); setInternal("saport", "lr"); @@ -280,10 +280,6 @@ void Settings::validate() if(i < 0) setInternal("joydeadzone", "0"); else if(i > 29) setInternal("joydeadzone", "29"); - s = getString("mcontrol"); - if(s != "never" && s != "auto" && s != "rom") - setInternal("mcontrol", "auto"); - if(i < 1) setInternal("dsense", "1"); else if(i > 10) setInternal("dsense", "10"); @@ -373,8 +369,7 @@ void Settings::usage() << " -logtoconsole <1|0> Log output to console/commandline\n" << " -joydeadzone Sets 'deadzone' area for analog joysticks (0-29)\n" << " -joyallow4 <1|0> Allow all 4 directions on a joystick to be pressed simultaneously\n" - << " -mcontrol \n" + << " -usemouse <1|0> Use mouse as a controller as specified by ROM properties (see manual)\n" << " -dsense Sensitivity of digital emulated paddle movement (1-10)\n" << " -msense Sensitivity of mouse emulated paddle movement (1-15)\n" << " -saport How to assign virtual ports to multiple Stelladaptor/2600-daptors\n" diff --git a/src/emucore/TrackBall.cxx b/src/emucore/TrackBall.cxx index b5deda560..36aceb3f7 100644 --- a/src/emucore/TrackBall.cxx +++ b/src/emucore/TrackBall.cxx @@ -29,7 +29,8 @@ TrackBall::TrackBall(Jack jack, const Event& event, const System& system, Type type) : Controller(jack, event, system, type), myHCounter(0), - myVCounter(0) + myVCounter(0), + myMouseEnabled(false) { // This code in ::read() is set up to always return IOPortA values in // the lower 4 bits data value @@ -115,6 +116,9 @@ uInt8 TrackBall::read() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TrackBall::update() { + if(!myMouseEnabled) + return; + // Get the current mouse position myHCounter = myEvent.get(Event::MouseAxisXValue); myVCounter = myEvent.get(Event::MouseAxisYValue); @@ -135,6 +139,19 @@ void TrackBall::update() (myEvent.get(Event::MouseButtonRightValue) == 0); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool TrackBall::setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid) +{ + // Currently, the various trackball controllers take full control of the + // mouse, and use both mouse buttons for the single fire button + // As well, there's no separate setting for x and y axis, so any + // combination of Controller and id is valid + myMouseEnabled = (xtype == myType || ytype == myType) && + (xid != -1 || yid != -1); + return true; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const uInt32 TrackBall::ourTrakBallTableTB_H[2][2] = { { 0x40, 0x00 }, { 0xc0, 0x80 } diff --git a/src/emucore/TrackBall.hxx b/src/emucore/TrackBall.hxx index a74fc00d7..229b88134 100644 --- a/src/emucore/TrackBall.hxx +++ b/src/emucore/TrackBall.hxx @@ -71,6 +71,25 @@ class TrackBall : public Controller */ void update(); + /** + Determines how this controller will treat values received from the + X/Y axis and left/right buttons of the mouse. Since not all controllers + use the mouse the same way (or at all), it's up to the specific class to + decide how to use this data. + + In the current implementation, the left button is tied to the X axis, + and the right one tied to the Y axis. + + @param xtype The controller to use for x-axis data + @param xid The controller ID to use for x-axis data (-1 for no id) + @param ytype The controller to use for y-axis data + @param yid The controller ID to use for y-axis data (-1 for no id) + + @return Whether the controller supports using the mouse + */ + bool setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid); + private: // Counter to iterate through the gray codes int myHCounter, myVCounter; @@ -89,6 +108,9 @@ class TrackBall : public Controller int myScanCountH, myScanCountV, myCountH, myCountV; + // Whether to use the mouse to emulate this controller + int myMouseEnabled; + // CX-22 static const uInt32 ourTrakBallTableTB_H[2][2]; static const uInt32 ourTrakBallTableTB_V[2][2]; diff --git a/src/emucore/stella.pro b/src/emucore/stella.pro index 52d96f7de..98aee3d56 100644 --- a/src/emucore/stella.pro +++ b/src/emucore/stella.pro @@ -402,14 +402,6 @@ "Controller.MouseAxis" "01" "" -"Cartridge.MD5" "c246e05b52f68ab2e9aee40f278cd158" -"Cartridge.Manufacturer" "Thomas Jentzsch" -"Cartridge.Name" "Star Wars - Ewok Adventure (Thomas Jentzsch) (Prototype)" -"Cartridge.Note" "NTSC Conversion" -"Cartridge.Rarity" "Homebrew" -"Display.Height" "230" -"" - "Cartridge.MD5" "7b5207e68ee85b16998bea861987c690" "Cartridge.Manufacturer" "Atari, Carol Shaw" "Cartridge.ModelNo" "CX26163P" @@ -421,6 +413,14 @@ "Cartridge.Name" "Fu Kung! (V0.16) (2003) (AD)" "" +"Cartridge.MD5" "c246e05b52f68ab2e9aee40f278cd158" +"Cartridge.Manufacturer" "Thomas Jentzsch" +"Cartridge.Name" "Star Wars - Ewok Adventure (Thomas Jentzsch) (Prototype)" +"Cartridge.Note" "NTSC Conversion" +"Cartridge.Rarity" "Homebrew" +"Display.Height" "230" +"" + "Cartridge.MD5" "cba56e939252b05df7b7de87307d12ca" "Cartridge.Name" "Playfield Text Demo (2001) (Roger Williams)" "" @@ -760,11 +760,6 @@ "Cartridge.Rarity" "Prototype" "" -"Cartridge.MD5" "bdf1996e2dd64baf8eff5511811ca6ca" -"Cartridge.Manufacturer" "Tron" -"Cartridge.Name" "H.E.R.O. (Tron)" -"" - "Cartridge.MD5" "81414174f1816d5c1e583af427ac89fc" "Cartridge.Manufacturer" "Thomas Jentzsch" "Cartridge.Name" "Treasure Below (Thomas Jentzsch)" @@ -782,6 +777,11 @@ "Cartridge.Note" "AKA International Soccer" "" +"Cartridge.MD5" "bdf1996e2dd64baf8eff5511811ca6ca" +"Cartridge.Manufacturer" "Tron" +"Cartridge.Name" "H.E.R.O. (Tron)" +"" + "Cartridge.MD5" "521f4dd1eb84a09b2b19959a41839aad" "Cartridge.Manufacturer" "Bit Corporation" "Cartridge.ModelNo" "PG206" @@ -3581,7 +3581,10 @@ "Cartridge.Manufacturer" "M Network, Hal Finney - INTV" "Cartridge.ModelNo" "MT5666" "Cartridge.Name" "Astroblast (1982) (M Network)" +"Cartridge.Note" "Can also use left joystick" "Cartridge.Rarity" "Uncommon" +"Controller.Left" "PADDLES" +"Controller.SwapPaddles" "YES" "" "Cartridge.MD5" "db971b6afc9d243f614ebf380af0ac60" @@ -5676,6 +5679,15 @@ "Cartridge.Note" "AKA Chuck Norris Superkicks" "" +"Cartridge.MD5" "90b647bfb6b18af35fcf613573ad2eec" +"Cartridge.Manufacturer" "AtariAge (Chris Walton)" +"Cartridge.Name" "Juno First (2009)" +"Cartridge.Note" "AtariVox supported" +"Cartridge.Rarity" "Homebrew" +"Controller.Right" "ATARIVOX" +"Display.Phosphor" "YES" +"" + "Cartridge.MD5" "f8240e62d8c0a64a61e19388414e3104" "Cartridge.Manufacturer" "Activision, Steve Cartwright" "Cartridge.ModelNo" "AX-013" @@ -11041,7 +11053,10 @@ "Cartridge.Manufacturer" "M Network, Hal Finney - INTV" "Cartridge.ModelNo" "MT5666" "Cartridge.Name" "Astroblast (1982) (M Network) [fixed]" +"Cartridge.Note" "Can also use left joystick" "Cartridge.Rarity" "Uncommon" +"Controller.Left" "PADDLES" +"Controller.SwapPaddles" "YES" "" "Cartridge.MD5" "047ac3b9faea64522b7a23c4465a7aa8" @@ -12621,7 +12636,6 @@ "Cartridge.Note" "Uses the Paddle Controllers" "Controller.Left" "PADDLES" "Controller.Right" "PADDLES" -"Controller.MouseAxis" "01" "" "Cartridge.MD5" "75028162bfc4cc8e74b04e320f9e6a3f" @@ -14296,7 +14310,10 @@ "Cartridge.MD5" "3d7aad37c55692814211c8b590a0334c" "Cartridge.Manufacturer" "Atari, Dan Oliver" "Cartridge.Name" "Telepathy (1983) (Atari) (Prototype)" +"Cartridge.Note" "Uses both left joystick and right Mindlink controllers (press Fire on respective controller to begin)" "Cartridge.Rarity" "Prototype" +"Controller.Right" "MINDLINK" +"Controller.MouseAxis" "78" "" "Cartridge.MD5" "f777444fc21a5925e066b68b1d350575" @@ -15889,6 +15906,9 @@ "Cartridge.MD5" "46e9428848c9ea71a4d8f91ff81ac9cc" "Cartridge.Manufacturer" "Telegames" "Cartridge.Name" "Astroblast (1989) (Telegames) (PAL)" +"Cartridge.Note" "Can also use left joystick" +"Controller.Left" "PADDLES" +"Controller.SwapPaddles" "YES" "" "Cartridge.MD5" "43c7eb836378b1b3df6788d908940b59" @@ -19568,6 +19588,16 @@ "Cartridge.Rarity" "Hack" "" +"Cartridge.MD5" "fa98d48cd609c9babc819e0a1bd8d598" +"Cartridge.Manufacturer" "AtariAge (Chris Walton)" +"Cartridge.Name" "Juno First (2009) (PAL60)" +"Cartridge.Note" "AtariVox supported" +"Cartridge.Rarity" "Homebrew" +"Controller.Right" "ATARIVOX" +"Display.Format" "PAL60" +"Display.Phosphor" "YES" +"" + "Cartridge.MD5" "c59633dbebd926c150fb6d30b0576405" "Cartridge.Manufacturer" "Telegames" "Cartridge.ModelNo" "5861 A030" @@ -19944,21 +19974,3 @@ "Cartridge.Name" "Seaquest (Digivision)" "" -"Cartridge.MD5" "90b647bfb6b18af35fcf613573ad2eec" -"Cartridge.Manufacturer" "AtariAge (Chris Walton)" -"Cartridge.Name" "Juno First (2009)" -"Cartridge.Note" "AtariVox supported" -"Cartridge.Rarity" "Homebrew" -"Controller.Right" "ATARIVOX" -"Display.Phosphor" "YES" -"" - -"Cartridge.MD5" "fa98d48cd609c9babc819e0a1bd8d598" -"Cartridge.Manufacturer" "AtariAge (Chris Walton)" -"Cartridge.Name" "Juno First (2009) (PAL60)" -"Cartridge.Note" "AtariVox supported" -"Cartridge.Rarity" "Homebrew" -"Controller.Right" "ATARIVOX" -"Display.Format" "PAL60" -"Display.Phosphor" "YES" -"" diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 677995397..355792c50 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -21,6 +21,7 @@ //============================================================================ #include "Console.hxx" +#include "MouseControl.hxx" #include "Dialog.hxx" #include "EditTextWidget.hxx" #include "Launcher.hxx" @@ -300,14 +301,17 @@ GameInfoDialog::GameInfoDialog( // Mouse controller specific axis lwidth = font.getStringWidth("X-Axis is: "); - pwidth = font.getStringWidth("Driving 0"); + pwidth = font.getStringWidth("MindLink 0"); items.clear(); - items.push_back("Paddle 0", BSPF_toString(MouseControl::Paddle0)); - items.push_back("Paddle 1", BSPF_toString(MouseControl::Paddle1)); - items.push_back("Paddle 2", BSPF_toString(MouseControl::Paddle2)); - items.push_back("Paddle 3", BSPF_toString(MouseControl::Paddle3)); - items.push_back("Driving 0", BSPF_toString(MouseControl::Driving0)); - items.push_back("Driving 1", BSPF_toString(MouseControl::Driving1)); + items.push_back("None", BSPF_toString(MouseControl::NoControl)); + items.push_back("Paddle 0", BSPF_toString(MouseControl::Paddle0)); + items.push_back("Paddle 1", BSPF_toString(MouseControl::Paddle1)); + items.push_back("Paddle 2", BSPF_toString(MouseControl::Paddle2)); + items.push_back("Paddle 3", BSPF_toString(MouseControl::Paddle3)); + items.push_back("Driving 0", BSPF_toString(MouseControl::Driving0)); + items.push_back("Driving 1", BSPF_toString(MouseControl::Driving1)); + items.push_back("MindLink 0", BSPF_toString(MouseControl::MindLink0)); + items.push_back("MindLink 1", BSPF_toString(MouseControl::MindLink1)); xpos = 45; ypos += lineHeight + 4; myMouseX = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items, diff --git a/src/gui/InputDialog.cxx b/src/gui/InputDialog.cxx index ab5b7b6a0..cc7ac6ad3 100644 --- a/src/gui/InputDialog.cxx +++ b/src/gui/InputDialog.cxx @@ -181,7 +181,7 @@ void InputDialog::addDevicePortTab(const GUI::Font& font) "Allow all 4 directions on joystick"); wid.push_back(myAllowAll4); - // Grab mouse (in windowed mode) + // Grab mouse (in windowed mode) ypos += lineHeight + 4; myGrabMouse = new CheckboxWidget(myTab, font, xpos, ypos, "Grab mouse in emulation mode"); @@ -190,17 +190,10 @@ void InputDialog::addDevicePortTab(const GUI::Font& font) myGrabMouse->clearFlags(WIDGET_ENABLED); #endif - // Mouse is controller type - ypos += lineHeight + 12; - lwidth = font.getStringWidth("Use mouse as a controller: "); - pwidth = font.getStringWidth("Automatic"); - items.clear(); - items.push_back("Never", "never"); - items.push_back("Automatic", "auto"); - items.push_back("By ROM", "rom"); - myMouseControl = - new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items, - "Use mouse as a controller: ", lwidth); + // Use mouse as a controller + ypos += lineHeight + 4; + myMouseControl = new CheckboxWidget(myTab, font, xpos, ypos, + "Use mouse as a controller"); wid.push_back(myMouseControl); // Add items for virtual device ports @@ -233,9 +226,8 @@ void InputDialog::loadConfig() // Allow all 4 joystick directions myAllowAll4->setState(instance().settings().getBool("joyallow4")); - // Mouse is controller type - myMouseControl->setSelected( - instance().settings().getString("mcontrol"), "auto"); + // Use mouse as a controller + myMouseControl->setState(instance().settings().getBool("usemouse")); myTab->loadConfig(); } @@ -271,10 +263,10 @@ void InputDialog::saveConfig() instance().settings().setBool("joyallow4", allowall4); instance().eventHandler().allowAllDirections(allowall4); - // Mouse is controller type - const string& mcontrol = myMouseControl->getSelectedTag(); - instance().settings().setString("mcontrol", mcontrol); - instance().eventHandler().setMouseControllerMode(mcontrol); + // Use mouse as a controller + bool usemouse = myMouseControl->getState(); + instance().settings().setBool("usemouse", usemouse); + instance().eventHandler().setMouseControllerMode(usemouse); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -314,8 +306,8 @@ void InputDialog::setDefaults() // Allow all 4 joystick directions myAllowAll4->setState(false); - // Mouse is controller type - myMouseControl->setSelected(1); + // Use mouse as a controller + myMouseControl->setState(true); break; } diff --git a/src/gui/InputDialog.hxx b/src/gui/InputDialog.hxx index 0c833cf44..e242fb889 100644 --- a/src/gui/InputDialog.hxx +++ b/src/gui/InputDialog.hxx @@ -78,7 +78,7 @@ class InputDialog : public Dialog StaticTextWidget* myMPaddleLabel; CheckboxWidget* myAllowAll4; CheckboxWidget* myGrabMouse; - PopUpWidget* myMouseControl; + CheckboxWidget* myMouseControl; }; #endif