Code: Select all
1joy1::
MsgBox Test
Code: Select all
1joy1::
MsgBox Test
Couldn't find it, at least I assume. Got this error when running the code.
What documentation? The forum post for the API contains very little. If you're referring to the first batch of code from the forum post, I have no clue how to install it.boiler wrote: ↑27 May 2023, 08:21That’s not the dll file it’s not finding. That’s the ahk file itself. Did you download lexikos’ library? Where did you put it? To use that style of #Include syntax, it needs to be in a standard library location. Otherwise, use the “normal” include syntax. See the documentation for details. Make sure you use the v1 version since you are apparently using AHK v1.
Alright, I got the library and script working, thanks for linking the documentation. But is there more documentation somewhere on the library? Like how to figure out what each controller button is named?
Then I run into the same issue I had before. It only works with the main AHK window open.boiler wrote: ↑27 May 2023, 14:03Check out the Controller Test Script from the documentation’s Script Showcase.
Because I'm back to square one. I figure out the button, I try to use it as a hotkey, and it doesn't work when out of focus.
Code: Select all
1joy1::
msgBox Test
You have to use the library. I was just telling you to use the other script to see what the various buttons are. To use the library, follow the examples at that link.
I don't understand how to use it, the notes in the code are vague and it's out of my reach as a beginner.
I'm looking at the example code and notes in the library and I don't understand it.boiler wrote: ↑28 May 2023, 10:02I’ve never used it, but looking at the user notes in the code, it apparently doesn’t support making hotkeys out of the buttons. You would have to have your script continuously check the state of the buttons and act when the state of the button of interest indicates it has been pressed, as shown in the example.
Code: Select all
XInput_Init()
Loop {
Loop, 4 {
if State := XInput_GetState(A_Index-1) {
LT := State.bLeftTrigger
RT := State.bRightTrigger
XInput_SetState(A_Index-1, LT*257, RT*257)
}
}
Sleep, 100
}
Code: Select all
; Constants for gamepad buttons
XINPUT_GAMEPAD_DPAD_UP := 0x0001
XINPUT_GAMEPAD_DPAD_DOWN := 0x0002
XINPUT_GAMEPAD_DPAD_LEFT := 0x0004
XINPUT_GAMEPAD_DPAD_RIGHT := 0x0008
XINPUT_GAMEPAD_START := 0x0010
XINPUT_GAMEPAD_BACK := 0x0020
XINPUT_GAMEPAD_LEFT_THUMB := 0x0040
XINPUT_GAMEPAD_RIGHT_THUMB := 0x0080
XINPUT_GAMEPAD_LEFT_SHOULDER := 0x0100
XINPUT_GAMEPAD_RIGHT_SHOULDER := 0x0200
XINPUT_GAMEPAD_GUIDE := 0x0400
XINPUT_GAMEPAD_A := 0x1000
XINPUT_GAMEPAD_B := 0x2000
XINPUT_GAMEPAD_X := 0x4000
XINPUT_GAMEPAD_Y := 0x8000
I mean, all I want to do is have the following performed when I hit the left trigger.boiler wrote: ↑28 May 2023, 14:20For the buttons, you need to use State.wButtons, and you can tell which button (or multiple buttons) are pressed by its value. It is one number that contains the state of all the buttons at once, and you need to do bitwise math on it to see if a specific button is pressed, as outlined in the comments:Code: Select all
; Constants for gamepad buttons XINPUT_GAMEPAD_DPAD_UP := 0x0001 XINPUT_GAMEPAD_DPAD_DOWN := 0x0002 XINPUT_GAMEPAD_DPAD_LEFT := 0x0004 XINPUT_GAMEPAD_DPAD_RIGHT := 0x0008 XINPUT_GAMEPAD_START := 0x0010 XINPUT_GAMEPAD_BACK := 0x0020 XINPUT_GAMEPAD_LEFT_THUMB := 0x0040 XINPUT_GAMEPAD_RIGHT_THUMB := 0x0080 XINPUT_GAMEPAD_LEFT_SHOULDER := 0x0100 XINPUT_GAMEPAD_RIGHT_SHOULDER := 0x0200 XINPUT_GAMEPAD_GUIDE := 0x0400 XINPUT_GAMEPAD_A := 0x1000 XINPUT_GAMEPAD_B := 0x2000 XINPUT_GAMEPAD_X := 0x4000 XINPUT_GAMEPAD_Y := 0x8000
It sounds like it is probably too complex for you, and I’m not sure how to help you other than to make a wrapper function for his wrapper function to simplify it, which I don’t have time to do right now.
Code: Select all
Click, 1794, 685, Down
sleep 100
Click, 1794, 685, Up
Code: Select all
#Include <XInput>
XInput_Init()
Loop {
Loop, 4 {
if State := XInput_GetState(A_Index-1) {
if (State.bLeftTrigger > 0) {
Click, 1794, 685, Down
Sleep, 100
Click, 1794, 685, Up
}
}
}
Sleep, 100
}
return