|
void | SDL_LockJoysticks (void) SDL_ACQUIRE(SDL_joystick_lock) |
|
void | SDL_UnlockJoysticks (void) SDL_RELEASE(SDL_joystick_lock) |
|
bool | SDL_HasJoystick (void) |
|
SDL_JoystickID * | SDL_GetJoysticks (int *count) |
|
const char * | SDL_GetJoystickNameForID (SDL_JoystickID instance_id) |
|
const char * | SDL_GetJoystickPathForID (SDL_JoystickID instance_id) |
|
int | SDL_GetJoystickPlayerIndexForID (SDL_JoystickID instance_id) |
|
SDL_GUID | SDL_GetJoystickGUIDForID (SDL_JoystickID instance_id) |
|
Uint16 | SDL_GetJoystickVendorForID (SDL_JoystickID instance_id) |
|
Uint16 | SDL_GetJoystickProductForID (SDL_JoystickID instance_id) |
|
Uint16 | SDL_GetJoystickProductVersionForID (SDL_JoystickID instance_id) |
|
SDL_JoystickType | SDL_GetJoystickTypeForID (SDL_JoystickID instance_id) |
|
SDL_Joystick * | SDL_OpenJoystick (SDL_JoystickID instance_id) |
|
SDL_Joystick * | SDL_GetJoystickFromID (SDL_JoystickID instance_id) |
|
SDL_Joystick * | SDL_GetJoystickFromPlayerIndex (int player_index) |
|
| SDL_COMPILE_TIME_ASSERT (SDL_VirtualJoystickDesc_SIZE,(sizeof(void *)==4 &&sizeof(SDL_VirtualJoystickDesc)==84)||(sizeof(void *)==8 &&sizeof(SDL_VirtualJoystickDesc)==136)) |
|
SDL_JoystickID | SDL_AttachVirtualJoystick (const SDL_VirtualJoystickDesc *desc) |
|
bool | SDL_DetachVirtualJoystick (SDL_JoystickID instance_id) |
|
bool | SDL_IsJoystickVirtual (SDL_JoystickID instance_id) |
|
bool | SDL_SetJoystickVirtualAxis (SDL_Joystick *joystick, int axis, Sint16 value) |
|
bool | SDL_SetJoystickVirtualBall (SDL_Joystick *joystick, int ball, Sint16 xrel, Sint16 yrel) |
|
bool | SDL_SetJoystickVirtualButton (SDL_Joystick *joystick, int button, bool down) |
|
bool | SDL_SetJoystickVirtualHat (SDL_Joystick *joystick, int hat, Uint8 value) |
|
bool | SDL_SetJoystickVirtualTouchpad (SDL_Joystick *joystick, int touchpad, int finger, bool down, float x, float y, float pressure) |
|
bool | SDL_SendJoystickVirtualSensorData (SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values) |
|
SDL_PropertiesID | SDL_GetJoystickProperties (SDL_Joystick *joystick) |
|
const char * | SDL_GetJoystickName (SDL_Joystick *joystick) |
|
const char * | SDL_GetJoystickPath (SDL_Joystick *joystick) |
|
int | SDL_GetJoystickPlayerIndex (SDL_Joystick *joystick) |
|
bool | SDL_SetJoystickPlayerIndex (SDL_Joystick *joystick, int player_index) |
|
SDL_GUID | SDL_GetJoystickGUID (SDL_Joystick *joystick) |
|
Uint16 | SDL_GetJoystickVendor (SDL_Joystick *joystick) |
|
Uint16 | SDL_GetJoystickProduct (SDL_Joystick *joystick) |
|
Uint16 | SDL_GetJoystickProductVersion (SDL_Joystick *joystick) |
|
Uint16 | SDL_GetJoystickFirmwareVersion (SDL_Joystick *joystick) |
|
const char * | SDL_GetJoystickSerial (SDL_Joystick *joystick) |
|
SDL_JoystickType | SDL_GetJoystickType (SDL_Joystick *joystick) |
|
void | SDL_GetJoystickGUIDInfo (SDL_GUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16) |
|
bool | SDL_JoystickConnected (SDL_Joystick *joystick) |
|
SDL_JoystickID | SDL_GetJoystickID (SDL_Joystick *joystick) |
|
int | SDL_GetNumJoystickAxes (SDL_Joystick *joystick) |
|
int | SDL_GetNumJoystickBalls (SDL_Joystick *joystick) |
|
int | SDL_GetNumJoystickHats (SDL_Joystick *joystick) |
|
int | SDL_GetNumJoystickButtons (SDL_Joystick *joystick) |
|
void | SDL_SetJoystickEventsEnabled (bool enabled) |
|
bool | SDL_JoystickEventsEnabled (void) |
|
void | SDL_UpdateJoysticks (void) |
|
Sint16 | SDL_GetJoystickAxis (SDL_Joystick *joystick, int axis) |
|
bool | SDL_GetJoystickAxisInitialState (SDL_Joystick *joystick, int axis, Sint16 *state) |
|
bool | SDL_GetJoystickBall (SDL_Joystick *joystick, int ball, int *dx, int *dy) |
|
Uint8 | SDL_GetJoystickHat (SDL_Joystick *joystick, int hat) |
|
bool | SDL_GetJoystickButton (SDL_Joystick *joystick, int button) |
|
bool | SDL_RumbleJoystick (SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) |
|
bool | SDL_RumbleJoystickTriggers (SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms) |
|
bool | SDL_SetJoystickLED (SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) |
|
bool | SDL_SendJoystickEffect (SDL_Joystick *joystick, const void *data, int size) |
|
void | SDL_CloseJoystick (SDL_Joystick *joystick) |
|
SDL_JoystickConnectionState | SDL_GetJoystickConnectionState (SDL_Joystick *joystick) |
|
SDL_PowerState | SDL_GetJoystickPowerInfo (SDL_Joystick *joystick, int *percent) |
|
CategoryJoystick
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 The joystick structure used to identify an SDL joystick.
This is opaque data.
- Since
- This struct is available since SDL 3.2.0.
Definition at line 86 of file SDL_joystick.h.
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.
If the joystick is disconnected and reconnected, it will get a new ID.
The value 0 is an invalid ID.
- Since
- This datatype is available since SDL 3.2.0.
Definition at line 98 of file SDL_joystick.h.
Get the current state of an axis control on a joystick.
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_GetJoystickAxis() 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.
- Parameters
-
joystick | an SDL_Joystick structure containing joystick information. |
axis | the axis to query; the axis indices start at index 0. |
- Returns
- a 16-bit signed integer representing the current position of the axis or 0 on failure; call SDL_GetError() for more information.
- Since
- This function is available since SDL 3.2.0.
- See also
- SDL_GetNumJoystickAxes
Start a rumble effect in the joystick's triggers.
Each call to this function cancels any previous trigger rumble effect, and calling it with 0 intensity stops any rumbling.
Note that this is rumbling of the triggers and not the game controller as a whole. This is currently only supported on Xbox One controllers. If you want the (more common) whole-controller rumble, use SDL_RumbleJoystick() instead.
This function requires you to process SDL events or call SDL_UpdateJoysticks() to update rumble state.
- Parameters
-
joystick | the joystick to vibrate. |
left_rumble | the intensity of the left trigger rumble motor, from 0 to 0xFFFF. |
right_rumble | the intensity of the right trigger rumble motor, from 0 to 0xFFFF. |
duration_ms | the duration of the rumble effect, in milliseconds. |
- Returns
- true on success or false on failure; call SDL_GetError() for more information.
- Since
- This function is available since SDL 3.2.0.
- See also
- SDL_RumbleJoystick
Send a sensor update for an opened virtual joystick.
Please note that values set here will not be applied until the next call to SDL_UpdateJoysticks, which can either be called directly, or can be called indirectly through various other SDL APIs, including, but not limited to the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, SDL_WaitEvent.
- Parameters
-
joystick | the virtual joystick on which to set state. |
type | the type of the sensor on the virtual joystick to update. |
sensor_timestamp | a 64-bit timestamp in nanoseconds associated with the sensor reading. |
data | the data associated with the sensor reading. |
num_values | the number of values pointed to by data . |
- Returns
- true on success or false on failure; call SDL_GetError() for more information.
- Since
- This function is available since SDL 3.2.0.
Set the state of an axis on an opened virtual joystick.
Please note that values set here will not be applied until the next call to SDL_UpdateJoysticks, which can either be called directly, or can be called indirectly through various other SDL APIs, including, but not limited to the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, SDL_WaitEvent.
Note that when sending trigger axes, you should scale the value to the full range of Sint16. For example, a trigger at rest would have the value of SDL_JOYSTICK_AXIS_MIN
.
- Parameters
-
joystick | the virtual joystick on which to set state. |
axis | the index of the axis on the virtual joystick to update. |
value | the new value for the specified axis. |
- Returns
- true on success or false on failure; call SDL_GetError() for more information.
- Since
- This function is available since SDL 3.2.0.
Generate ball motion on an opened virtual joystick.
Please note that values set here will not be applied until the next call to SDL_UpdateJoysticks, which can either be called directly, or can be called indirectly through various other SDL APIs, including, but not limited to the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, SDL_WaitEvent.
- Parameters
-
joystick | the virtual joystick on which to set state. |
ball | the index of the ball on the virtual joystick to update. |
xrel | the relative motion on the X axis. |
yrel | the relative motion on the Y axis. |
- Returns
- true on success or false on failure; call SDL_GetError() for more information.
- Since
- This function is available since SDL 3.2.0.
Set the state of a button on an opened virtual joystick.
Please note that values set here will not be applied until the next call to SDL_UpdateJoysticks, which can either be called directly, or can be called indirectly through various other SDL APIs, including, but not limited to the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, SDL_WaitEvent.
- Parameters
-
joystick | the virtual joystick on which to set state. |
button | the index of the button on the virtual joystick to update. |
down | true if the button is pressed, false otherwise. |
- Returns
- true on success or false on failure; call SDL_GetError() for more information.
- Since
- This function is available since SDL 3.2.0.
Set the state of a hat on an opened virtual joystick.
Please note that values set here will not be applied until the next call to SDL_UpdateJoysticks, which can either be called directly, or can be called indirectly through various other SDL APIs, including, but not limited to the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, SDL_WaitEvent.
- Parameters
-
joystick | the virtual joystick on which to set state. |
hat | the index of the hat on the virtual joystick to update. |
value | the new value for the specified hat. |
- Returns
- true on success or false on failure; call SDL_GetError() for more information.
- Since
- This function is available since SDL 3.2.0.
bool SDL_SetJoystickVirtualTouchpad |
( |
SDL_Joystick * |
joystick, |
|
|
int |
touchpad, |
|
|
int |
finger, |
|
|
bool |
down, |
|
|
float |
x, |
|
|
float |
y, |
|
|
float |
pressure |
|
) |
| |
|
extern |
Set touchpad finger state on an opened virtual joystick.
Please note that values set here will not be applied until the next call to SDL_UpdateJoysticks, which can either be called directly, or can be called indirectly through various other SDL APIs, including, but not limited to the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, SDL_WaitEvent.
- Parameters
-
joystick | the virtual joystick on which to set state. |
touchpad | the index of the touchpad on the virtual joystick to update. |
finger | the index of the finger on the touchpad to set. |
down | true if the finger is pressed, false if the finger is released. |
x | the x coordinate of the finger on the touchpad, normalized 0 to 1, with the origin in the upper left. |
y | the y coordinate of the finger on the touchpad, normalized 0 to 1, with the origin in the upper left. |
pressure | the pressure of the finger. |
- Returns
- true on success or false on failure; call SDL_GetError() for more information.
- Since
- This function is available since SDL 3.2.0.