Jump to content
  • Advertisement
Sign in to follow this  
littlekid

How to use WM_INPUT to detect continous mouse clicks?

This topic is 4229 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently using WM_INPUT to detect my mouse updates, when I click my mouse button 1, I will detect that button 1 is down. However if i hold down the button, the subsequent updates for the mouse will show that button 1 is not depressed. I add a simple code to display the state of the mouse and found this problem. Here is what it look like Button 1 down State / Mouse X direction movement --------------------------------- true / 0.0 (press button down and hold) false / -1.0 (Button still depressed, but when mouse is move, it does not show) false / -1.0 (Button still depressed, but when mouse is move, it does not show) false / -1.0 (Button still depressed, but when mouse is move, it does not show) false / 0.6 (Button still depressed, but when mouse is move, it does not show) Is there any way to solve it? I wish to make a function such that when the user click and hold the mouse, he/she can then rotate the camera, else the camera won't move. Thanks alot

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Emmanuel Deloget
I know it's less general, but why don't you use the WM_kBUTTONDOWN and WM_kBUTTONUP? It seems easier to me (and more natural).

Anyway, here is a thread with some details about WM_INPUT handling. Maybe it can help you.


And more important:
Quote:
MSDN
...
usButtonFlags
Transition state of the mouse buttons. This member can be one or more of the following values.
...

Emphasis is mine.

If I understand everything correctly, this means that the usButtonFlags of RAWMOUSE is set only at when the state of a button changes (that's a transitional state). On the next call, the value will not be set.

Now, you should get the raw button state in ulRawButtons, but this is not fully documented on the MSDN. I can't find much information about that on the web, and I fear that the real data depends on the hardware.

Share this post


Link to post
Share on other sites
Here is the code section that handles the mouse input. The keyboard input is ok so I left it out.


if (pRawInput->header.dwType == RIM_TYPEMOUSE)
{
RAWMOUSE RawMouse = pRawInput->data.mouse;

RCI::RenderCoreState.GetMouseButton()[0] = (RawMouse.usButtonFlags == RI_MOUSE_BUTTON_1_DOWN);
RCI::RenderCoreState.GetMouseButton()[1] = (RawMouse.usButtonFlags == RI_MOUSE_BUTTON_2_DOWN);
RCI::RenderCoreState.GetMouseButton()[2] = (RawMouse.usButtonFlags == RI_MOUSE_BUTTON_3_DOWN);
RCI::RenderCoreState.GetMouseButton()[3] = (RawMouse.usButtonFlags == RI_MOUSE_BUTTON_4_DOWN);
RCI::RenderCoreState.GetMouseButton()[4] = (RawMouse.usButtonFlags == RI_MOUSE_BUTTON_5_DOWN);

if (RawMouse.usButtonFlags == RI_MOUSE_WHEEL)
RCI::RenderCoreState.SetMouseDelta((short)RawMouse.usButtonData);
else
RCI::RenderCoreState.SetMouseDelta(0.0f);

RCI::RenderCoreState.SetMouseOffsetX((float)RawMouse.lLastX);
RCI::RenderCoreState.SetMouseOffsetY((float)RawMouse.lLastY);
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!