Autohotkey unreliably detecting joysticks

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Buzzerb
Posts: 4
Joined: 21 Jan 2018, 01:34

Autohotkey unreliably detecting joysticks

02 Dec 2018, 23:53

I am attempting to make a program which makes use of detecting joystick input. Detecting buttons functions fine, however I am unable to detect Axis values correctly.

The below script was designed to print the X value of the stick to a message box, however no matter the stick position, it returns "49.999237".

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Sleep 500

GetKeyState, JoyA, 2JoyX

MsgBox, %JoyA%
(the use of joystick 2 is intentional, read below)

However, when the official joystick test script (https://autohotkey.com/docs/scripts/JoystickTest.htm) is used to test the output of joystick 2 , the joystick is detected perfectly. As far as I can see, there is no functional difference between the two scripts. This has been tested with multiple joysticks of the same type, and the same result always ensues.

Any help would be greatly appreciated.

Extra info:
The Joystick is a logitech extreme 3D pro. I am using Windows 7 64 bit. Windows detects the joystick correctly in it's calibration utility.
User avatar
Gio
Posts: 1247
Joined: 30 Sep 2013, 10:54
Location: Brazil

Re: Autohotkey unreliably detecting joysticks

03 Dec 2018, 10:57

MOD BUMP (Post approved on page 2)
oif2003
Posts: 214
Joined: 17 Oct 2018, 11:43
Contact:

Re: Autohotkey unreliably detecting joysticks

03 Dec 2018, 15:50

Hi, it seems to work fine once it is inside a loop. Perhaps the inital read is always that value.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

loop
{
	Sleep 500
	GetKeyState, JoyA, JoyX
	MsgBox, %JoyA%
}
Tested with xbox 360 controller.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 204 guests