Fix non-ASCII keyboard input#3199
Merged
LeftofZen merged 8 commits intoOpenLoco:masterfrom Aug 19, 2025
Merged
Conversation
Contributor
Author
Contributor
Author
src/OpenLoco/src/Input/Keyboard.cpp
Outdated
| } | ||
|
|
||
| uint32_t index = _keyQueueLastWrite; | ||
| _keyQueue[index].charCode = Localisation::convertUnicodeToLoco(Localisation::readCodePoint((unsigned char**)&text)); |
Contributor
There was a problem hiding this comment.
we don't use c style casts in this code base. readCodePoint should be taking a const utf8_t** (but its not so please correct that) so that this call becomes readCodePoint(static_cast<utf8_t**>(&text))
Contributor
Author
There was a problem hiding this comment.
static_cast does not work here, I think because of the conversion from signed to unsigned. Using reinterpret_cast works, but I decided to still use unsigned char in my new changes, as I am not sure if it would be best practise to reinterpret directly to utf8_t? Thank you for your patience.
src/OpenLoco/src/Input/Keyboard.cpp
Outdated
| } | ||
|
|
||
| uint32_t index = _keyQueueLastWrite; | ||
| auto unsignedText = reinterpret_cast<const unsigned char*>(text); |
Contributor
There was a problem hiding this comment.
can you at least use uint8_t instead of unsigned char since that is what we use throughout the codebase.
duncanspumpkin
approved these changes
Aug 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Fixes #3198
It feels kind of stupid, both to be using a module named localization here,
as well as the crazy cast,but it works.Previously the behaviour was bugged such that
äwould become{keyCode=228 charCode=4294967235}instead of{keyCode=228 charCode=228}.