Expand description
Module for SDL joystick event handling.
The term device_index
identifies currently plugged in joystick devices
between 0 and SDL_NumJoysticks(), with the exact joystick behind a
device_index changing as joysticks are plugged and unplugged.
The term instance_id
is the current instantiation of a joystick device in
the system, if the joystick is removed and then re-inserted then it will get
a new instance_id, instance_id’s are monotonically increasing identifiers of
a joystick plugged in.
The term JoystickGUID
is a stable 128-bit identifier for a joystick device
that does not change over time, it identifies class of the device (a X360
wired controller for example). This identifier is platform dependent.
In order to use these functions, SDL_Init
must have been called
with the SDL_INIT_JOYSTICK
flag. This causes SDL to scan the system
for joysticks, and load appropriate drivers.
If you would like to receive joystick updates while the application
is in the background, you should set the
SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
hint before calling
SDL_Init
.
See Also: gamecontroller
Structs
- The
SDL_Joystick
type is an opaque structure. - A structure that encodes the stable unique id for a joystick device.
- This is a unique ID for a joystick for the time it is connected to the system.
- The power level of a joystick.
- The general physical category of a joystick device.
Constants
- Set max recognized G-force from accelerometer.
- A joystick axis uses the
i16
range, so this is justi16::MAX
- A joystick axis uses the
i16
range, so this is justi16::MIN
- <= 5%
- <= 100%
- <= 20%
- Honestly, this particular constant is probably pointless.
- <= 70%
- The power level is unknown.
- This joystick is wired to the rest of the system.
Functions
- Attaches a new virtual joystick.
- Close a joystick previously opened with
SDL_JoystickOpen
. - Return the battery level of this joystick.
- Enable/disable joystick event polling.
- Return the SDL_Joystick associated with an instance id.
- Return the SDL_Joystick associated with a player index.
- Returns
SDL_TRUE
if the joystick has been opened and it is currently connected, orSDL_FALSE
if it has not. - Get the current state of an axis control on a joystick.
- Get the initial state of an axis control on a joystick.
- Get the ball axis change since the last poll.
- Get the current state of a button on a joystick.
- Return the GUID for the joystick at this index.
- Get the instance ID of a joystick.
- Get the player index of a joystick, or -1 if it’s not available.
- Get the USB product ID of a joystick, if available.
- Get the product version of a joystick, if available.
- Get the type of a joystick, if available.
- Get the USB vendor ID of a joystick, if available.
- Return the GUID for this opened joystick.
- Convert a string into a joystick guid
- Return a string representation for this guid.
- Get the current state of a POV hat on a joystick.
- Get the player index of an opened joystick, or -1 if it’s not available.
- Get the USB product ID of an opened joystick, if available.
- Get the product version of an opened joystick, if available.
- Get the serial number of an opened joystick, if available.
- Get the type of an opened joystick.
- Get the USB vendor ID of an opened joystick, if available.
- Return whether a joystick has an LED
- Get the instance ID of an opened joystick or -1 if the joystick is invalid.
- Indicates whether or not a virtual-joystick is at a given device index.
- Return the name for this currently opened joystick.
- Get the implementation dependent name of a joystick.
- Get the number of general axis controls on a joystick.
- Get the number of trackballs on a joystick.
- Get the number of buttons on a joystick.
- Get the number of POV hats on a joystick.
- Open a joystick for use.
- Start a rumble effect.
- Start a rumble effect in the joystick’s triggers
- Update a joystick’s LED color.
- Set the player index of an opened joystick.
- Set values on an opened, virtual-joystick’s controls.
- Set values on an opened, virtual-joystick’s controls.
- Set values on an opened, virtual-joystick’s controls.
- Update the current state of the open joysticks.
- Locking for multi-threaded access to the joystick API
- Count the number of joysticks attached to the system right now