Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Mouse & WM_INPUT problems

Started by Samurai Jack 1 reply 800+ views
Original Post
Samurai Jack
Samurai Jack
Greetings! My problem is that when someone moves the mouse WM_INPUT is called like it should. That is ok. But let us say, you move the mouse to the left and WM_INPUT comes with the relative x change = -1. That is ok. But my problem is the following: I have a loop which calls m_pInput->Update(); what is when the user moves the mouse after Update() and the next update clears the mouse? Should I add the mouse movement changes or is there any better suggestion?
Kylotan
Kylotan
It's not clear what you're doing. What is 'm_pInput', what does its Update() function do, and how are you handling the mouse? If you handle individual messages, then nothing gets cleared, as such. So it would help to know exactly what you're doing. If the problem is that you poll for input twice in one frame, it's usually simplest just to stop doing that!
Samurai Jack
Samurai Jack
Hm, the problem was that the engine calls once per frame the Update() function which should check keystrokes, mouse and joysticks and then fire up action mapping. Update was not called by WM_INPUT but from the engine loop instead. The problem was what if, the update() block was allready processed and we were in the middle of the rendering and someone moves the mouse. Even if he left the mouse alone my variable still had the value of -1 for example. In this case it ment the following: if one moved mouse to the left (Relavtive X=-1) there IS no message, that says he does not move the mouse anymore, so the RelativeX is still -1. I did the following: if a WM_INPUT message gets processed it sums all X and Y into a buffer. And then when Input() gets called it copyies the BUFFER into RELATIVEXY and then clears the buffer. If no mouse movement available, mouse buffer is empty and RELATIVEXY will be empty by the next call on Update();

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.