Jump to content

Moving mouse relative to center


JRowe
 Share

Recommended Posts

I'm trying to work out a "relative" version of the Smoother mouse move.

This code demonstrates a relative mouse move, from the screen center context, as in a 3D game, where instead of the pointer moving, your whole view moves. When a game traps your mouse, this is the context.

Func _MouseMoveRelative ($iX, $iY)
    Local Const $MOUSEEVENTF_MOVE = 0x01
    DllCall ("user32.dll", "int", "mouse_event", _
                                "int", $MOUSEEVENTF_MOVE, _
                                "int", $iX, _
                                "int", $iY, _
                                "int", 0, _
                                "int", 0)
EndFunc

This is the "Smoother Mouse Move" script by DtTvB, which creates a 2 point spline path and moves the mouse point along it. I want to use this in a relative fashion, for smooth camera transitions w/ au3irrlicht.

CODE
; Smoother Mouse Move

; by the DtTvB

; Ease in function

func __calci1($i, $sm)

return $i ^ $sm;

endFunc

; Ease out function

func __calci2($i, $sm)

return 1 - ((1 - $i) ^ $sm);

endFunc

; Ease in out function

func __calci($i, $sm)

if ($i < 0.5) then

return __calci1($i * 2, $sm) / 2;

else

return (__calci2(($i - 0.5) * 2, $sm) / 2) + 0.5;

endIf

endFunc

; Ease backward function

func __calof($i, $sm)

if ($i < 0.5) then

return __calci($i * 2, $sm);

else

return __calci((1 - $i) * 2, $sm);

endIf

endfunc

; MAIN FUNCTION

func mouseMove2($x2, $y2, $m)

$x1 = mouseGetPos(0);

$y1 = mouseGetPos(1);

$xv = random(-100, 100);

$yv = random(-100, 100);

$sm = random(1.5, 2);

for $i = 0 to $m

$ci = __calci($i / $m, $sm);

$co = __calof($i / $m, $sm);

$cx = $x1 + (($x2 - $x1) * $ci) + ($xv * $co);

$cy = $y1 + (($y2 - $y1) * $ci) + ($yv * $co);

mouseMove ($cx, $cy, 0);

next

endFunc

fixed some copy/paste issues :)

Edited by JRowe
Link to comment
Share on other sites

Anyone got an idea? I've tried replacing mousemove in the script with the mousemove2 function, and it doesn't work. It ends up pointing the camera straight up.

Link to comment
Share on other sites

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...