none
DirectInput Error 0x80070216 RRS feed

  • General discussion

  • Hello!

    First of all I did not find a proper SDK theme - sorry, I write here.

    I want to write a program interacting with joystick. I am using a standard SDK example and dinput8.lib.

    Here's the code. GUID Is taken from enumJoysticksCallback function. I throw away everything to minimise chance of error.

    LPDIRECTINPUT8          g_pDI = NULL;
    LPDIRECTINPUTDEVICE8    g_pJoystick = NULL;
    
    HRESULT hr = DirectInput8Create ( GetModuleHandle( NULL ), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&g_pDI, NULL );
    
    	GUID  *GUID_Saitek = new _GUID ;
    	GUID_Saitek->Data1 = 0xA00DBD70;
    	GUID_Saitek->Data2 = 0x7FB5;
    	GUID_Saitek->Data3 = 0x11E3;
    	char tmp[8] = { 0x80, 0x3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 };
    	memcpy(GUID_Saitek->Data4, tmp, 8);
    
    	g_pDI->CreateDevice( *GUID_Saitek, &g_pJoystick, NULL );
    	hr = g_pJoystick->SetDataFormat( &c_dfDIJoystick2 ) ;

    Program fails on this string 

    hr = g_pJoystick->SetDataFormat( &c_dfDIJoystick2 );

    hr returns 0x80070216 which seems to be ERROR_ARITHMETIC_OVERFLOW. 

    &c_dfDIJoystick instead of &c_dfDIJoystick2 does not help too.

    For mouse it is the same...

    LPDIRECTINPUT8          di = NULL;
    LPDIRECTINPUTDEVICE8    Mouse = NULL;
    HRESULT hr = DirectInput8Create(GetModuleHandle( NULL ),  DIRECTINPUT_VERSION, IID_IDirectInput8,  (VOID**)&di, NULL);
    hr = di->CreateDevice( GUID_SysMouse, &Mouse, NULL );
    hr = Mouse->SetDataFormat( &c_dfDIMouse ) ;
    hr returns 0x80070216 again

    The example application "Joystick.exe" works no problem.

    GetCapabilities returns some random stuff which is definately not true

    • Embarcadero RAD Studio XE5/Borland CPP Builder 6 (both have same results)
    • DirectInput
    • Saitek Rudder Pedals/Saitek X52 controllers (both crash program)
    • 32bit app
    • standard SDK example "Joystick"

    What is wrong? Error does not match anything related to directinput.

    Thanks!


    UPDATE: SetCooperativeLevel function returns 0x80070006 which is ERROR_INVALID_HANDLE










    Tuesday, April 8, 2014 11:13 AM

All replies

  • Hello,

    Post your thread on the following forum.

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=gametechnologiesdirectx101.

    http://xboxforums.create.msdn.com/forums/.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 9, 2014 9:17 AM
    Moderator
  • Thank you!
    Wednesday, April 9, 2014 10:12 AM
  • Finally I found out what was the problem. It lied here: &c_dfDIJoystick2

    For some reason Microsoft attached pre-defined structures that do not match anythig. Even &c_dfDIMouse does not match my simple 3 button mouse.
    The answer came with another sample code "Custom Format". 
    You have to make a new format structure for each device because even EnumObjects function will not make it for you, which makes DirectInput quite inconvenient.
    Thursday, April 10, 2014 3:06 PM
  • The predefined structures do in fact work. They are used in the standard Joystick sample that you note works for you as well:

    if( FAILED( hr = g_pJoystick->SetDataFormat( &c_dfDIJoystick2 ) ) )
        return hr;

    In one of your reports, you mentioned that you were using something besides Visual C++ to build your code, so perhaps there is some linker setting or alignment issue at work here rather than it being a general problem with DirectInput?

    You could try debugging your application and inspecting the contents of c_dfDIJoystick2 (or use printf/OutputDebugString to dump it out). It should be:

    dwSize=24
    dwObjSize=16
    dwFlags=1
    dwDataSize=272
    dwNumObjs=164
    rgodf.pguid = {A36D02E0-C9F3-11CF-BFC7-444553540000} 
    rgodf.dwOfs = 0
    rgodf.dwType = 2164260611
    rgodf.dwFlags = 256

    If these values don't match your debug inspecting, then the problem is in the linker or compiler settings you are using...



    Thursday, April 10, 2014 5:18 PM
  • I mean I tried them both. 8 years between compilers. I think if problem would be in compiler - one of them would work. But thanks for your answer anyway.

    I don't know why "Joystick" source code did not work and "Custom format" did. The fact is - custom format did the trick.

    Frankly speaking I do not know how to make a dump of c_dfDIJoystick2. Could you tell me where this structure lies (what file I mean)? All I see in "dinput.h" is "extern const DIDATAFORMAT c_dfDIJoystick2;" And when I add it to the watch list - RAD Studio of cause says that it is an undefined symbol. 

    Thursday, April 10, 2014 7:12 PM