fixed MindLink controller (resolves #821)

This commit is contained in:
Thomas Jentzsch 2021-09-09 10:21:26 +02:00
parent 91caf521c1
commit 2b3bb70052
6 changed files with 46 additions and 17 deletions

View File

@ -21,6 +21,8 @@
* Added web links for many games * Added web links for many games
* Fixe MindLink controller
* Debugger: enhanced prompt's auto complete and history * Debugger: enhanced prompt's auto complete and history
* Debugger: added optional logging of breaks and traps * Debugger: added optional logging of breaks and traps

View File

@ -20,6 +20,7 @@
#include "Console.hxx" #include "Console.hxx"
#include "Joystick.hxx" #include "Joystick.hxx"
#include "Paddles.hxx" #include "Paddles.hxx"
#include "MindLink.hxx"
#include "PointingDevice.hxx" #include "PointingDevice.hxx"
#include "Driving.hxx" #include "Driving.hxx"
#include "Settings.hxx" #include "Settings.hxx"
@ -1074,6 +1075,7 @@ void PhysicalJoystickHandler::changeMousePaddleSensitivity(int direction)
myOSystem.settings().setValue("msense", sense); myOSystem.settings().setValue("msense", sense);
Paddles::setMouseSensitivity(sense); Paddles::setMouseSensitivity(sense);
MindLink::setMouseSensitivity(sense);
ostringstream ss; ostringstream ss;
ss << sense * 10 << "%"; ss << sense * 10 << "%";

View File

@ -28,6 +28,7 @@
#include "OSystem.hxx" #include "OSystem.hxx"
#include "Joystick.hxx" #include "Joystick.hxx"
#include "Paddles.hxx" #include "Paddles.hxx"
#include "MindLink.hxx"
#include "Lightgun.hxx" #include "Lightgun.hxx"
#include "PointingDevice.hxx" #include "PointingDevice.hxx"
#include "Driving.hxx" #include "Driving.hxx"
@ -106,6 +107,7 @@ void EventHandler::initialize()
Paddles::setDejitterDiff(myOSystem.settings().getInt("dejitter.diff")); Paddles::setDejitterDiff(myOSystem.settings().getInt("dejitter.diff"));
Paddles::setDigitalSensitivity(myOSystem.settings().getInt("dsense")); Paddles::setDigitalSensitivity(myOSystem.settings().getInt("dsense"));
Paddles::setMouseSensitivity(myOSystem.settings().getInt("msense")); Paddles::setMouseSensitivity(myOSystem.settings().getInt("msense"));
MindLink::setMouseSensitivity(myOSystem.settings().getInt("msense"));
PointingDevice::setSensitivity(myOSystem.settings().getInt("tsense")); PointingDevice::setSensitivity(myOSystem.settings().getInt("tsense"));
Driving::setSensitivity(myOSystem.settings().getInt("dcsense")); Driving::setSensitivity(myOSystem.settings().getInt("dcsense"));
Controller::setAutoFireRate(myOSystem.settings().getInt("autofirerate")); Controller::setAutoFireRate(myOSystem.settings().getInt("autofirerate"));

View File

@ -22,10 +22,6 @@
MindLink::MindLink(Jack jack, const Event& event, const System& system) MindLink::MindLink(Jack jack, const Event& event, const System& system)
: Controller(jack, event, system, Controller::Type::MindLink) : Controller(jack, event, system, Controller::Type::MindLink)
{ {
setPin(DigitalPin::One, true);
setPin(DigitalPin::Two, true);
setPin(DigitalPin::Three, true);
setPin(DigitalPin::Four, true);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -39,19 +35,16 @@ void MindLink::update()
if(!myMouseEnabled) if(!myMouseEnabled)
return; return;
myMindlinkPos = (myMindlinkPos & 0x3fffffff) + myMindlinkPos = BSPF::clamp((myMindlinkPos & ~CALIBRATE_FLAG) +
(myEvent.get(Event::MouseAxisXMove) << 3); myEvent.get(Event::MouseAxisXMove) * MOUSE_SENSITIVITY,
if(myMindlinkPos < 0x2800) MIN_POS, MAX_POS);
myMindlinkPos = 0x2800;
if(myMindlinkPos >= 0x3800)
myMindlinkPos = 0x3800;
myMindlinkShift = 1;
nextMindlinkBit();
if(myEvent.get(Event::MouseButtonLeftValue) || if(myEvent.get(Event::MouseButtonLeftValue) ||
myEvent.get(Event::MouseButtonRightValue)) myEvent.get(Event::MouseButtonRightValue))
myMindlinkPos |= 0x4000; // this bit starts a game myMindlinkPos = CALIBRATE_FLAG; // flag starts game & calibates
myMindlinkShift = 1; // start transfer with least significant bit
nextMindlinkBit();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -63,7 +56,7 @@ void MindLink::nextMindlinkBit()
setPin(DigitalPin::Four, false); setPin(DigitalPin::Four, false);
if(myMindlinkPos & myMindlinkShift) if(myMindlinkPos & myMindlinkShift)
setPin(DigitalPin::Four, true); setPin(DigitalPin::Four, true);
myMindlinkShift <<= 1; myMindlinkShift <<= 1; // next bit
} }
} }
@ -79,3 +72,12 @@ bool MindLink::setMouseControl(
(xid != -1 || yid != -1); (xid != -1 || yid != -1);
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MindLink::setMouseSensitivity(int sensitivity)
{
MOUSE_SENSITIVITY = BSPF::clamp(sensitivity, MIN_MOUSE_SENSE, MAX_MOUSE_SENSE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int MindLink::MOUSE_SENSITIVITY = -1;

View File

@ -35,7 +35,7 @@
the Stella core actually stores this information in boolean arrays the Stella core actually stores this information in boolean arrays
addressable by DigitalPin number. addressable by DigitalPin number.
@author Stephen Anthony & z26 team @author Stephen Anthony, Thomas Jentzsch & z26 team
*/ */
class MindLink : public Controller class MindLink : public Controller
{ {
@ -101,13 +101,32 @@ class MindLink : public Controller
bool setMouseControl( bool setMouseControl(
Controller::Type xtype, int xid, Controller::Type ytype, int yid) override; 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: private:
void nextMindlinkBit(); void nextMindlinkBit();
// Range of valid values
static constexpr int MIN_POS = 0x2700;
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: private:
// Position value in Mindlink controller // Position value in Mindlink controller
// Gets transferred bitwise (16 bits) // Gets transferred bitwise (16 bits)
int myMindlinkPos{0x2800}; int myMindlinkPos{MIN_POS};
// Which bit to transfer next // Which bit to transfer next
int myMindlinkShift{1}; int myMindlinkShift{1};

View File

@ -21,6 +21,7 @@
#include "EventHandler.hxx" #include "EventHandler.hxx"
#include "Joystick.hxx" #include "Joystick.hxx"
#include "Paddles.hxx" #include "Paddles.hxx"
#include "MindLink.hxx"
#include "PointingDevice.hxx" #include "PointingDevice.hxx"
#include "Driving.hxx" #include "Driving.hxx"
#include "SaveKey.hxx" #include "SaveKey.hxx"
@ -487,6 +488,7 @@ void InputDialog::saveConfig()
sensitivity = myMPaddleSpeed->getValue(); sensitivity = myMPaddleSpeed->getValue();
settings.setValue("msense", sensitivity); settings.setValue("msense", sensitivity);
Paddles::setMouseSensitivity(sensitivity); Paddles::setMouseSensitivity(sensitivity);
MindLink::setMouseSensitivity(sensitivity);
// Trackball speed // Trackball speed
sensitivity = myTrackBallSpeed->getValue(); sensitivity = myTrackBallSpeed->getValue();