summaryrefslogtreecommitdiff
path: root/src/joystick.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-28 23:04:08 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-28 23:04:08 +0000
commit391203d83ed7a72b54fb7d7c72dbe35db14f0ea9 (patch)
treea9a9e14bbbdde0b48c66b99038d505a42a51609b /src/joystick.cpp
parentaf61e1e7df91b97c3f7516e9eb2b37b621f069ad (diff)
downloadmana-391203d83ed7a72b54fb7d7c72dbe35db14f0ea9.tar.gz
mana-391203d83ed7a72b54fb7d7c72dbe35db14f0ea9.tar.bz2
mana-391203d83ed7a72b54fb7d7c72dbe35db14f0ea9.tar.xz
mana-391203d83ed7a72b54fb7d7c72dbe35db14f0ea9.zip
Merged trunk development between revisions 2530 and 2618 to the 0.1.0 branch.
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;
}