finalized new paddle settings

This commit is contained in:
Thomas Jentzsch 2021-09-15 18:02:10 +02:00
parent fb41c41470
commit 4d78865ab2
18 changed files with 143 additions and 180 deletions

View File

@ -21,6 +21,8 @@
* Added web links for many games
* Added dead zone and linearity settings for analog controllers
* Fixed MindLink controller
* Added TIA randomization on startup option

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -1607,12 +1607,12 @@
</tr>
<tr>
<td><i>Decrease</i> analog paddle acceleration</td>
<td><i>Decrease</i> analog paddle linearity</td>
<td>Shift-Control-Alt + F2</td>
<td>Shift-Control-Cmd + F2</td>
</tr>
<tr>
<td><i>Increase</i> analog paddle acceleration</td>
<td><i>Increase</i> analog paddle linearity</td>
<td>Control-Alt + F2</td>
<td>Control-Cmd + F2</td>
</tr>
@ -2965,29 +2965,31 @@
<td>Set the joystick axis dead zone area for analog joysticks/gamepads
emulating digital controllers.
All values within the dead zone are treated as zero-axis values,
while only those values outside are registered as valid input.
while only those values outside are registered as valid input.</br>
Dead zone is calculated as 3200 + value * 1000. So the possible dead
zone values range from 3200 to 32200 (= 10% - 98%).</td>
</tr>
<tr>
<td><pre>-adeadzone &lt;0 - 16500&gt;</pre></td>
<td><pre>-adeadzone &lt;0 - 29&gt;</pre></td>
<td>Set the joystick axis dead zone area for analog joysticks/gamepads
emulating analog controllers. All values within the
dead zone are treated as zero-axis values, while only those values
outside are registered as valid input. Range: 0% - 50%</td>
emulating analog controllers. All values within the dead zone are
treated as zero-axis values, while only those values outside are
registered as valid input. </br>
Dead zone is calculated as value * 565. So the possible dead zone
values range from 0 to 16384 (= 0% - 50%)</td>
</tr>
<tr>
<td><pre>-psense &lt;number&gt;</pre></td>
<td>Sensitivity for emulation of paddles when using analog paddles.
Valid range of values is from 0 to 30, with larger numbers causing
faster movement.</td>
<td><pre>-psense &lt;0 - 30&gt;</pre></td>
<td>Sensitivity for emulation of paddles when using analog controllers.
Larger numbers are causing faster movement.</td>
</tr>
<tr>
<td><pre>-paccel &lt;0 - 100&gt;</pre></td>
<td>Acceleration of analog paddles while moving them fast.</td>
<td><pre>-plinear &lt;25 - 100&gt;</pre></td>
<td>Linearity of analog paddles. Lower numbers allow finer control
around the paddle center.</td>
</tr>
<tr>
@ -4036,8 +4038,8 @@
<tr><td>Analog dead zone size</td><td>Dead zone area for axes on joysticks/gamepads emulating
analog controllers
</td><td>-adeadzone</td></tr>
<tr><td>(Analog paddle) Sensitivity</td><td>Sensitivity of an analog paddle</td><td>-psense</td></tr>
<tr><td>(Analog paddle) Acceleration</td><td>Acceleration of analog paddles when moving them fast</td><td>-paccel</td></tr>
<tr><td>(Analog paddle) Sensitivity</td><td>Sensitivity of analog paddles</td><td>-psense</td></tr>
<tr><td>(Analog paddle) Linearity</td><td>Linearity of analog paddles</td><td>-plinear</td></tr>
<tr><td>(Analog paddle) Dejitter averaging</td><td>Strength of paddle input averaging, suppresses paddle jitter<br>
Note: The 2600-daptor has built-in dejitter, so there should be no need to use Stella's dejitter.
</td><td>-dejitter.base</td></tr>

View File

@ -789,22 +789,7 @@ void PhysicalJoystickHandler::handleRegularAxisEvent(const PhysicalJoystickPtr j
if((abs(j->axisLastValue[axis] - value) < 30000)
&& (eventAxisAnalog = j->joyMap.get(EventMode::kEmulationMode, button, JoyAxis(axis), JoyDir::ANALOG)) != Event::Type::NoType)
{
// TODO: TEST!!!
if(abs(value) > Controller::analogDeadZone())
myHandler.handleEvent(eventAxisAnalog, value);
else
{
// Treat any dead zone value as zero
value = 0;
// Now filter out consecutive, similar values
// (only pass on the event if the state has changed)
if(j->axisLastValue[axis] != value)
{
// Turn off events
myHandler.handleEvent(eventAxisAnalog, 0);
}
}
myHandler.handleEvent(eventAxisAnalog, value);
}
else
{
@ -978,13 +963,14 @@ void PhysicalJoystickHandler::changeDigitalDeadZone(int direction)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::changeAnalogPaddleDeadZone(int direction)
{
int deadZone = BSPF::clamp(myOSystem.settings().getInt("adeadzone") + direction * 500,
int deadZone = BSPF::clamp(myOSystem.settings().getInt("adeadzone") + direction,
Controller::MIN_ANALOG_DEADZONE, Controller::MAX_ANALOG_DEADZONE);
myOSystem.settings().setValue("adeadzone", deadZone);
Controller::setAnalogDeadZone(deadZone);
ostringstream ss;
ss << std::round(deadZone * 100.F / 32768) << "%";
ss << std::round(Controller::analogDeadZoneValue(deadZone) * 100.F / 32768) << "%";
myOSystem.frameBuffer().showGaugeMessage("Analog controller dead zone", ss.str(), deadZone,
Controller::MIN_ANALOG_DEADZONE, Controller::MAX_ANALOG_DEADZONE);
@ -1007,22 +993,22 @@ void PhysicalJoystickHandler::changeAnalogPaddleSensitivity(int direction)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::changeAnalogPaddleAcceleration(int direction)
void PhysicalJoystickHandler::changeAnalogPaddleLinearity(int direction)
{
int accel = BSPF::clamp(myOSystem.settings().getInt("paccel") + direction * 5,
Paddles::MIN_ANALOG_ACCEL, Paddles::MAX_ANALOG_ACCEL);
myOSystem.settings().setValue("paccel", accel);
int linear = BSPF::clamp(myOSystem.settings().getInt("plinear") + direction * 5,
Paddles::MIN_ANALOG_LINEARITY, Paddles::MAX_ANALOG_LINEARITY);
myOSystem.settings().setValue("plinear", linear);
Paddles::setAnalogAccel(accel);
Paddles::setAnalogLinearity(linear);
ostringstream ss;
if(accel)
ss << accel << "%";
if(linear)
ss << linear << "%";
else
ss << "Off";
myOSystem.frameBuffer().showGaugeMessage("Analog paddle acceleration", ss.str(), accel,
Paddles::MIN_ANALOG_ACCEL, Paddles::MAX_ANALOG_ACCEL);
myOSystem.frameBuffer().showGaugeMessage("Analog paddle linearity", ss.str(), linear,
Paddles::MIN_ANALOG_LINEARITY, Paddles::MAX_ANALOG_LINEARITY);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -113,7 +113,7 @@ class PhysicalJoystickHandler
void changeDigitalDeadZone(int direction = +1);
void changeAnalogPaddleDeadZone(int direction = +1);
void changeAnalogPaddleSensitivity(int direction = +1);
void changeAnalogPaddleAcceleration(int direction = +1);
void changeAnalogPaddleLinearity(int direction = +1);
void changePaddleDejitterAveraging(int direction = +1);
void changePaddleDejitterReaction(int direction = +1);
void changeDigitalPaddleSensitivity(int direction = +1);

View File

@ -693,8 +693,8 @@ PhysicalKeyboardHandler::DefaultCommonMapping = {
{ Event::IncAnalogDeadzone, KBDK_F1, KBDM_CTRL | MOD3},
{ Event::DecAnalogSense, KBDK_F2, KBDM_CTRL | KBDM_SHIFT },
{ Event::IncAnalogSense, KBDK_F2, KBDM_CTRL },
{ Event::DecAnalogAccel, KBDK_F2, KBDM_CTRL | MOD3 | KBDM_SHIFT},
{ Event::IncAnalogAccel, KBDK_F2, KBDM_CTRL | MOD3},
{ Event::DecAnalogLinear, KBDK_F2, KBDM_CTRL | MOD3 | KBDM_SHIFT},
{ Event::IncAnalogLinear, KBDK_F2, KBDM_CTRL | MOD3},
{ Event::DecDejtterAveraging, KBDK_F3, KBDM_CTRL | KBDM_SHIFT },
{ Event::IncDejtterAveraging, KBDK_F3, KBDM_CTRL },
{ Event::DecDejtterReaction, KBDK_F4, KBDM_CTRL | KBDM_SHIFT },

View File

@ -199,8 +199,8 @@ NLOHMANN_JSON_SERIALIZE_ENUM(Event::Type, {
{Event::IncAnalogDeadzone, "IncAnalogDeadzone"},
{Event::DecAnalogSense, "DecAnalogSense"},
{Event::IncAnalogSense, "IncAnalogSense"},
{Event::DecAnalogAccel, "DecAnalogAccel"},
{Event::IncAnalogAccel, "IncAnalogAccel"},
{Event::DecAnalogLinear, "DecAnalogLinear"},
{Event::IncAnalogLinear, "IncAnalogLinear"},
{Event::DecDejtterAveraging, "DecDejtterAveraging"},
{Event::IncDejtterAveraging, "IncDejtterAveraging"},
{Event::DecDejtterReaction, "DecDejtterReaction"},

View File

@ -165,9 +165,18 @@ int Controller::digitalDeadZoneValue(int deadZone)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Controller::setAnalogDeadZone(int deadZone)
{
ANALOG_DEAD_ZONE = BSPF::clamp(deadZone, MIN_ANALOG_DEADZONE, MAX_ANALOG_DEADZONE);
ANALOG_DEAD_ZONE = analogDeadZoneValue(deadZone);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Controller::analogDeadZoneValue(int deadZone)
{
deadZone = BSPF::clamp(deadZone, MIN_ANALOG_DEADZONE, MAX_ANALOG_DEADZONE);
return deadZone * std::round(32768 / 2. / MAX_DIGITAL_DEADZONE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Controller::setMouseSensitivity(int sensitivity)
{

View File

@ -74,7 +74,7 @@ class Controller : public Serializable
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 MAX_ANALOG_DEADZONE = 29;
static constexpr int MIN_MOUSE_SENSE = 1;
static constexpr int MAX_MOUSE_SENSE = 20;
@ -290,7 +290,7 @@ class Controller : public Serializable
/**
Sets the dead zone for analog paddles.
@param deadZone Value from 0 to 16500
@param deadZone Value from 0 to 29
*/
static void setAnalogDeadZone(int deadZone);
@ -299,6 +299,11 @@ class Controller : public Serializable
*/
static int digitalDeadZoneValue(int deadZone);
/**
Retrieves the effective analog dead zone value
*/
static int Controller::analogDeadZoneValue(int deadZone);
inline static int digitalDeadZone() { return DIGITAL_DEAD_ZONE; }
inline static int analogDeadZone() { return ANALOG_DEAD_ZONE; }

View File

@ -149,7 +149,7 @@ class Event
DecreaseDeadzone, IncreaseDeadzone,
DecAnalogDeadzone, IncAnalogDeadzone,
DecAnalogSense, IncAnalogSense,
DecAnalogAccel, IncAnalogAccel,
DecAnalogLinear, IncAnalogLinear,
DecDejtterAveraging, IncDejtterAveraging,
DecDejtterReaction, IncDejtterReaction,
DecDigitalSense, IncDigitalSense,

View File

@ -101,7 +101,7 @@ void EventHandler::initialize()
Controller::setDigitalDeadZone(myOSystem.settings().getInt("joydeadzone"));
Controller::setAnalogDeadZone(myOSystem.settings().getInt("adeadzone"));
Paddles::setAnalogAccel(myOSystem.settings().getInt("paccel"));
Paddles::setAnalogLinearity(myOSystem.settings().getInt("plinear"));
Paddles::setDejitterDiff(myOSystem.settings().getInt("dejitter.diff"));
Paddles::setDejitterBase(myOSystem.settings().getInt("dejitter.base"));
Paddles::setDejitterDiff(myOSystem.settings().getInt("dejitter.diff"));
@ -461,7 +461,7 @@ bool EventHandler::skipInputSetting() const
|| (!paddle
&& (myAdjustSetting == AdjustSetting::ANALOG_DEADZONE
|| myAdjustSetting == AdjustSetting::ANALOG_SENSITIVITY
|| myAdjustSetting == AdjustSetting::ANALOG_ACCEL
|| myAdjustSetting == AdjustSetting::ANALOG_LINEARITY
|| myAdjustSetting == AdjustSetting::DEJITTER_AVERAGING
|| myAdjustSetting == AdjustSetting::DEJITTER_REACTION
|| myAdjustSetting == AdjustSetting::DIGITAL_SENSITIVITY
@ -599,7 +599,7 @@ AdjustFunction EventHandler::getAdjustSetting(AdjustSetting setting)
std::bind(&PhysicalJoystickHandler::changeDigitalDeadZone, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changeAnalogPaddleDeadZone, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changeAnalogPaddleSensitivity, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changeAnalogPaddleAcceleration, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changeAnalogPaddleLinearity, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changePaddleDejitterAveraging, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changePaddleDejitterReaction, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changeDigitalPaddleSensitivity, &joyHandler(), _1),
@ -1415,20 +1415,20 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
}
return;
case Event::DecAnalogAccel:
case Event::DecAnalogLinear:
if(pressed)
{
myPJoyHandler->changeAnalogPaddleAcceleration(-1);
myAdjustSetting = AdjustSetting::ANALOG_ACCEL;
myPJoyHandler->changeAnalogPaddleLinearity(-1);
myAdjustSetting = AdjustSetting::ANALOG_LINEARITY;
myAdjustActive = true;
}
return;
case Event::IncAnalogAccel:
case Event::IncAnalogLinear:
if(pressed)
{
myPJoyHandler->changeAnalogPaddleAcceleration(+1);
myAdjustSetting = AdjustSetting::ANALOG_ACCEL;
myPJoyHandler->changeAnalogPaddleLinearity(+1);
myAdjustSetting = AdjustSetting::ANALOG_LINEARITY;
myAdjustActive = true;
}
return;
@ -3328,8 +3328,8 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { {
{ Event::IncAnalogDeadzone, "Increase analog dead zone", "" },
{ Event::DecAnalogSense, "Decrease analog paddle sensitivity", "" },
{ Event::IncAnalogSense, "Increase analog paddle sensitivity", "" },
{ Event::DecAnalogAccel, "Decrease analog paddle acceleration", "" },
{ Event::IncAnalogAccel, "Increase analog paddle acceleration", "" },
{ Event::DecAnalogLinear, "Decrease analog paddle linearity", "" },
{ Event::IncAnalogLinear, "Increase analog paddle linearity", "" },
{ Event::DecDejtterAveraging, "Decrease paddle dejitter averaging", "" },
{ Event::IncDejtterAveraging, "Increase paddle dejitter averaging", "" },
{ Event::DecDejtterReaction, "Decrease paddle dejitter reaction", "" },
@ -3515,7 +3515,7 @@ const Event::EventSet EventHandler::DevicesEvents = {
Event::DecreaseDeadzone, Event::IncreaseDeadzone,
Event::DecAnalogDeadzone, Event::IncAnalogDeadzone,
Event::DecAnalogSense, Event::IncAnalogSense,
Event::DecAnalogAccel, Event::IncAnalogAccel,
Event::DecAnalogLinear, Event::IncAnalogLinear,
Event::DecDejtterAveraging, Event::IncDejtterAveraging,
Event::DecDejtterReaction, Event::IncDejtterReaction,
Event::DecDigitalSense, Event::IncDigitalSense,

View File

@ -475,7 +475,7 @@ class EventHandler
DEADZONE,
ANALOG_DEADZONE,
ANALOG_SENSITIVITY,
ANALOG_ACCEL,
ANALOG_LINEARITY,
DEJITTER_AVERAGING,
DEJITTER_REACTION,
DIGITAL_SENSITIVITY,

View File

@ -57,7 +57,7 @@ void MindLink::nextMindlinkBit()
if(myMindlinkPos & myMindlinkShift)
setPin(DigitalPin::Four, true);
myMindlinkShift <<= 1; // next bit
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -25,8 +25,8 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system,
bool swappaddle, bool swapaxis, bool swapdir, bool altmap)
: Controller(jack, event, system, Controller::Type::Paddles)
{
// We must start with minimum resistance; see commit
// 38b452e1a047a0dca38c5bcce7c271d40f76736e for more information
// We must start with a physical valid resistance (e.g. 0);
// see commit 38b452e1a047a0dca38c5bcce7c271d40f76736e for more information
setPin(AnalogPin::Five, AnalogReadout::connectToVcc());
setPin(AnalogPin::Nine, AnalogReadout::connectToVcc());
@ -197,11 +197,21 @@ void Paddles::update()
AnalogReadout::Connection Paddles::getReadOut(int lastAxis, int& newAxis, int center)
{
const double range = ANALOG_RANGE - analogDeadZone() * 2;
// dead zone, ignore changes inside the dead zone
if(newAxis > analogDeadZone())
newAxis -= analogDeadZone();
else if(newAxis < -analogDeadZone())
newAxis += analogDeadZone();
else
newAxis = 0; // treat any dead zone value as zero
static constexpr std::array<double, MAX_DEJITTER - MIN_DEJITTER + 1> bFac = {
// higher values mean more dejitter strength
0, // off
0.50, 0.59, 0.67, 0.74, 0.80,
0.85, 0.89, 0.92, 0.94, 0.95
// higher values mean more dejitter strength
0, // off
0.50, 0.59, 0.67, 0.74, 0.80,
0.85, 0.89, 0.92, 0.94, 0.95
};
static constexpr std::array<double, MAX_DEJITTER - MIN_DEJITTER + 1> dFac = {
// lower values mean more dejitter strength
@ -220,24 +230,30 @@ AnalogReadout::Connection Paddles::getReadOut(int lastAxis, int& newAxis, int ce
if(abs(newVal - newAxis) > 10)
newAxis = newVal;
// TODO: deadzone
// here or in PJoystickhandler?
// apply linearity
double linearVal = newAxis / (range / 2); // scale to -1.0..+1.0
// accelerate, reduces sensitivity accordingly
int diff = newAxis - lastAxis;
float factor = diff ? pow(abs(diff), ACCEL) / abs(diff) : 0;
if(newAxis >= 0)
linearVal = pow(abs(linearVal), LINEARITY);
else
linearVal = -pow(abs(linearVal), LINEARITY);
newAxis = lastAxis - diff * factor * pow(MOUSE_SENSITIVITY, 1.f/ACCEL); // TODO: predefine pow(...)
newAxis = linearVal * (range / 2); // scale back to ANALOG_RANGE
// scale axis to range including dead zone
const Int32 scaledAxis = newAxis * ANALOG_RANGE / range;
// scale result
return AnalogReadout::connectToVcc(MAX_RESISTANCE *
(BSPF::clamp(32768 - Int32(Int32(newAxis) * SENSITIVITY + center), 0, 65536) / 65536.0));
BSPF::clamp((ANALOG_MAX_VALUE - (scaledAxis * SENSITIVITY + center)) / double(ANALOG_RANGE),
0.0, 1.0));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Paddles::updateAnalogAxes()
{
// Analog axis events from Stelladaptor-like devices
// Analog axis events from Stelladaptor-like devices,
// (which includes analog USB controllers)
// These devices generate data in the range -32768 to 32767,
// so we have to scale appropriately
// Since these events are generated and stored indefinitely,
@ -245,20 +261,6 @@ bool Paddles::updateAnalogAxes()
// previous values by a pre-defined amount)
// Otherwise, it would always override input from digital and mouse
//static constexpr std::array<double, MAX_DEJITTER - MIN_DEJITTER + 1> bFac = {
// // higher values mean more dejitter strength
// 0, // off
// 0.50, 0.59, 0.67, 0.74, 0.80,
// 0.85, 0.89, 0.92, 0.94, 0.95
//};
//static constexpr std::array<double, MAX_DEJITTER - MIN_DEJITTER + 1> dFac = {
// // lower values mean more dejitter strength
// 1, // off
// 1.0 / 181, 1.0 / 256, 1.0 / 362, 1.0 / 512, 1.0 / 724,
// 1.0 / 1024, 1.0 / 1448, 1.0 / 2048, 1.0 / 2896, 1.0 / 4096
//};
//const double baseFactor = bFac[DEJITTER_BASE];
//const double diffFactor = dFac[DEJITTER_DIFF];
int sa_xaxis = myEvent.get(myAAxisValue);
int sa_yaxis = myEvent.get(myBAxisValue);
@ -266,34 +268,13 @@ bool Paddles::updateAnalogAxes()
if(abs(myLastAxisX - sa_xaxis) > 10)
{
//// dejitter, suppress small changes only
//double dejitter = pow(baseFactor, abs(sa_xaxis - myLastAxisX) * diffFactor);
//int new_val = sa_xaxis * (1 - dejitter) + myLastAxisX * dejitter;
//// only use new dejittered value for larger differences
//if(abs(new_val - sa_xaxis) > 10)
// sa_xaxis = new_val;
//setPin(AnalogPin::Nine, AnalogReadout::connectToVcc(MAX_RESISTANCE *
// (BSPF::clamp(32768 - Int32(Int32(sa_xaxis) * SENSITIVITY + XCENTER), 0, 65536) / 65536.0)));
setPin(AnalogPin::Nine, getReadOut(myLastAxisX, sa_xaxis, XCENTER));
sa_changed = true;
}
if(abs(myLastAxisY - sa_yaxis) > 10)
{
//// dejitter, suppress small changes only
//double dejitter = pow(baseFactor, abs(sa_yaxis - myLastAxisY) * diffFactor);
//int new_val = sa_yaxis * (1 - dejitter) + myLastAxisY * dejitter;
//// only use new dejittered value for larger differences
//if(abs(new_val - sa_yaxis) > 10)
// sa_yaxis = new_val;
//setPin(AnalogPin::Five, AnalogReadout::connectToVcc(MAX_RESISTANCE *
// (BSPF::clamp(32768 - Int32(Int32(sa_yaxis) * SENSITIVITY + YCENTER), 0, 65536) / 65536.0)));
setPin(AnalogPin::Nine, getReadOut(myLastAxisY, sa_yaxis, YCENTER));
setPin(AnalogPin::Five, getReadOut(myLastAxisY, sa_yaxis, YCENTER));
sa_changed = true;
}
myLastAxisX = sa_xaxis;
@ -329,20 +310,9 @@ void Paddles::updateMouse(bool& firePressedA, bool& firePressedB)
// mapped to a separate paddle
if(myMPaddleIDX > -1)
{
// TODO: REMOVE! Test for 2600-daptor paddles only!
// deadzone
// TODO
//
// accelerate
int diff = myEvent.get(myAxisMouseMotion);
float factor = diff ? pow(abs(diff), ACCEL) / abs(diff) : 0;
int newVal = myCharge[myMPaddleIDX] - diff * factor * pow(MOUSE_SENSITIVITY, 1.f/ACCEL);
myCharge[myMPaddleIDX] = BSPF::clamp(newVal, TRIGMIN, TRIGRANGE);
/* myCharge[myMPaddleIDX] = BSPF::clamp(myCharge[myMPaddleIDX] -
myCharge[myMPaddleIDX] = BSPF::clamp(myCharge[myMPaddleIDX] -
(myEvent.get(Event::MouseAxisXMove) * MOUSE_SENSITIVITY),
TRIGMIN, TRIGRANGE);*/
TRIGMIN, TRIGRANGE);
if(myMPaddleIDX == 0)
firePressedA = firePressedA
|| myEvent.get(Event::MouseButtonLeftValue);
@ -479,9 +449,9 @@ float Paddles::analogSensitivityValue(int sensitivity)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Paddles::setAnalogAccel(int accel)
void Paddles::setAnalogLinearity(int linearity)
{
ACCEL = 1.f + BSPF::clamp(accel, MIN_ANALOG_ACCEL, MAX_ANALOG_ACCEL) / 100.f;
LINEARITY = 100.f / BSPF::clamp(linearity, MIN_ANALOG_LINEARITY, MAX_ANALOG_LINEARITY);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Paddles::setDejitterBase(int strength)
@ -513,7 +483,7 @@ void Paddles::setDigitalPaddleRange(int range)
int Paddles::XCENTER = 0;
int Paddles::YCENTER = 0;
float Paddles::SENSITIVITY = 1.0;
float Paddles::ACCEL = 1.0;
float Paddles::LINEARITY = 1.0;
int Paddles::DEJITTER_BASE = 0;
int Paddles::DEJITTER_DIFF = 0;
int Paddles::TRIGRANGE = Paddles::TRIGMAX;

View File

@ -48,11 +48,14 @@ class Paddles : public Controller
~Paddles() override = default;
public:
static constexpr int ANALOG_MIN_VALUE = -32768;
static constexpr int ANALOG_MAX_VALUE = 32767;
static constexpr int ANALOG_RANGE = ANALOG_MAX_VALUE - ANALOG_MIN_VALUE + 1;
static constexpr float BASE_ANALOG_SENSE = 0.148643628F;
static constexpr int MIN_ANALOG_SENSE = 0;
static constexpr int MAX_ANALOG_SENSE = 30;
static constexpr int MIN_ANALOG_ACCEL = 0;
static constexpr int MAX_ANALOG_ACCEL = 100;
static constexpr int MIN_ANALOG_LINEARITY = 25;
static constexpr int MAX_ANALOG_LINEARITY = 100;
static constexpr int MIN_ANALOG_CENTER = -10;
static constexpr int MAX_ANALOG_CENTER = 30;
static constexpr int MIN_DIGITAL_SENSE = 1;
@ -112,11 +115,11 @@ class Paddles : public Controller
static void setAnalogYCenter(int ycenter);
/**
Sets the acceleration for analog paddles.
Sets the linearity of analog paddles.
@param accel Value from 100 to 300
@param linearity Value from 25 to 100
*/
static void setAnalogAccel(int accel);
static void setAnalogLinearity(int linearity);
/**
Sets the sensitivity for analog paddles.
@ -191,7 +194,7 @@ class Paddles : public Controller
static int XCENTER;
static int YCENTER;
static float SENSITIVITY, ACCEL;
static float SENSITIVITY, LINEARITY;
static int DIGITAL_SENSITIVITY, DIGITAL_DISTANCE;
static int DEJITTER_BASE, DEJITTER_DIFF;

View File

@ -116,7 +116,7 @@ Settings::Settings()
setPermanent("grabmouse", "true");
setPermanent("cursor", "2");
setPermanent("adeadzone", "0");
setPermanent("paccel", "100");
setPermanent("plinear", "100");
setPermanent("dejitter.base", "0");
setPermanent("dejitter.diff", "0");
setPermanent("dsense", "10");
@ -368,8 +368,8 @@ void Settings::validate()
setValue("psense", BSPF::clamp(getInt("psense"),
Paddles::MIN_ANALOG_SENSE, Paddles::MAX_ANALOG_SENSE));
setValue("paccel", BSPF::clamp(getInt("paccel"),
Paddles::MIN_ANALOG_ACCEL, Paddles::MAX_ANALOG_ACCEL));
setValue("plinear", BSPF::clamp(getInt("plinear"),
Paddles::MIN_ANALOG_LINEARITY, Paddles::MAX_ANALOG_LINEARITY));
setValue("dejitter.base", BSPF::clamp(getInt("dejitter.base"),
Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER));
@ -525,9 +525,8 @@ void Settings::usage() const
<< " properties in given mode(see manual)\n"
<< " -grabmouse <1|0> Locks the mouse cursor in the TIA window\n"
<< " -cursor <0,1,2,3> Set cursor state in UI/emulation modes\n"
<< " -adeadzone <number> Sets analog 'dead zone' area for analog joysticks\n"
<< " (0-16500)\n"
<< " -paccel <0-100> Sets paddle acceleration strength\n"
<< " -adeadzone <0-29> Sets analog 'dead zone' area for analog joysticks\n"
<< " -plinear <25-100> Sets paddle linearity\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"
<< " -psense <0-30> Sensitivity of analog paddle movement\n"

View File

@ -121,7 +121,7 @@ void InputDialog::addDevicePortTab()
lwidth, kDDeadzoneChanged, 3 * fontWidth, "%");
myDigitalDeadzone->setMinValue(Controller::MIN_DIGITAL_DEADZONE);
myDigitalDeadzone->setMaxValue(Controller::MAX_DIGITAL_DEADZONE);
myDigitalDeadzone->setTickmarkIntervals(4);
myDigitalDeadzone->setTickmarkIntervals(5);
myDigitalDeadzone->setToolTip("Adjust dead zone size for analog joysticks when emulating digital controllers.");
wid.push_back(myDigitalDeadzone);
@ -132,8 +132,7 @@ void InputDialog::addDevicePortTab()
lwidth, kADeadzoneChanged, 3 * fontWidth, "%");
myAnalogDeadzone->setMinValue(Controller::MIN_ANALOG_DEADZONE);
myAnalogDeadzone->setMaxValue(Controller::MAX_ANALOG_DEADZONE);
myAnalogDeadzone->setStepValue(500);
myAnalogDeadzone->setTickmarkIntervals(3);
myAnalogDeadzone->setTickmarkIntervals(5);
myAnalogDeadzone->setToolTip("Adjust dead zone size for analog joysticks when emulating analog controllers.");
wid.push_back(myAnalogDeadzone);
@ -151,17 +150,16 @@ void InputDialog::addDevicePortTab()
myPaddleSpeed->setTickmarkIntervals(3);
wid.push_back(myPaddleSpeed);
// Add analog paddle acceleration
// Add analog paddle linearity
ypos += lineHeight + VGAP;
myPaddleAccel = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight,
"Acceleration",
lwidth - fontWidth * 2, kPAccelChanged, 4 * fontWidth);
myPaddleAccel->setMinValue(Paddles::MIN_ANALOG_ACCEL);
myPaddleAccel->setMaxValue(Paddles::MAX_ANALOG_ACCEL);
myPaddleAccel->setStepValue(5);
myPaddleAccel->setTickmarkIntervals(4);
myPaddleAccel->setToolTip("Adjust fast paddle movement acceleration.");
wid.push_back(myPaddleAccel);
myPaddleLinearity = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight,
"Linearity", lwidth - fontWidth * 2, 0, 4 * fontWidth, "%");
myPaddleLinearity->setMinValue(Paddles::MIN_ANALOG_LINEARITY);
myPaddleLinearity->setMaxValue(Paddles::MAX_ANALOG_LINEARITY);
myPaddleLinearity->setStepValue(5);
myPaddleLinearity->setTickmarkIntervals(3);
myPaddleLinearity->setToolTip("Adjust paddle movement linearity.");
wid.push_back(myPaddleLinearity);
// Add dejitter (analog paddles)
ypos += lineHeight + VGAP;
@ -371,8 +369,8 @@ void InputDialog::loadConfig()
// Paddle speed (analog)
myPaddleSpeed->setValue(settings.getInt("psense"));
// Paddle acceleration (analog)
myPaddleAccel->setValue(settings.getInt("paccel"));
// Paddle linearity (analog)
myPaddleLinearity->setValue(settings.getInt("plinear"));
// Paddle dejitter (analog)
myDejitterBase->setValue(settings.getInt("dejitter.base"));
myDejitterDiff->setValue(settings.getInt("dejitter.diff"));
@ -447,10 +445,10 @@ void InputDialog::saveConfig()
int sensitivity = myPaddleSpeed->getValue();
settings.setValue("psense", sensitivity);
Paddles::setAnalogSensitivity(sensitivity);
// Paddle acceleration (analog)
int accel = myPaddleAccel->getValue();
settings.setValue("paccel", accel);
Paddles::setAnalogAccel(accel);
// Paddle linearity (analog)
int linearity = myPaddleLinearity->getValue();
settings.setValue("plinear", linearity);
Paddles::setAnalogLinearity(linearity);
// Paddle dejitter (analog)
int dejitter = myDejitterBase->getValue();
@ -539,8 +537,8 @@ void InputDialog::setDefaults()
// Paddle speed (analog)
myPaddleSpeed->setValue(20);
// Paddle acceleration
myPaddleAccel->setValue(0);
// Paddle linearity
myPaddleLinearity->setValue(100);
#if defined(RETRON77)
myDejitterBase->setValue(2);
myDejitterDiff->setValue(6);
@ -700,11 +698,13 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
break;
case kDDeadzoneChanged:
myDigitalDeadzone->setValueLabel(std::round(Controller::digitalDeadZoneValue(myDigitalDeadzone->getValue()) * 100.f / 32768));
myDigitalDeadzone->setValueLabel(std::round(Controller::digitalDeadZoneValue(myDigitalDeadzone->getValue()) * 100.f /
(Paddles::ANALOG_RANGE / 2)));
break;
case kADeadzoneChanged:
myAnalogDeadzone->setValueLabel(std::round(myAnalogDeadzone->getValue() * 100.f / 32768));
myAnalogDeadzone->setValueLabel(std::round(Controller::analogDeadZoneValue(myAnalogDeadzone->getValue()) * 100.f /
(Paddles::ANALOG_RANGE / 2)));
break;
case kPSpeedChanged:
@ -712,10 +712,6 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
myPaddleSpeed->getValue()) * 100.F));
break;
case kPAccelChanged:
updatePaddleAccel();
break;
case kDejitterAvChanged:
updateDejitterAveraging();
break;
@ -791,13 +787,6 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
}
}
void InputDialog::updatePaddleAccel()
{
int strength = myPaddleAccel->getValue();
myPaddleAccel->setValueLabel(strength ? std::to_string(strength) + "%" : "Off");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::updateDejitterAveraging()
{

View File

@ -64,7 +64,6 @@ class InputDialog : public Dialog
void handleMouseControlState();
void handleCursorState();
void updatePaddleAccel();
void updateDejitterAveraging();
void updateDejitterReaction();
void updateAutoFireRate();
@ -75,7 +74,6 @@ class InputDialog : public Dialog
kDDeadzoneChanged = 'DDch',
kADeadzoneChanged = 'ADch',
kPSpeedChanged = 'Ppch',
kPAccelChanged = 'PAch',
kDejitterAvChanged = 'JAch',
kDejitterReChanged = 'JRch',
kDPSpeedChanged = 'DSch',
@ -102,7 +100,7 @@ class InputDialog : public Dialog
SliderWidget* myDigitalDeadzone{nullptr};
SliderWidget* myAnalogDeadzone{nullptr};
SliderWidget* myPaddleSpeed{nullptr};
SliderWidget* myPaddleAccel{nullptr};
SliderWidget* myPaddleLinearity{nullptr};
SliderWidget* myDejitterBase{nullptr};
SliderWidget* myDejitterDiff{nullptr};
SliderWidget* myDPaddleSpeed{nullptr};