Raw mouse input from a win32 hwnd.
Hello, i am writing a game with raylib, but the mouse input is inconsistant and pretty terrible so i wanted to know of any ways(im fine with any deps) to get raw mouse input. all i really need to recieve is the mouse coordinates. It needs to be precise and fast
16 Replies
how does this work, are you using a winform? if so you would have an event loop and you can set an eventhandler for mousemove
but if you say "hwnd" i assume you don't have that
ah no i am using raylib
just a bare dotnet project
i need someting identitcal to GLFW's raw mouse motion https://www.glfw.org/docs/3.3/input_guide.html#:~:text=Raw%20mouse%20motion%20is%20closer,for%20example%20a%203D%20camera.
ok but will you have a surface to render on, even if a windows api registered form?
also if you are that raw then why go c#
because c# is very modular and easy to distribute
and im most proficient in it
YES
i am using RAYLIB TO RENDER
all i need is MOUSE INPUT
raylib is not a windows class, tho
you have to know which windows object you have under the hood to get coordinates in your context
or you get global mouse position, but it will require to run as admin, probably, and you still have to scale for resolution
raylib uses glfw to handle windowing, i cant get a glfw handle from raylib but i can get a win32 window handle
i want to use that window handle to get mouse input
are you really sure this is an easier problem to solve than try getting better mouse movement from raylib itself?
i would search if raylib lets the dev in the event loop to catch wm mouse move events
if that's a no then you kinda need to do the more harsh way
it doesnt, i have tried everything with raylib
i need to do the harsh way i just am not sure HOW
you can search for api SetWindowsHookEx, could be one way
i believe you can try with GetRawInputData api series, but i never used that
there are other ways too, with windows api iirc you could add another method for processing messages and catch mouse events there
but since it's all apis you need to interop outside of c#
theres the RawInput api
and theres the new GameInput api that ive never used
are there any c# examples of the rawinput api?
not really, youd have to pinvoke
or find a lib ig
alreight
ill try that out
but how come raylibs input system isnt good
its a pretty popular library so thats a bit surprising
this is from someone that is very very familiar with raylib
try putting it in raw mode
tracking via window messages isnt going to be reliable yeab