hidapi/libusb: enable support for Xbox 360 and Xbox One controllers #572

Merged
slouken merged 2 commits from 0001-hidapi-libusb-enable-support-for-Xbox-360-and-Xbox-O.patch into master 2023-07-23 04:57:49 -05:00
slouken commented 2023-05-26 11:07:27 -05:00 (Migrated from github.com)

Xbox controllers are not technically HID devices, but you can talk to them directly using libusb, and SDL uses this to talk to controllers which may not have OS-level support.

Xbox controllers are not technically HID devices, but you can talk to them directly using libusb, and [SDL](https://github.com/libsdl-org/SDL) uses this to talk to controllers which may not have OS-level support.
slouken commented 2023-05-26 22:32:38 -05:00 (Migrated from github.com)

This pull request depends on https://github.com/libusb/hidapi/pull/568, which must be merged before this will pass.

This pull request depends on https://github.com/libusb/hidapi/pull/568, which must be merged before this will pass.
mcuee commented 2023-05-26 22:59:59 -05:00 (Migrated from github.com)

@slouken

There are warnings treated as errors so that ubuntu-cmake github action failed. Please help to fix. Thanks.

@slouken There are warnings treated as errors so that ubuntu-cmake github action failed. Please help to fix. Thanks.
slouken commented 2023-05-26 23:07:16 -05:00 (Migrated from github.com)

I fixed the warnings, and I'll squash the PR once the build passes. There's still one error left that requires #568 to be merged first.

I fixed the warnings, and I'll squash the PR once the build passes. There's still one error left that requires #568 to be merged first.
slouken commented 2023-05-26 23:20:02 -05:00 (Migrated from github.com)

All ready to go!

All ready to go!
Youw (Migrated from github.com) reviewed 2023-05-31 11:46:12 -05:00
@ -678,0 +736,4 @@
0x10f5, /* Turtle Beach */
0x1532, /* Razer Wildcat */
0x20d6, /* PowerA */
0x24c6, /* PowerA */
Youw (Migrated from github.com) commented 2023-05-31 11:46:12 -05:00

looks like some debug code
remove?

looks like some debug code remove?
Youw (Migrated from github.com) reviewed 2023-05-31 11:48:22 -05:00
@ -987,0 +1139,4 @@
if (res < 0) {
LOG("xbox init: can't set alt setting %d: %d\n", intf_desc->bInterfaceNumber, res);
}
Youw (Migrated from github.com) commented 2023-05-31 11:48:21 -05:00

zero-initialize the data
otherwise, libusb_control_transfer may try to read it, which is undefined behavior

zero-initialize the `data` otherwise, `libusb_control_transfer` may try to read it, which is undefined behavior
Youw (Migrated from github.com) reviewed 2023-05-31 11:50:24 -05:00
@ -678,0 +736,4 @@
0x10f5, /* Turtle Beach */
0x1532, /* Razer Wildcat */
0x20d6, /* PowerA */
0x24c6, /* PowerA */
Youw (Migrated from github.com) commented 2023-05-31 11:50:24 -05:00

please don't use UPPER_SNAKE_CASE for named constants - it is generally error-prone in C/C++ due to fact that usually it is used for macros

here and elsewhere

please don't use `UPPER_SNAKE_CASE` for named constants - it is generally error-prone in C/C++ due to fact that usually it is used for macros here and elsewhere
Youw (Migrated from github.com) reviewed 2023-05-31 11:51:49 -05:00
@ -987,0 +1139,4 @@
if (res < 0) {
LOG("xbox init: can't set alt setting %d: %d\n", intf_desc->bInterfaceNumber, res);
}
Youw (Migrated from github.com) commented 2023-05-31 11:51:49 -05:00

I'm pretty sure if we're passing the libusb_config_descriptor *conf_desc - int config_number is redundant
lets omit it

I'm pretty sure if we're passing the `libusb_config_descriptor *conf_desc` - `int config_number` is redundant lets omit it
Youw commented 2023-05-31 11:53:45 -05:00 (Migrated from github.com)

Does SDL users ever use hidraw backend on Linux for devices like this?

Does SDL users ever use hidraw backend on Linux for devices like this?
slouken (Migrated from github.com) reviewed 2023-05-31 12:03:19 -05:00
@ -678,0 +736,4 @@
0x10f5, /* Turtle Beach */
0x1532, /* Razer Wildcat */
0x20d6, /* PowerA */
0x24c6, /* PowerA */
slouken (Migrated from github.com) commented 2023-05-31 12:03:19 -05:00

I uncomment this frequently for debugging purposes. I can remove it from this PR if you like.

I uncomment this frequently for debugging purposes. I can remove it from this PR if you like.
slouken commented 2023-05-31 12:04:06 -05:00 (Migrated from github.com)

Does SDL users ever use hidraw backend on Linux for devices like this?

No, hidraw doesn't expose Xbox controllers.

> Does SDL users ever use hidraw backend on Linux for devices like this? No, hidraw doesn't expose Xbox controllers.
Youw (Migrated from github.com) reviewed 2023-05-31 12:22:10 -05:00
@ -678,0 +736,4 @@
0x10f5, /* Turtle Beach */
0x1532, /* Razer Wildcat */
0x20d6, /* PowerA */
0x24c6, /* PowerA */
Youw (Migrated from github.com) commented 2023-05-31 12:22:10 -05:00

at least make it a /* C comment */ (our code-style agreement)
or hide it under #if 0

at least make it a `/* C comment */` (our code-style agreement) or hide it under `#if 0`
slouken (Migrated from github.com) reviewed 2023-05-31 18:02:55 -05:00
@ -678,0 +736,4 @@
0x10f5, /* Turtle Beach */
0x1532, /* Razer Wildcat */
0x20d6, /* PowerA */
0x24c6, /* PowerA */
slouken (Migrated from github.com) commented 2023-05-31 18:02:54 -05:00

Would this be the preferred naming convention for these constants?

xb360_iface_subclass, ..., supported_vendors
Would this be the preferred naming convention for these constants? ``` xb360_iface_subclass, ..., supported_vendors ```
Youw (Migrated from github.com) reviewed 2023-05-31 18:04:34 -05:00
@ -678,0 +736,4 @@
0x10f5, /* Turtle Beach */
0x1532, /* Razer Wildcat */
0x20d6, /* PowerA */
0x24c6, /* PowerA */
Youw (Migrated from github.com) commented 2023-05-31 18:04:33 -05:00

yes

yes
slouken commented 2023-06-01 09:48:25 -05:00 (Migrated from github.com)

This has been updated with the suggestions.

This has been updated with the suggestions.
Youw (Migrated from github.com) approved these changes 2023-06-01 09:50:15 -05:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi!572
No description provided.