Xbox Controller LT+RT at same time

I use the xbox 360 controller for my game and I want set the LT for aim and RT for fire. Works fine when I not press LT or RT at same time. But both Buttons at same time doesn’t work because LT and RT uses the same axis (3rd axis), LT (-1.0) and RT (1.0), when I press both buttons at same time I get a value of 0 (1 -1=0).

How can I solve this problem ?

Then just create a new virtual axis for one of them.

LT + RT is by microsoft definition of the DirectPlay drivers for the X360 Pad a value of 0 actually. (Microsoft defines LT as 0 to -1 and RT as 0 to 1 on the same axis in DirectInput - Only in xinput they show up as distinct axis)

so there is no problem to fix, its correct.
its your code logic that requires fixing or you need to use the XInput .NEt assembly available for Unity to use the x360 controller that way

Thanks,

but try it self. I have also created a new virtual axis but it doesn’t work.

I can only select “3rd axis” for LT RT and when I press RT then the value of LT will be also changed (also reversed).

My code:

if (Input.GetAxis(“Joy_Fire1”) > 0) // set as 3rd axis
aim = true;

if (Input.GetAxis(“Joy_Fire2”) < 0) // set as 3rd axis
fire = true;

will now try it with XInput.Net

Using a virtual axis won’t do it. The driver that microsoft provides for the Pad on windows for DirectPlay (or for “not XInput”) enforces them to be on the same axis, no matter what.

The XInput extension is really the way to get there, its freely available, so no worries on that end

If you’re using 2 separate virtual buttons for them and you only need to know if a virtual button is being pressed, then use Input.GetButton instead of Input.GetAxis.

EDIT: Actually, let me do some research regarding this since it’s a tad interesting.

Thanks, but Input.GetButton doesn’t work with 3rd Axis (on LT RT). Result is always false. I have tested it today.

Really interesting. With XInput it works !! I get 2 different values when I press LT RT at same time. I think this is a unity Input problem with virtual keys.

Thanks dreamora for your great tip! :slight_smile:

No its no Unity bug, virtual key problem or anything alike.

As mentioned above, thats a Microsoft thing. Microsoft decided that the DirectPlay drivers, used for anything but XInput, don’t offer the buttons on seperated axis, instead they map to the same axis with LT from 0 to -1 and RT from 0 to +1.
Unity can’t do the slightest bit about it as unity only gets the final input value from the driver and thats already the sum of the buttons

So basically just check:

if < -0.1 then left button pressed
if > 0.1 then right button pressed
if abs(value)<0.1 then both buttons pressed

forget it, it doesn’t work, even with abs. I have tested all methods. Only with XInput works fine.

And a value of <0.1 (=0) is nothing pressed or both buttons are pressed. :wink:

1 Like

pls tell me how you did it I’ve been trying for a while now