This is the code i use to create the directinput stuff:



DI_Init proc hWin:DWORD
invoke DirectInputCreate, hInstance, DIRECTINPUT_VERSION, ADDR lpdi,0
DIINVOKE CreateDevice, lpdi, ADDR GUID_SysKeyboard, ADDR lpdikey, 0
.if eax!=DI_OK
FATAL "Creating Input Device failed!"
.endif
DIDEVINVOKE SetCooperativeLevel, lpdikey, hWin,DISCL_NONEXCLUSIVE or DISCL_BACKGROUND
.if eax!=DI_OK
FATAL "DI: SetCooperativeLevel failed!"
.endif
DIDEVINVOKE SetDataFormat, lpdikey, ADDR c_dfDIKeyboard
.if eax!=DI_OK
FATAL "DI: SetDataFormat failed!"
.endif
DIDEVINVOKE Acquire, lpdikey
.if eax!=DI_OK
FATAL "DI: Acquire keyboard failed!"
.endif
DIINVOKE CreateDevice, lpdi, ADDR GUID_SysMouse, ADDR lpdimouse, 0
.if eax!=DI_OK
FATAL "DI: Creating mouse device failed!"
.endif
DIDEVINVOKE SetCooperativeLevel, lpdimouse, hWin,DISCL_NONEXCLUSIVE or DISCL_BACKGROUND
.if eax!=DI_OK
FATAL "DI: SetCooperativeLevel (MOUSE) failed!"
.endif
DIDEVINVOKE SetDataFormat, lpdimouse, ADDR c_dfDIMouse
.if eax!=DI_OK
FATAL "DI: SetDataFormat (MOUSE) failed!"
.endif
DIDEVINVOKE Acquire, lpdimouse
.if eax!=DI_OK
FATAL "DI:Acquire mouse failed!"
.endif
ret
DI_Init endp


now i need to read the mouse. i don't know how to do that, does anybody perhaps have a code example?

thanks.. bye
Posted on 2002-07-21 15:33:21 by NOP-erator
Hi NOP !

This is what the SDK-Help says:


Immediate Mouse Data

To retrieve the current state of the mouse, call IDirectInputDevice8::GetDeviceState with a pointer to a DIMOUSESTATE or a DIMOUSESTATE2 structure, depending on the data format. The mouse state returned in the structure includes axis data and the state of each of the buttons.

The first three members of the structure hold the axis coordinates. (See Interpreting Mouse Axis Data.)

The rgbButtons member is an array of bytes, one for each of four or eight buttons. For a traditional mouse, the first element in the array is generally the left button, the second is the right button, and the third is the middle button. The high bit is set if the button is down, and it is clear if the button is up or not present.



typedef struct DIMOUSESTATE {
LONG lX;
LONG lY;
LONG lZ;
BYTE rgbButtons[4];
} DIMOUSESTATE, *LPDIMOUSESTATE;



IDirectInputDevice8::GetDeviceState

Retrieves immediate data from the device.



HRESULT GetDeviceState(
DWORD cbData,
LPVOID lpvData
);


Parameters
cbData Size of the buffer in the lpvData parameter, in bytes.
lpvData Address of a structure that receives the current state of the device. The format of the data is established by a prior call to the IDirectInputDevice8::SetDataFormat method.
Return Values
If the method succeeds, the return value is DI_OK.

If the method fails, the return value can be one of the following error values:


DIERR_INPUTLOST
DIERR_INVALIDPARAM
DIERR_NOTACQUIRED
DIERR_NOTINITIALIZED
E_PENDING


This should help you ...

Greetings, Caleb
Posted on 2002-07-21 17:35:51 by Caleb
hi,

it took me about 1,5 hours, but it works now. you know.. till i noticed that i have to draw the mouse cursor myself :rolleyes: .... and then i had problems with relative and absolute mouse axis coordinates (problems with changing between the two modes).. but i solved everything.. it works nice now, thank you very much!


bye
Posted on 2002-07-22 07:21:27 by NOP-erator