I have it synced to my wireless reciever, inputs on the gamepad buttons are working correctly in SteamOS as well as "X360 Wireless Controller" shows as a device I can add to the profile, which I did. But all the keys register as Xbox gamepad inputs for some reason, like Left Stick X etc. Not sure how to go about this from here? No other input devices available are really standing out here
#How to map X360 Keytar in YARG Linux?
1 messages ยท Page 1 of 1 (latest)
Hey McGriggles, I had the same problem, so I've since written code for YARG to handle inputs from the Xbox360 Wireless Reciever directly, rather than going through the sub-par linux controller driver.
At the moment, we're waiting for a review from @hasty kernel , but I can send you a YARG build directly if you would be happy to test it for us ๐
Umm.. yes please! Cool!
No problem! I've sent you a dm ๐
Sweet ill check it out after work!
Just got around to testing, works great! At least for the 360 keytar, Im not sure if this is a complete rewrite of how the receiver inputs are handled or if this is aimed at the 360 keytar? Either way it seems functional. Only minor gripe is that this seems to intercept the "home" button call functions for SteamOS navigation. Before the Xbox button would bring up the Steam menu on press while running YARG (Of course the keys inputs werent reading right then). But now with YARG running the Xbox button does nothing, but continues to function as expected once this build was closed or the Yarg session was minimized (or shelved or whatever the proper terminology is? When you dont close the game but you arent in the gamescope sandbox
Hope this gets merged soon!
Hello, me again. I decided to test this build out with more X360 receiver instruments, namely 2 wireless P-Bass's and I noticed the devices are now properly recognized as "rockband" instruments instead of a generic x360 controller, but I was not able to map them at all. Just thought I'd give you a heads up. In nightly I'm able to map them but I'm sure you know they just get read as a generic x360 controller and I don't think YARG can recognize them as unique devices if there's multiple instruments connected to the receiver.
Which i think means you can only use one at a time? Correct me if I'm wrong there though
Disregard basically all of that. Not sure what happened on the first go around but it all seems to be correct now
Hey @bold cliff , if you're getting intermittent behaviour, you might be fighting with the 'xpad' kernel module, which will also be trying to claim the reciever and communicate with the instruments ๐
Any chance you could share that build with me as well @compact glen ? I'm trying to get an improved YARG setup for Ubuntu. The microphone delay that I had in Windows is gone in Linux, but just need my instruments working ๐
I can post what was shared with me here, or DM it to you. If thats okay of course. Just noticed the lack of response
Would very much appreciate that @bold cliff, if you don't mind. DM or posting here works for me ๐
DM'd
Thank you! Just tried it out, and surprisingly my game crashes when I have my OEM X360 receiver plugged in. If I unplug it, the game will run, and the game won't load at all if I have it plugged in. I can try to figure out where to get an error log if you're interested @compact glen
Hey @minor zealot, that's interesting, I've not experienced that before. If you could DM me your Player.Log file I'll see if I can get to the bottom of it ๐
https://docs.unity3d.com/6000.1/Documentation/Manual/log-files.html
Hey Joe, here's what I'm seeing on ~/.config/unity3d/YARC/YARG/Player.log
requesting fullscreen 2560 x 1440 at 60 Hz
Desktop is 3440 x 1440 @ 144 Hz
InitializeOrResetSwapChain 2560x1440 hdr=0 samples=1
FindXInputDeviceLayout:MidiDevice
[<a href="Assets/Script/Song/SongContainer.cs" line="150">SongContainer.cs:RunRefresh:150</a>] Scan time: 0.9156229s
[<a href="/Users/jw/Projects/YARG/YARG.Core/YARG.Core/Song/Entries/Ini/SongEntry.UnpackedIni.cs" line="76">SongEntry.UnpackedIni.cs:LoadAudio:76</a>] Loaded 6 stems
[HIDrogen] Inspecting new USB Device
[HIDrogen] Found X360Receiver
[HIDrogen] [X360Receiver] init
[HIDrogen LibUSBWrapper.cs(191)] Failed to open USB device: Access denied (insufficient permissions) (0xFFFFFFFD)
Caught fatal signal - signo:11 code:1 errno:0 addr:0x48
Access denied makes me wonder if it's a me problem as this is my first time running a portable build. I did chmod +x and launched yarg.x86_64 from the terminal
Did you add the udev rule?
That's not ringing any bells. Would that be in the contribution guide?
https://github.com/YARC-Official/YARG?tab=readme-ov-file#linux
Sorry, checking now
Did McGriggles send you a zip or just the yarg.x86_64? There should be a zipped folder with a readme ๐
It was a zip indeed, and I flew right past that README ๐
Finished adding the 69-hid.rules and about to reboot, but let me review that and I'll report back
Think I should keep that 69-hid.rules file around before adding the 99-x360-yarg-driver.rules file?
There shouldn't be an issue with adding them both to the /etc/dev/rules.d/ folder, you'll need the latter one for sure
One other thing you might need to do is prevent the native xpad kernel module from trying to claim your reciever. To do this it's modprobe -r xpad. To revert this (in case you want other applications to use the reciever) do the same command without the -r ๐
done! Honestly the only reason I'm running Ubuntu is for YARG so this receiver isn't being used for anything else
Not sure if this makes a difference but I moved the new file to /usr/lib/udev/rules.d/ since that's where all the existing files were
Great! Any luck? Once connected, the device name should appear with 'XInput' at the start, so 'XInput Rock Band Drumkit' for instance
trying shortly
dang, it crashed. checking log
false alarm, I botched the sudo cp lol. trying again!
guy@desktop:/usr/lib/udev/rules.d$ ls -lah 99*
-rw-r--r-- 1 root root 98 Nov 2 2020 99-libsane1.rules
-rw-r--r-- 1 root root 5.0K Oct 17 2024 99-systemd.rules
-rwx------ 1 root root 236 May 19 15:42 99-x360-yarg-driver.rules
Paired the keytar!!! Now just checking the inputs
We are truly in business now
@compact glen , thank you thank you
So this update should show up in YARG nightly once the HIDrogen version gets updated then?
Hey no problem, happy YARGing!
Hopefully, Nathan has given me some pointers to futher cleanups, and we also need to figure out how to build libusb... but hopefully soon yes ๐
i should have a new HIDrogen version ready somewhat soon, i've been doing a lot of spec reading and cleanup lol
Hey - Any ideas on how we can get the libusb dll/so/dylib into the unity build? Not sure if it's best to build from source or to include prebuild in the YARG repo
it'd probably be best to just throw a pre-built binary into the Plugins folder
Thanks for your second round of feedback btw, I will aim to get around to that soon ๐
i've already been kinda working on it myself lol
That's cool, I'm not precious about the code or anything, but it would be great to get it merged when time allows ๐
it already has been
there's a lot of additional knowledge involved in the changes i've made so far, and it'd take quite a while to keep iterating through that in PRs
Ah I meant in YARG ๐
ah alright
yeah, that should be ready somewhat soon
at this point i just need to take one last look over everything and then test it
Oh you mean you're working on the 360/libusb code?
yeah
Oh awesome! Well in that case it's in excellent hands, happy to pass the torch over. I'm interested to see what's improved, and if you want to share for testing purposes you certainly can
@compact glen got all of my changes finished if you wanna give them a look over and test on Linux
one particular note: i'm not 100% certain the library name for libusb was set correctly, you had it as libusb-1.0.0 but the Windows binary is named libusb-1.0, and when installing it on my WSL Ubuntu install it only provided libusb-0.1 and libusb-1.0
i changed it to libusb-1.0.so.0 for Linux specifically to ensure it picks the right versioned one
otherwise i'm pretty sure it should all still work
capability info should also be mostly complete now, there's a separate output report to request the rest of the capabilities
the only thing i'm not certain on how to determine is the flags, there's no specifications for that
Yeah - I also spent a while looking for flags in the XUSB docs... nothing! It looks like you've got somewhere in your latest commit however? ๐
Unfortunatly I'm not able to build the branch at the moment. There's errors in the console about things missing in the ./XInput directory. It looks like the use of #if UNITY_STANDALONE_WIN in there are hiding things from non-windows builds?
Regarding renaming the dll... that's fine, I'm not sure it matters provided it matches the name of the dll/dylib/so in the /Assets/Plugins folder?
Okay I've fixed the build, you might want to pull in https://github.com/joewestcott/HIDrogen/commit/a4b4996de45ab1e0907ca9164dfd9c014456eb3e
I'm now hitting Failed to get configuration descriptor: Entity not found (0xFFFFFFFB) from X360ReceiverL97. The libusb method is libusb_get_active_config_descriptor, which makes me wonder if my receiver might not have an active configuration set by default?
hmm
that works fine for me on Windows, perhaps the libusb driver there is automatically setting a configuration
Hey folks, I wasn't sure if I should mention it here or open another thread but I'm having some issues with my USB Rock Band drumkit, and the behavior seems to be a bit different on this build. On Stable, it will be recognized, but random things like the red pad don't work. On nightly, the pop-up will appear and then show disconnected. On this X360 wireless build no popup appears. If you have any ideas, I'd appreciate it. I've seen Steam Input mentioned as a workaround, but no inputs seem to be recognized in the game unfortunately.
Running this X360 wireless build, here is the error from Player.log when I plug in the drumkit:
FindXInputDeviceLayout:Joystick
Could not create a device for 'Harmonix Music Harmonix Rock Band Drumkit (Linux)' (exception: UnityEngine.InputSystem.Layouts.InputControlLayout+LayoutNotFoundException: Cannot find control layout 'Unsupported'
at UnityEngine.InputSystem.Layouts.InputControlLayout+Cache.FindOrLoadLayout (System.String name, System.Boolean throwIfNotFound) [0x0003b] in <10161bd09ede4f5fbcf0351a78e63cd5>:0
at UnityEngine.InputSystem.Layouts.InputDeviceBuilder.FindOrLoadLayout (System.String name) [0x00005] in <10161bd09ede4f5fbcf0351a78e63cd5>:0
at UnityEngine.InputSystem.Layouts.InputDeviceBuilder.InstantiateLayout (UnityEngine.InputSystem.Utilities.InternedString layout, UnityEngine.InputSystem.Utilities.InternedString variants, UnityEngine.InputSystem.Utilities.InternedString name, UnityEngine.InputSystem.InputControl parent) [0x00006] in <10161bd09ede4f5fbcf0351a78e63cd5>:0
at UnityEngine.InputSystem.Layouts.InputDeviceBuilder.Setup (UnityEngine.InputSystem.Utilities.InternedString layout, UnityEngine.InputSystem.Utilities.InternedString variants, UnityEngine.InputSystem.Layouts.InputDeviceDescription deviceDescription) [0x0000b] in <10161bd09ede4f5fbcf0351a78e63cd5>:0
at UnityEngine.InputSystem.InputDevice.Build[TDevice] (System.String layoutName, System.String layoutVariants, UnityEngine.InputSystem.Layouts.InputDeviceDescription deviceDescription, System.Boolean noPrecompiledLayouts) [0x00087] in <10161bd09ede4f5fbcf0351a78e63cd5>:0
at UnityEngine.InputSystem.InputManager.AddDevice (UnityEngine.InputSystem.Utilities.InternedString layout, System.Int32 deviceId, System.String deviceName, UnityEngine.InputSystem.Layouts.InputDeviceDescription deviceDescription, UnityEngine.InputSystem.InputDevice+DeviceFlags deviceFlags, UnityEngine.InputSystem.Utilities.InternedString variants) [0x0001a] in <10161bd09ede4f5fbcf0351a78e63cd5>:0
at UnityEngine.InputSystem.InputManager.AddDevice (UnityEngine.InputSystem.Layouts.InputDeviceDescription description, System.Boolean throwIfNoLayoutFound, System.String deviceName, System.Int32 deviceId, UnityEngine.InputSystem.InputDevice+DeviceFlags deviceFlags) [0x0004e] in <10161bd09ede4f5fbcf0351a78e63cd5>:0
at UnityEngine.InputSystem.InputManager.OnNativeDeviceDiscovered (System.Int32 deviceId, System.String deviceDescriptor) [0x000c4] in <10161bd09ede4f5fbcf0351a78e63cd5>:0 )
[HIDrogen] Inspecting new USB Device
[HIDrogen] Ignoring USB Device (VID 0x1BAD PID 0x0003)
this error is normal, it's a side-effect of the workaround the game does to ignore Unity's built-in controller support on Linux (since it's fairly broken)
it should be picking things up so long as you have hidapi installed and the udev rules for HID devices configured
pushed a change to make it explicitly set the configuration and alternate setting, hopefully that helps lol
it also receives the configuration descriptor explicitly by configuration number
I seee. It seems like I have both the hid rules and necessary libs in place mentioned in the README. Wonder if I need different versions of these libraries or something.
$ cat /usr/lib/udev/rules.d/69-hid.rules
KERNEL=="hidraw*", TAG+="uaccess"
$ sudo apt install libhidapi-hidraw0 libudev1
[sudo] password for lilbighead:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libhidapi-hidraw0 is already the newest version (0.14.0-1build1).
libudev1 is already the newest version (255.4-1ubuntu8.6).
libudev1 set to manually installed.
The following packages were automatically installed and are no longer required:
libfcft4t64 libutf8proc3 ncurses-term
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
@hasty kernel After the latest commits:
- I still need to apply my 'fix build for non-windows platforms' commit.
- libusb_set_configuration works with '1' (configuration number?) not '0' (the index?)
- unplugging/replugging during play no longer works
- Exit doesn't seem to power off the controllers
I still need to apply my 'fix build for non-windows platforms' commit.
i forgot about that bit, whoops lol
libusb_set_configuration works with '1' (configuration number?) not '0' (the index?)
the set configuration call isn't happy on Windows with 1 for whatever reason
not sure what's up with the other two
made some more fixes, there were various issues on my end after trying with the WinUSB driver instead of libusbK
relying on device handles being unique was also not working, so i made it grab bus/port numbers and device addresses and use those to construct a better unique ID
both hotplugging and powering off works fine for me after fixing everything else that was blocking things on my end, if it's still not working after pulling the new changes i'm not sure what's going on lol
Much better after the latest commits:
โ
it now builds without ifdef changes.
โ
set_configuration works without changes.
It seems like my 'Powering off at exit' issue was because I was testing in the Unity Editor (where class lifecycles seem a bit different?). When testing with an actual build, it works fine.
One remaining issue is hotplugging. I sometimes (maybe one in 5) get a failure to reconnect with the controller. After a bit of debugging, I can see it's because I'm stuck inside the while loop of X360WirelessController.PollThread with a m_ConnectionState of ConnectionState.LinkControl, which is unhandled by the switch statement. No idea why at the moment... hope that helps?
where class lifecycles seem a bit different?
yeah, the editor is a little bit odd with its domain reloading stuff
for me, powering off works fine when triggering a script recompile or when starting Play Mode
it just doesn't do anything when exiting Play Mode
since the input system's state isn't scoped to play mode
and HIDrogen isn't doing anything to detect when it's exited
do you think you could get a packet capture of the USB traffic that occurs when it gets stuck?
I'm not sure I'd know how to do that...
tbh i'm not particularly sure either for Linux lol
on Windows i use Wireshark with the USBPcap driver
After trying to get my head around the new code, I'm not actually sure if you're requesting a link control packet are you? Afaik, you only get one when the controller first connects to the reciver, which could come at a time when we're not listening?
i'll have to double-check that, i didn't see anything about requesting the link packet in the docs
does that request the link packet? as best as i can tell it only requests the connection status
and it's still done in the new code, repeatedly on a timer instead of just once on initialization
i desperately need to get some sleep rn lol, so i'll take a further look at it all later once i've had time to rest on it
Just for info, is this going to fix controllers not having certain inputs on Linux? It's just the red buttons I'm so close to having something playable ๐ญ
this will only fix wireless Xbox 360 controllers specifically, but yes
Do you have an idea of how long it will take to fix other controllers? On the issue tracker online it says it's planned for release 1.13 which just came out on beta but it doesn't seem to be fixed
v0.13 has no official form of release beyond the indev nightly versions, not sure what you mean by "just came out on beta" lol
any features planned for it are worked on as people have time for it, and they make it into nightly within 12 hours after the commit is pushed
Ah yes, I can see that now. Is this polling needed? My receiver seems to annouce connection and disconnect events when they happen. The only time you'd need to request is at the start
I'm still no closer with working out what's going on with my hotplugging though... have you replicated it yet @hasty kernel
i just figure it's safe to have as a backup, though without a way to manually initiate link control it's a little moot lol
haven't had a moment to try and replicate it yet, no
@hasty kernel I'm still not entirely sure how, but I'm quite easily able to get X360WirelessController stuck in the m_ConnectionState == ConnectionState.LinkControl status after hotplugging a few times, which will never finish the connection process. It seems like there's a race condition somewhere causing the link control packet to get missed.
I have found a solution however, which is to add case ConnectionState.LinkControl: to X360WirelessController after L225, which will retry sending the RequestConnectionStatus() packet every 5 seconds ๐
that shouldn't be the case unless Linux doesn't have any kind of ring buffer for USB packets
I'm testing on macos
It could also be a quirk with my unofficial receiver
But other than that, I think it works very well! Is there anything left to do with this now?
only things left are:
- figure out what's going on with this issue (which you've given a good lead on now)
- switch to libusb's asynchronous API so that it's not constantly spamming the USB stack with read requests lol
Hey @hasty kernel, I've been doing some testing with linux, and have come across two issues so far:
- instruments aren't connecting. I've traced this down to a bad second argument in
libusb_set_auto_detach_kernel_driver, and hardcoding it to1fixes this. - when patching around the above, the instruments connect, but inputs are delayed by a second or more and sometimes aren't registered at all. Not exactly sure why yet.
and hardcoding it to
1fixes this
hmm, it should already be getting 1
Is L557 in libusb.cs correct?
this?
ah hold on
i have additions skewing the line numbers here
it should be, UnmanagedType.Bool refers to the Win32 BOOL type which is typedef'ed as int
That line must be an issue on non-windows platforms then, as changing it to int and passing 1 works, but I don't yet know enough about c# to tell you why ๐
I did also try [MarshalAs(UnmanagedType.I1)] bool enable, and had the same issue :/
it needs to be a 4-byte integer
Hmm. Something to do with platform endianness?
not very likely, i'm not aware of any modern PC architectures that aren't little-endian
in particular, x86 is always little-endian
did some testing in WSL and it all seems to check out (though this is in .NET Core and not Mono)
works fine on standalone Mono as well
Do you have a linux VM or something you could try it on?
that's effectively what WSL is lol
having one heck of a time trying to get the asynchronous API to work correctly lol
consistently crashing on exit, and sometimes on startup
Hey @hasty kernel, I've tried again with the latest changes, and I can't replicate the issue I was having with ConnectionState.LinkControl, so that seems fixed โ
Regarding the second arg of libusb_set_auto_detach_kernel_driver... I'm beginning to think that was a bit of red herring, and was never a problem. I'm still getting the 'extreme lag on linux' issue, and I think that was what led me down the path of the second argument. A bit random in retrospect. Sorry for sending you down a rabbit hole on that one. ๐
So yeah, input lagging seems to be the only issue left, which seems to only affect linux and not macos. When the controllers eventually connect, which can often take a minute, I'm seeing missed inputs and sometimes inputs stuck 'on'. This issue wasn't present with my build (which I'm still daily driving atm).
Hey @hasty kernel. I've had another look at the X360WirelessController class to see if I can spot the issue I'm having with stuck and missed inputs. Is there a good reason to wait for 1ms on L239, in addition to the 5ms of blocking on L308? I'm wondering if the former is the cause of the missed inputs.
without that wait, the read thread will be constantly running and unnecessarily burning through CPU cycles
The libusb_interrupt_transfer will block for $timeout ms, though, right?
only if there are no packets to receive
if a packet is received within that timeframe, it will return before the timeout duration elapses
but i don't know whether libusb uses a thread sleep or a busy loop for waiting
What about if packets arrive when we're not waiting at libusb_interrupt_transfer for 5ms?
In an earlier message I guestimed about 1 in 5 input events seem to be missed... this theory lines up almost perfectly with that suspicion
It's thread sleep according to https://libusb.sourceforge.io/api-1.0/libusb_io.html
Considering we're using PollThread exclusivly for libusb_interrupt_transfer shouldn't be a problem to just wait for it to resolve (or timeout)
That while loop could essentially be while(true)
Hey everyone I know itโs a year out I recently joined this server to look further into making the 360 keytar play on Linux specifically on steam deck and so far no luck is there any method/fixes?
Hey @granite ingot, welcome to the server!
Your keytar should work fine on Linux, but you will need to follow the step in this document that starts with โFor improved compatibilityโ. Let us know how it goes.