Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- TheNoobPolice's Autohotkey script to generalize mouse input into lp space (outside of acceleration function).
- See document here: https://docs.google.com/document/d/19vvstC00Lptwc1vuedK1FkBeomteXBa2KgsG3pdyyH8/edit?usp=sharing
- Requires the Interception driver and evilC's AutoHotInterception library. https://github.com/evilC/AutoHotInterception/releases
- Install as per the docs on the GitHub, and copy the library into Documents\Autohotkey\Lib
- You need to know the VID and PID of the mouse device you are using to test (can be obtained from device manager or the included AHI monitor.ahk script)
- Edit those values as shown at the top of the script.
- Alt + BackSpace to enable / disable the effect on mouse input. Starts disabled.
- Bracket keys scale the LpNorm Up or Down for diagonal direction scaling. Default is 1 i.e Rectilinear distance. 2 is the "real-life" Euclidean distance, > 10 is the infinity "max" norm
- -/= keys set bias towards vertical / horizontal direction. Default of 1 (no bias)
- Ctrl + Esc closes the script and removes any effect on mouse input
- Currently uses a tooltip to show values / status, I may make this a simple GUI at somepoint but it works ok for now
- */
- VID := 0x1532
- PID := 0x0094
- ListLines Off
- #KeyHistory 0
- #NoEnv
- #SingleInstance force
- SetBatchlines, -1
- #include <AutoHotInterception>
- AHI := new AutoHotInterception()
- MouseID := AHI.GetMouseId(VID, PID)
- Math := {newX :0, newY :0, roundedX :0, roundedY:0, carryX :0, carryY :0, p :1, pInv :1, bias :1, biasInv :1}
- AHI.SubscribeMouseMoveRelative(MouseID, true, Func("Mouseloop").Bind(AHI, MouseID, Math))
- AHI.SetState(0)
- Process, Priority,, A
- Tooltip, % "Lp Norm disabled - Alt + BackSpace to enable / disable"
- SetTimer tooltipOFF, -2000
- Return
- !BS up::
- AHI.SetState((toggle:=!toggle) ? 1 : 0)
- Tooltip, % toggle ? "Lp Norm Active, Lp = " (Math.p) ", Vertical Bias = " (Math.bias) : "Lp Norm disabled"
- SetTimer tooltipOFF, -2000
- return
- ]::
- [::
- if (A_ThisHotkey = "]") {
- if (Math.p >= 3 && Math.p <= 10)
- Math.p ++
- else if (Math.p < 3)
- Math.p := round((Math.p += 0.1), 1)
- }
- else if (A_ThisHotkey = "[") {
- if (Math.p >= 4)
- Math.p --
- else if (Math.p > 1 && Math.p <= 3)
- Math.p := round((Math.p -= 0.1), 1)
- }
- Math.pInv := 1 / Math.p
- TooltipON(round(Math.p, ((Math.p < 3) ? 1 : "")))
- return
- -::
- =::
- if (A_ThisHotkey = "-") {
- if (Math.bias > 0.83)
- Math.bias -= 0.01
- }
- else if (A_ThisHotkey = "=") {
- if (Math.bias < 1.2)
- Math.bias += 0.01
- }
- Math.biasInv := 1 / Math.bias
- TooltipON(Math.bias, 1)
- return
- TooltipON(Value, vert := 0){
- Tooltip, % vert ? ("Vertical Bias = " Value) : ("Lp Norm = " (Value > 10 ? "Infinity" : Value))
- SetTimer TooltipOFF, -1000
- }
- TooltipOFF(){
- Tooltip
- }
- ^Esc::Exitapp
- Mouseloop(AHI, MouseID, Math, x, y){
- LpRatio := CalcRatio(abs(x), abs(y), Math)
- Math.newX := ((x * LpRatio) * Math.biasInv) + Math.carryX, Math.newY := ((y * LpRatio) * Math.bias) + Math.carryY
- Math.roundedX := round(Math.newX), Math.roundedY := round(Math.newY)
- AHI.Instance.SendMouseMoveRelative(MouseID, Math.roundedX, Math.roundedY)
- Math.carryX := Math.newX - Math.roundedX, Math.carryY := Math.newY - Math.roundedY
- }
- CalcRatio(x, y, Math){
- Euclid := sqrt(x**2 + y**2)
- LpDist := ((Math.p > 10) ? Max(x, y) : ((Math.p <= 1) ? (x + y) : (Math.p = 2) ? Euclid : (x**Math.p + y**Math.p)**Math.pInv))
- return LpDist / Euclid
- }
Add Comment
Please, Sign In to add comment