Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

GUI - Controller: Fix int16_t to uint8_t cast (Fix #189) #243

Merged
merged 1 commit into from
May 30, 2020

Conversation

flplv
Copy link
Contributor

@flplv flplv commented May 25, 2020

Fixing a bad cast that was causing the L2 and R2 buttons to overflow.

Fixing a bad cast that was causing the L2 and R2 buttons to overflow.
@flplv
Copy link
Contributor Author

flplv commented May 25, 2020

Accordingly to this doc: https://wiki.libsdl.org/SDL_GameControllerGetAxis the function returns int16_t, to cast to uint8_t it is need 7 bit shifts instead of 4.

In practice you will observe L2_state to overflow as you further press the button down, making the console to interpret it as rapid L2 button press.

@thestr4ng3r thestr4ng3r changed the title GUI - Controller: Fixing int16_t to uint8_t cast GUI - Controller: Fix int16_t to uint8_t cast (Fix #189) May 30, 2020
@thestr4ng3r
Copy link
Owner

Thanks, good catch!
No idea how I came to 4.

@thestr4ng3r thestr4ng3r merged commit df8d537 into thestr4ng3r:master May 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants