Looking-Glass / JoyconLib

Joy-Con library for Unity.
MIT License
467 stars 91 forks source link

Linux Support? #43

Open ghost opened 3 years ago

ghost commented 3 years ago

Hi! I'm looking to add linux support to this library. I've downloaded and built HIDAPI from this GitHub repo but I was left with multiple files, none of which were simply named "hidapi" like the windows and mac versions in this repo's plugins folder.

The files created are: libhidapi-hidraw.a libhidapi-hidraw.la libhidapi-hidraw.so libhidapi-hidraw.so.0 libhidapi-hidraw.so.0.0.0 libhidapi-libusb.a libhidapi-libusb.la libhidapi-libusb.so libhidapi-libusb.so.0 libhidapi-libusb.so.0.0.0

Also, I'd like some help knowing what to do once I've selected the right file.

Thank you! :)

Ghostbird commented 2 years ago

What I did, is: sudo apt-get install libhidapi-libusb0 Then in the _JoyconLibplugins folder I did: ln -s /usr/lib/x86_64-linux-gnu/libhidapi-libusb.so libhidapi.so That made it build, however, my Joycons are still not enumerated.

The reason why you have the differently named files is that many linux distros supply two variants of libhidapi. One that does low-level access through libusb (the method used in this repository) and one that does low-level access through libhidraw.

In my case adding libhidapi-hidraw.so doesn't work at all and Unity complains that it cannot find the library.

Ghostbird commented 2 years ago

I reread some related stuff, and I found an interesting mention:

Linux/FreeBSD/libusb (libusb/hid.c):

This back-end uses libusb-1.0 to communicate directly to a USB device. This back-end will of course not work with Bluetooth devices.

So it seems that we must use libhidraw as back-end on Linux/Android to get it to work, however, when I tried that, it doesn't see to work at all with the JoyconLib unity code.

ZhQriks commented 1 year ago

libhidraw as back-

Did you tackled it?

Ghostbird commented 1 year ago

I delved some more into this, and managed to get a successful Android build but I ran into issues where Android provides no way to give permissions to the low-level device data. I could do it on my rooted device, but it's not useful when building a game. So this isn't really useful for Android. I didn't look further into supporting desktop Linux as my use-case was Android only.