split paddle dejitter settings

This commit is contained in:
thrust26 2019-05-09 19:05:33 +02:00
parent f619fe33d2
commit 41b990109a
6 changed files with 83 additions and 33 deletions

View File

@ -98,7 +98,8 @@ void EventHandler::initialize()
setActionMappings(kMenuMode);
Joystick::setDeadZone(myOSystem.settings().getInt("joydeadzone"));
Paddles::setDejitter(myOSystem.settings().getInt("dejitter"));
Paddles::setDejitterBase(myOSystem.settings().getInt("dejitterBase"));
Paddles::setDejitterDiff(myOSystem.settings().getInt("dejitterDiff"));
Paddles::setDigitalSensitivity(myOSystem.settings().getInt("dsense"));
Paddles::setMouseSensitivity(myOSystem.settings().getInt("msense"));
PointingDevice::setSensitivity(myOSystem.settings().getInt("tsense"));

View File

@ -272,11 +272,11 @@ void Paddles::update()
const double dFac[MAX_DEJITTER - MIN_DEJITTER + 1] = {
// lower values mean more dejitter strength
1, // off
1.0 / 45 , 1.0 / 64 , 1.0 / 90 , 1.0 / 128, 1.0 / 181,
1.0 / 256, 1.0 / 362, 1.0 / 512, 1.0 / 724, 1.0 / 1024
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];
const double diffFactor = dFac[DEJITTER];
const double baseFactor = bFac[DEJITTER_BASE];
const double diffFactor = dFac[DEJITTER_DIFF];
if(abs(myLastAxisX - sa_xaxis) > 10)
{
@ -423,9 +423,15 @@ bool Paddles::setMouseControl(
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Paddles::setDejitter(int strength)
void Paddles::setDejitterBase(int strength)
{
DEJITTER = BSPF::clamp(strength, MIN_DEJITTER, MAX_DEJITTER);
DEJITTER_BASE = BSPF::clamp(strength, MIN_DEJITTER, MAX_DEJITTER);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Paddles::setDejitterDiff(int strength)
{
DEJITTER_DIFF = BSPF::clamp(strength, MIN_DEJITTER, MAX_DEJITTER);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -453,7 +459,8 @@ int Paddles::TRIGRANGE = Paddles::TRIGMAX;
int Paddles::DIGITAL_SENSITIVITY = -1;
int Paddles::DIGITAL_DISTANCE = -1;
int Paddles::MOUSE_SENSITIVITY = -1;
int Paddles::DEJITTER = 0;
int Paddles::DEJITTER_BASE = 0;
int Paddles::DEJITTER_DIFF = 0;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Controller::DigitalPin Paddles::ourButtonPin[2] = {

View File

@ -90,9 +90,14 @@ class Paddles : public Controller
Controller::Type ytype, int yid) override;
/**
@param strength Value from 0 to 20
@param strength Value from 0 to 10
*/
static void setDejitter(int strength);
static void setDejitterBase(int strength);
/**
@param strength Value from 0 to 10
*/
static void setDejitterDiff(int strength);
/**
Sets the sensitivity for digital emulation of paddle movement.
@ -153,7 +158,7 @@ class Paddles : public Controller
static int TRIGRANGE; // This one is variable for the upper range
static int DIGITAL_SENSITIVITY, DIGITAL_DISTANCE;
static int DEJITTER;
static int DEJITTER_BASE, DEJITTER_DIFF;
static int MOUSE_SENSITIVITY;
// Lookup table for associating paddle buttons with controller pins

View File

@ -87,7 +87,8 @@ Settings::Settings()
setPermanent("usemouse", "analog");
setPermanent("grabmouse", "true");
setPermanent("cursor", "2");
setPermanent("dejitter", "0");
setPermanent("dejitterBase", "0");
setPermanent("dejitterDiff", "0");
setPermanent("dsense", "10");
setPermanent("msense", "10");
setPermanent("tsense", "10");

View File

@ -143,7 +143,7 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
// Add joystick deadzone setting
ypos += lineHeight + VGAP*3;
myDeadzone = new SliderWidget(myTab, font, HBORDER, ypos,
myDeadzone = new SliderWidget(myTab, font, HBORDER, ypos, 13 * fontWidth, lineHeight,
"Joystick deadzone size ", lwidth, kDeadzoneChanged);
myDeadzone->setMinValue(0); myDeadzone->setMaxValue(29);
myDeadzone->setTickmarkInterval(4);
@ -153,18 +153,25 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
// Add dejitter (Stelladaptor emulation for now only)
ypos += lineHeight + VGAP;
myDejitter = new SliderWidget(myTab, font, HBORDER, ypos,
"Paddle dejitter strength",
lwidth, kDejitterChanged);
myDejitter->setMinValue(Paddles::MIN_DEJITTER); myDejitter->setMaxValue(Paddles::MAX_DEJITTER);
myDejitter->setTickmarkInterval(4);
xpos = HBORDER + myDejitter->getWidth() + 5;
myDejitterLabel = new StaticTextWidget(myTab, font, xpos, ypos + 1, 24, lineHeight, "");
wid.push_back(myDejitter);
myDejitterBase = new SliderWidget(myTab, font, HBORDER, ypos, 6 * fontWidth, lineHeight,
"Paddle dejitter strength", lwidth, kDejitterChanged);
myDejitterBase->setMinValue(Paddles::MIN_DEJITTER); myDejitterBase->setMaxValue(Paddles::MAX_DEJITTER);
myDejitterBase->setTickmarkInterval(2);
xpos = HBORDER + myDejitterBase->getWidth() + fontWidth;
wid.push_back(myDejitterBase);
myDejitterDiff = new SliderWidget(myTab, font, xpos, ypos, 6 * fontWidth, lineHeight,
"", 0, kDejitterChanged);
myDejitterDiff->setMinValue(Paddles::MIN_DEJITTER); myDejitterDiff->setMaxValue(Paddles::MAX_DEJITTER);
myDejitterDiff->setTickmarkInterval(2);
xpos += myDejitterDiff->getWidth() + 5;
wid.push_back(myDejitterDiff);
myDejitterLabel = new StaticTextWidget(myTab, font, xpos, ypos + 1, 7 * fontWidth, lineHeight, "");
// Add paddle speed (digital emulation)
ypos += lineHeight + VGAP;
myDPaddleSpeed = new SliderWidget(myTab, font, HBORDER, ypos,
myDPaddleSpeed = new SliderWidget(myTab, font, HBORDER, ypos, 13 * fontWidth, lineHeight,
"Digital paddle sensitivity ",
lwidth, kDPSpeedChanged);
myDPaddleSpeed->setMinValue(1); myDPaddleSpeed->setMaxValue(20);
@ -175,7 +182,7 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
// Add paddle speed (mouse emulation)
ypos += lineHeight + VGAP;
myMPaddleSpeed = new SliderWidget(myTab, font, HBORDER, ypos,
myMPaddleSpeed = new SliderWidget(myTab, font, HBORDER, ypos, 13 * fontWidth, lineHeight,
"Mouse paddle sensitivity ",
lwidth, kMPSpeedChanged);
myMPaddleSpeed->setMinValue(1); myMPaddleSpeed->setMaxValue(20);
@ -186,7 +193,7 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
// Add trackball speed
ypos += lineHeight + VGAP;
myTrackBallSpeed = new SliderWidget(myTab, font, HBORDER, ypos,
myTrackBallSpeed = new SliderWidget(myTab, font, HBORDER, ypos, 13 * fontWidth, lineHeight,
"Trackball sensitivity ",
lwidth, kTBSpeedChanged);
myTrackBallSpeed->setMinValue(1); myTrackBallSpeed->setMaxValue(20);
@ -275,8 +282,9 @@ void InputDialog::loadConfig()
myDeadzoneLabel->setValue(Joystick::deadzone());
// Paddle speed (digital and mouse)
myDejitter->setValue(instance().settings().getInt("dejitter"));
myDejitterLabel->setLabel(instance().settings().getString("dejitter"));
myDejitterBase->setValue(instance().settings().getInt("dejitterBase"));
myDejitterDiff->setValue(instance().settings().getInt("dejitterDiff"));
UpdateDejitter();
myDPaddleSpeed->setValue(instance().settings().getInt("dsense"));
myDPaddleLabel->setLabel(instance().settings().getString("dsense"));
myMPaddleSpeed->setValue(instance().settings().getInt("msense"));
@ -330,9 +338,12 @@ void InputDialog::saveConfig()
Joystick::setDeadZone(deadzone);
// Paddle speed (digital and mouse)
int dejitter = myDejitter->getValue();
instance().settings().setValue("dejitter", dejitter);
Paddles::setDejitter(dejitter);
int dejitter = myDejitterBase->getValue();
instance().settings().setValue("dejitterBase", dejitter);
Paddles::setDejitterBase(dejitter);
dejitter = myDejitterDiff->getValue();
instance().settings().setValue("dejitterDiff", dejitter);
Paddles::setDejitterDiff(dejitter);
int sensitivity = myDPaddleSpeed->getValue();
instance().settings().setValue("dsense", sensitivity);
@ -402,8 +413,9 @@ void InputDialog::setDefaults()
myDPaddleLabel->setLabel("10");
myMPaddleSpeed->setValue(10);
myMPaddleLabel->setLabel("10");
myDejitter->setValue(0);
myDejitterLabel->setLabel("0");
myDejitterBase->setValue(0);
myDejitterDiff->setValue(0);
UpdateDejitter();
myTrackBallSpeed->setValue(10);
myTrackBallLabel->setLabel("10");
@ -529,7 +541,7 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
break;
case kDejitterChanged:
myDejitterLabel->setValue(myDejitter->getValue());
UpdateDejitter();
break;
case kTBSpeedChanged:
@ -573,3 +585,25 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
Dialog::handleCommand(sender, cmd, data, 0);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::UpdateDejitter()
{
int strength = myDejitterBase->getValue();
stringstream label;
if (strength)
label << myDejitterBase->getValue();
else
label << "Off";
label << " ";
strength = myDejitterDiff->getValue();
if (strength)
label << myDejitterDiff->getValue();
else
label << "Off";
myDejitterLabel->setLabel(label.str());
}

View File

@ -56,6 +56,7 @@ class InputDialog : public Dialog
void addDevicePortTab(const GUI::Font& font);
void eraseEEPROM();
void UpdateDejitter();
private:
enum {
@ -82,7 +83,8 @@ class InputDialog : public Dialog
SliderWidget* myDeadzone;
StaticTextWidget* myDeadzoneLabel;
SliderWidget* myDejitter;
SliderWidget* myDejitterBase;
SliderWidget* myDejitterDiff;
SliderWidget* myDPaddleSpeed;
SliderWidget* myMPaddleSpeed;
SliderWidget* myTrackBallSpeed;