-
Notifications
You must be signed in to change notification settings - Fork 603
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
nsyshid: add linux support using libusb #946
Conversation
Appreciate the effort. However this seems to replicate a lot of the work done in PR #903. Can you coordinate with the author there and work towards either a unified PR or something that will keep both libusb and emulated devices support intact. |
I didn't notice #903, at least that wasn't there when I started hacking on this 😅 |
From what I understand, libusb would require the zadig drivers on Windows while the Windows HID API works with the default windows drivers requiring no extra steps from the user. I'd say we don't need to have Windows HID API because most users coming from Dolphin will already have the zadig libusb drivers installed anyway, but it would still be nice to have it. However it's not a priority and can be added back with a separate PR. I'd follow the advice suggested by @deReeperJosh in the other PR and implement the devices as a class with virtual methods that roughly match the Wii U API. Then new back-end APIs (libusb, emulated devices or Windows HID) can easily be added by inheriting from the device class and implementing the methods. |
Superseded by #950 |
hey, could you tell me where to find the information for and how to wire a udev rule? |
Hi @Funkeemonkee06, the arch wiki has a bunch of good info on that :) If all you want to do is use a device like the Lego Dimensions portal, you have to figure out that device's vendor and product id. By the way: This PR is outdated and #950 contains basically everything that was included here, but in a more abstracted way, plus some other stuff. |
This adds USB hid support to the linux build using libusb.
Works nicely with the Lego Dimensions portal (and has seen several hours of (ab)use); I can't test with any other devices though because I don't own them or the games that use them.
Libusb needs to be installed as a system dependency.
To be able to use a device, one needs to add some udev rules. For example to use the Lego Dimensions portal, you'd need to create a file
/etc/udev/rules.d/99-lego-dimensions-portal.rules
with the following contents:Some things aren't implemented, but it seems like they are not needed for Lego Dimensions to function properly.
This has been cooking for a while (and at least somewhat working since may 2023). I always told myself that I would implement the missing stuff, but never got around to it 😅
So, since at least the device I wanted to support seems to work very well, I'm just gonna declare this as ready now.
Note that I am not experienced at all when it comes to working with usb devices or libusb. Suggestions how to improve this are very welcome :)
One neat thing that is included here as well is hotplug support - having to restart the game because of a flaky USB connection drove me mad enough to add this.
For hotplug support there needs to be someone that regularily calls
libusb_handle_events_completed
. I did this with a separate thread, but feel like there should be a better place to call this from.Originally, I wanted to wrap only the parts that were different in preprocessor statements, but I ended up changing a bunch of other stuff as well and have no way to (easily) test on windows, so the implementation using libusb is completely separate from the native windows one.
Should ideally close #275 but, as I said above, I've got no way to test devices other than the Lego Dimensions portal.
Flatpak build: Shouldn't cause any issues, because
libusb
is already bundled by the line- shared-modules/libusb/libusb.json
in themodules
section ofinfo.cemu.Cemu.yml
.AppImage: Seems to assume that
libusb
is part of the base system because it is on the excludelist and thus shouldn't cause any issues either.This might also work on macOS if we were to bundle libusb (and in
nsyshid.cpp
the#elif __linux__
is replaced by something like#elif __unix__
and we always link against libusb by replacingif (UNIX AND NOT APPLE)
withif (UNIX)
insrc/Cafe/CMakeLists.txt
), but I don't know anything about macOS USB handling / permissions and have no way to test on that OS.Things that I'd have liked to add, but am not planning to, and probably belong in another pr anyways:
export_HIDGetDescriptor
creates pretty much the same config descriptor for all devices