sdl2 escapes keycodes to support 32bits #919
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why?
OCaml on 32bits systems, have an int size of 31 bits, but SDL keycodes are actually 32bits integers, and some of them actually uses 31 bits of the integer, like
let right = 1073741903
.One platform that suffers of this is problem is the Raspberry Pi, which by default is 32bits.
Solution
There is no SDL keycode negative, so to fix that without a breaking change we can use the negative part of our 31 bits int to fit any SDL keycode.
The only problem is that if you try to serialize big keycodes they will be different based on the platform, that is not ideal, but seems like a really small edge case and changing everything to
int32
is probably not worth it.