Advertisement Jump to content
Sign in to follow this  

Handling mouse

This topic is 4909 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
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
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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!