summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/tabs/setup_joystick.cpp36
-rw-r--r--src/gui/widgets/tabs/setup_joystick.h2
-rw-r--r--src/input/joystick.cpp49
-rw-r--r--src/input/joystick.h11
4 files changed, 3 insertions, 95 deletions
diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp
index 16c248c48..3542f39a5 100644
--- a/src/gui/widgets/tabs/setup_joystick.cpp
+++ b/src/gui/widgets/tabs/setup_joystick.cpp
@@ -44,12 +44,6 @@
Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
SetupTab(widget),
- mCalibrateLabel(new Label(this,
- // TRANSLATORS: joystick settings tab label
- _("Press the button to start calibration"))),
- // TRANSLATORS: joystick settings tab button
- mCalibrateButton(new Button(this, _("Calibrate"), "calibrate",
- BUTTON_SKIN, this)),
// TRANSLATORS: joystick settings tab button
mDetectButton(new Button(this, _("Detect joysticks"), "detect",
BUTTON_SKIN, this)),
@@ -76,7 +70,6 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
mJoystickEnabled->setActionEventId("joystick");
mJoystickEnabled->addActionListener(this);
- mCalibrateButton->setEnabled(mOriginalJoystickEnabled);
int tolerance = config.getIntValue("joystickTolerance");
mToleranceSlider->setValue(tolerance);
@@ -114,10 +107,8 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
place(0, 3, mUseInactiveCheckBox, 1, 1);
place(0, 4, mDetectButton, 1, 1);
- place(0, 5, mCalibrateLabel, 1, 1);
- place(0, 6, mCalibrateButton, 1, 1);
- setDimension(Rect(0, 0, 365, 95));
+ setDimension(Rect(0, 0, 365, 60));
}
Setup_Joystick::~Setup_Joystick()
@@ -152,36 +143,11 @@ void Setup_Joystick::action(const ActionEvent &event)
else
mNamesDropDown->setSelected(0);
}
- else
- {
- if (joystick == nullptr)
- return;
-
- if (joystick->isCalibrating())
- {
- // TRANSLATORS: joystick settings tab button
- mCalibrateButton->setCaption(_("Calibrate"));
- mCalibrateLabel->setCaption
- // TRANSLATORS: joystick settings tab label
- (_("Press the button to start calibration"));
- joystick->finishCalibration();
- }
- else
- {
- // TRANSLATORS: joystick settings tab button
- mCalibrateButton->setCaption(_("Stop"));
- mCalibrateLabel->setCaption(
- // TRANSLATORS: joystick settings tab label
- _("Rotate the stick and don't press buttons"));
- joystick->startCalibration();
- }
- }
}
void Setup_Joystick::setTempEnabled(const bool sel)
{
Joystick::setEnabled(sel);
- mCalibrateButton->setEnabled(sel);
if (joystick != nullptr)
{
if (sel)
diff --git a/src/gui/widgets/tabs/setup_joystick.h b/src/gui/widgets/tabs/setup_joystick.h
index 8e347d0f6..fce59a02c 100644
--- a/src/gui/widgets/tabs/setup_joystick.h
+++ b/src/gui/widgets/tabs/setup_joystick.h
@@ -51,8 +51,6 @@ class Setup_Joystick final : public SetupTab
void setTempEnabled(const bool sel);
private:
- Label *mCalibrateLabel A_NONNULLPOINTER;
- Button *mCalibrateButton A_NONNULLPOINTER;
Button *mDetectButton A_NONNULLPOINTER;
CheckBox *mJoystickEnabled A_NONNULLPOINTER;
NamesModel *mNamesModel A_NONNULLPOINTER;
diff --git a/src/input/joystick.cpp b/src/input/joystick.cpp
index 48b4488b0..4bcb070d3 100644
--- a/src/input/joystick.cpp
+++ b/src/input/joystick.cpp
@@ -49,9 +49,7 @@ Joystick::Joystick(const int no) :
mDirection(0),
mJoystick(nullptr),
mTolerance(0),
- mCalibrating(false),
mNumber(no >= joystickCount ? joystickCount : no),
- mCalibrated(false),
mButtonsNumber(MAX_BUTTONS),
mUseInactive(false),
mHaveHats(false),
@@ -197,12 +195,8 @@ bool Joystick::open()
mButtonsNumber = MAX_BUTTONS;
#ifdef __SWITCH__
- config.setValue("joystick" + toString(mNumber) + "calibrated", true);
config.setValue("joystickTolerance", 10000);
#endif
- mCalibrated = config.getValueBool("joystick"
- + toString(mNumber) + "calibrated", false);
-
mTolerance = config.getIntValue("joystickTolerance");
mUseInactive = config.getBoolValue("useInactiveJoystick");
@@ -236,15 +230,7 @@ void Joystick::setNumber(const int n)
void Joystick::logic()
{
BLOCK_START("Joystick::logic")
- // When calibrating, don't bother the outside with our state
- if (mCalibrating)
- {
- doCalibration();
- BLOCK_END("Joystick::logic")
- return;
- }
-
- if (!mEnabled || !mCalibrated)
+ if (!mEnabled)
{
BLOCK_END("Joystick::logic")
return;
@@ -313,37 +299,6 @@ void Joystick::logic()
BLOCK_END("Joystick::logic")
}
-void Joystick::startCalibration()
-{
- mTolerance = 0;
- mCalibrating = true;
-}
-
-void Joystick::doCalibration()
-{
- // X-Axis
- int position = SDL_JoystickGetAxis(mJoystick, 0);
- if (position > mTolerance)
- mTolerance = position;
- else if (position < -mTolerance)
- mTolerance = -position;
-
- // Y-Axis
- position = SDL_JoystickGetAxis(mJoystick, 1);
- if (position > mTolerance)
- mTolerance = position;
- else if (position < -mTolerance)
- mTolerance = -position;
-}
-
-void Joystick::finishCalibration()
-{
- mCalibrated = true;
- mCalibrating = false;
- config.setValue("joystick" + toString(mNumber) + "calibrated", true);
- config.setValue("joystickTolerance", mTolerance);
-}
-
bool Joystick::buttonPressed(const unsigned char no) const
{
return (mEnabled && no < MAX_BUTTONS) ? mActiveButtons[no] : false;
@@ -414,7 +369,7 @@ bool Joystick::isActionActive(const InputActionT index) const
bool Joystick::validate() const
{
- if (mCalibrating || !mEnabled || !mCalibrated)
+ if (!mEnabled)
return false;
return mUseInactive ||
diff --git a/src/input/joystick.h b/src/input/joystick.h
index 198b6fe9e..d90420395 100644
--- a/src/input/joystick.h
+++ b/src/input/joystick.h
@@ -98,13 +98,6 @@ class Joystick final
*/
void logic();
- void startCalibration();
-
- void finishCalibration();
-
- bool isCalibrating() const noexcept2 A_WARN_UNUSED
- { return mCalibrating; }
-
bool buttonPressed(const unsigned char no) const A_WARN_UNUSED;
bool isUp() const noexcept2 A_WARN_UNUSED
@@ -152,9 +145,7 @@ class Joystick final
SDL_Joystick *mJoystick;
int mTolerance;
- bool mCalibrating;
int mNumber;
- bool mCalibrated;
int mButtonsNumber;
bool mUseInactive;
bool mHaveHats;
@@ -171,8 +162,6 @@ class Joystick final
static bool mEnabled;
static bool mInitialized;
static int joystickCount;
-
- void doCalibration();
};
extern Joystick *joystick;