DirectInput SetDataFormat error -


i want write program interacting joystick. using standard sdk example , dinput8.lib.

here's code. guid taken enumjoystickscallback function. throw away 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 string

hr = g_pjoystick->setdataformat( &c_dfdijoystick2 ); 

hr returns 0x80070216 seems error_arithmetic_overflow.

&c_dfdijoystick instead of &c_dfdijoystick2 not too.

for mouse 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 example application "joystick.exe" works no problem.

getcapabilities returns random stuff 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 wrong? error not match related directinput. device creates no errors work leads errors.

thanks!

update: setcooperativelevel function returns 0x80070006 error_invalid_handle

finally found out problem. lied here: &c_dfdijoystick2

for reason microsoft attached pre-defined structures not match anythig. &c_dfdimouse not match simple 3 button mouse. answer came sample code "custom format". have make new format structure each device because enumobjects function not make you, makes directinput quite inconvenient.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -