I'm trying to use DirectInput in the DirectX SDK to do USB
reading (a device as joystick). There's no error when compiling the codes but whenever it
tries to excecute:
g_pDI->EnumDevices(DI 8DEVCLASS_GAMEC TRL, EnumJoysticksCa llback,
NULL, DIEDFL_ATTACHED ONLY);
where
BOOL CALLBACK EnumJoysticksCa llback(const DIDEVICEINSTANC E*
pdidInstance, VOID* pContext)
{
HRESULT hr;
// Obtain an interface to the enumerated joystick.
hr = g_pDI->CreateDevice(p didInstance->guidInstance ,
&joystick, NULL);
if(FAILED(hr))
return DIENUM_CONTINUE ;
return DIENUM_STOP;
}
...I get "A first chance exception of
type 'System.NullRef erenceException ' occurred in test.exe" error
message; the program could still continue but it would just throw
the exception and doesn't do what it is supposed to do.
I've tested it by placing a flag in EnumJoysticksCa llback and it
seems to me that it is not the callback function that is causing
the problem.
Appreciate any suggestion :]
reading (a device as joystick). There's no error when compiling the codes but whenever it
tries to excecute:
g_pDI->EnumDevices(DI 8DEVCLASS_GAMEC TRL, EnumJoysticksCa llback,
NULL, DIEDFL_ATTACHED ONLY);
where
BOOL CALLBACK EnumJoysticksCa llback(const DIDEVICEINSTANC E*
pdidInstance, VOID* pContext)
{
HRESULT hr;
// Obtain an interface to the enumerated joystick.
hr = g_pDI->CreateDevice(p didInstance->guidInstance ,
&joystick, NULL);
if(FAILED(hr))
return DIENUM_CONTINUE ;
return DIENUM_STOP;
}
...I get "A first chance exception of
type 'System.NullRef erenceException ' occurred in test.exe" error
message; the program could still continue but it would just throw
the exception and doesn't do what it is supposed to do.
I've tested it by placing a flag in EnumJoysticksCa llback and it
seems to me that it is not the callback function that is causing
the problem.
Appreciate any suggestion :]
Comment