Compare commits

...

10 commits

Author SHA1 Message Date
67b1191b8c never commit anything early in the morning 2021-01-20 08:11:41 +01:00
921e16def8 Merge branch 'develop' into release 2021-01-20 08:09:13 +01:00
fd8e396226 CHANGELOG updated 2021-01-20 08:08:11 +01:00
2015f51dde axis monitoring now watches for changes instead of absolute
Will now keep the last axis reading and compare against that, instead of
just using a deviation from the center value.

That means it will correctly work with axes that do not have a resting
position in the center, e.g. physical throttles.

Also added the Z, R, U, V axis (aka all AHK axes are now supported)

fixes #1

makes #2 less pressing :)
2021-01-19 13:18:53 +01:00
ab8c5d022e Merge branch 'develop' into release 2020-08-03 20:11:56 +02:00
54546997c1 imagine putting the wrong version number in the CHANGELOG 2020-08-03 20:11:51 +02:00
2e22e19cd5 Merge branch 'develop' into release 2020-08-03 20:08:21 +02:00
83fdd8589f README: fixed Discord invite 2020-04-24 10:23:44 +02:00
115e886c39 Pull the README fixes; no changes to the script 2020-02-08 15:35:51 +01:00
e37675cc1d Merge branch 'release-prep/0.1' into release 2020-02-08 15:25:04 +01:00
3 changed files with 37 additions and 14 deletions

View file

@ -1,4 +1,20 @@
# v0.2 (2020-08-03)
# v0.2.0 (2021-01-20)
This release adds proper support for devices beyond just Joysticks, e.g.
physical throttle units.
## Changed
* Now watching all available axes, not just X and Y. See below.
## Fixed
* Instead of watching an axis for deviation from the middle (only works with
sticks, really), now watching for a _change_ in axis value. (#1)
-----
# v0.1.1 (2020-08-03)
## Fixed

View file

@ -14,7 +14,7 @@ randomly and silently crashing on me, defeating its purpose.
* starts tools you need with the application when its up
* (optional) kills the tools again when its down
* when its up, watches configured devices for input and focuses the application
if you move the X/Y axis or hit a button
if you move any of the axes or hit a button
## Requirements

View file

@ -2,7 +2,7 @@
; This script will raise / focus a target application when you move
; your Joystick/Throttle/Gamepad/whatever axes or hit a button.
;
; Im using it with twin sticks for Elite Dangerous, but it should be
; Im using it with twin sticks for Elite Dangerous, but it should be
; generically usable.
;
; It will also start a list of tools if the target application is
@ -25,7 +25,7 @@ setWorkingDir %A_ScriptDir%
#Persistent
; check for config file and exit if it doesnt exist
; check for config file and exit if it doesnt exist
if (!FileExist("focus.ini")) {
msgbox, No config file found. Please follow the instructions in the README file.
ExitApp, 1
@ -33,6 +33,7 @@ if (!FileExist("focus.ini")) {
; read focus.ini
config := readConfig("focus.ini")
state := {}
; set the target watcher
SetTimer, watchTarget, % config["polling"]["targetcheckrate"]
@ -102,8 +103,8 @@ readConfig(file) {
return config
}
; nothing but jump labels beyond this point, lets make it explicit
; (AHK v2 will finally get rid of those …)
; nothing but jump labels beyond this point, lets make it explicit
; (AHK v2 will finally get rid of those …)
return
; this one will check for a running target process
@ -114,6 +115,10 @@ return
; 1. stop the stick watching routine
; 2. (optional) stop ALL THE TOOLS
watchTarget:
watchTarget()
return
watchTarget() {
global config
if (WinExist("ahk_exe " config["target"]["name"])) {
; start stick watcher
SetTimer, watchSticks, % config["polling"]["pollingrate"]
@ -138,26 +143,28 @@ watchTarget:
}
}
}
return
}
; this one will check the sticks for input on the X/Y axes or buttons
; if an axis is currently active or a button down, focuses the target program
watchSticks:
watchSticks()
return
watchSticks() {
global config, state
target := "ahk_exe " config["target"]["name"]
; poll all axes
for id, dev in config["devices"]["names"] {
; check if axes are enabled for this device
if (config["devices"]["useAxes"][id]) {
for ia, axis in [ "X", "Y" ] {
; axes are 0-100
; -50 means we get a deviation from "0" aka resting state
; abs() since we dont care which direction you push the thing
if (abs(getKeyState(dev axis) - 50)
* config["devices"]["sensitivities"][id]
for ia, axis in [ "X", "Y", "Z", "R", "U", "V" ] {
if (abs(getKeyState(dev axis) - state[id][axis])
* config["devices"]["sensitivities"][id]
> config["devices"]["threshold"]) {
; focus the target!
WinActivate, % target
}
state[id, axis] := getKeyState(dev axis)
}
}
}
@ -176,4 +183,4 @@ watchSticks:
}
}
}
return
}