Skip to content
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

Add driver for generic HID joysticks/gamepads #26

Merged
merged 5 commits into from
Mar 8, 2020
Merged

Add driver for generic HID joysticks/gamepads #26

merged 5 commits into from
Mar 8, 2020

Conversation

valpackett
Copy link
Contributor

Tested on an off-brand cheap USB gamepad with <16 buttons :D but I'm relatively confident in the lots-of-buttons (BTN_TRIGGER_HAPPY) support code.

The list of individual buttons in struct hmap_item[] sucks, would be nice to have a .usage_mask instead of .usage that would allow me to match all HUP_BUTTONs…

@wulf7
Copy link
Owner

wulf7 commented Mar 8, 2020

Thanks for hgame driver.

Could you rework it without using callbacks? Although currently callbacks look better, there are plans to implement HID usage ranges and scatter-gather maps for such a drivers

Also add comment about testing on an XBox 360/XInput compatible gamepad.
Using the direct number mapping with our custom descriptor
results in buttons being wrong.

For now, match using Microsoft vendor.
@valpackett
Copy link
Contributor Author

  • Removed callback usage for regular buttons
  • Added support for d-pad usages (that required a new callback though :D)
    • basically, "hat switch" is when there's one HID usage that returns a value like: 1 is up, 2 is up-right, 3 is right, …
      • Linux exposes that value directly as the X axis of a hat switch
    • "d-pad" is like 4 separate buttons
      • but Linux exposes that as two axes of a hat switch that go from -1 to 1, hence somewhat ugly callback
  • Added correct button mapping for Xbox 360 controllers
    • currently matching by vendor (Microsoft), would be nice to somehow use the USB_IFACE_SUBCLASS(UISUBCLASS_XBOX360_CONTROLLER) knowledge from usbhid instead
      • interestingly, the xpad driver for Linux keeps a list of vendor/device pairs that includes 3rd party vendors. (My 3rd party gamepad just pretends to be Microsoft when it's in XInput mode lol)

@wulf7 wulf7 merged commit 69584d3 into wulf7:master Mar 8, 2020
@wulf7
Copy link
Owner

wulf7 commented Mar 8, 2020

Merged, thanx

that required a new callback though
hence somewhat ugly callback

Callbacks were added for things like this one, They should be used if translation can not be written in declarative way.

currently matching by vendor (Microsoft), would be nice to somehow use the USB_IFACE_SUBCLASS(UISUBCLASS_XBOX360_CONTROLLER) knowledge from usbhid instead

May be create hgame.h with required constants?

@valpackett
Copy link
Contributor Author

May be create hgame.h with required constants?

I mean how would I pass the info between drivers.. I guess via hid_device_info, which is passed as ivars

@wulf7
Copy link
Owner

wulf7 commented Mar 8, 2020

Yes, hid_device_info is intended to pass information between layers. Do you want place quirks here too?

@valpackett
Copy link
Contributor Author

Yeah, I guess. (I specifically need to pass a USB-level match to a HID driver)

@wulf7
Copy link
Owner

wulf7 commented Mar 10, 2020

Other way is a global function that compares hid_device_info structure with the predefined quirk list. That is what USB's usb_test_quirk (and usb_quirk(4)) do. But I never dug in to it so I do not know if it can replace passing quirks between drivers.

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.

None yet

2 participants