Added gamepad rumble to rcore_desktop.c and rcore_desktop_sdl.c

Still need to add to the rest of the platforms.
This commit is contained in:
Gideon Serfontein 2024-02-23 16:13:46 +02:00
parent 23616153d4
commit e577614a04
3 changed files with 26 additions and 10 deletions

View File

@ -1050,6 +1050,12 @@ int SetGamepadMappings(const char *mappings)
return glfwUpdateGamepadMappings(mappings); return glfwUpdateGamepadMappings(mappings);
} }
// Set gamepad vibration
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float durationMs)
{
TRACELOG(LOG_WARNING, "GamepadSetVibration() not available on target platform");
}
// Set mouse position XY // Set mouse position XY
void SetMousePosition(int x, int y) void SetMousePosition(int x, int y)
{ {

View File

@ -938,6 +938,15 @@ int SetGamepadMappings(const char *mappings)
return SDL_GameControllerAddMapping(mappings); return SDL_GameControllerAddMapping(mappings);
} }
// Set gamepad vibration
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float durationMs)
{
if (IsGamepadAvailable(gamepad))
{
SDL_JoystickRumble(platform.gamepad[gamepad], (Uint16)(leftMotor*0xFFFF), (Uint16)(rightMotor*0xFFFF), durationMs);
}
}
// Set mouse position XY // Set mouse position XY
void SetMousePosition(int x, int y) void SetMousePosition(int x, int y)
{ {

View File

@ -1172,6 +1172,7 @@ RLAPI int GetGamepadButtonPressed(void); // Get the last ga
RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis
RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB) RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB)
RLAPI void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float durationMs); // Set gamepad vibration for both motors
// Input-related functions: mouse // Input-related functions: mouse
RLAPI bool IsMouseButtonPressed(int button); // Check if a mouse button has been pressed once RLAPI bool IsMouseButtonPressed(int button); // Check if a mouse button has been pressed once