Skip to content

feat(CapabilityMap): add generic hidraw button driver#563

Open
honjow wants to merge 4 commits intoShadowBlip:mainfrom
honjow:feat/generic_hidraw
Open

feat(CapabilityMap): add generic hidraw button driver#563
honjow wants to merge 4 commits intoShadowBlip:mainfrom
honjow:feat/generic_hidraw

Conversation

@honjow
Copy link
Copy Markdown
Contributor

@honjow honjow commented Mar 24, 2026

Summary

Add a generic hidraw button driver that uses capability map YAML configs to define button mappings, following the same pattern as existing evdev capability maps. This removes the need to write per-device Rust driver modules for simple HID button devices.

Includes GPD Win 5 HID button support (new firmware) as the first use case. Supersedes #558, which implements the same functionality with a dedicated driver.

Approach

The existing evdev source already uses a declarative approach — devices like MSI Claw and GPD define button mappings in YAML capability maps without any device-specific Rust code. This PR extends that pattern to hidraw by:

  1. Extending HidrawConfig with flexible detection modes (non-zero byte, exact value match, specific bit check)
  2. Adding HidrawEventTranslator to translate raw HID reports based on the capability map
  3. Falling back to the generic driver automatically when DriverType::Unknown but a hidraw capability map is present

Adding support for a new simple HID button device now only requires a YAML capability map file — no Rust code or recompilation needed.

Test plan

  • Verify GPD Win 5 back buttons (mode switch, L4, R4) work with new firmware
  • Verify existing hidraw devices (DualSense, Legion Go, etc.) are unaffected

Copy link
Copy Markdown
Contributor

@pastaq pastaq left a comment

Choose a reason for hiding this comment

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

Much needed feature, thanks for working on this. I want to discuss a few things, so before you change anything below lets get to a consensus.

Copy link
Copy Markdown
Contributor

@pastaq pastaq 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 making those changes. I'll test it this week and verify there are no strange effects in other hid devices.

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.

3 participants