ManaPlus
|
#include <joystick.h>
Public Types | |
enum | { MAX_BUTTONS = 64 } |
enum | { UP = 1 , DOWN = 2 , LEFT = 4 , RIGHT = 8 } |
Public Member Functions | |
Joystick (const int no) | |
~Joystick () | |
bool | open () |
void | close () |
void | setNumber (const int n) |
void | logic () |
void | startCalibration () |
void | finishCalibration () |
bool | isCalibrating () const |
bool | buttonPressed (const unsigned char no) const |
bool | isUp () const |
bool | isDown () const |
bool | isLeft () const |
bool | isRight () const |
int | getNumber () const |
void | setUseInactive (const bool b) |
void | update () |
KeysVector * | getActionVector (const SDL_Event &event) |
KeysVector * | getActionVectorByKey (const int i) |
int | getButtonFromEvent (const SDL_Event &event) const |
bool | isActionActive (const InputActionT index) const |
bool | validate () const |
void | handleRepeat (const int time) |
void | resetRepeat (const int key) |
void | reload () |
Static Public Member Functions | |
static void | init () |
static int | getNumberOfJoysticks () |
static bool | isEnabled () |
static void | setEnabled (const bool enabled) |
static void | getNames (std::vector< std::string > &names) |
Protected Member Functions | |
void | doCalibration () |
Protected Attributes | |
unsigned char | mDirection |
bool | mActiveButtons [MAX_BUTTONS] |
SDL_Joystick * | mJoystick |
int | mUpTolerance |
int | mDownTolerance |
int | mLeftTolerance |
int | mRightTolerance |
bool | mCalibrating |
int | mNumber |
bool | mCalibrated |
int | mButtonsNumber |
bool | mUseInactive |
bool | mHaveHats |
KeyToActionMap | mKeyToAction |
KeyToIdMap | mKeyToId |
KeyTimeMap | mKeyTimeMap |
Static Protected Attributes | |
static bool | mEnabled = false |
static int | joystickCount = 0 |
Definition at line 34 of file joystick.h.
anonymous enum |
anonymous enum |
Directions, to be used as bitmask values.
Enumerator | |
---|---|
UP | |
DOWN | |
LEFT | |
RIGHT |
Definition at line 48 of file joystick.h.
|
explicit |
Constructor, pass the number of the joystick the new object should access.
Definition at line 47 of file joystick.cpp.
References mActiveButtons, and MAX_BUTTONS.
Referenced by init().
Joystick::~Joystick | ( | ) |
Definition at line 68 of file joystick.cpp.
References close().
bool Joystick::buttonPressed | ( | const unsigned char | no | ) | const |
void Joystick::close | ( | ) |
Definition at line 200 of file joystick.cpp.
References Logger::log(), logger, mJoystick, and mNumber.
Referenced by Setup_Joystick::setTempEnabled(), and ~Joystick().
|
protected |
Definition at line 319 of file joystick.cpp.
References mDownTolerance, mJoystick, mLeftTolerance, mRightTolerance, and mUpTolerance.
Referenced by logic().
void Joystick::finishCalibration | ( | ) |
Definition at line 336 of file joystick.cpp.
References config, mCalibrated, mCalibrating, mDownTolerance, mLeftTolerance, mNumber, mRightTolerance, mUpTolerance, Configuration::setValue(), and Catch::toString().
Referenced by Setup_Joystick::action().
KeysVector * Joystick::getActionVector | ( | const SDL_Event & | event | ) |
Definition at line 365 of file joystick.cpp.
References getButtonFromEvent(), mButtonsNumber, and mKeyToAction.
Referenced by InputManager::handleEvent().
KeysVector * Joystick::getActionVectorByKey | ( | const int | i | ) |
Definition at line 377 of file joystick.cpp.
References mButtonsNumber, and mKeyToAction.
Referenced by handleRepeat().
int Joystick::getButtonFromEvent | ( | const SDL_Event & | event | ) | const |
Definition at line 387 of file joystick.cpp.
References mNumber.
Referenced by getActionVector(), and InputManager::setNewKey().
|
static |
Definition at line 352 of file joystick.cpp.
References joystickCount, and SDL_JoystickNameForIndex.
Referenced by Setup_Joystick::action(), and Setup_Joystick::Setup_Joystick().
|
inline |
Definition at line 117 of file joystick.h.
Referenced by Setup_Joystick::action(), and Setup_Joystick::Setup_Joystick().
|
inlinestatic |
void Joystick::handleRepeat | ( | const int | time | ) |
Definition at line 424 of file joystick.cpp.
References BLOCK_END, BLOCK_START, FOR_EACH, getActionVectorByKey(), inputManager, mActiveButtons, mButtonsNumber, mKeyTimeMap, and InputManager::triggerAction().
Referenced by InputManager::handleRepeat().
|
static |
Initializes the joystick subsystem.
Definition at line 73 of file joystick.cpp.
References config, Configuration::getBoolValue(), Configuration::getIntValue(), joystick, Joystick(), joystickCount, Logger::log(), logger, mEnabled, open(), and SDL_JoystickNameForIndex.
Referenced by Client::gameInit().
bool Joystick::isActionActive | ( | const InputActionT | index | ) | const |
Definition at line 394 of file joystick.cpp.
References InputManager::getKey(), inputFunctionSize, inputManager, InputType::JOYSTICK, mActiveButtons, mButtonsNumber, InputItem::type, validate(), InputItem::value, and InputFunction::values.
Referenced by InputManager::isActionActive0().
|
inline |
|
inline |
Definition at line 108 of file joystick.h.
References BeingDirection::DOWN.
Referenced by Game::handleMove().
|
inlinestatic |
|
inline |
Definition at line 111 of file joystick.h.
References BeingDirection::LEFT.
Referenced by Game::handleMove().
|
inline |
Definition at line 114 of file joystick.h.
References BeingDirection::RIGHT.
Referenced by Game::handleMove().
|
inline |
Definition at line 105 of file joystick.h.
References BeingDirection::UP.
Referenced by Game::handleMove().
void Joystick::logic | ( | ) |
Updates the direction and button information.
Definition at line 230 of file joystick.cpp.
References BLOCK_END, BLOCK_START, doCalibration(), DOWN, Actions::hat(), Settings::inputFocused, LEFT, Logger::log(), logger, mActiveButtons, mButtonsNumber, mCalibrated, mCalibrating, mDirection, mDownTolerance, mEnabled, mHaveHats, mJoystick, mLeftTolerance, mRightTolerance, mUpTolerance, mUseInactive, resetRepeat(), RIGHT, settings, KeyboardFocus::Unfocused, and UP.
Referenced by Game::handleInput().
bool Joystick::open | ( | ) |
Definition at line 93 of file joystick.cpp.
References CAST_U32, config, Configuration::getBoolValue(), Configuration::getIntValue(), ConfigurationObject::getValueBool(), joystickCount, Logger::log(), Logger::log1(), logger, MAX_BUTTONS, mButtonsNumber, mCalibrated, mDownTolerance, mHaveHats, mJoystick, mLeftTolerance, mNumber, mRightTolerance, mUpTolerance, mUseInactive, Configuration::setValue(), strprintf(), and Catch::toString().
Referenced by init(), setNumber(), and Setup_Joystick::setTempEnabled().
void Joystick::reload | ( | ) |
Definition at line 210 of file joystick.cpp.
References joystickCount, mNumber, and setNumber().
Referenced by Setup_Joystick::action().
void Joystick::resetRepeat | ( | const int | key | ) |
Definition at line 450 of file joystick.cpp.
References mKeyTimeMap, and tick_time.
Referenced by logic().
|
inlinestatic |
Definition at line 86 of file joystick.h.
Referenced by Setup_Joystick::cancel(), and Setup_Joystick::setTempEnabled().
void Joystick::setNumber | ( | const int | n | ) |
|
inline |
void Joystick::startCalibration | ( | ) |
Definition at line 310 of file joystick.cpp.
References mCalibrating, mDownTolerance, mLeftTolerance, mRightTolerance, and mUpTolerance.
Referenced by Setup_Joystick::action().
void Joystick::update | ( | ) |
Definition at line 359 of file joystick.cpp.
References inputManager, InputType::JOYSTICK, mKeyTimeMap, mKeyToAction, mKeyToId, and InputManager::updateKeyActionMap().
Referenced by Client::gameInit(), initEngines(), and InputManager::update().
bool Joystick::validate | ( | ) | const |
Definition at line 415 of file joystick.cpp.
References Settings::inputFocused, mCalibrated, mCalibrating, mEnabled, mUseInactive, settings, and KeyboardFocus::Unfocused.
Referenced by InputManager::handleEvent(), and isActionActive().
|
staticprotected |
Definition at line 169 of file joystick.h.
Referenced by getNames(), init(), open(), and reload().
|
protected |
Definition at line 144 of file joystick.h.
Referenced by buttonPressed(), handleRepeat(), isActionActive(), Joystick(), and logic().
|
protected |
Definition at line 155 of file joystick.h.
Referenced by getActionVector(), getActionVectorByKey(), handleRepeat(), isActionActive(), logic(), and open().
|
protected |
Definition at line 154 of file joystick.h.
Referenced by finishCalibration(), logic(), open(), and validate().
|
protected |
Definition at line 152 of file joystick.h.
Referenced by finishCalibration(), logic(), startCalibration(), and validate().
|
protected |
Definition at line 142 of file joystick.h.
Referenced by logic().
|
protected |
Definition at line 149 of file joystick.h.
Referenced by doCalibration(), finishCalibration(), logic(), open(), and startCalibration().
|
staticprotected |
Is joystick support enabled.
Definition at line 168 of file joystick.h.
Referenced by buttonPressed(), init(), logic(), and validate().
|
protected |
Definition at line 157 of file joystick.h.
|
protected |
Definition at line 146 of file joystick.h.
Referenced by close(), doCalibration(), logic(), open(), and setNumber().
|
protected |
Definition at line 163 of file joystick.h.
Referenced by handleRepeat(), resetRepeat(), and update().
|
protected |
Definition at line 159 of file joystick.h.
Referenced by getActionVector(), getActionVectorByKey(), and update().
|
protected |
Definition at line 161 of file joystick.h.
Referenced by update().
|
protected |
Definition at line 150 of file joystick.h.
Referenced by doCalibration(), finishCalibration(), logic(), open(), and startCalibration().
|
protected |
Definition at line 153 of file joystick.h.
Referenced by close(), finishCalibration(), getButtonFromEvent(), open(), reload(), and setNumber().
|
protected |
Definition at line 151 of file joystick.h.
Referenced by doCalibration(), finishCalibration(), logic(), open(), and startCalibration().
|
protected |
Definition at line 148 of file joystick.h.
Referenced by doCalibration(), finishCalibration(), logic(), open(), and startCalibration().
|
protected |
Definition at line 156 of file joystick.h.
Referenced by logic(), open(), and validate().