Skip to content

Commit

Permalink
v1.2
Browse files Browse the repository at this point in the history
* Update TPMouse.au3

* Update README.md

* Update TPMouse.au3

* Update TPMouse.au3

* Update README.md

* Add files via upload

* Update TPMouse.au3

* Update keybinds.au3

* Update TPMouse.au3
  • Loading branch information
user726687 authored Oct 23, 2022
1 parent c746d32 commit 91c5fdf
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 98 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ Control the cursor with your hand staying on the keyboard's homerow, even if you
Inspired by [rvaiya/warpd](https://github.com/rvaiya/warpd).

## Inertia Mode
![image](https://user-images.githubusercontent.com/98432183/197324047-3de42601-3606-4f05-92a4-6645897085fb.png)
![image](https://user-images.githubusercontent.com/98432183/197381484-b4e669f0-c5bd-42af-a469-f21f5191a6a3.png)


1. Press `Shift` `CapsLk` `C` to activate inertia mode. You'll see your main cursor switched to a crosshair.
2. Use `I`/`J`/`K`/`L` to move the cursor. Hold `Shift` to brake for more precise movement, hold `Space` or `CapsLk` to scroll vertically/horizontally.
1. Press `CapsLk` `C` or `LShift` `RShift` `C` to activate inertia mode. You'll see your main cursor switched to a crosshair.
2. Use `I`/`J`/`K`/`L` to move the cursor. Hold `S` to brake for more precise movement, hold `Space` to scroll vertically/horizontally.
3. Press `F`/`E`/`R` to left/right/middle click at the cursor position.
4. Press `Esc` to quit mode.


## Grid Mode
![image](https://user-images.githubusercontent.com/98432183/197323322-09607efb-c940-4add-95e8-660c94c18306.png)

1. Press `Shift` `CapsLk` `G` to activate overlay. You'll see your main cursor switched to a crosshair, and a thin grey border surrounding your screen.
1. Press `CapsLk` `G` or `LShift` `RShift` `G` to activate overlay. You'll see your main cursor switched to a crosshair, and a thin grey border surrounding your screen.
2. Press `I`/`J`/`K`/`L` to bisect the warp region and move your cursor to its center.
3. Press `F`/`E`/`R` to left/right/middle click at the cursor position.
4. Press `Esc` to quit mode.
Expand Down
113 changes: 19 additions & 94 deletions TPMouse.au3
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#OnAutoItStartRegister SetProcessDPIAware
#include 'keybinds.au3'
_Singleton('TPMouse',0)
Opt('GUICloseOnESC',False)
Opt('TrayMenuMode',3)
Expand Down Expand Up @@ -53,6 +54,7 @@ Func SetRawinput($hWnd, $enable)
EndFunc

Func ProcessKeypress($struct)
Local Static $_ = SingletonKeybinds, $sks=SingletonKeyState
If $struct.VKey>0 and $struct.VKey<256 Then SingletonKeyState($struct.VKey,$struct.MakeCode,$struct.Flags)
Switch $struct.VKey
Case 0x1B ; esc
Expand All @@ -65,7 +67,7 @@ Func ProcessKeypress($struct)
EndIf
Case 0x47 ; G
If BitAnd(0x0001,$struct.Flags) Then
If SingletonKeyState(0x10) And SingletonKeyState(0x14) Then ; Shift CapsLk G
If $sks(0x14) Or ($sks(0xA0) And $sks(0xA1)) Then ; CapsLk+G or LShift+RShift+G
If SingletonInertia() Then SingletonInertia('deactivate')
SingletonOverlay('activate')
DllCall($user32, "bool", "SetSystemCursor", "handle", CopyIcon($hCursors[2]), "dword", 32512)
Expand All @@ -75,31 +77,31 @@ Func ProcessKeypress($struct)
EndIf
Case 0x43 ; C
If BitAnd(0x0001,$struct.Flags) Then
If SingletonKeyState(0x10) And SingletonKeyState(0x14) Then ; Shift CapsLk C
If $sks(0x14) Or ($sks(0xA0) And $sks(0xA1)) Then ; CapsLk+C or LShift+RShift+C
If SingletonOverlay() Then SingletonOverlay('deactivate')
SingletonInertia('activate')
DllCall($user32, "bool", "SetSystemCursor", "handle", CopyIcon($hCursors[1]), "dword", 32512)
TraySetIcon("%windir%\Cursors\aero_person_xl.cur")
TraySetToolTip('TPMouse - Inertia')
EndIf
EndIf
Case 0x49 ; I
Case $_('up')
If BitAnd(0x0001,$struct.Flags) Then SingletonOverlay('I')
Case 0x4A ; J
Case $_('left')
If BitAnd(0x0001,$struct.Flags) Then SingletonOverlay('J')
Case 0x4B ; K
Case $_('down')
If BitAnd(0x0001,$struct.Flags) Then SingletonOverlay('K')
Case 0x4C ; L
Case $_('right')
If BitAnd(0x0001,$struct.Flags) Then SingletonOverlay('L')
Case 0x46 ; F
Case $_('mb1')
SingletonMoupress('mb1',Not BitAnd(0x0001,$struct.Flags))
Case 0x45 ; E
Case $_('mb2')
SingletonMoupress('mb2',Not BitAnd(0x0001,$struct.Flags))
Case 0x52 ; R
Case $_('mb3')
SingletonMoupress('mb3',Not BitAnd(0x0001,$struct.Flags))
Case 0x10 ; shift
Case $_('brake')
If BitAnd(1,$struct.Flags) Then SingletonInertia('clip',15)
Case 0x14, 0x20 ; capslk or space
Case $_('scroll')
SingletonInertia('lock',Not BitAnd(0x0001,$struct.Flags))
EndSwitch
EndFunc
Expand Down Expand Up @@ -158,6 +160,7 @@ Func SingletonMoupress($msg=null,$arg=null)
EndFunc

Func SingletonInertia($msg=null,$arg=null)
Local Static $_=SingletonKeybinds, $sks=SingletonKeyState
Local Static $lastTime = TimerInit(), $self = DllStructCreate('bool active;bool lock;bool up;bool down;bool left;bool right;bool brake;float rx;float ry;float vx;float vy;float vmax;float mu')
With $self
Switch $msg
Expand Down Expand Up @@ -212,11 +215,11 @@ Func SingletonInertia($msg=null,$arg=null)
.ry = $dy-Round($dy)
.vx = ($vx*$vx+$vy*$vy<1?0:$vx)
.vy = ($vx*$vx+$vy*$vy<1?0:$vy)
.up = SingletonKeyState(0x49)
.left = SingletonKeyState(0x4A)
.down = SingletonKeyState(0x4B)
.right = SingletonKeyState(0x4C)
.brake = SingletonKeyState(0x10)
.up = $sks($_('up'))
.left = $sks($_('left'))
.down = $sks($_('down'))
.right = $sks($_('right'))
.brake = $sks($_('brake'))
Local $cur=GetCursorPos()
SingletonInertia('clip', 1*($cur.x=0) + 2*($cur.x=@DesktopWidth-1) + 4*($cur.y=0) + 8*($cur.y=@DesktopHeight-1))
EndIf
Expand Down Expand Up @@ -483,81 +486,3 @@ Func _Singleton($sOccurrenceName, $iFlag = 0)
EndIf
Return $aHandle[0]
EndFunc ;==>_Singleton

Func EnableHotKeys()
HotKeySet('i',i)
HotKeySet('j',j)
HotKeySet('k',k)
HotKeySet('l',l)
HotKeySet('f',f)
HotKeySet('e',e)
HotKeySet('r',r)
HotKeySet('{space}',space)
HotKeySet('+i',i)
HotKeySet('+j',j)
HotKeySet('+k',k)
HotKeySet('+l',l)
HotKeySet('+f',f)
HotKeySet('+e',e)
HotKeySet('+r',r)
HotKeySet('+{space}',space)
EndFunc
Func DisableHotKeys()
HotKeySet('{space}')
HotKeySet('i')
HotKeySet('j')
HotKeySet('k')
HotKeySet('l')
HotKeySet('f')
HotKeySet('e')
HotKeySet('r')
HotKeySet('{space}')
HotKeySet('+i')
HotKeySet('+j')
HotKeySet('+k')
HotKeySet('+l')
HotKeySet('+f')
HotKeySet('+e')
HotKeySet('+r')
HotKeySet('+{space}')
EndFunc
func space()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x20
ProcessKeypress($struct)
endfunc
func i()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x49
ProcessKeypress($struct)
endfunc
func j()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x4A
ProcessKeypress($struct)
endfunc
func k()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x4B
ProcessKeypress($struct)
endfunc
func l()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x4C
ProcessKeypress($struct)
endfunc
func f()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x46
ProcessKeypress($struct)
endfunc
func e()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x45
ProcessKeypress($struct)
endfunc
func r()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x52
ProcessKeypress($struct)
endfunc
118 changes: 118 additions & 0 deletions keybinds.au3
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
Func EnableHotKeys()
Local Static $_ = SingletonKeybinds, $arr = ['up','left','down','right','mb1','mb2','mb3','brake','scroll']
For $cmd in $arr
HotKeySet( $_($cmd,1) , $_($cmd,2) )
HotKeySet( '+' & $_($cmd,1) , $_($cmd,2) )
Next
EndFunc
Func DisableHotKeys()
Local Static $_ = SingletonKeybinds, $arr = ['up','left','down','right','mb1','mb2','mb3','brake','scroll']
For $cmd in $arr
HotKeySet( $_($cmd,1) )
HotKeySet( '+' & $_($cmd,1) )
Next
EndFunc
Func SingletonKeybinds($action, $mode=0)
; mode 0 returns vkey, mode 1 returns hotkey, mode 2 returns function
Switch $action
Case 'up'
If $mode Then
Return ( $mode=1 ? '{i}' : callback_i )
Else
Return 0x49
EndIf
Case 'left'
If $mode Then
Return ( $mode=1 ? '{j}' : callback_j )
Else
Return 0x4A
EndIf
Case 'down'
If $mode Then
Return ( $mode=1 ? '{k}' : callback_k )
Else
Return 0x4B
EndIf
Case 'right'
If $mode Then
Return ( $mode=1 ? '{l}' : callback_l )
Else
Return 0x4C
EndIf
Case 'mb1'
If $mode Then
Return ( $mode=1 ? '{f}' : callback_f )
Else
Return 0x46
EndIf
Case 'mb2'
If $mode Then
Return ( $mode=1 ? '{e}' : callback_e )
Else
Return 0x45
EndIf
Case 'mb3'
If $mode Then
Return ( $mode=1 ? '{r}' : callback_r )
Else
Return 0x52
EndIf
Case 'brake'
If $mode Then
Return ( $mode=1 ? '{s}' : callback_s )
Else
Return 0x53
EndIf
Case 'scroll'
If $mode Then
Return ( $mode=1 ? '{space}' : callback_space )
Else
Return 0x20
EndIf
EndSwitch
EndFunc
Func callback_i()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x49
ProcessKeypress($struct)
EndFunc
Func callback_j()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x4A
ProcessKeypress($struct)
EndFunc
Func callback_k()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x4B
ProcessKeypress($struct)
EndFunc
Func callback_l()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x4C
ProcessKeypress($struct)
EndFunc
Func callback_f()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x46
ProcessKeypress($struct)
EndFunc
Func callback_e()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x45
ProcessKeypress($struct)
EndFunc
Func callback_r()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x52
ProcessKeypress($struct)
EndFunc
Func callback_s()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x53
ProcessKeypress($struct)
EndFunc
Func callback_space()
Local $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;')
$struct.Vkey = 0x20
ProcessKeypress($struct)
EndFunc

0 comments on commit 91c5fdf

Please sign in to comment.