Skip to content

Instantly share code, notes, and snippets.

@dlwyatt
Created July 2, 2020 03:44
Show Gist options
  • Save dlwyatt/50fb667f0a11bbf6a166e689eae8dc7b to your computer and use it in GitHub Desktop.
Save dlwyatt/50fb667f0a11bbf6a166e689eae8dc7b to your computer and use it in GitHub Desktop.
Tweaked autofocus
; joyfocus 1.1 LazyTech
; A public domain work under the UnLicense. See LICENSE for details.
#Persistent
axesToWatch := { 2JoyX: 0, 2JoyY: 0, 2JoyZ: 0, 2JoyU: 0, 2JoyR: 0, 2JoyV: 0, 3JoyX: 0, 3JoyY: 0, 3JoyZ: 0, 3JoyR: 0, 3JoyU: 0, 3JoyV: 0}
for key, val in axesToWatch
{
axesToWatch[key] := GetKeyState(key)
}
SetTimer, WatchAxis, 100 ; milliseconds
return
; If this doesn't work with your stick/throttle/gamepad/edtracker, use
; the joylist.ahk script to find out what numbers AHK thinks your devices
; are on.
; Please check the README at https://github.com/RetroRodent/joyfocus before using.
; To change any of these checks, insert your detected device number from joylist.ahk
; This would monitor Yaw on device 2 and Throttle on device 5
; GetKeyState, JoyX, 2JoyX
; GetKeyState, JoyZ, 5JoyZ
WatchAxis:
changeFocus := 0
currentValues := {}
for key, prev in axesToWatch
{
current := GetKeyState(key)
f := Floor(current)
currentValues[key] := f
if (prev - f > 10 || prev - f < -10) {
changeFocus := 1
}
}
if changeFocus = 1
{
IfWinExist, Elite - Dangerous (CLIENT)
{
for key, current in currentValues
{
axesToWatch[key] := current
}
WinActivate
}
}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment