Jump to content
  • Advertisement
Sign in to follow this  
JamesCobras

[Super Noob]Getting Mouse Input

This topic is 3501 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, yes a really easy question, well two actually. 1. Is it best to get input via direct x through DirectInput or through other methods. 2. What code do i need to allow me to get mouse input (buttons scroll and move) in both DirectInput and through other means. I presume other means are through windows. What includes, and basic example code would be nice. JamesCobras

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by JamesCobras
Hi guys, yes a really easy question, well two actually.

1. Is it best to get input via direct x through DirectInput or through other methods.

2. What code do i need to allow me to get mouse input (buttons scroll and move) in both DirectInput and through other means.

I presume other means are through windows.

What includes, and basic example code would be nice.

JamesCobras
As I understand it, DirectInput has been deprecated; Microsoft now recommend using the Windows message loop for events (assuming a typical PC application). Another option would be to use a cross-platform library such as SDL or SFML.

If you need further advice, you might specify what programming language you're using and what platforms you're targeting.

Share this post


Link to post
Share on other sites
if you include windows.h all you need to do to get mouse coordinates is

POINT mouse;
GetCursorPos(&mouse);
mouse.x and mouse.y

and in your windows message loop to check for clicks and coordinates something like this would work


case WM_RBUTTONDOWN:
{
POINT ptMouse;
ptMouse.x=(int)LOWORD(lParam);
ptMouse.y=(int)HIWORD(lParam);
//do something with it
RightMouseClick(ptMouse);

}break;

case WM_LBUTTONDOWN:
{
POINT ptMouse;
ptMouse.x=(int)LOWORD(lParam);
ptMouse.y=(int)HIWORD(lParam);
//do something with it
LeftMouseClick(ptMouse);

}break;



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!