several config file changes

Changed the naming for some options to make them clearer (IMO).

Added option to disable monitoring of certain devices’ axes and/or
buttons.

Made axes/buttons/sensitivity settings for devices optional.
This commit is contained in:
alterNERDtive 2020-02-08 15:15:45 +01:00
parent 27662ada0c
commit 7bed785a4b
3 changed files with 72 additions and 50 deletions

View file

@ -67,27 +67,32 @@ If you feel like 100ms are too slow, set a delay thats smaller.
``` ```
[devices] [devices]
name1="2Joy" device1="2Joy"
name2="4Joy" device2="4Joy"
sensitivity1=10 device1sensitivity=10
sensitivity2=1 device5useaxes=False
device6usebuttons=False
threshold=5 threshold=5
``` ```
In this section of the config file you are defining the devices the script In this section of the config file you are defining the devices the script
should be monitoring. should be monitoring.
`name1` through `nameX` are the names in AHK terms, with `Joy` or `1Joy` being `device1` through `deviceX` are the device names in AHK terms, with `Joy` or
the first in the list. Youll probably have to go through them in sequence to `1Joy` being the first in the list. Youll probably have to go through them in
find out which physical device is which number. The ordering MIGHT change after sequence to find out which physical device is which number. The ordering MIGHT
you reboot the system but has been consistent for me so far. It should change after you reboot the system but has been consistent for me so far. It
definitely change if you reboot with one of the devices unplugged. should definitely change if you reboot with one of the devices unplugged.
`sensitivity1` through `sensitivityX` is a multiplier used for the axis inputs `deviceXsensitivity` is an (optional) multiplier used for the axis inputs of the
of the device with the same number as above. If you do not have set any curves device with the same number as above. If you do not have set any curves for your
for your device(s), you should probably leave this at `1` for all of them. device(s), you should probably leave this at `1` for all of them (or just dont
Personally I have a very non-aggressive curve on my right stick, so that ones put a setting into your config). Personally I have a very non-aggressive curve
multiplier is cranked all the way up to `10`. on my right stick, so that ones multiplier is cranked all the way up to `10`.
Similarly, `deviceXuseaxes` and `deviceXuseButtons` can be set to `False` to
disable monitoring of certain devices axes or buttons. If you leave this out,
it is assumed `True`.
Last but not least, `threshold` will be the intensity of input needed on an axis Last but not least, `threshold` will be the intensity of input needed on an axis
to trigger the script to focus your application. `5` means a 10% movement up or to trigger the script to focus your application. `5` means a 10% movement up or
@ -99,14 +104,14 @@ not to produce ghost inputs, you might have to increase this.
``` ```
[tools] [tools]
path1="C:\Program Files (x86)\EDMarketConnector\EDMarketConnector.exe" tool1="C:\Program Files (x86)\EDMarketConnector\EDMarketConnector.exe"
path2="D:\Tools\SSChanger\SSChanger.exe" tool2="D:\Tools\SSChanger\SSChanger.exe"
kill=True kill=True
``` ```
Here you can set tools the script should run alongside your application. Here you can set tools the script should run alongside your application.
`path1` to `pathX` has to be set to the full paths of the tools. `tool1` to `toolX` has to be set to the full paths of the tools executables.
`kill` is a boolean (`True`/`False`) to tell the script whether to kill the `kill` is a boolean (`True`/`False`) to tell the script whether to kill the
tools again after your target application has shut down. If you want them to tools again after your target application has shut down. If you want them to

View file

@ -9,8 +9,8 @@
; detected and (optional, default on) close them again when the ; detected and (optional, default on) close them again when the
; target is gone. ; target is gone.
; ;
; Make sure your % file file is setup properly. If not you might ; Make sure your focus.ini file is setup properly. If not you might
; have to go kill the script from Task Manager :) ; have to go kill the script from the systray or Task Manager :)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#NoEnv #NoEnv
@ -55,29 +55,39 @@ readConfig(file) {
names := [] names := []
error := False error := False
while (!error) { while (!error) {
IniRead, tmp, % file, devices, name%A_Index% IniRead, tmp, % file, devices, device%A_Index%
if (tmp == "ERROR") if (tmp == "ERROR")
error := True error := True
else else
names.push(tmp) names.push(tmp)
} }
devcount := names.MaxIndex()
senses := [] senses := []
error := False useAxes := []
while (!error) { useButtons := []
IniRead, tmp, % file, devices, sensitivity%A_Index% loop, %devcount%
{
IniRead, tmp, % file, devices, device%A_Index%sensitivity
if (tmp == "ERROR") if (tmp == "ERROR")
error := True tmp := 1
else senses.push(tmp)
senses.push(tmp) IniRead, tmp, % file, devices, device%A_Index%useAxes
if (tmp == "ERROR")
tmp := True
useAxes.push(tmp)
IniRead, tmp, % file, devices, device%A_Index%useButtons
if (tmp == "ERROR")
tmp := True
useButtons.push(tmp)
} }
config["devices"] := {"threshold": thold, "names": names, "sensitivities": senses} config["devices"] := {"threshold": thold, "names": names, "sensitivities": senses, "useAxes": useAxes, "UseButtons": useButtons}
; [tools] ; [tools]
IniRead, tkill, % file, tools, kill IniRead, tkill, % file, tools, kill
paths := [] paths := []
error := False error := False
while (!error) { while (!error) {
IniRead, tmp, % file, tools, path%A_Index% IniRead, tmp, % file, tools, tool%A_Index%
if (tmp == "ERROR") if (tmp == "ERROR")
error := True error := True
else else
@ -132,27 +142,33 @@ watchSticks:
target := "ahk_exe " config["target"]["name"] target := "ahk_exe " config["target"]["name"]
; poll all axes ; poll all axes
for id, dev in config["devices"]["names"] { for id, dev in config["devices"]["names"] {
for ia, axis in [ "X", "Y" ] { ; check if axes are enabled for this device
; axes are 0-100 if config["devices"]["useAxes"][id] = True {
; -50 means we get a deviation from "0" aka resting state for ia, axis in [ "X", "Y" ] {
; abs() since we dont care which direction you push the thing ; axes are 0-100
if (abs(getKeyState(dev axis) - 50) ; -50 means we get a deviation from "0" aka resting state
* config["devices"]["sensitivities"][id] ; abs() since we dont care which direction you push the thing
> config["devices"]["threshold"]) { if (abs(getKeyState(dev axis) - 50)
; focus the target! * config["devices"]["sensitivities"][id]
WinActivate, % target > config["devices"]["threshold"]) {
; focus the target!
WinActivate, % target
}
} }
} }
} }
; check ALL THE BUTTONS! ; check ALL THE BUTTONS!
for id, dev in config["devices"]["names"] { for id, dev in config["devices"]["names"] {
; get button count for the device and loop over all of them ; check if buttons are enabled for this device
buttons := getKeystate(dev "Buttons") if config["devices"]["useButtons"][id] = True {
Loop, %buttons% ; get button count for the device and loop over all of them
{ buttons := getKeystate(dev "Buttons")
if (getKeyState(dev A_Index)) { Loop, %buttons%
; focus the target! {
WinActivate, % target if (getKeyState(dev A_Index)) {
; focus the target!
WinActivate, % target
}
} }
} }
} }

View file

@ -6,13 +6,14 @@ pollingrate=100
targetcheckrate=5000 targetcheckrate=5000
[devices] [devices]
name1="2Joy" device1="2Joy"
name2="4Joy" device2="4Joy"
sensitivity1=10 device1sensitivity=10
sensitivity2=1 device5useaxes=False
device6usebuttons=False
threshold=5 threshold=5
[tools] [tools]
path1="C:\Program Files (x86)\EDMarketConnector\EDMarketConnector.exe" tool1="C:\Program Files (x86)\EDMarketConnector\EDMarketConnector.exe"
path2="D:\Tools\SSChanger\SSChanger.exe" tool2="D:\Tools\SSChanger\SSChanger.exe"
kill=True kill=True