Archived

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

Moose

Get absolute coordinates with DirectInput

Recommended Posts

Does anyone know how to use DirectInput to return absolute coordinated instead of relative coordinates as i am creating a program and i need the coordinates to test whether a region has been clicked.there is an example shown in "Windows Game Programming for dummies",but i can''t seem to find out which line of code does the trick.Could it be a version problem as i am using DX8 and the book uses DX6,thanx

Share this post


Link to post
Share on other sites
From the DX8 help file:

"To set the axis mode to absolute, call IDirectInputDevice8::SetProperty with the DIPROP_AXISMODE value in the rguidProp parameter and with DIPROPAXISMODE_ABS in the dwData member of the DIPROPDWORD structure."

This will not give you screen co-ordinates. It will give you an absolute position based on the position the mouse was in when the device was created by DirectInput. Therefore, you may want to use the Win32 mouse messages to get the initial position when the device is created and then use DirectInput from there.

Cheers,
John

John Reynolds
Programmer
Creative Asylum Ltd

Share this post


Link to post
Share on other sites
I''d consider using the win32 GetCursorPos function. It does what you want and it''s easy.

I was in the same spot as you and gave it a try - it was the goods.

El Duderino

Share this post


Link to post
Share on other sites