Xbox Controller - How select right or left hand? - C++

Hello All,

I have been trying to use the Xbox Controller codes. I can’t to find the correct command to pick between left or right hand (klefthand or krighthand).

What am I supposed to put in the blank area below?

if(m_XboxDriverOne.GetBumperPressed(___________) == 1)

{m_LaunchMotorPower = m_LaunchMotorPower + .1;}

what do you mean by right or left hand?

In Java, that method takes a value of type Hand which is an enumeration with kLeft and kRight values (in GenericHID.java). I am not sure, but it looks like you might be using C++ in which case it take a value of type JoystickHand which is an enumeration with kLeftHand and kRightHand values (in GenericHID.h).

In either case, read the documentation for GetBumper and GetBumperPressed to understand the difference. I have seen several people use GetBumperPressed when they really wanted GetBumper.

There is a generic object “Hand” so you could call Hand.kLeft and Hand.kRight. At least this is how I did it last year.

Left side or right side of the controller

I just tried that. I VS code says the identifier “hand” is undefined.

I am using C++. I want to use both GetBumper and GetBumperPressed. I just can’t seem pick left or right.

What goes in the parenthesis for left and right? .GetBumper(?)?

It has been a while since I wrote C++, but either JoystickHand.kLeftHand or JoystickHand.kRightHand. You will need to import GenericHID.h.

I just tried the joystickHand.kLeftHand. Did not work.

Here is what i’m looking at:

Did you import GenericHID.h?

Yes

Try GenericHID.JoystickHand.kLeftHand.

May want to find someone that has done C++ more recently than I, but that may do it.

Didn’t work. Thanks for trying

I have a way around it. I just want to use the xbox controller code.

we do this using this command
if(Driver.GetBumper(frc::XboxController::kRightHand) ==1)

Driver is the name of our Xbox Controller.

Thanks for stepping in. My last major foray into C++ was pre-namespaces. This solution makes sense since XBoxContoller has GenericHID as its base class (look, I said base class instead saying extends).

I’ll try that code when I’m back in the shop. Thank you

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.