summaryrefslogtreecommitdiff
path: root/src/joystick.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-10 02:51:44 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-10 02:56:05 +0300
commit2556c72eea6a7d28d543d991e5d5c519726028f0 (patch)
tree111cf3f26eaf3a5734ec1e22d3985897feb6cd04 /src/joystick.h
parent8f3be5cd0544af07c6cb65bef7a1f3ba1a3704bb (diff)
downloadmv-2556c72eea6a7d28d543d991e5d5c519726028f0.tar.gz
mv-2556c72eea6a7d28d543d991e5d5c519726028f0.tar.bz2
mv-2556c72eea6a7d28d543d991e5d5c519726028f0.tar.xz
mv-2556c72eea6a7d28d543d991e5d5c519726028f0.zip
Add joystick key assign ability in keyboard dialog.
Diffstat (limited to 'src/joystick.h')
-rw-r--r--src/joystick.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/joystick.h b/src/joystick.h
index 87d1e81a9..55b75d373 100644
--- a/src/joystick.h
+++ b/src/joystick.h
@@ -23,6 +23,8 @@
#ifndef JOYSTICK_H
#define JOYSTICK_H
+#include "inputevent.h"
+
#include <SDL.h>
#include <string>
@@ -86,7 +88,7 @@ class Joystick
/**
* Updates the direction and button information.
*/
- void update();
+ void logic();
void startCalibration();
@@ -98,16 +100,16 @@ class Joystick
bool buttonPressed(unsigned char no) const;
bool isUp() const
- { return mEnabled && (mDirection & UP); };
+ { return mEnabled && (mDirection & UP); }
bool isDown() const
- { return mEnabled && (mDirection & DOWN); };
+ { return mEnabled && (mDirection & DOWN); }
bool isLeft() const
- { return mEnabled && (mDirection & LEFT); };
+ { return mEnabled && (mDirection & LEFT); }
bool isRight() const
- { return mEnabled && (mDirection & RIGHT); };
+ { return mEnabled && (mDirection & RIGHT); }
int getNumber() const
{ return mNumber; }
@@ -115,9 +117,19 @@ class Joystick
void setUseInactive(bool b)
{ mUseInactive = b; }
+ void update();
+
+ KeysVector *getActionVector(const SDL_Event &event);
+
+ int getButtonFromEvent(const SDL_Event &event);
+
+ bool isActionActive(int index) const;
+
protected:
unsigned char mDirection;
- bool mButtons[MAX_BUTTONS];
+
+ bool mActiveButtons[MAX_BUTTONS];
+
SDL_Joystick *mJoystick;
int mUpTolerance;
@@ -131,6 +143,8 @@ class Joystick
bool mUseInactive;
bool mHaveHats;
+ KeyToActionMap mKeyToAction;
+
/**
* Is joystick support enabled.
*/