Skip to content

Commit 719b1e0

Browse files
committed
M2J Absolute mode now working well
Added in threshold (ie deadzone)
1 parent dce6150 commit 719b1e0

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

Changelog.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ Key:
77
0.0.16 - ??
88
+ The ButtonToButton plugin now has a Toggle mode
99
+ MouseToJoy plugin enhancements:
10-
Renamed Threshold in Absolute mode to Scale Factor.
11-
You may lose your setting for this GuiControl as it was renamed.
10+
Added Scale Factor to Absolute mode.
1211
Plugin can now be configured to only take input from a specific mouse.
1312
You can now use multiple MouseToJoy plugins if you have more than one pointing device.
1413
+ Added "HoldButton" functionality to OneSwitch Pulse plugin.

Plugins/Core/MouseToJoy.ahk

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ class MouseToJoy extends _Plugin {
3030
;~ Gui, Add, Button, % "x+5 yp hwndhwnd", Calibrate
3131
;~ fn := this.Calibrate.Bind(this, "X")
3232
;~ GuiControl +g, % hwnd, % fn
33-
Gui, Add, Text, % "x120 w40 center y" title_row, Timeout
34-
this.AddControl("AbsoluteTimeout", this.TimeoutChanged.Bind(this, "X"), "Edit", "x120 w40 y" x_row + 10, 50)
33+
Gui, Add, Text, % "x120 w40 center y" title_row-5, Timeout
34+
this.AddControl("AbsoluteTimeout", this.TimeoutChanged.Bind(this, "X"), "Edit", "x120 w40 y" x_row - 10, 50)
35+
36+
Gui, Add, Text, % "x120 w40 center y" y_row - 10, Threshold
37+
this.AddControl("AbsoluteThreshold", this.TimeoutChanged.Bind(this, "X"), "Edit", "x120 w40 y" y_row + 5, 2)
3538

3639
this.AddControl("AbsoluteScaleY", this.AbsoluteScaleChanged.Bind(this, "Y"), "Edit", "x70 w30 y" y_row, 10)
3740
;~ Gui, Add, Button, % "x+5 yp hwndhwnd", Calibrate
@@ -118,7 +121,7 @@ class MouseToJoy extends _Plugin {
118121
MouseEvent(value){
119122
; The "Range" for a given axis is -50 to +50
120123
try {
121-
x := value.axes.x, y := value.axes.y, MouseID := value.MouseID, dox := (x != ""), doy := (y != "")
124+
x := value.axes.x, y := value.axes.y, ax := Abs(x), ay := Abs(y), MouseID := value.MouseID, dox := (x != ""), doy := (y != "")
122125
} catch {
123126
; M2J sometimes seems to crash eg when switching from a profile with M2J to a profile without
124127
; This seems to fix it, but this should probably be properly investigated.
@@ -129,11 +132,20 @@ class MouseToJoy extends _Plugin {
129132
return
130133

131134
if (this.Mode = 1){
132-
if (dox)
135+
; Absolute
136+
threshold := this.GuiControls.AbsoluteThreshold.value
137+
if (dox && ax && ax <= threshold)
138+
dox := 0
139+
if (doy && ay && ay <= threshold)
140+
doy := 0
141+
if (dox){
133142
this.CurrX := x * this.AbsoluteScaleFactor.X
134-
if (doy)
143+
}
144+
if (doy){
135145
this.CurrY := y * this.AbsoluteScaleFactor.Y
146+
}
136147
} else {
148+
; Relative
137149
if (dox){
138150
if (this.GuiControls.InvertX.value)
139151
x *= -1

0 commit comments

Comments
 (0)