Problems with DirectInput and the Mouse

Started by
2 comments, last by stranger4u 21 years, 8 months ago
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?
Advertisement
look up buffered input in the SDK. Buffered input keeps accumulates all the movement of the moust and gives yo the absolute coordinates when call GetDeviceData

''There''s something out there....something stupid...''
- Daria

DirectInput8 with the Keyboard , DirectInput8 with the Mouse , Using DirectX Audio 8
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.
thanks for the replies. sounds good, will try it.

This topic is closed to new replies.

Advertisement