Skip to content

feat(stable): experimental Sony controller gyro support via WebHID - #394

Closed
zortos293 wants to merge 2 commits into
devfrom
capy/experimental-sony-gyro-hid
Closed

feat(stable): experimental Sony controller gyro support via WebHID#394
zortos293 wants to merge 2 commits into
devfrom
capy/experimental-sony-gyro-hid

Conversation

@zortos293

@zortos293 zortos293 commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds experimental Sony DualShock 4/DualSense gyro support for the Electron desktop client only. When enabled via a new "Experimental Gamepad Gyro" setting (off by default), the client negotiates HID support with GFN, requests WebHID access to Sony controllers (vendor ID 0x054c), reads motion samples, and sends DS4-compatible synthetic HID packets (input type 17) containing gyro/accelerometer data. Normal XInput gamepad behavior remains unchanged unless the setting is enabled, a Sony controller is detected, and fresh motion data is available.

  • Add INPUT_GAMEPAD_HID = 17 constant and 72-byte HID packet layout in inputProtocol.ts
  • Add encodeSonyGamepadHidState method matching DS4 report ID 1 structure and official GFN vendor packet offsets
  • Add WebHID motion helper (gamepadMotion.ts) with GamepadMotionManager and requestSonyGamepadHidAccess helper
  • Parse DS4 (offsets 12/14/16 gyro, 18/20/22 accel) and DualSense (best-effort offsets 15/17/19 gyro, 21/23/25 accel) motion samples based on device product ID/name
  • Add Electron device permission/check handlers restricted to Sony vendor ID 0x054c; add select-hid-device auto-selection
  • Add experimentalGamepadGyro setting to shared/main/renderer settings/defaults/CloudMatch negotiation
  • Expose setting toggle with Beta badge in Input settings section
  • Wire client gamepad polling to send HID packets when enabled; fallback to existing XInput path otherwise
  • Add focused unit coverage for DS4 HID packet encoder

Test plan

  • Run npm run typecheck
  • Run npx tsx --test src/renderer/src/gfn/inputProtocol.test.ts
  • Verified HID permission request occurs synchronously within user activation when toggle is enabled in Settings
  • Verified device cleanup in GamepadMotionManager.stop() closes HID handles and removes listeners
  • Verified CloudMatch sends supportedHidDevices: 3 and minimal remoteControllersBitmap when enabled
  • Verified non-Sony controllers and cases without fresh motion fall back to existing XInput path unchanged

Open OPE-086 OPE-086

…4-compatible HID packets

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@zortos293 zortos293 added the capy Generated by capy.ai label May 4, 2026 — with Capy AI

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added 1 comment

Comment thread opennow-stable/src/main/index.ts Outdated
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@zortos293 zortos293 linked an issue May 4, 2026 that may be closed by this pull request
@zortos293 zortos293 closed this May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capy Generated by capy.ai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can you map gyroscope in controllers?

1 participant