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] Add basic support for scancodes #4481

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

JeffM2501
Copy link
Contributor

Currently raylib does not expose the scancode data for keyboard input received from the platform. This makes it VERY hard to build keyboard bindings that work with different keyboard mappings and localizations. They KeyboardKey enum is just the physical keys and does not take the keyboard mapping into account. For most game input this is fine, as you want the physical key, but there are use cases where you need local mapping of non-text keys.

GetCharPressed handles the mapping, but only for printable characters.

Any user that wants the 'logical' key that is provided by the keyboard mapping as no way to get this data.
The data was passed to the keyboard input functions of most platforms, but the raylib key system has no place to store it.
In SDL this scancode is the 'virtual key'

This PR adds GetKeyPressedPro that takes an optional scancode to fill out, allowing people to see the localized key for each event.
Platforms that don't provide a scancode set the code to -1.

I don't know if this should go into 5.5 or if we should discuss the API for the future. This is just the smallest possible change to raylib to expose the data that it's currently ignoring. I am just posting this so it doesn't get lost.

@raysan5
Copy link
Owner

raysan5 commented Nov 11, 2024

@JeffM2501 I see the issue but I want to review this change more carefully, waiting after 5.5 release for further discussion.

@JeffM2501
Copy link
Contributor Author

@JeffM2501 I see the issue but I want to review this change more carefully, waiting after 5.5 release for further discussion.

Absolutely understandable

@raysan5 raysan5 changed the title [rInput] Add basic support for scancodes [rcore] Add basic support for scancodes Nov 16, 2024
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