Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcore] fix gamepad axis movement and its automation event recording #4184

Merged
merged 2 commits into from
Jul 28, 2024

Conversation

maxmutant
Copy link
Contributor

While working with Automation Events, I recognized that my gamepad input was not recorded correctly. Negative axis movements (e.g. stick going left/up) weren't recorded at all.

Furthermore, GetGamepadAxisMovement seems to snap trigger axis values to 0.0 if they are in the region [-0.1, 0.1]. I think the delta/drift check was intended to ignore values in between the range [-1.0, -0.9] instead (since -1.0 is the default state for triggers).

This PR addresses both of these issues.

Remark:
With my changes GetGamepadAxisMovement always returns the default value for each axis, even if a gamepad is not attached. This makes more sense in my opinion, but it is a behavior change for triggers.
Please let me know if you don't want that, and I'll change it back to always return 0.0 if the gamepad isn't available.

src/rcore.c Outdated Show resolved Hide resolved
This commit fixes 2 issues:
- Automation events aren't recorded for negative axis movements on
  gamepads (e.g. stick going left/up)
- 'GetGamepadAxisMovement' drift check isn't working correctly for
  triggers. Axis values between [-0.1, 0.1] are clamped to 0.0

Behaviour change:
- 'GetGamepadAxisMovement' returns default value for each axis, even
  if gamepad isn't attached.
@maxmutant maxmutant force-pushed the fix/ae_record_gamepad_negative_axis branch from 486795d to 675a072 Compare July 28, 2024 20:00
@raysan5 raysan5 merged commit 9e39788 into raysan5:master Jul 28, 2024
@raysan5
Copy link
Owner

raysan5 commented Jul 28, 2024

@maxmutant Thanks for the improvement! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants