summaryrefslogtreecommitdiff
path: root/src/joystick.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-26 20:19:39 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-26 20:19:39 +0000
commitbe3b639a879a5a8eb73b2e652683da222796af44 (patch)
tree35d5ed3957c283dbb49fd9b92112c7cc919b7ba9 /src/joystick.cpp
parentef82a7df8aafb569f6db5e77ff2dd67fde860148 (diff)
downloadmana-be3b639a879a5a8eb73b2e652683da222796af44.tar.gz
mana-be3b639a879a5a8eb73b2e652683da222796af44.tar.bz2
mana-be3b639a879a5a8eb73b2e652683da222796af44.tar.xz
mana-be3b639a879a5a8eb73b2e652683da222796af44.zip
Applied patch by Pascal, adding sliders to configure the scrolling behaviour
and a checkbox to enable or disable the joystick.
Diffstat (limited to 'src/joystick.cpp')
-rw-r--r--src/joystick.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/joystick.cpp b/src/joystick.cpp
index bb6e887b..a5dab4f4 100644
--- a/src/joystick.cpp
+++ b/src/joystick.cpp
@@ -59,10 +59,11 @@ Joystick::Joystick(int no):
logger->log("Hats: %i", SDL_JoystickNumHats(mJoystick));
logger->log("Buttons: %i", SDL_JoystickNumButtons(mJoystick));
- mUpTolerance = (int)config.getValue("upTolerance", 100);
- mDownTolerance = (int)config.getValue("downTolerance", 100);
- mLeftTolerance = (int)config.getValue("leftTolerance", 100);
- mRightTolerance = (int)config.getValue("rightTolerance", 100);
+ mEnabled = (int) config.getValue("joystickEnabled", 0) != 0;
+ mUpTolerance = (int) config.getValue("upTolerance", 100);
+ mDownTolerance = (int) config.getValue("downTolerance", 100);
+ mLeftTolerance = (int) config.getValue("leftTolerance", 100);
+ mRightTolerance = (int) config.getValue("rightTolerance", 100);
}
Joystick::~Joystick()
@@ -73,6 +74,7 @@ Joystick::~Joystick()
void Joystick::update()
{
mDirection = 0;
+
SDL_JoystickUpdate();
// When calibrating, don't bother the outside with our state
@@ -81,6 +83,8 @@ void Joystick::update()
return;
};
+ if (!mEnabled) return;
+
// X-Axis
int position = SDL_JoystickGetAxis(mJoystick, 0);
if (position >= mRightTolerance)
@@ -144,7 +148,6 @@ void Joystick::doCalibration()
}
}
-
void Joystick::finishCalibration()
{
config.setValue("leftTolerance", mLeftTolerance);
@@ -154,10 +157,7 @@ void Joystick::finishCalibration()
mCalibrating = false;
}
-bool Joystick::buttonPressed(unsigned char no)
+bool Joystick::buttonPressed(unsigned char no) const
{
- if (no > MAX_BUTTONS)
- return false;
-
- return mButtons[no];
+ return (no < MAX_BUTTONS) ? mButtons[no] : false;
}