-
Notifications
You must be signed in to change notification settings - Fork 787
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
Conversation
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Thanks for the pull request! I've left one comment on your code. |
Btw don't worry about the CI failing. I'll fix that after merging the pull request. |
I've now merged your PR. Again thanks for submitting it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds
LB/RB
andLT/RT
enum values for the Xbox controllers, in place of the originalL1/R1
andL2/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.