Sign in to follow this  

Need help with acquiring mouse in DInput...

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

Here, I have this fucntion and it is failing in the SetDataFormat for some reason:
int initMouse(dinputMainData *di)
{
 	if (!di)
 	    return 0;
 	 
    if (FAILED(di->lpdinput->CreateDevice(GUID_SysKeyboard, &di->lpdimouse, NULL)))
        return 0;
    
    if (FAILED(di->lpdimouse->SetCooperativeLevel(di->hWnd, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))
        return 0;
    
    if (FAILED(di->lpdimouse->SetDataFormat(&c_dfDIMouse)))
        return 0;
    
    if (FAILED(di->lpdimouse->Acquire()))
        return 0;
   
    return 1;
}
struct dinputMainData
{
    static dinputMainData *direct_input() { if (!dinput) dinput = new dinputMainData;  return dinput; }
    
    HINSTANCE	hInstance;
    HWND		hWnd;
    
    LPDIRECTINPUT8			lpdinput;
    LPDIRECTINPUTDEVICE8	lpdikey;
    LPDIRECTINPUTDEVICE8	lpdimouse;
    LPDIRECTINPUTDEVICE8	lpdijoy;
    
    GUID  joyGUID;
    TCHAR joyName[80];
    int	  joyFound;
    
    BYTE 			keyState[256];
    DIMOUSESTATE	mouseState;
    DIJOYSTATE		joyState;
    
    ~dinputMainData();
    
    int init();

protected:
    
    dinputMainData();
    dinputMainData(dinputMainData&);
    dinputMainData &operator=(dinputMainData&);
    
    static dinputMainData *dinput;
};

Share this post


Link to post
Share on other sites

This topic is 4689 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this