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

Feature request: support NumPad keys for cursor navigation #245

Closed
data-man opened this issue Sep 19, 2024 · 4 comments
Closed

Feature request: support NumPad keys for cursor navigation #245

data-man opened this issue Sep 19, 2024 · 4 comments

Comments

@data-man
Copy link

They aren't work with SDL2 or SFML at least.
Thank you for the cool project!

@texus
Copy link
Owner

texus commented Sep 19, 2024

I'll have a look if this can be easily added.
I can move the cursor on the key press, but I also get that event when the Num Lock is on. So I will probably need to check if I can somehow detect whether Num Lock is on or not to properly handle this.

@texus
Copy link
Owner

texus commented Sep 19, 2024

This functionality will have to be implemented per backend. I've done some research and only SDL and GLFW seem to currently allow me to get the num lock state.

SDL
SDL_GetModState() can be used to get the state of the Num Lock key.
Prior to SDL 2.0.22 the KMOD_NUM state might not have been correct on Linux though. So I might limit support for using numpad cursor navigation to newer SDL versions.

GLFW
As of GLFW 3.3 the num lock state is part of the modifiers, but only if you manually call glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, GLFW_TRUE); first. I'll probably call this myself when creating the gui.

SFML
There is currently no way to get the Num Lock state. (Update: SFML/SFML#3238 would add support)
Since this is the most used backend, I'll probably still have a look at how to get the state directly through the Windows API and try to add it as a Windows-only feature. (I don't want to do this for Linux because it requires linking to X11 and I was just happy that I finally got rid of that dependency)

Raylib
I don't see a way to get the num lock state.
IsKeyDown(KEY_NUM_LOCK) returns 0 even when starting with the Num Lock on, but then it permanently becomes 1 once I toggle Num Lock once (the value stays 1 even after toggling more).

@texus
Copy link
Owner

texus commented Sep 30, 2024

This has been added to the SDL and GLFW backends.

The code for the SFML backend has already been written and will be enabled later when support for reading the Num Lock state is merged in SFML 3.

@data-man
Copy link
Author

Thank you!

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

No branches or pull requests

2 participants