GGGlide - Mouse cursor momentum for touchpad (ergonomics enhancement)

Post your working scripts, libraries and tools
User avatar
IOrot
Posts: 7
Joined: 16 Aug 2017, 15:33

GGGlide - Mouse cursor momentum for touchpad (ergonomics enhancement)

16 Aug 2017, 17:49

This is an ergonomic improvement for touchpad users. It has not been tested with a traditional mouse but it should still work (you may have to lift your mouse from the surface as to simulate a finger flick).

GGGlide is emulating the behavior of the Synaptics touchpad setting 'Momentum'.
One quick flick of the finger on the TouchPad surface can move the cursor across the entire computer screen. Momentum reduces the repetitive motion and fatigue associated with moving the cursor long distances.

It is a great feature which now is available to any touchpad/trackpad ! :bravo:

Depending on the forcefulness and direction of the finger flick the cursor glides on the screen an equivalent distance while decelerating.
After a flick of the finger, your movements inertia is transferred to the pointer which continues its trajectory with the same speed and direction of your finger, effectively gliding through your desktop. The gliding pointers' physics include friction and hence it will slow down over time eventually stopping. After several tries it is easy to estimate how far the pointer will end up vastly improving touchpad ergonomics.

While gliding:
    If the user interacts with the position of the pointer (e.g. moves the mouse) the glide is interrupted.
    If the user presses down left click the glide is interrupted.
    If the user releases left click the glide is interrupted (hold down left click, initiate glide, release to stop).
    If pointer encounters screen edge glide is interrupted (when starting at an edge you can still glide on the screens' borders).
    The user can perform another pointer glide while already gliding.
    The pointer will decelerate until it stops if none of the above occurs.

I have a Logitech T650 touchpad and this has been a feature I had been sorely missing. Apart from AHK I guess the only alternative would have been to implement some sort of driver.

The script functions mostly satisfactory but I would greatly appreciate/value any input, suggestions or improvements!


Code: [Select all] [Expand] [Download] (ggglide.ahk)GeSHi © Codebox Plus



Notes:
  • Added moving average filtering
  • Overkill VarSetCapacity size
  • R.I.P. readability (single line code)
  • Default Sleep was highly unreliable for such short intervals
  • Did not notice any overall performance hit by timeBeginPeriod setting
Last edited by IOrot on 14 Nov 2017, 09:40, edited 16 times in total.
GeekDude
Posts: 742
Joined: 02 Oct 2013, 22:13

Re: GGGlide - Mouse cursor momentum for touchpad (or any pointing device)

17 Aug 2017, 22:18

Great work! My only Windows system I have on hand is virtual, so I can't actually use this script, but it sounds pretty nice. One thing I noticed is that you don't seem to tweak the SetBatchLines setting. The default has AHK automatically performing a 10ms (effectively 15-16ms) every 10ms, which can limit the fluidity of scripts that do motion.

I use SetBatchLines, -1 as one of only two lines in my default script template (the other being #NoEnv). This disables the feature entirely and makes the script run at full speed. You can still insert your own sleep commands at opportune moments if you need them.
User avatar
IOrot
Posts: 7
Joined: 16 Aug 2017, 15:33

Re: GGGlide - Mouse cursor momentum for touchpad (or any pointing device)

20 Aug 2017, 07:45

Thanks for the tip ! :D I had missed that particular setting and I did see improvement (although Critical supposedly alters that anyway?). :wtf:
It was rather helpful because I stumbled upon a slew of other things I had totally missed which made the script much more consistent and smooth. Cheers, GeekDude !
User avatar
evilC
Posts: 3599
Joined: 27 Feb 2014, 12:30

Re: GGGlide - Mouse cursor momentum for touchpad (or any pointing device)

21 Aug 2017, 04:35

I have a version of this which uses mouse delta instead of cursor position - it will work in games (eg first person shooters) as well as on the desktop.
https://autohotkey.com/boards/viewtopic.php?t=8439

I also have a version which is partially backed by C# code, so it is a bit more CPU efficient: https://autohotkey.com/boards/viewtopic ... 62#p152062
Also see the MicroTimer library that this version uses, it will give you more accurate, lower CPU usage timers than QPX - it will quite happily do 1ms ticks.
User avatar
IOrot
Posts: 7
Joined: 16 Aug 2017, 15:33

Re: GGGlide - Mouse cursor momentum for touchpad (or any pointing device)

22 Aug 2017, 12:41

evilC wrote:I have a version of this which uses mouse delta instead of cursor position - it will work in games (eg first person shooters) as well as on the desktop.
https://autohotkey.com/boards/viewtopic.php?t=8439

I also have a version which is partially backed by C# code, so it is a bit more CPU efficient: https://autohotkey.com/boards/viewtopic ... 62#p152062
Also see the MicroTimer library that this version uses, it will give you more accurate, lower CPU usage timers than QPX - it will quite happily do 1ms ticks.

Wow… Wish I knew this sooner it would have been much easier.!! :headwall: Impressive to say the least..! Plus, the GUI is very appealing. Thanks for bringing your work to my attention. :clap:

Haven’t looked at the C# yet but I tested briefly the RollMouse script. Unfortunately it does not perform exactly as expected on my setup (win7 x64, Core 2 Duo 2.45Ghz). Don’t know if this is by design/use case or due to my touchpad.

I have adjusted the MoveFactor and MoveThreshold to match my speeds and I do get a roll/glide to occur, which is what you would expect (constant velocity with no deceleration, infinite displacement). Then, if I perform a finger flick while gliding, lets say perpendicular to the direction of travel, often enough although my mouse movement is registered (the pointer moves visibly in perpendicular fashion) the current glide is not interrupted albeit shifted by the pointer movement.

Would that be because of the MOVE_BUFFER_SIZE ?
Might it be caused by the Sleep in this part?

Code: [Select all] [Download] GeSHi © Codebox Plus

while (this.State == this.STATE_ROLLING){

; Send output

DllCall("user32.dll\mouse_event", "UInt", 0x0001, "UInt", this.LastMove.x, "UInt", this.LastMove.y, "UInt", 0, "UPtr", 0)

; Wait for a bit (allow real mouse movement to be detected, which will turn off roll)

Sleep % this.RollFreq

}


Something felt off while trying it and I have perused the code a little further but cannot experiment currently so I will go forward with some of my thoughts even if nobody asked for them! I understand that RollMouse is intended for FPS games using mice but I will be looking at it from a desktop use standpoint with a touchpad.

I think your approach of the xy movement threshold makes its use somewhat inconsistent especially when around the lowest activation speeds.
It ignores the actual resultant displacement vector of x and y and treats them independently which means you may need to perform up to 40% larger movement (e.g. at 45 degrees angles) to reach the thresholds when not moving strictly on the x or y axis. You can end up with an actual delta larger than either the x or y delta component threshold but still have no activation.
More importantly this also affects the direction vector of your glide, presumably this further interacts with the smoothing you perform based on discarding input smaller than MOVE_BUFFER_SIZE as relatively small perpendicular vectors can have a noticeable effect in direction.

When you add up the last deltas at LastMove you essentially integrate the pointers’ change in displacement over time. Assuming a constant sampling rate this would provide the total displacement over some time period. I cannot find any such time period within the gliding context (but I am rather ignorant of the nature of the delta movement capture mechanics). The summing will also zero out displacements with both negative and positive readings, which makes the gliding less responsive.

Is there a specific way/methodology to check CPU usage or should I prop up taskmangr?

As I mentioned previously I am aware this was not necessarily designed with desktop use in mind and I apologise for neat picking your script but I wouldn’t have if it weren’t so interesting and informative. :D :D To be honest I cannot be sure I fully understood your code so hopefully I did not misinterpret it. :oops:
User avatar
evilC
Posts: 3599
Joined: 27 Feb 2014, 12:30

Re: GGGlide - Mouse cursor momentum for touchpad (or any pointing device)

23 Aug 2017, 08:48

Sounds like you have a pretty good understanding of ways to make this work, maybe even better than me. TBH maths is not my strongest suit ;)
The old (AHK implementation) of RollMouse is not hugely reliable TBH, and I would like to improve the technique - would you like to work together to take what we have and improve it?
User avatar
IOrot
Posts: 7
Joined: 16 Aug 2017, 15:33

Re: GGGlide - Mouse cursor momentum for touchpad (or any pointing device)

30 Aug 2017, 14:02

I think that it will be easy to change most of the things I mentioned so I can help you out with my suggestions. That said, my script above currently works pretty well even within games (tested strategy games, I own no FPS). It is very responsive in my system and I see no high CPU load issues. I am also planning to test some further optimizations and add some additional physics in the gliding. I would be glad to help with anything that comes to my attention but as is I see no incentive for switching and re-implementing the GGGlide features in RollMouse.
CapGuy

Re: GGGlide - Mouse cursor momentum for touchpad (ergonomics enhancement)

22 Nov 2017, 09:48

Hell(o) 10rot,

Thanks a lot for this simple and efficient AHK script : tested and approved !

The best for a just-user like me could be to have a simple graphic user interface (say : to run a kind of assistant-screens could be perfect) to set up easily the speed of cursor, duration of momentum (setting of inertia), and so on...

But already as this, it will let me happy as I can use my Logitech Touchpad almost as easy and useful as my Synaptics ones !

(for those who could think this function is not needed : no mistake, only one try with a trackpad and you will not want to do without !)

Best Regards,
Guy
CapGuy
Posts: 1
Joined: 22 Nov 2017, 11:52

Re: GGGlide - Mouse cursor momentum for touchpad (ergonomics enhancement)

25 Nov 2017, 10:08

Hell(o),

One thing which could be very useful is just to do the cursor stops when we touch the pad without moving the finger touching.
For now we need to move the finger while touching pad, but when we only touch it without moving our finger the cursor continues on its own momentum, say it is not possible to stop it just touching the pad without moving the finger.
This behavior could be very interesting, because if now we can continue the cursor movement where we need to "send" it, it is more difficult to just stop it where we need.

Do you thing you could implement just this easily ?

Best Regards,
Guy
User avatar
boiler
Posts: 2008
Joined: 21 Dec 2014, 02:44

Re: GGGlide - Mouse cursor momentum for touchpad (ergonomics enhancement)

25 Nov 2017, 12:10

Thanks for sharing this. Works well on my Surface Laptop. I found that adjusting the speed threshold to around 400 works better for me so I have to purposely flick it and it doesn't keep running when I am just making small movements.

I understand that there may not be much reason for you to spend time to add a GUI interface or work with evilC to incorporate your techniques into RollMouse, but I'll note my interest in that for what it's worth.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: arcticir and 16 guests