Added MAX_GAMEPAD_VIBRATION_TIME
The rumble in SDL2 will continue for MAX_GAMEPAD_VIBRATION_TIME unless the user cancels it with a call to SetGamepadVibration(0.0f,0.0f,0.0f)
This commit is contained in:
parent
9ff3e32f7d
commit
23113818ad
|
|
@ -81,6 +81,7 @@
|
|||
#define MAX_GAMEPADS 4 // Maximum number of gamepads supported
|
||||
#define MAX_GAMEPAD_AXIS 8 // Maximum number of axis supported (per gamepad)
|
||||
#define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad)
|
||||
#define MAX_GAMEPAD_VIBRATION_TIME 2 // Maximum vibration time in seconds
|
||||
#define MAX_TOUCH_POINTS 8 // Maximum number of touch points supported
|
||||
#define MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue
|
||||
#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
|
||||
|
|
|
|||
|
|
@ -614,7 +614,7 @@ int SetGamepadMappings(const char *mappings)
|
|||
}
|
||||
|
||||
// Set gamepad vibration
|
||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float durationMs)
|
||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GamepadSetVibration() not implemented on target platform");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1051,7 +1051,7 @@ int SetGamepadMappings(const char *mappings)
|
|||
}
|
||||
|
||||
// Set gamepad vibration
|
||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float durationMs)
|
||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GamepadSetVibration() not available on target platform");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -939,11 +939,17 @@ int SetGamepadMappings(const char *mappings)
|
|||
}
|
||||
|
||||
// Set gamepad vibration
|
||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float durationMs)
|
||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor)
|
||||
{
|
||||
//Limit input values to between 0.0f and 1.0f
|
||||
leftMotor = (0.0f > leftMotor) ? 0.0f : leftMotor;
|
||||
rightMotor = (0.0f > rightMotor) ? 0.0f : rightMotor;
|
||||
leftMotor = (1.0f < leftMotor) ? 1.0f : leftMotor;
|
||||
rightMotor = (1.0f < rightMotor) ? 1.0f : rightMotor;
|
||||
|
||||
if (IsGamepadAvailable(gamepad))
|
||||
{
|
||||
SDL_JoystickRumble(platform.gamepad[gamepad], (Uint16)(leftMotor*0xFFFF), (Uint16)(rightMotor*0xFFFF), durationMs);
|
||||
SDL_JoystickRumble(platform.gamepad[gamepad], (Uint16)(leftMotor*65535.0f), (Uint16)(rightMotor*65535.0f), MAX_GAMEPAD_VIBRATION_TIME*1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -520,7 +520,7 @@ int SetGamepadMappings(const char *mappings)
|
|||
}
|
||||
|
||||
// Set gamepad vibration
|
||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float durationMs)
|
||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GamepadSetVibration() not implemented on target platform");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -851,7 +851,7 @@ int SetGamepadMappings(const char *mappings)
|
|||
}
|
||||
|
||||
// Set gamepad vibration
|
||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float durationMs)
|
||||
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GamepadSetVibration() not implemented on target platform");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1172,7 +1172,7 @@ RLAPI int GetGamepadButtonPressed(void);
|
|||
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 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
|
||||
RLAPI void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor); // Set gamepad vibration for both motors
|
||||
|
||||
// Input-related functions: mouse
|
||||
RLAPI bool IsMouseButtonPressed(int button); // Check if a mouse button has been pressed once
|
||||
|
|
|
|||
|
|
@ -224,6 +224,9 @@ __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigne
|
|||
#ifndef MAX_GAMEPAD_BUTTONS
|
||||
#define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad)
|
||||
#endif
|
||||
#ifndef MAX_GAMEPAD_BUTTONS
|
||||
#define MAX_GAMEPAD_VIBRATION_TIME 2.0f // Maximum vibration time in seconds
|
||||
#endif
|
||||
#ifndef MAX_TOUCH_POINTS
|
||||
#define MAX_TOUCH_POINTS 8 // Maximum number of touch points supported
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user