Plusieurs joystick directinput

silkgandalf Messages postés 2 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 1 août 2003 - 30 juil. 2003 à 16:59
cs_Nico_972 Messages postés 3 Date d'inscription mercredi 28 septembre 2005 Statut Membre Dernière intervention 6 octobre 2005 - 6 oct. 2005 à 23:24
bon alors voila mon probleme:
je veut pouvoir utiliser 2 joysticks.
en avoir 1 j'y arrive, mais pour en avoir 2 je ne sait pas comment faire.
2 LPDIRECTINPUTDEVICE8?
dans ce cas, comment initialiser le 2eme

donc si je pouvais avoir de l'aide.... merci

4 réponses

silkgandalf Messages postés 2 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 1 août 2003
1 août 2003 à 11:04
pour repondre a moi meme, et pour ceux qui sont interresser:
voila la fonction callback pour l'enumeration des joysticks.

BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance,VOID* pContext )
{
if (pJoystick2 == NULL)
{
if(lpDI->CreateDevice( pdidInstance->guidInstance, &pJoystick2, NULL)!=DI_OK)
return DIENUM_CONTINUE;
}
if(lpDI->CreateDevice( pdidInstance->guidInstance, &pJoystick, NULL)!=DI_OK)
return DIENUM_CONTINUE;

return DIENUM_CONTINUE;
}
0
cs_Nico_972 Messages postés 3 Date d'inscription mercredi 28 septembre 2005 Statut Membre Dernière intervention 6 octobre 2005
3 oct. 2005 à 14:52
Salut [auteurdetail.aspx?ID=19940 silkgandalf],



je désire faire la même chose que toi. J'y suis depuis hier soir.

Si t'as trouvé comment faire, fait-le moi savoir, je ferais de même.



Merci
0
cs_Nico_972 Messages postés 3 Date d'inscription mercredi 28 septembre 2005 Statut Membre Dernière intervention 6 octobre 2005
6 oct. 2005 à 23:18
Pour étendre le nombre maximum de joysticks à "NBR_JOYSTICKS" :


#define NBR_JOYSTICKS 2

int numJoystick = -1;
LPDIRECTINPUTDEVICE8 g_pJoystick[2] = {NULL, NULL};

...
...

// Cette fonction est appelée à chaque fois qu'un joystick est trouvé.
BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE* pdidInstance,
VOID* pContext )
{
HRESULT window;

numJoystick++;

//printf("-> EnumJoysticksCallback (joystick %d)\n", numJoystick);

window = g_pDI->CreateDevice(pdidInstance->guidInstance, &g_pJoystick[numJoystick], NULL);

if( FAILED(window) )
return DIENUM_CONTINUE;

if( FAILED( g_pJoystick[numJoystick]->SetDataFormat( &c_dfDIJoystick2 ) ) )
return DIENUM_CONTINUE;

window = g_pJoystick[numJoystick]->EnumObjects( EnumAxesCallback, (VOID*)&numJoystick, DIDFT_AXIS );
if ( FAILED( window ) )
return DIENUM_CONTINUE;

if ( FAILED( g_pJoystick[numJoystick]->Acquire() ) )
return DIENUM_CONTINUE;

// tant qu'on a pas trouvé les "NBR_JOYSTICKS" joysticks
if (numJoystick < NBR_JOYSTICKS-1)
return DIENUM_CONTINUE;

return DIENUM_STOP;
}
0
cs_Nico_972 Messages postés 3 Date d'inscription mercredi 28 septembre 2005 Statut Membre Dernière intervention 6 octobre 2005
6 oct. 2005 à 23:24
Je me suis gouré sur une ligne!



LPDIRECTINPUTDEVICE8 g_pJoystick[NBR_JOXSTICKS];
0
Rejoignez-nous