Jump to content
  • Advertisement
Sign in to follow this  
Drew_Benton

Receiving mouse input outside of the WinProc function

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

At GameTutorials.com, they have a nice little tutorial showing how to obtain keyboard input outside the WinProc function. To do this, you use GetKeyboardState. Now I need to do the same for mouse input, but in the sense of mouse buttons and such. I can easily obtain the position, so that's not a problem, but I do not know how to get the current state of the mouse as well as if the wheel was scrolled. Is this possible or must you process the mouse in the event loop? Thanks in advance! - Drew [Edited by - Drew_Benton on May 25, 2005 9:45:16 PM]

Share this post


Link to post
Share on other sites
Advertisement
If you are doing games under windows, you should really just go learn DirectInput. It will let you get the state of the mouse, of the keyboard, and of any joysticks from outside WinProc(), and it gives more detail and more control than Win32 does.

Share this post


Link to post
Share on other sites
Quote:
Original post by mumpo
If you are doing games under windows, you should really just go learn DirectInput. It will let you get the state of the mouse, of the keyboard, and of any joysticks from outside WinProc(), and it gives more detail and more control than Win32 does.


[smile] I knew someone would reccomend that, but heres the thing - this is for an input plugin. I already have DInput as a plugin and now I wanted to make the Win32 input the same way. This is just more for "Can I do this", rather than application. I already have the Win32 input setup to work with the WinProc - but I would like to see if its possible to get it to work outside as well, so I can easily add it as a plugin. Thanks for the suggestion though.

- Drew

[edit] After looking in MSDN, it seems that the WinProc is the only way - does anyone happen to have any tricks up their sleeves? [/edit]

[Edited by - Drew_Benton on May 25, 2005 9:12:26 PM]

Share this post


Link to post
Share on other sites
Use GetAsyncKeyState();
The left mouse button is VK_LBUTTON and the right mouse button is VK_RBUTTON

*EDIT* VK_MBUTTON is the middle mouse button, but I'm not sure about a scroll wheel. You can find the list on MSDN here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/virtualkeycodes.asp
*EDIT*

Share this post


Link to post
Share on other sites
Quote:
Original post by wyrzy
Use GetAsyncKeyState();
The left mouse button is VK_LBUTTON and the right mouse button is VK_RBUTTON

*EDIT* VK_MBUTTON is the middle mouse button, but I'm not sure about a scroll wheel. You can find the list on MSDN here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/virtualkeycodes.asp
*EDIT*


Thank you so much, it works perfectly! I'd give you a rating++, but your already at the top [wink]. I guess I was always looking at keystate for keyboards and didn't check the VKs for mouse defines. Thanks again!

- Drew

[Edited by - Drew_Benton on May 25, 2005 9:43:35 PM]

Share this post


Link to post
Share on other sites
The VK Codes are defined in WinUser.h in your VC++ directory, but I didn't see anything about a mouse wheel. Do you really need a mouse wheel? You could leave it as "unsupported" in the Win32 version unless someone else knows how to get input outside the Windows Message Loop without Direct Input.

Share this post


Link to post
Share on other sites
Oh no, the mouse wheel was just an idea. I don't even have it inplemented for DInput and I doubt that our engine will use it. Thanks though!

[Edited by - Drew_Benton on May 25, 2005 9:48:44 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Drew_Benton
Thank you so much, it works perfectly! I'd give you a rating++, but your already at the top [wink]. I guess I was always looking at keystate for keyboards and didn't check the VKs for mouse defines. Thanks again!

- Drew

Your welcome. Did you know you can rate users more than once? I've tried it once just cause I was wondering, and the user's rating increased the same second.

Share this post


Link to post
Share on other sites
Quote:
Original post by wyrzy
Quote:
Original post by Drew_Benton
Thank you so much, it works perfectly! I'd give you a rating++, but your already at the top [wink]. I guess I was always looking at keystate for keyboards and didn't check the VKs for mouse defines. Thanks again!

- Drew

Your welcome. Did you know you can rate users more than once? I've tried it once just cause I was wondering, and the user's rating increased the same second.


I think it was a coincidence - I read somewhere on GameDev that you only have one rating per user - in which you can change at times. But if someone who has rated a person get's a better rating, than the other person's rating goes up as well - since they have a higher rating now. I tried the rating again and yours still stayed the same. Thanks for all the help!

- Drew

[Edited by - Drew_Benton on May 25, 2005 9:03:58 PM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!