From 2556c72eea6a7d28d543d991e5d5c519726028f0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 10 Apr 2012 02:51:44 +0300 Subject: Add joystick key assign ability in keyboard dialog. --- src/joystick.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/joystick.h') 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 #include @@ -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. */ -- cgit v1.2.3-60-g2f50