Scripts / [SOLVED] mouse cursor speed

Author
Message
Nevin
9
Years of Service
User Offline
Joined: 19th May 2015
Location: U.S.A
Posted: 26th Apr 2020 00:37
Hello,

Is there a way to adjust mouse speed settings.

If I use ActivateMouse() to use the mouse it works great. But I would like to adjust the speed.

Is this possible with scripts OR a setting we can change somewhere

The author of this post has marked a post as an answer.

Go to answer
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 26th Apr 2020 11:08 Edited at: 26th Apr 2020 11:15
This post has been marked by the post author as the answer.
you're positioning the mouse yourself so yes
something like (edit, you will also want to keep the mouse on screen)

--script set up
local speedMod = 2

--store the original mouse pos into oldmousex and y when you trigger ActivateMouse() (make sure this is not being called every frame)
i.e.
ActivateMouse()
oldmousex = g_MouseX
oldmousey = g_MouseY

--while the mouse is activated check how much the mouse has moved and modify it by some amount
newx = g_MouseX + ( (g_MouseX - oldmousex) * speedMod )
newy = g_MouseY + ((g_MouseY - oldmousey) * speedMod )
if newx < 0 then
newx = 0
elseif newx > 100 then
newx = 100
end
if newy < 0 then
newy = 0
elseif newy > 100 then
newy = 100
end
oldmousex = g_MouseX
oldmousey = g_MouseY
SetSpritePosition(cursor_spr,newx,newy)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Nevin
9
Years of Service
User Offline
Joined: 19th May 2015
Location: U.S.A
Posted: 26th Apr 2020 17:32
That is awesome. Thank you
synchromesh
Forum Support
10
Years of Service
User Offline
Joined: 24th Jan 2014
Location:
Posted: 26th Apr 2020 19:54
Moved to scripts
Please post questions in the relevant section.
The only person ever to get all his work done by "Friday" was Robinson Crusoe..
PM
Nevin
9
Years of Service
User Offline
Joined: 19th May 2015
Location: U.S.A
Posted: 15th May 2020 01:54 Edited at: 15th May 2020 01:58
@smallg

It does work like you said. But setting the speed at x2 makes the cursor jump as im moving it. For me, setting it over 0.60 gives it a jump when moving. The code looks fine to me and I did try some things to fix, but nothing worked. If you set it to x10 its really jumpy.

if something == 1 then
ActivateMouse()
oldmousex=g_MouseX
oldmousey=g_MouseY
something=2
end


if something == 2 then

newx=g_MouseX+((g_MouseX-oldmousex)*speedmod)
newy=g_MouseY+((g_MouseY-oldmousey)*speedmod)
if newx < 0 then
newx=0
elseif newx > 100 then
newx=100
end
if newy < 0 then
newy=0
elseif newy > 100 then
newy=100
end
oldmousey=g_MouseY
oldmousex=g_MouseX
SetSpritePosition (spr_two, newx,newy)

end
Nevin
9
Years of Service
User Offline
Joined: 19th May 2015
Location: U.S.A
Posted: 15th May 2020 14:48 Edited at: 15th May 2020 14:59
Okay so I got it working for me. For anyone who reads this, here is the script. Same as before like smallg said but had to change couple things. Also do not put this bit of code in the same script you use to detect if the mouse is hovering over buttons or whatever, give it its own script. Hope this helps someone.

if something == 1 then
ActivateMouse()
g_MouseX=50 <<<<<<<<<<<<<<----- added this so that the mouse starts in middle of screen when we want to use it
g_MouseY=50 <<<<<<<<<<<<<<----- added this so that the mouse starts in middle of screen when we want to use it
oldmousex=g_MouseX
oldmousey=g_MouseY
something=2
end


if something == 2 then

newx=g_MouseX+((g_MouseX-oldmousex)*speedmod)
newy=g_MouseY+((g_MouseY-oldmousey)*speedmod)
if newx < 0 then
newx=0
elseif newx > 100 then <<<<<<<<<<<<<<----- I would mess around with this, mouse gos off screen at 100 x
newx=100
end
if newy < 0 then
newy=0
elseif newy > 100 then <<<<<<<<<<<<<<----- I would mess around with this, mouse gos off screen at 100 y
newy=100
end
oldmousey=g_MouseY <<<<<<<<<<<<<<---------------- change this to g_MouseY=newy
oldmousex=g_MouseX <<<<<<<<<<<<<<---------------- change this to g_MouseX=newx
SetSpritePosition (spr_two, newx,newy)

end

Login to post a reply

Server time is: 2024-12-22 03:31:30
Your offset time is: 2024-12-22 03:31:30