Joystick

SDL Library Documentation
Prev |  | Next

# Chapter 9. Joystick

Joysticks, and other similar input devices, have a very strong role in game playing and SDL provides comprehensive support for them. Axes, Buttons, POV Hats and trackballs are all supported.

Joystick support is initialized by passed the `SDL_INIT_JOYSTICK` flag to `SDL_Init`. Once initilized joysticks must be opened using `SDL_JoystickOpen`.

While using the functions describe in this secton may seem like the best way to access and read from joysticks, in most cases they aren't. Ideally joysticks should be read using the event system. To enable this, you must set the joystick event processing state with `SDL_JoystickEventState`. Joysticks must be opened before they can be used of course.

> Note: If you are not handling the joystick via the event queue then you must explicitly request a joystick update by calling `SDL_JoystickUpdate`.

> Note: Force Feedback is not yet support. Sam (slouken@libsdl.org) is soliciting suggestions from people with force-feedback experience on the best wat to desgin the API.

Prev | Home | Next
SDL_JoystickEventState | Up | SDL_NumJoysticks