mirror of
https://github.com/joleuger/vuinputd.git
synced 2026-11-05 01:17:20 +00:00
[GH-ISSUE #10] Controller vibration through vuinputd-virtualized device causes Sunshine session to softlock #8
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
joleuger/vuinputd#8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @griffi-gh on GitHub (Mar 23, 2026).
Original GitHub issue: https://github.com/joleuger/vuinputd/issues/10
vibration seems to cause all sorts of weird issues...
for example Eden emulator drops to one frame per 10 seconds or so while vibration is active.
Vibration in Dead Cells brings down both session AND the game itself, and somehow kills the entire session???
@joleuger commented on GitHub (Mar 23, 2026):
Thanks for reporting. This seems to be an issue with the ioctls
I actually haven't tested the vibration functionality. Can you please send the logs?
My guess: The problem seems to be the UI_BEGIN_FF_UPLOAD. I guess this code here triggers
assert!(_in_bufsz != 0, "should have _in_bufsz");.Very likely this fails:
fuse_lowlevel::fuse_reply_ioctl_retry(_req, &iov, 1, &iov, 1);I need to read the interface in the kernel first. I guess it needs to be
fuse_lowlevel::fuse_reply_ioctl_retry(_req, &iov, 1, std::ptr::null(), 0));Edit: No, it actually is a read write structure: https://github.com/torvalds/linux/blob/master/drivers/input/misc/uinput.c
@joleuger commented on GitHub (Mar 23, 2026):
Ok, I have asked gemini (haven't tried it out, yet):
The Real Bug: Mutating _in_buf
The issue you are experiencing is almost certainly happening in the actual processing block due to how FUSE's memory is being handled:
Rust
FUSE provides _in_buf as a *const c_void. It is fundamentally a read-only view of the data fetched during the retry phase. Casting a *const FUSE buffer to a *mut pointer and letting ui_begin_ff_upload mutate it in-place is undefined behavior. Depending on how the FUSE C library mapped that buffer, writing to it directly can cause a segfault, a kernel EFAULT, or silent memory corruption.
The Fix
Instead of casting and modifying the read-only buffer directly, you should safely copy it into a local, mutable struct, perform the ioctl on your local copy, and then pass that local copy back to FUSE so it can handle copying it back to the calling process.
Here is how you can correct the block:
Very likely, the same problem is in UI_BEGIN_FF_ERASE. I need to figure out, how to write an isolated test.
@joleuger commented on GitHub (Mar 23, 2026):
Just to ensure, can you please check if this line in your logs when switching debug logging on?
If yes, then the issue is not with the ioctls but because I missed to implement copying the ff stuff here https://github.com/joleuger/vuinputd/blob/0.3.2/vuinputd/src/cuse_device/vuinput_write.rs#L61
Edit: But actually this should not be the case, because sunshine is creating the device.
@griffi-gh commented on GitHub (Mar 23, 2026):
nothing suspicious in vuinputd logs but sunshine is spamming literal gigabytes of logs like this:
i am not sure if it's related to this specific issue or just some red herring that can be ignored/doesn't cause actual failure
@griffi-gh commented on GitHub (Mar 23, 2026):
i don't think i've ever seen that appear in journalctl logs
@joleuger commented on GitHub (Mar 23, 2026):
Failed reading uinput fd comes from inputtino:
github.com/games-on-whales/inputtino@f4ce2b0df5/src/uinput/include/inputtino/protected_types.hpp (L28)The reason is a ENOSYS 38 Function not implemented
https://man7.org/linux/man-pages/man3/errno.3.html
ENOSYS is thrown here https://github.com/torvalds/linux/blob/master/drivers/input/misc/uinput.c#L265-L266
@joleuger commented on GitHub (Mar 23, 2026):
Hmmm, from my understanding, EV_FF should actually be set
github.com/games-on-whales/inputtino@f4ce2b0df5/src/uinput/joypad_xbox.cpphttps://gitlab.freedesktop.org/libevdev/libevdev/-/blob/master/libevdev/libevdev-uinput.c?ref_type=heads#L93
@joleuger commented on GitHub (Mar 23, 2026):
I guess I need to try it out on my own machine to be able to write a reproducible test case. Just to be able to reproduce: Did you manage to get any game working? Might also be the case that for vibration, ioctls after device setup are necessary. Need to check out. But will be next week.
Anyway, thanks for reporting!
@griffi-gh commented on GitHub (Mar 23, 2026):
yes, games work properly if i turn off controller vibration in in-game settings
https://github.com/girl-pp-ua/nixos-infra/tree/master/modules/services/experimental/gayming-nixos
this is the full config of the container and system (as reproducible nix) i'm running for testing; if you need any configs from my system it should all be there
@joleuger commented on GitHub (Mar 31, 2026):
Ok, I can reproduce the problem:
I need to implement the read and poll functions of the cuse device to forward the data of the ff request, which contains the pattern. The applications actually write that data via a write to the event device. When the application writes that ff data, we (as virtual device) need to read that data. Thus, whenever someone tries to read from the vuinput device, we need to read that data from the real uinput device.
@joleuger commented on GitHub (Apr 6, 2026):
I have implemented a simple poll function that should work for sunshine/inputtino. Should only work for that special case and might be a bit racy. I still need to work further on it and implement proper testing.
@joleuger commented on GitHub (Apr 14, 2026):
Ok, removed the code, because sunshine hangs during shutdown, see issue #12
I'll fix it, when I have the time to test. My current assumption is that a poll of sunshine is waiting for a response, but doesn't get it, when the device gets deleted to fast.
@joleuger commented on GitHub (Apr 15, 2026):
Code is active again. Could not test it yet with a real gamepad, but at least
fftestdoesn't break@joleuger commented on GitHub (Apr 16, 2026):
Fixed 100% cpu bug due to polling