Module joystick
dep_sdl3
only.Expand description
SDL joystick support.
This is the lower-level joystick handling. If you want the simpler option, where what each button does is well-defined, you should use the gamepad API instead.
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 “player_index” is the number assigned to a player on a specific controller. For XInput controllers this returns the XInput user index. Many joysticks will not be able to supply this information.
SDL_GUID
is used as 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 following hint before calling
[SDL_Init()
]: [SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
]
Structs§
- SDL_
Joystick - The joystick structure used to identify an SDL joystick.
- SDL_
Joystick Connection State - Possible connection states for a joystick device.
- SDL_
Joystick Type - An enum of some common joystick types.
- SDL_
Virtual Joystick Desc - The structure that describes a virtual joystick.
- SDL_
Virtual Joystick Sensor Desc - The structure that describes a virtual joystick sensor.
- SDL_
Virtual Joystick Touchpad Desc - The structure that describes a virtual joystick touchpad.
Constants§
- SDL_
HAT_ CENTERED - SDL_
HAT_ DOWN - SDL_
HAT_ LEFT - SDL_
HAT_ LEFTDOWN - SDL_
HAT_ LEFTUP - SDL_
HAT_ RIGHT - SDL_
HAT_ RIGHTDOWN - SDL_
HAT_ RIGHTUP - SDL_
HAT_ UP - SDL_
JOYSTICK_ AXIS_ MAX - The largest value an SDL_Joystick’s axis can report.
- SDL_
JOYSTICK_ AXIS_ MIN - The smallest value an SDL_Joystick’s axis can report.
- SDL_
JOYSTICK_ CONNECTION_ INVALID - SDL_
JOYSTICK_ CONNECTION_ UNKNOWN - SDL_
JOYSTICK_ CONNECTION_ WIRED - SDL_
JOYSTICK_ CONNECTION_ WIRELESS - SDL_
JOYSTICK_ TYPE_ ARCADE_ PAD - SDL_
JOYSTICK_ TYPE_ ARCADE_ STICK - SDL_
JOYSTICK_ TYPE_ COUNT - SDL_
JOYSTICK_ TYPE_ DANCE_ PAD - SDL_
JOYSTICK_ TYPE_ DRUM_ KIT - SDL_
JOYSTICK_ TYPE_ FLIGHT_ STICK - SDL_
JOYSTICK_ TYPE_ GAMEPAD - SDL_
JOYSTICK_ TYPE_ GUITAR - SDL_
JOYSTICK_ TYPE_ THROTTLE - SDL_
JOYSTICK_ TYPE_ UNKNOWN - SDL_
JOYSTICK_ TYPE_ WHEEL - SDL_
PROP_ JOYSTICK_ CAP_ MONO_ LED_ BOOLEAN - SDL_
PROP_ JOYSTICK_ CAP_ PLAYER_ LED_ BOOLEAN - SDL_
PROP_ JOYSTICK_ CAP_ RGB_ LED_ BOOLEAN - SDL_
PROP_ JOYSTICK_ CAP_ RUMBLE_ BOOLEAN - SDL_
PROP_ JOYSTICK_ CAP_ TRIGGER_ RUMBLE_ BOOLEAN
Functions§
- SDL_
Attach ⚠Virtual Joystick - Attach a new virtual joystick.
- SDL_
Close ⚠Joystick - Close a joystick previously opened with
SDL_OpenJoystick()
. - SDL_
Detach ⚠Virtual Joystick - Detach a virtual joystick.
- SDL_
GetJoystick ⚠Axis - Get the current state of an axis control on a joystick.
- SDL_
GetJoystick ⚠Axis Initial State - Get the initial state of an axis control on a joystick.
- SDL_
GetJoystick ⚠Ball - Get the ball axis change since the last poll.
- SDL_
GetJoystick ⚠Button - Get the current state of a button on a joystick.
- SDL_
GetJoystick ⚠Connection State - Get the connection state of a joystick.
- SDL_
GetJoystick ⚠Firmware Version - Get the firmware version of an opened joystick, if available.
- SDL_
GetJoystick ⚠FromID - Get the
SDL_Joystick
associated with an instance ID, if it has been opened. - SDL_
GetJoystick ⚠From Player Index - Get the
SDL_Joystick
associated with a player index. - SDL_
GetJoystickGUID ⚠ - Get the implementation-dependent GUID for the joystick.
- SDL_
GetJoystickGUID ⚠ForID - Get the implementation-dependent GUID of a joystick.
- SDL_
GetJoystickGUID ⚠Info - Get the device information encoded in a
SDL_GUID
structure. - SDL_
GetJoystick ⚠Hat - Get the current state of a POV hat on a joystick.
- SDL_
GetJoystickID ⚠ - Get the instance ID of an opened joystick.
- SDL_
GetJoystick ⚠Name - Get the implementation dependent name of a joystick.
- SDL_
GetJoystick ⚠Name ForID - Get the implementation dependent name of a joystick.
- SDL_
GetJoystick ⚠Path - Get the implementation dependent path of a joystick.
- SDL_
GetJoystick ⚠Path ForID - Get the implementation dependent path of a joystick.
- SDL_
GetJoystick ⚠Player Index - Get the player index of an opened joystick.
- SDL_
GetJoystick ⚠Player Index ForID - Get the player index of a joystick.
- SDL_
GetJoystick ⚠Power Info - Get the battery state of a joystick.
- SDL_
GetJoystick ⚠Product - Get the USB product ID of an opened joystick, if available.
- SDL_
GetJoystick ⚠Product ForID - Get the USB product ID of a joystick, if available.
- SDL_
GetJoystick ⚠Product Version - Get the product version of an opened joystick, if available.
- SDL_
GetJoystick ⚠Product Version ForID - Get the product version of a joystick, if available.
- SDL_
GetJoystick ⚠Properties - Get the properties associated with a joystick.
- SDL_
GetJoystick ⚠Serial - Get the serial number of an opened joystick, if available.
- SDL_
GetJoystick ⚠Type - Get the type of an opened joystick.
- SDL_
GetJoystick ⚠Type ForID - Get the type of a joystick, if available.
- SDL_
GetJoystick ⚠Vendor - Get the USB vendor ID of an opened joystick, if available.
- SDL_
GetJoystick ⚠Vendor ForID - Get the USB vendor ID of a joystick, if available.
- SDL_
GetJoysticks ⚠ - Get a list of currently connected joysticks.
- SDL_
GetNum ⚠Joystick Axes - Get the number of general axis controls on a joystick.
- SDL_
GetNum ⚠Joystick Balls - Get the number of trackballs on a joystick.
- SDL_
GetNum ⚠Joystick Buttons - Get the number of buttons on a joystick.
- SDL_
GetNum ⚠Joystick Hats - Get the number of POV hats on a joystick.
- SDL_
HasJoystick ⚠ - Return whether a joystick is currently connected.
- SDL_
IsJoystick ⚠Virtual - Query whether or not a joystick is virtual.
- SDL_
Joystick ⚠Connected - Get the status of a specified joystick.
- SDL_
Joystick ⚠Events Enabled - Query the state of joystick event processing.
- SDL_
Lock ⚠Joysticks - Locking for atomic access to the joystick API.
- SDL_
Open ⚠Joystick - Open a joystick for use.
- SDL_
Rumble ⚠Joystick - Start a rumble effect.
- SDL_
Rumble ⚠Joystick Triggers - Start a rumble effect in the joystick’s triggers.
- SDL_
Send ⚠Joystick Effect - Send a joystick specific effect packet.
- SDL_
Send ⚠Joystick Virtual Sensor Data - Send a sensor update for an opened virtual joystick.
- SDL_
SetJoystick ⚠Events Enabled - Set the state of joystick event processing.
- SDL_
SetJoystickLED ⚠ - Update a joystick’s LED color.
- SDL_
SetJoystick ⚠Player Index - Set the player index of an opened joystick.
- SDL_
SetJoystick ⚠Virtual Axis - Set the state of an axis on an opened virtual joystick.
- SDL_
SetJoystick ⚠Virtual Ball - Generate ball motion on an opened virtual joystick.
- SDL_
SetJoystick ⚠Virtual Button - Set the state of a button on an opened virtual joystick.
- SDL_
SetJoystick ⚠Virtual Hat - Set the state of a hat on an opened virtual joystick.
- SDL_
SetJoystick ⚠Virtual Touchpad - Set touchpad finger state on an opened virtual joystick.
- SDL_
Unlock ⚠Joysticks - Unlocking for atomic access to the joystick API.
- SDL_
Update ⚠Joysticks - Update the current state of the open joysticks.
Type Aliases§
- SDL_
JoystickID - This is a unique ID for a joystick for the time it is connected to the system, and is never reused for the lifetime of the application.