CalcView and cursor movement

I’ve wanted to do a bit of 3rd person prop dragging, but appearently CalcView doesn’t provide data about mouse movement/wheeling or any usage really that is done with active gui cursor.

In short: I’m looking for alternatives (other than drawing an invisible panel over the screen and fetching data from it).
http://wiki.garrysmod.com/page/GM/InputMouseApply doesn’t seem to work when cursor moves either.

gui.MousePos() ?

Or gui.MouseX(), gui.MouseY()

You don’t need to create a panel.

And use :

gui.EnableScreenClicker( )

To make a “trace” use : gui.ScreenToVector

I’m not looking for a way to get positions - I’m looking for a HOOK that is called when cursor moves.

use the cusercmd/movedata and use :GetMouseX() or whatever it is

0, 0 is center
-x, -y = left up
+x, +y = right bottom

It doesn’t return anything when cursor is visible

i don’t think there is a way to do it other than using a predicted hook and gui.MousePos for visible mouse

That’s the point - there is no hook related to mouse movement that runs when cursor is visible.

[editline]23rd April 2016[/editline]

No hook other than PANEL:OnCursorMoved

Well, make your own hook (on think hook), compare the mouse pos and hook.Run(“CursorMoved”, deltaX, deltaY).

Compare the mouse pos… in what, think hook? - That wouldn’t really work well.

Do something like this maybe?


local function MouseMoveHook(x, y, dx, dy)

end
hook.Add("MouseMoveHook", "mmh", MouseMoveHook)

local oMx, oMy = 0, 0
hook.Add("Think", "MouseMoveHook", function()

	local x, y = input.GetCursorPos()

	if x != oMx or y != oMy then
		local dx, dy = x - oMx, y - oMy
		hook.Run("MouseMoveHook", x, y, dx, dy)
	end

	oMx, oMy = x, y

end)

I’ve done similar things for third person camera rotation and worked fine.

[lua]
hook.Add(“Think”, “MouseMove hook”, function()
local x = gui.MouseX()
local y = gui.MouseY()
if x == 0 and y == 0 then return end – cursor not enabled
if not gui.OldMouseX then – first call
gui.OldMouseX = x;
gui.OldMouseY = y;
end

if ((gui.OldMouseY ~= y) or (gui.OldMouseX ~= x)) then
	hook.Run("MouseMoved", gui.OldMouseX, gui.OldMouseY, x, y) -- oldX, oldY, X, Y
	gui.OldMouseX = x;
	gui.OldMouseY = y;
end

end)

hook.Add(“MouseMoved”, “test”, function(oldX, oldY, X, Y)
print(SysTime(), oldX, oldY, X, Y)
end)

[/lua]

I already found a solution: http://wiki.garrysmod.com/page/Global/GetHUDPanel

Either way I end up using a panel, but atleast it’s one that exists there by default.