Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] mouse & DirectX.DirectInput

Started by p997 Aug 11, 2006 at 2:54 AM 0 replies 1k views
Original Post
p997
p997
Hi, im trying to incorporate mouse with my game through DirectInput. well, i know how to initialize & poll the device, but how do i get the current cursor x,y position relatively to the screen position. for instance, the screen resolution is 800 x 600, then when the mouse cursor is at upper left corner it should read 0,0 while it should read 800,600 when it is at bottom right corner. Could someone pls tell me how to use the mouse cursor to retrieve the screen position. Thanks in advance.
vovansim
vovansim
Well, the thing about DirectInput is, it doesn't know or care where the mouse is. :) This is fine for games where you use the mouse without a cursor (ie aiming in FPS). This is not fine for places where you need a cursor (ie main menu GUI). So, if you do care about where the mouse is, you have to keep track of it yourself. :)

See these resources for some help on how to accomplish that:

Developing a GUI Using C++ and DirectX
Moving Your Game to Windows, Part II: Mouse and Joystick Input <-- Really old article, so code is pretty useless, but it goes over the concepts.

Hope that helps,
Vovan
Vovan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.