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_drm] Adding support for more than one keyboard/mouse #4631

Open
4 tasks done
jwaxy opened this issue Dec 22, 2024 · 2 comments
Open
4 tasks done

[rcore_drm] Adding support for more than one keyboard/mouse #4631

jwaxy opened this issue Dec 22, 2024 · 2 comments

Comments

@jwaxy
Copy link

jwaxy commented Dec 22, 2024

Please, before submitting a new issue verify and check:

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

Issue description

First of all, thank you for creating and maintaining raylib—it's an amazing library that makes graphics programming fun and accessible!

While working on a project using raylib with the DRM backend (PLATFORM=DRM), I noticed that the DRM backend currently supports:

  • Only 1 mouse
  • Only 1 keyboard
  • A limited, configurable number of gamepads (default: 4).

To address this, I myself implemented dynamic support for multiple mouse and keyboard devices in a custom Raylib source. My approach involved:

  • Making mouseFd and keyboardFd pointers to dynamically allocated arrays.
  • Using RL_REALLOC to adjust the array size as new devices are configured.

I would like to clarify if the current limitation on device counts is intentional or simply a design decision. Additionally, I’m considering creating a pull request for this enhancement and would like feedback on whether it would be desirable. Specifically:

  • Should I implement this dynamic support for all devices (mouse, keyboard, gamepads)?
  • Or should I implement fixed, configurable amount for mouse and keyboard like gamepads are implemented
  • Are there specific concerns or guidelines I should be aware of?

Environment

Operating System: Arch Linux
Platform Backend: DRM
Other details are likely not relevant to this issue but can be provided if necessary.

@asdqwe
Copy link
Contributor

asdqwe commented Dec 22, 2024

In my opinion (and as far as I known), the limitation is probably a combination of lack of need (niche use case) and lack of backend support: GLFW (the default backend) doesn't support it (ref, ref, ref). SDL2 doesn't support it for keyboard (ref), just for mouse (ref). SDL3 does support it (ref, ref). The web API doesn't support it (ref, ref).

Regarding the PR, this change would cause a disparity between platforms and a breaking change (side note: raylib tries to avoid pointers, unless absolutely necessary, to keep the library easy and accessible for learning/new users). I'd suggest waiting for @raysan5 reply before spending the time drafting it.

@jwaxy
Copy link
Author

jwaxy commented Dec 22, 2024

I'm sure that GLFW does support multiple mouse and keyboard, it just can't distinguish them, this what your ref's say. Maybe there was a misunderstanding. I didn't ask for support to distinguish which mouse or keyboard is being used, the DRM backend polls only the last device it finds for each category (mouse, keyboard) except the gamepads which have a limited but configurable amount. And I wanted to know if this is intentional or should be changed. And regarding pointers they will only be used internally when polling so it won't change any APIs.

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