Skip to content

Conversation

@InvoxiPlayGames
Copy link
Member

This PR adds input APIs to get the "type" of the controller - a plastic guitar, racing wheel, dance mat etc - so if a game developer wanted to handle specific cases with these controllers, or a controller tester homebrew wanted display the different inputs provided by a given class of device, they could do that.

int pad_type = get_controller_type(idx);
if (pad_type == CTRL_TYPE_GUITAR || pad_type == CTRL_TYPE_GUITAR_ALT)
   control_handler_for_guitar(idx, &ctrl);
else if (pad_type == CTRL_TYPE_GAMEPAD)
   control_handler_for_pad(idx, &ctrl);

For wireless controllers, the information is fetched out of the link report. This currently isn't fetched when the wireless adapter is detected, so only newly connected controllers are given a controller type.

For wired controllers, currently a hardcoded list of VID/PID pairs is used for guitars in particular. The information is reported in one of the descriptors (type 0x21) and ideally should be fetched from there. (We should also probably check for the XUSB descriptors on all connected devices to avoid needing a big VID/PID whitelist for every single controller that might exist like the Linux drivers have...)

When a controller is disconnected, the type is set to CTRL_TYPE_NONE to indicate being disconnected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant