summaryrefslogtreecommitdiff
path: root/src/joystick.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-09 02:51:52 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-09 03:02:42 +0300
commit274737b8d9b46dfcf6fc696123e869bbf6adaaf6 (patch)
tree08bfff598179dd6083a38599811054f50e6a4e97 /src/joystick.h
parent0260dcea2e9fbd06ba2ee166862d089dc72516f4 (diff)
downloadmv-274737b8d9b46dfcf6fc696123e869bbf6adaaf6.tar.gz
mv-274737b8d9b46dfcf6fc696123e869bbf6adaaf6.tar.bz2
mv-274737b8d9b46dfcf6fc696123e869bbf6adaaf6.tar.xz
mv-274737b8d9b46dfcf6fc696123e869bbf6adaaf6.zip
Add support for joystick selection.
Fix enable/disable joystick support. Increase max joystick buttons number to 64. Prevent joystick usage without calibration.
Diffstat (limited to 'src/joystick.h')
-rw-r--r--src/joystick.h25
1 files changed, 22 insertions, 3 deletions
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 <std::string> &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