34 #include "utils/timer.h"
37 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
55 mNumber(
no >= joystickCount ? joystickCount :
no),
57 mButtonsNumber(MAX_BUTTONS),
75 SDL_InitSubSystem(SDL_INIT_JOYSTICK);
77 SDL_JoystickEventState(SDL_ENABLE);
99 logger->
log1(
"error: incorrect joystick selection");
108 logger->
log(
"Couldn't open joystick: %s", SDL_GetError());
116 SDL_JoystickGUID guid = SDL_JoystickGetGUID(
mJoystick);
118 for (
int f = 0; f < 16; f ++)
120 logger->
log(
"Guid: %s", guidStr.c_str());
121 #if SDL_VERSION_ATLEAST(2, 0, 6)
127 SDL_JoystickType type = SDL_JoystickGetType(
mJoystick);
132 case SDL_JOYSTICK_TYPE_UNKNOWN:
135 case SDL_JOYSTICK_TYPE_GAMECONTROLLER:
136 typeStr =
"game controller";
138 case SDL_JOYSTICK_TYPE_WHEEL:
141 case SDL_JOYSTICK_TYPE_ARCADE_STICK:
142 typeStr =
"arcade stick";
144 case SDL_JOYSTICK_TYPE_FLIGHT_STICK:
145 typeStr =
"flight stick";
147 case SDL_JOYSTICK_TYPE_DANCE_PAD:
148 typeStr =
"dance pad";
150 case SDL_JOYSTICK_TYPE_GUITAR:
153 case SDL_JOYSTICK_TYPE_DRUM_KIT:
154 typeStr =
"drum kit";
156 case SDL_JOYSTICK_TYPE_ARCADE_PAD:
157 typeStr =
"arcade pad";
159 case SDL_JOYSTICK_TYPE_THROTTLE:
160 typeStr =
"throttle";
253 int position = SDL_JoystickGetAxis(
mJoystick, 0);
260 position = SDL_JoystickGetAxis(
mJoystick, 1);
266 #ifdef DEBUG_JOYSTICK
279 if ((
hat & SDL_HAT_RIGHT) != 0)
281 else if ((
hat & SDL_HAT_LEFT) != 0)
283 if ((
hat & SDL_HAT_UP) != 0)
285 else if ((
hat & SDL_HAT_DOWN) != 0)
292 const bool state = (SDL_JoystickGetButton(
mJoystick, i) == 1);
296 #ifdef DEBUG_JOYSTICK
322 int position = SDL_JoystickGetAxis(
mJoystick, 0);
329 position = SDL_JoystickGetAxis(
mJoystick, 1);
389 if (event.jbutton.which !=
mNumber)
391 return event.jbutton.button;
405 const int value = val.
value;
430 const int key = (*it).first;
438 int &keyTime = (*it).second;
439 if (time > keyTime && abs(time - keyTime)
440 > SDL_DEFAULT_REPEAT_DELAY * 10)
bool getValueBool(const std::string &key, const bool deflt) const
bool getBoolValue(const std::string &key) const
void setValue(const std::string &key, const std::string &value)
int getIntValue(const std::string &key) const
KeysVector * getActionVector(const SDL_Event &event)
void handleRepeat(const int time)
void setNumber(const int n)
KeysVector * getActionVectorByKey(const int i)
static void getNames(std::vector< std::string > &names)
void resetRepeat(const int key)
bool mActiveButtons[MAX_BUTTONS]
bool isActionActive(const InputActionT index) const
bool buttonPressed(const unsigned char no) const
int getButtonFromEvent(const SDL_Event &event) const
KeyToActionMap mKeyToAction
void log(const char *const log_text,...)
void log1(const char *const log_text)
KeyboardFocusT inputFocused
#define FOR_EACH(type, iter, array)
bool hat(InputEvent &event)
std::string toString(T const &value)
converts any type to a string
#define BLOCK_START(name)
#define SDL_JoystickNameForIndex
std::string strprintf(const char *const format,...)