mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-25 14:09:10 +00:00
Added API for sensors on game controllers
Added support for the PS4 controller gyro and accelerometer on iOS and HIDAPI drivers Also fixed an issue with the accelerometer on iOS having inverted axes
This commit is contained in:
parent
b79e1baa36
commit
fcb21aa883
33 changed files with 810 additions and 118 deletions
|
@ -304,7 +304,7 @@ EMSCRIPTEN_JoystickGetDeviceInstanceID(int device_index)
|
|||
It returns 0, or -1 if there is an error.
|
||||
*/
|
||||
static int
|
||||
EMSCRIPTEN_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||
EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
{
|
||||
SDL_joylist_item *item = JoystickByDeviceIndex(device_index);
|
||||
|
||||
|
@ -336,7 +336,7 @@ EMSCRIPTEN_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
* and update joystick device state.
|
||||
*/
|
||||
static void
|
||||
EMSCRIPTEN_JoystickUpdate(SDL_Joystick * joystick)
|
||||
EMSCRIPTEN_JoystickUpdate(SDL_Joystick *joystick)
|
||||
{
|
||||
EmscriptenGamepadEvent gamepadState;
|
||||
SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
|
||||
|
@ -378,7 +378,7 @@ EMSCRIPTEN_JoystickUpdate(SDL_Joystick * joystick)
|
|||
|
||||
/* Function to close a joystick after use */
|
||||
static void
|
||||
EMSCRIPTEN_JoystickClose(SDL_Joystick * joystick)
|
||||
EMSCRIPTEN_JoystickClose(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
|
||||
if (item) {
|
||||
|
@ -398,13 +398,13 @@ EMSCRIPTEN_JoystickGetDeviceGUID(int device_index)
|
|||
}
|
||||
|
||||
static int
|
||||
EMSCRIPTEN_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
|
||||
EMSCRIPTEN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static int
|
||||
EMSCRIPTEN_JoystickRumbleTriggers(SDL_Joystick * joystick, Uint16 left_rumble, Uint16 right_rumble)
|
||||
EMSCRIPTEN_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
@ -416,13 +416,19 @@ EMSCRIPTEN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
|||
}
|
||||
|
||||
static SDL_bool
|
||||
EMSCRIPTEN_JoystickHasLED(SDL_Joystick * joystick)
|
||||
EMSCRIPTEN_JoystickHasLED(SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
EMSCRIPTEN_JoystickSetLED(SDL_Joystick * joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
EMSCRIPTEN_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static int
|
||||
EMSCRIPTEN_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
@ -442,6 +448,7 @@ SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver =
|
|||
EMSCRIPTEN_JoystickRumbleTriggers,
|
||||
EMSCRIPTEN_JoystickHasLED,
|
||||
EMSCRIPTEN_JoystickSetLED,
|
||||
EMSCRIPTEN_JoystickSetSensorsEnabled,
|
||||
EMSCRIPTEN_JoystickUpdate,
|
||||
EMSCRIPTEN_JoystickClose,
|
||||
EMSCRIPTEN_JoystickQuit,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue