33static SDL_Joystick*
stick =
nullptr;
74 unsigned int axes = 0;
75 unsigned int hats = 0;
92 int total = SDL_JoystickNumBalls(
stick);
96 for (
int i = 0;
i < total;
i++) {
99 SDL_JoystickGetBall(
stick,
i, &dx, &dy);
103 if (balldx || balldy) {
110 total = SDL_JoystickNumButtons(
stick);
114 for (
int i = 0;
i < total;
i++) {
115 const bool pressed = (SDL_JoystickGetButton(
stick,
i) != 0);
124 total = SDL_JoystickNumHats(
stick);
128 for (
int i = 0;
i < total;
i++)
129 ((Uint8 *)&hats)[
i] = SDL_JoystickGetHat(
stick,
i);
134 for (
int i = 0;
i < 4;
i++) {
135 if (((Uint8 *)&hats)[
i] != ((Uint8 *)&
stick_state.oldhats)[
i]) {
150 case SDL_HAT_RIGHTUP:
154 case SDL_HAT_RIGHTDOWN:
162 case SDL_HAT_LEFTDOWN:
170 switch (((Uint8 *)&hats)[
i]) {
183 case SDL_HAT_RIGHTUP:
187 case SDL_HAT_RIGHTDOWN:
195 case SDL_HAT_LEFTDOWN:
210 total = SDL_JoystickNumAxes(
stick);
213 for (
int i = 0;
i < 2;
i++) {
214 const Sint16 axis = SDL_JoystickGetAxis(
stick,
i);
215 const float velocity = ((float) axis) / 32767.0f;
240 for (
int i = 2;
i < total;
i++) {
241 const Sint16 axis = SDL_JoystickGetAxis(
stick,
i);
242 const float f = ((float) axis) / 32767.0f;
244 axes |= (1 << (
i * 2));
246 axes |= (1 << ((
i * 2) + 1));
254 for (
int i = 2;
i < 16;
i++) {
272 uiNode_t* joystickOptions =
nullptr;
273 const int total = SDL_NumJoysticks();
278 for (
int i = 0;
i < total;
i++)
279 UI_AddOption(&joystickOptions,
"", SDL_JoystickNameForIndex(
i),
va(
"%i",
i));
294 if (
stick !=
nullptr) {
295 Com_Printf(
"... closing already initialized joystick\n");
296 SDL_JoystickClose(
stick);
302 if (!SDL_WasInit(SDL_INIT_JOYSTICK)) {
304 if (SDL_Init(SDL_INIT_JOYSTICK) == -1) {
311 int total = SDL_NumJoysticks();
313 for (
int i = 0;
i < total;
i++)
322 if (
stick ==
nullptr) {
334 SDL_JoystickEventState(SDL_QUERY);
static cvar_t * in_joystick
static cvar_t * in_joystickSpeed
static cvar_t * in_joystickNo
void IN_StartupJoystick(void)
Init available joysticks.
void IN_JoystickMove(void)
static const int hat_keys[16]
static SDL_Joystick * stick
static struct @224014336222201121242030200310257117217277365276 stick_state
static cvar_t * in_joystickThreshold
void IN_JoystickInitMenu(void)
Adds joysticks to the options menu.
static const int joy_keys[16]
Primary header for client.
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
void Com_Printf(const char *const fmt,...)
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Atomic structure used to define most of the UI.
void UI_RegisterOption(int dataId, uiNode_t *option)
uiNode_t * UI_AddOption(uiNode_t **tree, const char *name, const char *label, const char *value)
Append an option to an option list.