Skip to content

Conversation

kalana-sahabandu
Copy link

@kalana-sahabandu kalana-sahabandu commented Sep 3, 2025

Description

Purpose of this PR is to bring HIDAPI support to Desktop Linux Platform along with HIDAPI support for PS5 controller. This PR adds necessary macros to following files to enable HIDAPI logic flow for Desktop Linux Platform (Editor and runtime):

  • DualShockTests.cs
  • DualShockGamepadHID.cs
  • DualShockSupport.cs

Note that this PR only enables HID API path in the New Input package. All the platform related ground work (detection and disconnection, read and write) is handled in the native platform code (see: PLAT-15472, PLAT-15473, PLAT-15474)

Testing status & QA

Overall Product Risks

Please rate the potential complexity and halo effect from low to high for the reviewers. Note down potential risks to specific Editor branches if any.

  • Complexity: Low
  • Halo Effect: Low

Comments to reviewers

Please describe any additional information such as what to focus on, or historical info for the reviewers.

Checklist

Before review:

  • Changelog entry added.

    • Explains the change in Changed, Fixed, Added sections.
    • Added: HIDAPI Support for Desktop Linux
    • PLAT-15476
  • Tests added/changed, if applicable.

    • N/A
  • Docs for new/changed API's.

    • N/A, since this PR only enables logic flow in New Input System for Desktop Linux Platform
    • Documentation will be added for Desktop Linux with DOCR-6100

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: HIDAPI Support for Desktop Linux Platform.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

@unity-cla-assistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov-github-com
Copy link

codecov-github-com bot commented Sep 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

@@             Coverage Diff             @@
##           develop    #2231      +/-   ##
===========================================
- Coverage    68.14%   68.13%   -0.01%     
===========================================
  Files          367      367              
  Lines        53662    53662              
===========================================
- Hits         36570    36565       -5     
- Misses       17092    17097       +5     
Flag Coverage Δ
linux_2021.3_pkg 5.45% <ø> (ø)
linux_2021.3_project 70.39% <ø> (ø)
linux_2022.3_pkg 5.23% <ø> (ø)
linux_2022.3_project 65.24% <ø> (ø)
linux_6000.0_pkg 5.23% <ø> (ø)
linux_6000.0_project 68.03% <ø> (ø)
linux_6000.2_pkg 5.23% <ø> (ø)
linux_6000.2_project 68.04% <ø> (-0.01%) ⬇️
linux_trunk_pkg 5.24% <ø> (ø)
linux_trunk_project 68.03% <ø> (ø)
mac_2021.3_pkg 5.45% <ø> (ø)
mac_2021.3_project 70.40% <ø> (ø)
mac_2022.3_pkg 5.22% <ø> (ø)
mac_2022.3_project 65.26% <ø> (ø)
mac_6000.0_pkg 5.23% <ø> (ø)
mac_6000.0_project 68.06% <ø> (ø)
mac_6000.2_pkg 5.23% <ø> (ø)
mac_6000.2_project 68.05% <ø> (ø)
mac_trunk_pkg 5.23% <ø> (ø)
mac_trunk_project 68.05% <ø> (ø)
win_2021.3_pkg 5.45% <ø> (ø)
win_2021.3_project 70.48% <ø> (ø)
win_2022.3_pkg 5.23% <ø> (ø)
win_2022.3_project 65.34% <ø> (ø)
win_6000.0_pkg 5.23% <ø> (ø)
win_6000.0_project 68.13% <ø> (ø)
win_6000.2_pkg 5.23% <ø> (ø)
win_6000.2_project 68.13% <ø> (+<0.01%) ⬆️
win_trunk_pkg 5.23% <ø> (ø)
win_trunk_project 68.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...putSystem/Plugins/DualShock/DualShockGamepadHID.cs 42.03% <ø> (ø)
.../InputSystem/Plugins/DualShock/DualShockSupport.cs 100.00% <ø> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ekcoh ekcoh changed the title HIDAPI for Desktop Linux NEW: HIDAPI for Desktop Linux Sep 4, 2025
Copy link
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this PR @kalana-sahabandu. Changes look good to me if all that is needed is to enable the device mapping/layouts for Linux backend to work with these gamepads over HID and Linux backends now. Will this work across all support Unity versions though? I cannot see that there is version based conditions attached to enabling this for Desktop Linux?

Copy link
Collaborator

@jfreire-unity jfreire-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. And good to have increased support for Gamepads on Linux.
Changes look fine. I assume we don't need a check for the availability of this feature in the package because the platform won't be sending any HID devices prior to that change, right? Just want to make sure you have tested this PR with Unity versions without the platform changes you mentioned, like @ekcoh has mentioned.

I just have a question: why do this only for Dualsense controllers? Why not all Sony controllers or even other controllers? I looked into the platform code you mentioned and basically it seems we have a new HID backend.
Are other controllers supported by SDL? And only the Dualsense is not supported?

@kalana-sahabandu
Copy link
Author

@ekcoh @jfreire-unity Thank you so much for the reviews and the questions.

Will this work across all support Unity versions though? I cannot see that there is version based conditions attached to enabling this for Desktop Linux?
Thank you so much for pointing this out. I haven't tested this on older Editor versions, I will test this on the supported Editor versions as well (I have a feeling I might need a version based condition for Desktop Linux).

Quick question here: It will be Editor versions 2021.3 and up ?

I just have a question: why do this only for Dualsense controllers? Why not all Sony controllers or even other controllers? I looked into the platform code you mentioned and basically it seems we have a new HID backend.
Are other controllers supported by SDL? And only the Dualsense is not supported?
Hey @jfreire-unity I only added for DualSense controllers for now. But adding other HID compatible controllers to this list is totally doable. Since we are accessing HID compatible devices much lower level, compared to SDL's Gamepad API.

So i have a quick question here, What are the other controllers New Input system access through HID ? If you could let me know a list of controllers that use HID for communication. I can definetly add them to the native implementation as well.

Again, thank you both for the kind feedback, very much appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants