-
Notifications
You must be signed in to change notification settings - Fork 922
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
Tracking Issue: Gamepad support and device events overhaul #944
Comments
Mentoring InstructionsAt a high level, there are two steps to implementing this:
Completing the first step will involve stubbing out the The second step is a bit more tricky, since it involves directly messing with the platform-specific APIs. MacOS and iOS can probably share a significant amount of code for this, since it looks like they use the same APIs for controller input. Similarly, Wayland and X11 can probably both use the evdev API (official page arch linux on Gamepads), but I'm not 100% certain on that. @vberger can confirm or deny that, and give more detailed mentoring instructions on Wayland if he deems necessary. Enumerating DevicesI've added APIs for enumerating attached
|
I imagine cross-platform rumble is also desired? I don't remember if that was discussed before. |
@francesca64 Yep! That's been implemented on Windows, and is exposed here. |
@Osspial right, but it's only implemented for XInput. The comment I left in for RAWINPUT isn't very helpful, and I learned more after that but never documented my findings. So, the reality is that XInput is probably the only API that directly exposes rumble to you. Otherwise, you have to go through the platform's low-level HID API and send some device-specific values to the device. The data you send to the device is going to be the same on every platform, so it's not as scary as it sounds. Chromium's source code is probably the best resource for both finding this info and for finding a reasonable range of devices to support. For instance, here's what you'd generate for the DS4 controller: https://chromium.googlesource.com/chromium/src/+/lkgr/device/gamepad/dualshock4_controller_base.cc#47 - and then From looking at the file list, there actually aren't a ton of devices (I doubt Chromium has sub-par device support, but it could still be a good idea to compare to Firefox, SDL, etc. to be sure). It's still an undertaking to implement, but it seems feasible. There's also other device-specific functionality out there, like the LEDs on DS4. Unsurprisingly, that doesn't fit neatly into winit's existing API patterns... but the workload is big enough already, so that's something that can be eventually implemented by whomever ends up needing it. |
I'm interested in implementing this for Linux X11/Wayland. I'm currently evaluating options for interacting with the Linux
|
FWIW, I'm in favor of alternative 3 - fixing up the pure Rust evdev crate, as that seems to be the most beneficial solution to the ecosystem overall. Provided that fixing it doesn't require stepping on too many toes of course. Also the repo seems to have been updated this summer so it seems the maintainer hasn't disappeared anywhere but is just busy. |
I've been doing some more work on this and I have a little update. There is an issue with enumerating X11 could simply present a single virtual As for HID and gamepad devices, both X11 and Wayland can use It must be noted that |
X11 could simply present a single virtual `KeyboardId` and `MouseId`.
This is probably how Wayland would do it, too, as the Wayland client
API does not appear to report individual keyboard/mouse devices at all.
To be more precise about how wayland does things, in the compositor configuration the user can assign each input device (mouse, keyboard or touchscreen) to a "seat", and the clients only see a single mouse/keyboard/touchscreen per seat.
So yes, the Wayland server presents virtual input devices, but there still may be more than one of each kind, and in this case it would be wrong to collapse them into a single device (each wayland seat potentially represents a different user, and each has its own clipboard for example).
However, wayland setups with more than one seat are quite niche in general. Though they could typically be used for games doing local multi-player, where each player has a keyboard, all plugged into the same computer, I guess.
|
I may be misreading the docs here, but could you use the If there's really no way to distinguish between the different device types, we could get rid of the distinction between |
On my system, there is a single virtual keyboard device with a |
@murarth I'll go ahead and remove |
@Osspial I don't think there will be any other major obstacles. I just need to really dig into evdev and get a complete sense of how best to present its data through the winit API. |
Hello there! I started to work on the device api changes for wasm32 target.
|
@FuriouZz You can use |
@ryanisaacg Maybe I am doing wrong, it does not seem to wort =/. I just created a pull request, if you want to look my changes #1414 |
Any progress about this issue? |
@FuriouZz there's not really anyone around to champion this issue anymore. It's only implemented in 2 backends, and I imagine there's also concern that the needs of the remaining platforms could violate some of the assumptions in the currently planned API design. I made the original implementation of this for Windows over 2 years ago, so um... at this point, I think we should just release this feature in an incomplete form. It's not useful to anyone if we don't release it, and the missing implementations would encourage people to make contributions that fill in the gaps. However, I don't have the bandwidth to champion this issue myself. If anyone wants to, getting this to a releasable state doesn't seem too difficult, though there's some cross-platform stubbing and API conformance stuff that needs to be done. The incompleteness would also need to be well-documented. |
@francesca64 I can have a look 😊 |
I'm also going to take a look and see if I can help |
Whats the status with this? Does it need more work still? How complex is the work left to be done? I'm asking because I'm considering contributing but would like to understand it before committing to any undertaking. -- update -- |
Is there a particular platform you were considering contributing to? We're currently trying to update the very old |
I have access to win10 21H1 , macOs 11.3 on intel and Ubuntu 21.04 and iOs 14.4. I'm not especially interested in supporting any legacy or old versions. I have two wired xbox 360 pads I can test with. |
Motivation discussed here: #695 (comment) tl;dr it's necessary for robust gamepad support on Windows + having gamepad support on Wayland at all, among other things. |
Has anyone discussed supporting SDL2 controller remapping? I know GLFW also supports it. |
Thanks for bringing this up! It's definitely something we should at least be compatible with. Without it, anything besides xinput is a pain for users. Parsing/etc. should live in a different crate. In an ideal world, we wouldn't depend on that crate, and users would have an ergonomic way to translate winit events themselves. I'm fine with us integrating it with winit if it turns out we don't live in that world, though. |
This issue tracks the implementation of gamepad support and the device events API changes begun in #804. PRs working on this should be made against the
gamepad-device-events
branch, and we'll merge that branch onto master once it's implemented on all platforms.The text was updated successfully, but these errors were encountered: