diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index 422eb1717..0909ad646 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -798,9 +798,9 @@ void PhysicalJoystickHandler::handleRegularAxisEvent(const PhysicalJoystickPtr j Event::Type eventAxisNeg = j->joyMap.get(EventMode::kEmulationMode, button, JoyAxis(axis), JoyDir::NEG); Event::Type eventAxisPos = j->joyMap.get(EventMode::kEmulationMode, button, JoyAxis(axis), JoyDir::POS); - if(value > Joystick::deadzone()) + if(value > Controller::digitalDeadzone()) myHandler.handleEvent(eventAxisPos); - else if(value < -Joystick::deadzone()) + else if(value < -Controller::digitalDeadzone()) myHandler.handleEvent(eventAxisNeg); else { @@ -823,14 +823,14 @@ void PhysicalJoystickHandler::handleRegularAxisEvent(const PhysicalJoystickPtr j #ifdef GUI_SUPPORT else if(myHandler.hasOverlay()) { - // A value change lower than Joystick::deadzone indicates analog input which is ignored - if((abs(j->axisLastValue[axis] - value) > Joystick::deadzone())) + // A value change lower than Controller::digitalDeadzone indicates analog input which is ignored + if((abs(j->axisLastValue[axis] - value) > Controller::digitalDeadzone())) { // First, clamp the values to simulate digital input // (the only thing that the underlying code understands) - if(value > Joystick::deadzone()) + if(value > Controller::digitalDeadzone()) value = 32000; - else if(value < -Joystick::deadzone()) + else if(value < -Controller::digitalDeadzone()) value = -32000; else value = 0; @@ -945,31 +945,34 @@ ostream& operator<<(ostream& os, const PhysicalJoystickHandler& jh) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PhysicalJoystickHandler::changeDeadzone(int direction) +void PhysicalJoystickHandler::changeDigitalDeadzone(int direction) { int deadzone = BSPF::clamp(myOSystem.settings().getInt("joydeadzone") + direction, - Joystick::DEAD_ZONE_MIN, Joystick::DEAD_ZONE_MAX); + Controller::MIN_DIGITAL_DEADZONE, Controller::MAX_DIGITAL_DEADZONE); myOSystem.settings().setValue("joydeadzone", deadzone); - Joystick::setDeadZone(deadzone); + Controller::setDigitalDeadZone(deadzone); - int value = Joystick::deadZoneValue(deadzone); + ostringstream ss; + ss << std::round(Controller::digitalDeadzoneValue(deadzone) * 100.F / 32768) << "%"; - myOSystem.frameBuffer().showGaugeMessage("Joystick deadzone", std::to_string(value), - deadzone, Joystick::DEAD_ZONE_MIN, Joystick::DEAD_ZONE_MAX); + myOSystem.frameBuffer().showGaugeMessage("Digital controller dead zone", ss. str(), deadzone, + Controller::MIN_DIGITAL_DEADZONE, Controller::MAX_DIGITAL_DEADZONE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystickHandler::changeAnalogPaddleDeadzone(int direction) { - int deadzone = BSPF::clamp(myOSystem.settings().getInt("pdeadzone") + direction * 500, - Paddles::MIN_ANALOG_DEADZONE, Paddles::MAX_ANALOG_DEADZONE); - myOSystem.settings().setValue("pdeadzone", deadzone); + int deadzone = BSPF::clamp(myOSystem.settings().getInt("adeadzone") + direction * 500, + Controller::MIN_ANALOG_DEADZONE, Controller::MAX_ANALOG_DEADZONE); + myOSystem.settings().setValue("adeadzone", deadzone); - Paddles::setAnalogDeadzone(deadzone); + Controller::setAnalogDeadzone(deadzone); + ostringstream ss; + ss << std::round(deadzone * 100.F / 32768) << "%"; - myOSystem.frameBuffer().showGaugeMessage("Analog paddle deadzone", std::to_string(deadzone), deadzone, - Paddles::MIN_ANALOG_DEADZONE, Paddles::MAX_ANALOG_DEADZONE); + myOSystem.frameBuffer().showGaugeMessage("Analog controller dead zone", ss.str(), deadzone, + Controller::MIN_ANALOG_DEADZONE, Controller::MAX_ANALOG_DEADZONE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1071,18 +1074,17 @@ void PhysicalJoystickHandler::changeDigitalPaddleSensitivity(int direction) void PhysicalJoystickHandler::changeMousePaddleSensitivity(int direction) { int sense = BSPF::clamp(myOSystem.settings().getInt("msense") + direction, - Paddles::MIN_MOUSE_SENSE, Paddles::MAX_MOUSE_SENSE); + Controller::MIN_MOUSE_SENSE, Controller::MAX_MOUSE_SENSE); myOSystem.settings().setValue("msense", sense); - Paddles::setMouseSensitivity(sense); - MindLink::setMouseSensitivity(sense); + Controller::setMouseSensitivity(sense); ostringstream ss; ss << sense * 10 << "%"; myOSystem.frameBuffer().showGaugeMessage("Mouse paddle sensitivity", ss.str(), sense, - Paddles::MIN_MOUSE_SENSE, Paddles::MAX_MOUSE_SENSE); + Controller::MIN_MOUSE_SENSE, Controller::MAX_MOUSE_SENSE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/PJoystickHandler.hxx b/src/common/PJoystickHandler.hxx index e5fb287e1..3b99a88de 100644 --- a/src/common/PJoystickHandler.hxx +++ b/src/common/PJoystickHandler.hxx @@ -110,7 +110,7 @@ class PhysicalJoystickHandler /** Returns a list of pairs consisting of joystick name and associated ID. */ VariantList database() const; - void changeDeadzone(int direction = +1); + void changeDigitalDeadzone(int direction = +1); void changeAnalogPaddleDeadzone(int direction = +1); void changeAnalogPaddleSensitivity(int direction = +1); void changeAnalogPaddleAcceleration(int direction = +1); diff --git a/src/emucore/Control.cxx b/src/emucore/Control.cxx index 22d12cc08..39f310ccb 100644 --- a/src/emucore/Control.cxx +++ b/src/emucore/Control.cxx @@ -148,6 +148,32 @@ Controller::Type Controller::getType(const string& propName) return Type::Unknown; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Controller::setDigitalDeadZone(int deadzone) +{ + DIGITAL_DEAD_ZONE = digitalDeadzoneValue(deadzone); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int Controller::digitalDeadzoneValue(int deadzone) +{ + deadzone = BSPF::clamp(deadzone, MIN_DIGITAL_DEADZONE, MAX_DIGITAL_DEADZONE); + + return 3200 + deadzone * 1000; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Controller::setAnalogDeadzone(int deadzone) +{ + ANALOG_DEAD_ZONE = BSPF::clamp(deadzone, MIN_ANALOG_DEADZONE, MAX_ANALOG_DEADZONE); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Controller::setMouseSensitivity(int sensitivity) +{ + MOUSE_SENSITIVITY = BSPF::clamp(sensitivity, MIN_MOUSE_SENSE, MAX_MOUSE_SENSE); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Controller::setAutoFireRate(int rate, bool isNTSC) { @@ -156,5 +182,7 @@ void Controller::setAutoFireRate(int rate, bool isNTSC) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int Controller::DIGITAL_DEAD_ZONE = 3200; +int Controller::ANALOG_DEAD_ZONE = 0; +int Controller::MOUSE_SENSITIVITY = -1; int Controller::AUTO_FIRE_RATE = 0; - diff --git a/src/emucore/Control.hxx b/src/emucore/Control.hxx index c329ecf2c..32e60824a 100644 --- a/src/emucore/Control.hxx +++ b/src/emucore/Control.hxx @@ -71,6 +71,13 @@ class Controller : public Serializable friend class ControllerLowLevel; public: + static constexpr int MIN_DIGITAL_DEADZONE = 0; + static constexpr int MAX_DIGITAL_DEADZONE = 29; + static constexpr int MIN_ANALOG_DEADZONE = 0; + static constexpr int MAX_ANALOG_DEADZONE = 16500; + static constexpr int MIN_MOUSE_SENSE = 1; + static constexpr int MAX_MOUSE_SENSE = 20; + /** Enumeration of the controller jacks */ @@ -273,6 +280,38 @@ class Controller : public Serializable */ static Type getType(const string& propName); + /** + Sets the deadzone amount for real analog joysticks. + Technically, this isn't really used by the Joystick class at all, + but it seemed like the best place to put it. + */ + static void setDigitalDeadZone(int deadzone); + + /** + Sets the deadzone for analog paddles. + + @param deadzone Value from 0 to 16500 + */ + static void setAnalogDeadzone(int deadzone); + + /** + Retrieves the effective digital deadzone value + */ + static int digitalDeadzoneValue(int deadzone); + + inline static int digitalDeadzone() { return DIGITAL_DEAD_ZONE; } + + inline static int analogDeadzone() { return ANALOG_DEAD_ZONE; } + + /** + Sets the sensitivity for analog emulation movement + using a mouse. + + @param sensitivity Value from 1 to MAX_MOUSE_SENSE, with larger + values causing more movement + */ + static void setMouseSensitivity(int sensitivity); + /** Sets the auto fire rate. 0 disables auto fire. @@ -366,6 +405,14 @@ class Controller : public Serializable /// The callback that is dispatched whenver an analog pin has changed onAnalogPinUpdateCallback myOnAnalogPinUpdateCallback{nullptr}; + /// Defines the dead zone of analog joysticks for digital Atari controllers + static int DIGITAL_DEAD_ZONE; + + /// Defines the dead zone of analog joysticks for analog Atari controllers + static int ANALOG_DEAD_ZONE; + + static int MOUSE_SENSITIVITY; + /// Defines the speed of the auto fire static int AUTO_FIRE_RATE; diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index e66f7b5e1..31c08f892 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -99,15 +99,14 @@ void EventHandler::initialize() setActionMappings(EventMode::kEmulationMode); setActionMappings(EventMode::kMenuMode); - Joystick::setDeadZone(myOSystem.settings().getInt("joydeadzone")); - Paddles::setAnalogDeadzone(myOSystem.settings().getInt("pdeadzone")); + Controller::setDigitalDeadZone(myOSystem.settings().getInt("joydeadzone")); + Controller::setAnalogDeadzone(myOSystem.settings().getInt("adeadzone")); Paddles::setAnalogAccel(myOSystem.settings().getInt("paccel")); Paddles::setDejitterDiff(myOSystem.settings().getInt("dejitter.diff")); Paddles::setDejitterBase(myOSystem.settings().getInt("dejitter.base")); Paddles::setDejitterDiff(myOSystem.settings().getInt("dejitter.diff")); Paddles::setDigitalSensitivity(myOSystem.settings().getInt("dsense")); - Paddles::setMouseSensitivity(myOSystem.settings().getInt("msense")); - MindLink::setMouseSensitivity(myOSystem.settings().getInt("msense")); + Controller::setMouseSensitivity(myOSystem.settings().getInt("msense")); PointingDevice::setSensitivity(myOSystem.settings().getInt("tsense")); Driving::setSensitivity(myOSystem.settings().getInt("dcsense")); Controller::setAutoFireRate(myOSystem.settings().getInt("autofirerate")); @@ -597,7 +596,7 @@ AdjustFunction EventHandler::getAdjustSetting(AdjustSetting setting) std::bind(&Console::toggleInter, &myOSystem.console(), _1), // *** Input settings *** - std::bind(&PhysicalJoystickHandler::changeDeadzone, &joyHandler(), _1), + std::bind(&PhysicalJoystickHandler::changeDigitalDeadzone, &joyHandler(), _1), std::bind(&PhysicalJoystickHandler::changeAnalogPaddleDeadzone, &joyHandler(), _1), std::bind(&PhysicalJoystickHandler::changeAnalogPaddleSensitivity, &joyHandler(), _1), std::bind(&PhysicalJoystickHandler::changeAnalogPaddleAcceleration, &joyHandler(), _1), @@ -1365,7 +1364,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) case Event::DecreaseDeadzone: if(pressed) { - myPJoyHandler->changeDeadzone(-1); + myPJoyHandler->changeDigitalDeadzone(-1); myAdjustSetting = AdjustSetting::DEADZONE; myAdjustActive = true; } @@ -1374,7 +1373,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) case Event::IncreaseDeadzone: if(pressed) { - myPJoyHandler->changeDeadzone(+1); + myPJoyHandler->changeDigitalDeadzone(+1); myAdjustSetting = AdjustSetting::DEADZONE; myAdjustActive = true; } diff --git a/src/emucore/Joystick.cxx b/src/emucore/Joystick.cxx index 6acacf6e4..067623699 100644 --- a/src/emucore/Joystick.cxx +++ b/src/emucore/Joystick.cxx @@ -157,20 +157,3 @@ bool Joystick::setMouseControl( return true; } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Joystick::setDeadZone(int deadzone) -{ - _DEAD_ZONE = deadZoneValue(deadzone); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int Joystick::deadZoneValue(int deadzone) -{ - deadzone = BSPF::clamp(deadzone, DEAD_ZONE_MIN, DEAD_ZONE_MAX); - - return 3200 + deadzone * 1000; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int Joystick::_DEAD_ZONE = 3200; diff --git a/src/emucore/Joystick.hxx b/src/emucore/Joystick.hxx index fa43960d3..97c89bcef 100644 --- a/src/emucore/Joystick.hxx +++ b/src/emucore/Joystick.hxx @@ -29,9 +29,6 @@ class Joystick : public Controller { public: - static constexpr int DEAD_ZONE_MIN = 0; - static constexpr int DEAD_ZONE_MAX = 29; - /** Create a new joystick controller plugged into the specified jack @@ -88,19 +85,6 @@ class Joystick : public Controller bool setMouseControl( Controller::Type xtype, int xid, Controller::Type ytype, int yid) override; - /** - Sets the deadzone amount for real analog joysticks. - Technically, this isn't really used by the Joystick class at all, - but it seemed like the best place to put it. - */ - static void setDeadZone(int deadzone); - - /** - Retrieves the effective deadzone value - */ - static int deadZoneValue(int deadzone); - inline static int deadzone() { return _DEAD_ZONE; } - protected: /** Update the button pin states. @@ -123,8 +107,6 @@ class Joystick : public Controller // Controller to emulate in normal mouse axis mode int myControlID{-1}; - static int _DEAD_ZONE; - private: /** Update the axes pin states according to the keyboard diff --git a/src/emucore/MindLink.cxx b/src/emucore/MindLink.cxx index 007d6a2bd..43e3e77cb 100644 --- a/src/emucore/MindLink.cxx +++ b/src/emucore/MindLink.cxx @@ -22,6 +22,10 @@ MindLink::MindLink(Jack jack, const Event& event, const System& system) : Controller(jack, event, system, Controller::Type::MindLink) { + setPin(DigitalPin::One, true); + setPin(DigitalPin::Two, true); + setPin(DigitalPin::Three, true); + setPin(DigitalPin::Four, true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -73,11 +77,3 @@ bool MindLink::setMouseControl( return true; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void MindLink::setMouseSensitivity(int sensitivity) -{ - MOUSE_SENSITIVITY = BSPF::clamp(sensitivity, MIN_MOUSE_SENSE, MAX_MOUSE_SENSE); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int MindLink::MOUSE_SENSITIVITY = -1; diff --git a/src/emucore/MindLink.hxx b/src/emucore/MindLink.hxx index eaef64f57..d2105fa7e 100644 --- a/src/emucore/MindLink.hxx +++ b/src/emucore/MindLink.hxx @@ -101,15 +101,6 @@ class MindLink : public Controller bool setMouseControl( Controller::Type xtype, int xid, Controller::Type ytype, int yid) override; - /** - Sets the sensitivity for analog emulation of MindLink movement - using a mouse. - - @param sensitivity Value from 1 to MAX_MOUSE_SENSE, with larger - values causing more movement - */ - static void setMouseSensitivity(int sensitivity); - private: void nextMindlinkBit(); @@ -118,11 +109,6 @@ class MindLink : public Controller static constexpr int MAX_POS = 0x3e00; static constexpr int CALIBRATE_FLAG = 0x8000; // this causes a left side calibration - static constexpr int MIN_MOUSE_SENSE = 1; - static constexpr int MAX_MOUSE_SENSE = 20; - - static int MOUSE_SENSITIVITY; - private: // Position value in Mindlink controller // Gets transferred bitwise (16 bits) diff --git a/src/emucore/Paddles.cxx b/src/emucore/Paddles.cxx index a02f53961..f469d08e5 100644 --- a/src/emucore/Paddles.cxx +++ b/src/emucore/Paddles.cxx @@ -478,12 +478,6 @@ float Paddles::analogSensitivityValue(int sensitivity) static_cast(BSPF::clamp(sensitivity, MIN_ANALOG_SENSE, MAX_ANALOG_SENSE))); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Paddles::setAnalogDeadzone(int deadzone) -{ - DEADZONE = BSPF::clamp(deadzone, MIN_ANALOG_DEADZONE, MAX_ANALOG_DEADZONE); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Paddles::setAnalogAccel(int accel) { @@ -508,12 +502,6 @@ void Paddles::setDigitalSensitivity(int sensitivity) DIGITAL_DISTANCE = 20 + (DIGITAL_SENSITIVITY << 3); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Paddles::setMouseSensitivity(int sensitivity) -{ - MOUSE_SENSITIVITY = BSPF::clamp(sensitivity, MIN_MOUSE_SENSE, MAX_MOUSE_SENSE); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Paddles::setDigitalPaddleRange(int range) { @@ -525,7 +513,6 @@ void Paddles::setDigitalPaddleRange(int range) int Paddles::XCENTER = 0; int Paddles::YCENTER = 0; float Paddles::SENSITIVITY = 1.0; -int Paddles::DEADZONE = 0; float Paddles::ACCEL = 1.0; int Paddles::DEJITTER_BASE = 0; int Paddles::DEJITTER_DIFF = 0; @@ -533,4 +520,3 @@ int Paddles::TRIGRANGE = Paddles::TRIGMAX; int Paddles::DIGITAL_SENSITIVITY = -1; int Paddles::DIGITAL_DISTANCE = -1; -int Paddles::MOUSE_SENSITIVITY = -1; diff --git a/src/emucore/Paddles.hxx b/src/emucore/Paddles.hxx index bb1c5e498..2c501771a 100644 --- a/src/emucore/Paddles.hxx +++ b/src/emucore/Paddles.hxx @@ -48,8 +48,6 @@ class Paddles : public Controller ~Paddles() override = default; public: - static constexpr int MIN_ANALOG_DEADZONE = 0; - static constexpr int MAX_ANALOG_DEADZONE = 15000; static constexpr float BASE_ANALOG_SENSE = 0.148643628F; static constexpr int MIN_ANALOG_SENSE = 0; static constexpr int MAX_ANALOG_SENSE = 30; @@ -59,8 +57,6 @@ class Paddles : public Controller static constexpr int MAX_ANALOG_CENTER = 30; static constexpr int MIN_DIGITAL_SENSE = 1; static constexpr int MAX_DIGITAL_SENSE = 20; - static constexpr int MIN_MOUSE_SENSE = 1; - static constexpr int MAX_MOUSE_SENSE = 20; static constexpr int MIN_DEJITTER = 0; static constexpr int MAX_DEJITTER = 10; static constexpr int MIN_MOUSE_RANGE = 1; @@ -115,13 +111,6 @@ class Paddles : public Controller */ static void setAnalogYCenter(int ycenter); - /** - Sets the deadzone for analog paddles. - - @param deadzone Value from 0 to 15000 - */ - static void setAnalogDeadzone(int deadzone); - /** Sets the acceleration for analog paddles. @@ -161,15 +150,6 @@ class Paddles : public Controller */ static void setDigitalSensitivity(int sensitivity); - /** - Sets the sensitivity for analog emulation of paddle movement - using a mouse. - - @param sensitivity Value from 1 to MAX_MOUSE_SENSE, with larger - values causing more movement - */ - static void setMouseSensitivity(int sensitivity); - /** Sets the maximum upper range for digital/mouse emulation of paddle movement (ie, a value of 50 means to only use 50% of the possible @@ -214,8 +194,7 @@ class Paddles : public Controller static float SENSITIVITY, ACCEL; static int DIGITAL_SENSITIVITY, DIGITAL_DISTANCE; - static int DEADZONE, DEJITTER_BASE, DEJITTER_DIFF; - static int MOUSE_SENSITIVITY; + static int DEJITTER_BASE, DEJITTER_DIFF; /** Swap two events. diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index d23deb3f8..85da5c588 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -115,7 +115,7 @@ Settings::Settings() setPermanent("usemouse", "analog"); setPermanent("grabmouse", "true"); setPermanent("cursor", "2"); - setPermanent("pdeadzone", "0"); + setPermanent("adeadzone", "0"); setPermanent("paccel", "100"); setPermanent("dejitter.base", "0"); setPermanent("dejitter.diff", "0"); @@ -358,10 +358,10 @@ void Settings::validate() #endif setValue("joydeadzone", BSPF::clamp(getInt("joydeadzone"), - Joystick::DEAD_ZONE_MIN, Joystick::DEAD_ZONE_MAX)); + Controller::MIN_DIGITAL_DEADZONE, Joystick::MAX_DIGITAL_DEADZONE)); - setValue("pdeadzone", BSPF::clamp(getInt("pdeadzone"), - Paddles::MIN_ANALOG_DEADZONE, Paddles::MAX_ANALOG_DEADZONE)); + setValue("adeadzone", BSPF::clamp(getInt("adeadzone"), + Controller::MIN_ANALOG_DEADZONE, Controller::MAX_ANALOG_DEADZONE)); setValue("psense", BSPF::clamp(getInt("psense"), Paddles::MIN_ANALOG_SENSE, Paddles::MAX_ANALOG_SENSE)); @@ -379,7 +379,7 @@ void Settings::validate() Paddles::MIN_DIGITAL_SENSE, Paddles::MAX_DIGITAL_SENSE)); setValue("msense", BSPF::clamp(getInt("msense"), - Paddles::MIN_MOUSE_SENSE, Paddles::MAX_MOUSE_SENSE)); + Controller::MIN_MOUSE_SENSE, Controller::MAX_MOUSE_SENSE)); i = getInt("cursor"); if(i < 0 || i > 3) @@ -514,7 +514,7 @@ void Settings::usage() const << " -loglevel <0|1|2> Set level of logging during application run\n" << endl << " -logtoconsole <1|0> Log output to console/commandline\n" - << " -joydeadzone Sets 'deadzone' area for analog joysticks (0-29)\n" + << " -joydeadzone <0-29> Sets digital 'dead zone' area for analog joysticks\n" << " -joyallow4 <1|0> Allow all 4 directions on a joystick to be\n" << " pressed simultaneously\n" << " -usemouse Locks the mouse cursor in the TIA window\n" << " -cursor <0,1,2,3> Set cursor state in UI/emulation modes\n" - << " -pdeadzone Sets 'deadzone' area for analog paddles (0-15000)\n" + << " -adeadzone Sets analog 'dead zone' area for analog joysticks\n" + << " (0-16500)\n" << " -paccel <0-100> Sets paddle acceleration strength\n" << " -dejitter.base <0-10> Strength of analog paddle value averaging\n" << " -dejitter.diff <0-10> Strength of analog paddle reaction to fast movements\n" diff --git a/src/gui/InputDialog.cxx b/src/gui/InputDialog.cxx index 2c5eca3e7..6ab997a36 100644 --- a/src/gui/InputDialog.cxx +++ b/src/gui/InputDialog.cxx @@ -112,34 +112,37 @@ void InputDialog::addDevicePortTab() // Devices/ports tabID = myTab->addTab(" Devices & Ports ", TabWidget::AUTO_WIDTH); - ypos = VBORDER; + xpos = HBORDER; ypos = VBORDER; lwidth = _font.getStringWidth("Digital paddle sensitivity "); - // Add joystick deadzone setting - myJoystickDeadzone = new SliderWidget(myTab, _font, HBORDER, ypos - 1, 13 * fontWidth, lineHeight, - "Joystick deadzone size", lwidth, kJDeadzoneChanged, 5 * fontWidth); - myJoystickDeadzone->setMinValue(Joystick::DEAD_ZONE_MIN); - myJoystickDeadzone->setMaxValue(Joystick::DEAD_ZONE_MAX); - myJoystickDeadzone->setTickmarkIntervals(4); - wid.push_back(myJoystickDeadzone); + // Add digital dead zone setting + myDigitalDeadzone = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, + "Digital dead zone", + lwidth, kDDeadzoneChanged, 3 * fontWidth, "%"); + myDigitalDeadzone->setMinValue(Controller::MIN_DIGITAL_DEADZONE); + myDigitalDeadzone->setMaxValue(Controller::MAX_DIGITAL_DEADZONE); + myDigitalDeadzone->setTickmarkIntervals(4); + myDigitalDeadzone->setToolTip("Adjust dead zone size for analog joysticks when emulating digital controllers."); + wid.push_back(myDigitalDeadzone); - xpos = HBORDER; ypos += lineHeight + VGAP * (3 - 2); + // Add analog dead zone + ypos += lineHeight + VGAP; + myAnalogDeadzone = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, + "Analog dead zone", + lwidth, kADeadzoneChanged, 3 * fontWidth, "%"); + myAnalogDeadzone->setMinValue(Controller::MIN_ANALOG_DEADZONE); + myAnalogDeadzone->setMaxValue(Controller::MAX_ANALOG_DEADZONE); + myAnalogDeadzone->setStepValue(500); + myAnalogDeadzone->setTickmarkIntervals(3); + myAnalogDeadzone->setToolTip("Adjust dead zone size for analog joysticks when emulating analog controllers."); + wid.push_back(myAnalogDeadzone); + + ypos += lineHeight + VGAP * (3 - 2); new StaticTextWidget(myTab, _font, xpos, ypos+1, "Analog paddle:"); xpos += fontWidth * 2; - // Add analog paddle deadzone - ypos += lineHeight; - myPaddleDeadzone = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, - "Deadzone size", - lwidth - fontWidth * 2, 0, 5 * fontWidth); - myPaddleDeadzone->setMinValue(Paddles::MIN_ANALOG_DEADZONE); - myPaddleDeadzone->setMaxValue(Paddles::MAX_ANALOG_DEADZONE); - myPaddleDeadzone->setStepValue(500); - myPaddleDeadzone->setTickmarkIntervals(3); - wid.push_back(myPaddleDeadzone); - // Add analog paddle sensitivity - ypos += lineHeight + VGAP; + ypos += lineHeight; myPaddleSpeed = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, "Sensitivity", lwidth - fontWidth * 2, kPSpeedChanged, 4 * fontWidth, "%"); @@ -360,11 +363,11 @@ void InputDialog::loadConfig() myCursorState->setSelected(settings.getString("cursor"), "2"); handleCursorState(); - // Joystick deadzone - myJoystickDeadzone->setValue(settings.getInt("joydeadzone")); + // Digital dead zone + myDigitalDeadzone->setValue(settings.getInt("joydeadzone")); + // Analog dead zone + myAnalogDeadzone->setValue(settings.getInt("adeadzone")); - // Paddle deadzone (analog) - myPaddleDeadzone->setValue(settings.getInt("pdeadzone")); // Paddle speed (analog) myPaddleSpeed->setValue(settings.getInt("psense")); // Paddle acceleration (analog) @@ -430,15 +433,15 @@ void InputDialog::saveConfig() Settings& settings = instance().settings(); // *** Device & Ports *** - // Joystick deadzone - int deadzone = myJoystickDeadzone->getValue(); + // Digital dead zone + int deadzone = myDigitalDeadzone->getValue(); settings.setValue("joydeadzone", deadzone); - Joystick::setDeadZone(deadzone); + Controller::setDigitalDeadZone(deadzone); + // Analog dead zone + deadzone = myAnalogDeadzone->getValue(); + settings.setValue("adeadzone", deadzone); + Controller::setAnalogDeadzone(deadzone); - // Paddle deadzone (analog) - deadzone = myPaddleDeadzone->getValue(); - settings.setValue("pdeadzone", deadzone); - Paddles::setAnalogDeadzone(deadzone); // Paddle speed (analog) int sensitivity = myPaddleSpeed->getValue(); settings.setValue("psense", sensitivity); @@ -526,11 +529,11 @@ void InputDialog::setDefaults() break; case 1: // Devices & Ports - // Joystick deadzone - myJoystickDeadzone->setValue(0); + // Digital dead zone + myDigitalDeadzone->setValue(0); - // Paddle deadzone - myPaddleDeadzone->setValue(0); + // Analog dead zone + myAnalogDeadzone->setValue(0); // Paddle speed (analog) myPaddleSpeed->setValue(20); @@ -695,8 +698,12 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd, setDefaults(); break; - case kJDeadzoneChanged: - myJoystickDeadzone->setValueLabel(Joystick::deadZoneValue(myJoystickDeadzone->getValue())); + case kDDeadzoneChanged: + myDigitalDeadzone->setValueLabel(std::round(Controller::digitalDeadzoneValue(myDigitalDeadzone->getValue()) * 100.f / 32768)); + break; + + case kADeadzoneChanged: + myAnalogDeadzone->setValueLabel(std::round(myAnalogDeadzone->getValue() * 100.f / 32768)); break; case kPSpeedChanged: diff --git a/src/gui/InputDialog.hxx b/src/gui/InputDialog.hxx index 6b75eb80a..793b59a57 100644 --- a/src/gui/InputDialog.hxx +++ b/src/gui/InputDialog.hxx @@ -72,12 +72,13 @@ class InputDialog : public Dialog private: enum { - kJDeadzoneChanged = 'DZch', + kDDeadzoneChanged = 'DDch', + kADeadzoneChanged = 'ADch', kPSpeedChanged = 'Ppch', kPAccelChanged = 'PAch', kDejitterAvChanged = 'JAch', kDejitterReChanged = 'JRch', - kDPSpeedChanged = 'PDch', + kDPSpeedChanged = 'DSch', kAutoFireChanged = 'AFch', kTBSpeedChanged = 'TBch', kDCSpeedChanged = 'DCch', @@ -98,9 +99,9 @@ class InputDialog : public Dialog PopUpWidget* myAVoxPort{nullptr}; - SliderWidget* myJoystickDeadzone{nullptr}; + SliderWidget* myDigitalDeadzone{nullptr}; + SliderWidget* myAnalogDeadzone{nullptr}; SliderWidget* myPaddleSpeed{nullptr}; - SliderWidget* myPaddleDeadzone{nullptr}; SliderWidget* myPaddleAccel{nullptr}; SliderWidget* myDejitterBase{nullptr}; SliderWidget* myDejitterDiff{nullptr};