From 274737b8d9b46dfcf6fc696123e869bbf6adaaf6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 9 Nov 2011 02:51:52 +0300 Subject: Add support for joystick selection. Fix enable/disable joystick support. Increase max joystick buttons number to 64. Prevent joystick usage without calibration. --- src/joystick.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/joystick.h') diff --git a/src/joystick.h b/src/joystick.h index 32efc5bff..3a2258cd5 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -33,7 +33,7 @@ class Joystick */ enum { - MAX_BUTTONS = 6 + MAX_BUTTONS = 64 }; /** @@ -66,12 +66,20 @@ class Joystick ~Joystick(); + bool open(); + + void close(); + bool isEnabled() const { return mEnabled; } - void setEnabled(bool enabled) + void setNumber(int n); + + static void setEnabled(bool enabled) { mEnabled = enabled; } + static void getNames(std::vector &names); + /** * Updates the direction and button information. */ @@ -98,6 +106,9 @@ class Joystick bool isRight() const { return mEnabled && (mDirection & RIGHT); }; + int getNumber() const + { return mNumber; } + protected: unsigned char mDirection; bool mButtons[MAX_BUTTONS]; @@ -105,11 +116,19 @@ class Joystick int mUpTolerance, mDownTolerance, mLeftTolerance, mRightTolerance; bool mCalibrating; - bool mEnabled; + int mNumber; + bool mCalibrated; + int mButtonsNumber; + /** + * Is joystick support enabled. + */ + static bool mEnabled; static int joystickCount; void doCalibration(); }; +extern Joystick *joystick; + #endif // JOYSTICK_H -- cgit v1.2.3-60-g2f50