diff options
author | Ira Rice <irarice@gmail.com> | 2008-11-27 22:24:48 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-11-27 22:24:48 +0000 |
commit | c6adb930edd2d0a88d7c5ca4edd58d95382a5abf (patch) | |
tree | 83e8a74019c8c633d90a7e24504dd22006e768cb /src/joystick.h | |
parent | 886a5d4803e277b053014ae6b5c1c347f7756d48 (diff) | |
download | mana-c6adb930edd2d0a88d7c5ca4edd58d95382a5abf.tar.gz mana-c6adb930edd2d0a88d7c5ca4edd58d95382a5abf.tar.bz2 mana-c6adb930edd2d0a88d7c5ca4edd58d95382a5abf.tar.xz mana-c6adb930edd2d0a88d7c5ca4edd58d95382a5abf.zip |
Merged a patch by Bjorn to fix allowing the joystick to be used without
being enabled first. A similar patch was asked for by Doorsman here, so
this combined with the setup button on client startup, should be enough
to fulfill that request from Doors.
Diffstat (limited to 'src/joystick.h')
-rw-r--r-- | src/joystick.h | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/joystick.h b/src/joystick.h index 4cc1babd..2baf3e61 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -30,12 +30,19 @@ class Joystick /** * Number of buttons we can handle. */ - enum { MAX_BUTTONS = 6 }; + enum { + MAX_BUTTONS = 6 + }; /** * Directions, to be used as bitmask values. */ - enum { UP = 1, DOWN = 2, LEFT = 4, RIGHT = 8 }; + enum { + UP = 1, + DOWN = 2, + LEFT = 4, + RIGHT = 8 + }; /** * Initializes the joystick subsystem. @@ -55,33 +62,27 @@ class Joystick ~Joystick(); - bool - isEnabled() const { return mEnabled; } + bool isEnabled() const { return mEnabled; } - void - setEnabled(bool enabled) { mEnabled = enabled; } + void setEnabled(bool enabled) { mEnabled = enabled; } /** * Updates the direction and button information. */ - void - update(); + void update(); - void - startCalibration(); + void startCalibration(); - void - finishCalibration(); + void finishCalibration(); - bool - isCalibrating() const { return mCalibrating; } + bool isCalibrating() const { return mCalibrating; } bool buttonPressed(unsigned char no) const; - bool isUp() const { return mDirection & UP; }; - bool isDown() const { return mDirection & DOWN; }; - bool isLeft() const { return mDirection & LEFT; }; - bool isRight() const { return mDirection & RIGHT; }; + bool isUp() const { return mEnabled && (mDirection & UP); }; + bool isDown() const { return mEnabled && (mDirection & DOWN); }; + bool isLeft() const { return mEnabled && (mDirection & LEFT); }; + bool isRight() const { return mEnabled && (mDirection & RIGHT); }; protected: unsigned char mDirection; @@ -97,4 +98,4 @@ class Joystick void doCalibration(); }; -#endif +#endif // _TMW_JOYSTICK_H |