This is new wiki software and old wiki content. It's a work in progress!
Here's the explanation.
Be gentle, report bugs, leave feedback on pages, or just edit them yourself! Thanks!

SDL Wiki

Draft

THIS PAGE IS A WORK IN PROGRESS ... Please make edits to this page to improve it!

SDL_JoystickGetAxis

Get the current state of an axis control on a joystick.

Syntax

Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick,
                           int axis);

Function Parameters

joystick

an SDL_Joystick structure containing joystick information

axis

the axis to query; the axis indices start at index 0

Return Value

Returns a 16-bit signed integer representing the current position of the axis or 0 on failure; call SDL_GetError() for more information.

Remarks

SDL makes no promises about what part of the joystick any given axis refers to. Your game should have some sort of configuration UI to let users specify what each axis should be bound to. Alternately, SDL's higher-level Game Controller API makes a great effort to apply order to this lower-level interface, so you know that a specific axis is the "left thumb stick," etc.

The value returned by SDL_JoystickGetAxis() is a signed integer (-32768 to 32767) representing the current position of the axis. It may be necessary to impose certain tolerances on these values to account for jitter.

Code Examples

extern SDL_Joystick* joy1;
Sint16 x_move, y_move;

x_move = SDL_JoystickGetAxis(joy1, 0);
y_move = SDL_JoystickGetAxis(joy1, 1);
SDL_JoystickNumAxes

CategoryAPI, CategoryJoystick, CategoryDraft


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.