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]
name1="2Joy"
name2="4Joy"
sensitivity1=10
sensitivity2=1
device1="2Joy"
device2="4Joy"
device1sensitivity=10
device5useaxes=False
device6usebuttons=False
threshold=5
```
In this section of the config file you are defining the devices the script
should be monitoring.
`name1` through `nameX` are the names in AHK terms, with `Joy` or `1Joy` being
the first in the list. Youll probably have to go through them in sequence to
find out which physical device is which number. The ordering MIGHT change after
you reboot the system but has been consistent for me so far. It should
definitely change if you reboot with one of the devices unplugged.
`device1` through `deviceX` are the device names in AHK terms, with `Joy` or
`1Joy` being the first in the list. Youll probably have to go through them in
sequence to find out which physical device is which number. The ordering MIGHT
change after you reboot the system but has been consistent for me so far. It
should definitely change if you reboot with one of the devices unplugged.
`sensitivity1` through `sensitivityX` is a multiplier used for the axis inputs
of the device with the same number as above. If you do not have set any curves
for your device(s), you should probably leave this at `1` for all of them.
Personally I have a very non-aggressive curve on my right stick, so that ones
multiplier is cranked all the way up to `10`.
`deviceXsensitivity` is an (optional) multiplier used for the axis inputs of the
device with the same number as above. If you do not have set any curves for your
device(s), you should probably leave this at `1` for all of them (or just dont
put a setting into your config). Personally I have a very non-aggressive curve
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
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]
path1="C:\Program Files (x86)\EDMarketConnector\EDMarketConnector.exe"
path2="D:\Tools\SSChanger\SSChanger.exe"
tool1="C:\Program Files (x86)\EDMarketConnector\EDMarketConnector.exe"
tool2="D:\Tools\SSChanger\SSChanger.exe"
kill=True
```
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
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
; target is gone.
;
; Make sure your % file file is setup properly. If not you might
; have to go kill the script from Task Manager :)
; Make sure your focus.ini file is setup properly. If not you might
; have to go kill the script from the systray or Task Manager :)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#NoEnv
@ -55,29 +55,39 @@ readConfig(file) {
names := []
error := False
while (!error) {
IniRead, tmp, % file, devices, name%A_Index%
IniRead, tmp, % file, devices, device%A_Index%
if (tmp == "ERROR")
error := True
else
names.push(tmp)
}
devcount := names.MaxIndex()
senses := []
error := False
while (!error) {
IniRead, tmp, % file, devices, sensitivity%A_Index%
useAxes := []
useButtons := []
loop, %devcount%
{
IniRead, tmp, % file, devices, device%A_Index%sensitivity
if (tmp == "ERROR")
error := True
else
senses.push(tmp)
tmp := 1
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]
IniRead, tkill, % file, tools, kill
paths := []
error := False
while (!error) {
IniRead, tmp, % file, tools, path%A_Index%
IniRead, tmp, % file, tools, tool%A_Index%
if (tmp == "ERROR")
error := True
else
@ -132,27 +142,33 @@ watchSticks:
target := "ahk_exe " config["target"]["name"]
; poll all axes
for id, dev in config["devices"]["names"] {
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]
> config["devices"]["threshold"]) {
; focus the target!
WinActivate, % target
; check if axes are enabled for this device
if config["devices"]["useAxes"][id] = True {
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]
> config["devices"]["threshold"]) {
; focus the target!
WinActivate, % target
}
}
}
}
; check ALL THE BUTTONS!
for id, dev in config["devices"]["names"] {
; get button count for the device and loop over all of them
buttons := getKeystate(dev "Buttons")
Loop, %buttons%
{
if (getKeyState(dev A_Index)) {
; focus the target!
WinActivate, % target
; check if buttons are enabled for this device
if config["devices"]["useButtons"][id] = True {
; get button count for the device and loop over all of them
buttons := getKeystate(dev "Buttons")
Loop, %buttons%
{
if (getKeyState(dev A_Index)) {
; focus the target!
WinActivate, % target
}
}
}
}

View file

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