Fix #4405 at runtime
This commit is contained in:
parent
4cd243f0a3
commit
85b90d8816
|
|
@ -1185,6 +1185,7 @@ RLAPI int GetGamepadAxisCount(int 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 duration); // Set gamepad vibration for both motors (duration in seconds)
|
||||
RLAPI void SetGamepadDeadzone(float deadzone); // Set gamepad global deadzone
|
||||
|
||||
// Input-related functions: mouse
|
||||
RLAPI bool IsMouseButtonPressed(int button); // Check if a mouse button has been pressed once
|
||||
|
|
|
|||
10
src/rcore.c
10
src/rcore.c
|
|
@ -349,6 +349,7 @@ typedef struct CoreData {
|
|||
char currentButtonState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Current gamepad buttons state
|
||||
char previousButtonState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Previous gamepad buttons state
|
||||
float axisState[MAX_GAMEPADS][MAX_GAMEPAD_AXIS]; // Gamepad axis state
|
||||
float globalDeadzone; // Global gamepad axis deadzone
|
||||
|
||||
} Gamepad;
|
||||
} Input;
|
||||
|
|
@ -642,6 +643,7 @@ void InitWindow(int width, int height, const char *title)
|
|||
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
|
||||
CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW;
|
||||
CORE.Input.Gamepad.lastButtonPressed = GAMEPAD_BUTTON_UNKNOWN;
|
||||
CORE.Input.Gamepad.globalDeadzone = 0.1f;
|
||||
|
||||
// Initialize platform
|
||||
//--------------------------------------------------------------
|
||||
|
|
@ -3296,12 +3298,18 @@ float GetGamepadAxisMovement(int gamepad, int axis)
|
|||
float movement = value < 0.0f ? CORE.Input.Gamepad.axisState[gamepad][axis] : fabsf(CORE.Input.Gamepad.axisState[gamepad][axis]);
|
||||
|
||||
// 0.1f = GAMEPAD_AXIS_MINIMUM_DRIFT/DELTA
|
||||
if (movement > value + 0.1f) value = CORE.Input.Gamepad.axisState[gamepad][axis];
|
||||
if (movement > value + CORE.Input.Gamepad.globalDeadzone) value = CORE.Input.Gamepad.axisState[gamepad][axis];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// Set gamepad global deadzone
|
||||
void SetGamepadDeadzone(float deadzone)
|
||||
{
|
||||
CORE.Input.Gamepad.globalDeadzone = deadzone;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition: Input Handling: Mouse
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user