Archived

This topic is now archived and is closed to further replies.

Problems with DirectInput and the Mouse

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

I''m having a lot of trouble getting DI and Mouse Input to work in my windowed game. The first problem is, that when I alt+tab out of my window DI tells me the mouse button has been clicked. I just check the mouse with GetDeviceState and the above happens.. Sure the mouse button works fine, but alt+tab too and that is kinda weird. Also I got no idea how to get absolute coordinates. Since DI only gives me the change in position I don''t know how to do it. I guess I''d have to figure out the cursor position with some windows function and then add/subtract the changes to keep track of the position. But how exactly do I do it and how do I find out if the cursor is within my game window? Or is there a better way to do it?

Share this post


Link to post
Share on other sites
Are you checking for device loss when you call GetDeviceState? When you Alt-Tab away, chances are that you lose access to the device and GetDeviceState returns DIERR_INPUTLOST. I think the debug runtimes fill the state buffer with random values if you try to get the state of a device that you''ve lost, hence the mouse click. You need to check the return value and ignore the state if the device was lost. Then wait until the user reactivates your window and try to reacquire the device.

Share this post


Link to post
Share on other sites