Jump to content
  • Advertisement
Sign in to follow this  
ProgrammerZ

Windows mouse/keyboard input questions

This topic is 3449 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

Hi guys. Lately, I've been looking a little more closely into Windows mouse and keyboard input for my GUI. Here were a few questions I had: 1. Is GetCursorPos() a reasonable alternative to WM_MOUSEMOVE? The reason I'm asking this is because WM_MOUSEMOVE tends to produce ugly cursor behavior in windowed mode when the cursor moves off the screen. 2. I know that WM_KEYDOWN/KEYUP and WM_CHAR work in approximately the same way (wParam indicates the key pressed). But, can I use WM_KEYDOWN for "keyboard input" (is the W key pressed) and WM_CHAR for "text input" (did the user type 'W')? Currently, to check for "keyboard input", I have to check for both lowercase and uppercase keys, in case the SHIFT key is also being pressed. Thanks in advance, and sorry if my questions aren't as clear as they could be (I wrote this kinda fast). -- ProgrammerZ

Share this post


Link to post
Share on other sites
Advertisement
1. You may be able to use SetCapture - I thought that it captured mouse input even when the mouse wasn't over the active window (I.e. just moving anywhere on the screen). If that doesn't work (I haven't tested it), GetCursorPos() is fine to use. You'll need to use ScreenToClient to convert to client coordinates though, since GetCursorPos() gives screen coordinates and WM_MOUSEMOVE gives client coordinates.

2. Yes - this is the correct way to do it. If you're inputting text, use WM_CHAR. If you want to see if a key is pressed, use WM_KEYDOWN (Remember that you'll get multiple messages sent for key repeat).

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!