Toggle right trigger on xbox one controller

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Andretti
Posts: 6
Joined: 19 Jul 2017, 13:53

Toggle right trigger on xbox one controller

Post by Andretti » 26 Nov 2022, 17:25

Hello.

I want RT on my xbox one controller to be on a toggle. So I tap it once and it remains held down until I tap it again. Can anyone please help me with the code?

Thank you.

Andretti
Posts: 6
Joined: 19 Jul 2017, 13:53

Re: Toggle right trigger on xbox one controller

Post by Andretti » 28 Nov 2022, 14:59

Bump. Anyone please?

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Toggle right trigger on xbox one controller

Post by mikeyww » 28 Nov 2022, 16:07

I do not have Xbox. Below is a general format that works on a keyboard. You may be able to adapt it.

Code: Select all

$x::Send % GetKeyState("x") ? "{x up}" : "{x down}"
You might want to look at the other forum posts about Xbox, too.

Andretti
Posts: 6
Joined: 19 Jul 2017, 13:53

Re: Toggle right trigger on xbox one controller

Post by Andretti » 28 Nov 2022, 18:35

mikeyww wrote:
28 Nov 2022, 16:07
I do not have Xbox. Below is a general format that works on a keyboard. You may be able to adapt it.

Code: Select all

$x::Send % GetKeyState("x") ? "{x up}" : "{x down}"
You might want to look at the other forum posts about Xbox, too.
Thank you. But I can't find the correct designation for the xbox controller buttons. I tried RT, 1joy (and other numbers), joy1, B1.

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Toggle right trigger on xbox one controller

Post by mikeyww » 28 Nov 2022, 19:07

Hi,

I can't help much with that part, but would have a look at XInput by lexikos, in case it works or leads in a useful direction.

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Toggle right trigger on xbox one controller

Post by boiler » 28 Nov 2022, 20:33

The triggers are analog devices that cannot be set to act as hotkeys because they are not binary. You sample their state using GetKeyState(), where the key name is JoyZ. The nominal value when both are in released state is 50. The left trigger adds 1-50 to that value depending on how far it is pulled. Similarly, the right trigger subtracts 1-50. AHK doesn't allow for distinguishing between the two when both are pulled simultaneously. For that, you can use lexikos' XInput as mikeyww suggested.

Andretti
Posts: 6
Joined: 19 Jul 2017, 13:53

Re: Toggle right trigger on xbox one controller

Post by Andretti » 29 Nov 2022, 05:16

boiler wrote:
28 Nov 2022, 20:33
The triggers are analog devices that cannot be set to act as hotkeys because they are not binary. You sample their state using GetKeyState(), where the key name is JoyZ. The nominal value when both are in released state is 50. The left trigger adds 1-50 to that value depending on how far it is pulled. Similarly, the right trigger subtracts 1-50. AHK doesn't allow for distinguishing between the two when both are pulled simultaneously. For that, you can use lexikos' XInput as mikeyww suggested.
I looked through lexikos' code and I have no idea what's going on. I haven't figured out how to make what I want work.

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Toggle right trigger on xbox one controller

Post by boiler » 29 Nov 2022, 06:10

I don’t know anything about his code, but it’s not necessary if you just want to act on the right trigger as long as the left and right triggers won’t be pulled simultaneously. You would just use native AHK as I described using GetKeyState().

Post Reply

Return to “Ask for Help (v1)”