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 Xbox Trigger Enums #650

Merged
merged 7 commits into from
Jul 15, 2021
Merged

Add Xbox Trigger Enums #650

merged 7 commits into from
Jul 15, 2021

Conversation

dmadison
Copy link
Contributor

@dmadison dmadison commented Jul 1, 2021

This adds LB/RB and LT/RT enum values for the Xbox controllers, in place of the original L1/R1 and L2/R2 keys. These are how Microsoft refers to the controls, and what is molded into the plastic on the Xbox 360 controllers. I've also updated the Xbox examples to swap out the keys and related strings.

While I was modifying the Original Xbox code, I also changed a duplicate reference to the VID/PID check and added support for the "Logitech Cordless Precision" controller.

This change uses the same button index value as before, so it should be backwards compatible with previous versions. The old key values can also still be used without issue.

dmadison added 5 commits July 1, 2021 04:50
Bumper and trigger in place of 1/2, as used on the Playstation controllers.
This is required to get the "correct" output from the trigger and bumper enums, which for legacy reasons do not match up with the L1/L2 keys indices.
Avoiding duplicating the VID/PID check logic in multiple places
// the button index function
switch (b) {
case(LT): b = L1; break; // normally L2
case(RT): b = R1; break; // normally R2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be L2 and R2 or have I misunderstood it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's correct, it just looks a little odd. My comment probably could have explained it better.

The library's implementation of the original Xbox controller is a little wonky because of the shared enum IDs. The controller only has one set of triggers so those were programmed as L1/R1, and the white/black buttons that became LB/RB on the 360 controller were programmed with the same IDs as L2/R2. That creates a conflict because the other Xbox controllers use the reverse - L2/R2 for the triggers and L1/R1 for the option buttons (bumpers).

Without this little filter that means LT/RT returns the white/black buttons, and LB/RB return the triggers. The filter swaps the enum values around before it runs through the ID filter, so whether L1 is passed (previous versions) or LT is passed (current versions) the trigger is still outputted.

@Lauszus
Copy link
Collaborator

Lauszus commented Jul 1, 2021

Thanks for the pull request! I've left one comment on your code.

@Lauszus
Copy link
Collaborator

Lauszus commented Jul 1, 2021

Btw don't worry about the CI failing. I'll fix that after merging the pull request.

@Lauszus Lauszus merged commit b56e8b7 into felis:master Jul 15, 2021
@Lauszus
Copy link
Collaborator

Lauszus commented Jul 15, 2021

I've now merged your PR. Again thanks for submitting it :)

@dmadison dmadison deleted the xbox-trigger-enums branch July 15, 2021 16:03
Copy link

@Luxruy Luxruy left a comment

Choose a reason for hiding this comment

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

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