Jump to content
  • Advertisement
Sign in to follow this  
renatoelt

Handling mouse

This topic is 4848 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! There are any standard C++ library that handle mouse? I know that mmsystem.h handle joystick. But what is the one that handle mouse and keyboard??? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Depends on the OS you use. If you use DOS you need to find some lib or write your own (having docs on Mouse interrupt it's not too difficult). If you develop under windowing system it has its own API including that for mouse. And, of course, there is no standard library in C++ for mouse :)

Share this post


Link to post
Share on other sites
For the keyboard, I use a pair of macros:
#define KEYDOWN( vk_code ) ( ( GetAsyncKeyState( vk_code ) & 0x8000 ) ? 1 : 0 )
#define KEYUP( vk_code ) ( ( GetAsyncKeyState( vk_code ) & 0x8000 ) ? 0 : 1 )
I believe GetAsyncKeyState is in windows.h. Then you use them like this:

// pressing the up arrow key
if (KEYDOWN(VK_UP))
{
cam.MoveForward( 128 );
}

VK_UP I believe is also defined somewhere in windows.h, but letters (a-z) are not defined, you have to define them yourself. I won't list all the other key values, but I'm sure they're out there somewhere.

#define VK_A 65
#define VK_B 66
#define VK_C 67
#define VK_D 68
#define VK_E 69
#define VK_F 70
#define VK_G 71
#define VK_H 72
#define VK_I 73
#define VK_J 74
#define VK_K 75
#define VK_L 76
#define VK_M 77
#define VK_N 78
#define VK_O 79
#define VK_P 80
#define VK_Q 81
#define VK_R 82
#define VK_S 83
#define VK_T 84
#define VK_U 85
#define VK_V 86
#define VK_W 87
#define VK_X 88
#define VK_Y 89
#define VK_Z 90

Hope that helps!

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!