-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Linux: add support for more virtual input devices #2315
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2315 +/- ##
=========================================
+ Coverage 6.51% 6.76% +0.25%
=========================================
Files 85 85
Lines 18382 17686 -696
Branches 8348 8009 -339
=========================================
- Hits 1197 1196 -1
+ Misses 15357 14662 -695
Partials 1828 1828
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I think for anyone to test this it will need the config ui updated to handle the options. Should be basically this #2261 (comment) ... except slightly different now that localization was added (https://docs.lizardbyte.dev/projects/sunshine/en/nightly/contributing/localization.html#extraction) Or, I could update it if you want? |
Thanks for the offer! I've been focusing on testing my real PS5 pad against the virtual one, and that's already being picked up without changing anything in the UI. |
Yea, there's an automatic mode. I personally wouldn't be able to test anything other than Xbox using auto mode. Does Moonlight send anything other than xbox360 or ds4 though? |
Yep, the 3 supported types are currently Xbox, PS and Nintendo. I've personally tested Xbox and PS whilst the Nintendo implementation has been tested by a user using Wolf (plus unit tests for all of them using SDL). |
"gamepad_ds5": "DS5 (PS5)", | ||
"gamepad_switch": "Nintendo Pro (Switch)", | ||
"gamepad_manual": "Manual DS4 options", | ||
"gamepad_x360": "X360 (Xbox 360)", | ||
"gamepad_xone": "XOne (Xbox One)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the localization library automatically fallback to EN if missing or should I copy this keys also in the other json files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, it will fallback to the en.json
.
@@ -147,7 +147,7 @@ <h1 class="my-4">{{ $t('config.configuration') }}</h1> | |||
<div class="form-text">{{ $t('config.controller_desc') }}</div> | |||
</div> | |||
|
|||
<!-- Emulated Gamepad Type --> | |||
<!-- Emulated Gamepad Type (Windows only) --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have one emulated gamepad block that covers Windows and Linux.
<!-- Emulated Gamepad Type -->
<div class="mb-3" v-if="config.controller === 'enabled' && platform !== 'macos'">
<label for="gamepad" class="form-label">{{ $t('config.gamepad') }}</label>
<select id="gamepad" class="form-select" v-model="config.gamepad">
<option value="auto">{{ $t('_common.auto') }}</option>
<option value="ds4" v-if="platform === 'windows'">{{ $t('config.gamepad_ds4') }}</option>
<option value="ds5" v-if="platform === 'linux'">{{ $t('config.gamepad_ds5') }}</option>
<option value="switch" v-if="platform === 'linux'">{{ $t('config.gamepad_switch') }}</option>
<option value="x360" v-if="platform === 'windows'">{{ $t('config.gamepad_x360') }}</option>
<option value="xone" v-if="platform === 'linux'">{{ $t('config.gamepad_xone') }}</option>
</select>
<div class="form-text">{{ $t('config.gamepad_desc') }}</div>
</div>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I've started with that and then refactored like it is now.
I think it's cleaner with two separate blocks since they don't share any option, but I'd be happy to switch it back if you prefer it that way..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer the single block since it's less code to maintain, lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The config layout has been refactored. @Hazer can provide guidance if needed.
@ReenigneArcher @ABeltramo I'm taking over this PR to #2606 so I can update the PR to allow for merging. @ABeltramo Can you review my changes to your PR, just to be sure I didn't hurt your work? |
@Hazer thanks for picking this up, I thought nobody was interested in this.. I think we should automatically fallback in case some requirements are missing, for example:
This would let us cover more use cases and allow people that don't want to expose uhid and/or uinput (to tighten security/on unprivileged containers or VMs) to still be able to run a session with just mouse and keyboard over Xorg. I believe there's no equivalent solution for Wayland, but I haven't looked too much into it.. Apart from that, there's still some quirk over gyro and acceleration on my PS5 virtual joypad but everything else seems to work, have you had a chance to run it on your end too? |
Closing, replaced by #2606 |
Description
I had to rename the branch for CI to work, this is a continuation of #2261
Added support for the followings new virtual devices:
And generally completely refactored all virtual input code using inputtino as a library
Requirements
The DualSense implementation requires access to
/dev/uhid
, (more on this later..) this is easily done by setting the right permissions, similar to how we deal withudev
already:First we’ll add our user to the input group:
Then we add an udev rule to allow access to /dev/uhid:
Finally, we have to make sure that the uhid kernel module is loaded at boot:
Code details
The main file is
src/platform/linux/inputtino.cpp
I've kept the originalinput.cpp
so that we can easily compare the two implementations and possibly add what's missing but the idea would be to completely replace that implementation with this. To switch from one implementation to the other you can just set the Cmake variable-DSUNSHINE_USE_INPUTTINO=OFF
.Unfortunately we have to deal with
uhid
in order to properly emulate gyro, acceleration and touchpad; there's a bit of a rationale into why this is not possible withudev
here. This might be a deal breaker for you guys but I hope it's not; if that's the case, we can still emulate a PS5 joypad usingudev
without supporting gyro and acceleration.I think bringing in
uhid
has also other benefits, since it sits at a lower level thanuinput
, we can really emulate any kind of usb device and possibly even completely integrate usb over IP if this will ever be considered as an addition to the protocol.As for the code itself, Inputtino has got unit tests using
libinput
for mouse, keyboard, pen and touchscreen andSDL2
for testing joypads. These aren't complete (yet) but should cover most of the codebase.Future plans
What's missing?
Most notably the XTest fallback that is present in
input.cpp
if this is something that is used we can easily add it here as well.Everything else should be implemented, please let me know if something is missing or misbeaving.
I'm probably forgetting something else..
Issues Fixed or Closed
Might help with #1720
Type of Change
.github/...
)Checklist
Branch Updates
LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.