mirror of
https://github.com/games-on-whales/inputtino.git
synced 2026-10-15 12:52:02 +00:00
[PR #39] feat(joypad): add recreate_device() to rebuild a virtual device in place #42
Labels
No labels
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
games-on-whales/inputtino#42
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?
📋 Pull Request Information
Original PR: https://github.com/games-on-whales/inputtino/pull/39
Author: @JBailes
Created: 6/16/2026
Status: 🔄 Open
Base:
stable← Head:fix/recreate-device📝 Commits (1)
6f7cc0dfeat(joypad): add recreate_device() to rebuild virtual device in place📊 Changes
8 files changed (+173 additions, -7 deletions)
View changed files
📝
include/inputtino/input.hpp(+22 -0)📝
src/uhid/include/uhid/protected_types.hpp(+6 -0)📝
src/uhid/joypad_ps5.cpp(+42 -2)📝
src/uinput/include/inputtino/protected_types.hpp(+14 -0)📝
src/uinput/joypad_nintendo.cpp(+28 -1)📝
src/uinput/joypad_ps.cpp(+28 -1)📝
src/uinput/joypad_utils.hpp(+5 -2)📝
src/uinput/joypad_xbox.cpp(+28 -1)📄 Description
Problem
We share one virtual joypad between containers by mknod-ing the node and faking udev events, then rm-ing it on unplug. Removing the node doesn't close an fd another process already has open, so anything that opened the device keeps reading it. There's no way to evict that reader from outside short of destroying the device.
Change
Add
Joypad::recreate_device(): tear the underlying device down (UI_DEV_DESTROY / UHID_DESTROY, which invalidates the stale fd) and build a fresh one in its place, keeping the object and its callbacks (rumble, LED, triggers) intact.DeviceDefinitionand bump a per-state generation so the detached rumble listener on the old device exits on its own.get_sys_nodes()matching stays stable. This also closes a latent race in the old destructor, which could reset the device while a detached pump was still writing.Base class default is a no-op.
Used by Wolf to stop gamepad input leaking across lobby switches (games-on-whales/wolf#435).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.