Insertion d'un joystick sous directx

Résolu
kennit69 Messages postés 2 Date d'inscription dimanche 7 août 2005 Statut Membre Dernière intervention 7 août 2005 - 7 août 2005 à 17:06
kennit69 Messages postés 2 Date d'inscription dimanche 7 août 2005 Statut Membre Dernière intervention 7 août 2005 - 7 août 2005 à 20:25
bonjour

je souhaite integrer un joystick dans mon programme directx
j'ai suivi les etapes explique sur le site msdn et lors de l'appele a la fonction
HRESULT hr = g_pJoystick->SetCooperativeLevel( DXUTGetHWND(), DISCL_EXCLUSIVE | DISCL_FOREGROUND ) ) )

hr prend la valeur de E_HANDLE (pour un fonctionnement normal il devrait etre a S_OK )

voila la parit de mon code d'initialisation


HRESULT InitDirectInput( HWND hDlg )


{


HRESULT hr;



// Register with the DirectInput subsystem and get a pointer



// to a IDirectInput interface we can use.



// Create a DInput object



if( FAILED( hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_pDI, NULL ) ) )



return hr;



// Look for a simple joystick we can use for this sample program.



if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, NULL, DIEDFL_ATTACHEDONLY ) ) )



return hr;



// Make sure we got a joystick



if( NULL == g_pJoystick )


{


MessageBox( NULL, TEXT("Joystick not found. The sample will now exit."),


TEXT("DirectInput Sample"),


MB_ICONERROR | MB_OK );


EndDialog( hDlg, 0 );



return S_OK;


}



// Set the data format to "simple joystick" - a predefined data format



//



// A data format specifies which controls on a device we are interested in,



// and how they should be reported. This tells DInput that we will be



// passing a DIJOYSTATE2 structure to IDirectInputDevice::GetDeviceState().



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



return hr;



// Set the cooperative level to let DInput know how this device should



// interact with the system and with other DInput applications.



if( FAILED( hr = g_pJoystick->SetCooperativeLevel( DXUTGetHWND(), DISCL_EXCLUSIVE | DISCL_FOREGROUND ) ) )



return hr;

...

et donc ça me fait une erreur de E_HANDLE a ce niveau

je vous remercie d'avance de votre aide

2 réponses

Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
7 août 2005 à 18:26
Salut, je pense qu'il faut passer un 'top-level window handle", passe hDlg.
3
kennit69 Messages postés 2 Date d'inscription dimanche 7 août 2005 Statut Membre Dernière intervention 7 août 2005
7 août 2005 à 20:25
oui merci c'etait ça
0
Rejoignez-nous