mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-01-10 00:34:32 +00:00
Add I_GamepadRumble, I_GamepadRumbleTriggers
This commit is contained in:
parent
37e7b82b8b
commit
769ce2ef65
2 changed files with 42 additions and 0 deletions
|
|
@ -62,6 +62,8 @@ void I_SetGamepadPlayerIndex(INT32 device_id, INT32 index);
|
|||
void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue);
|
||||
void I_GetGamepadGuid(INT32 device_id, char *out, int out_len);
|
||||
void I_GetGamepadName(INT32 device_id, char *out, int out_len);
|
||||
void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength);
|
||||
void I_GamepadRumbleTriggers(INT32 device_id, UINT16 left_strength, UINT16 right_strength);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
|||
|
|
@ -1019,6 +1019,46 @@ void I_GetGamepadName(INT32 device_id, char *out, int out_len)
|
|||
out[out_len - 1] = 0;
|
||||
}
|
||||
|
||||
void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength)
|
||||
{
|
||||
#if !(SDL_VERSION_ATLEAST(2,0,9))
|
||||
(void)device_id;
|
||||
(void)low_strength;
|
||||
(void)high_strength;
|
||||
(void)length_ms;
|
||||
#else
|
||||
I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher
|
||||
|
||||
SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1);
|
||||
if (controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_GameControllerRumble(controller, low_strength, high_strength, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void I_GamepadRumbleTriggers(INT32 device_id, UINT16 left_strength, UINT16 right_strength)
|
||||
{
|
||||
#if !(SDL_VERSION_ATLEAST(2,0,14))
|
||||
(void)device_id;
|
||||
(void)low_strength;
|
||||
(void)high_strength;
|
||||
(void)length_ms;
|
||||
#else
|
||||
I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher
|
||||
|
||||
SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1);
|
||||
if (controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_GameControllerRumbleTriggers(controller, left_strength, right_strength, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// I_StartupInput
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue