Jump to content
  • Advertisement
Sign in to follow this  
Si0n

Need help with acquiring mouse in DInput...

This topic is 5031 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!