Problème de getdevicestate

vini456 Messages postés 6 Date d'inscription lundi 7 novembre 2005 Statut Membre Dernière intervention 11 décembre 2005 - 9 nov. 2005 à 23:24
cali70 Messages postés 71 Date d'inscription mercredi 29 septembre 2004 Statut Membre Dernière intervention 19 mars 2008 - 16 nov. 2005 à 14:30
Bonsoir,
J'ai une exception lorsque j'exécute mon programme
pourtant il me semble que tout est correct.
TCHAR buffer [256];


ZeroMemory( &buffer,
sizeof(buffer) );


// là ca plante
g_lpDIDevice->GetDeviceState (
sizeof(buffer), (LPVOID)&buffer);



// pression sur la fleche haut ou la touche 8



// pression sur la fleche droite ou la touche 6



if (KEYDOWN(buffer, DIK_RIGHT) || KEYDOWN(buffer, DIK_NUMPAD6))


{};



if ( KEYDOWN(buffer, DIK_NUMPAD0) )


{};
Merci d'avance pour votre aide.

2 réponses

24Karas Messages postés 233 Date d'inscription jeudi 4 juillet 2002 Statut Membre Dernière intervention 5 juillet 2008
11 nov. 2005 à 18:49
Remarks



Before device data can be obtained, set the cooperative level by using the IDirectInputDevice8::SetCooperativeLevel method, then set the data format by using IDirectInputDevice8::SetDataFormat, and acquire the device by using the IDirectInputDevice8::Acquire method.






regarde à cette page, ça peut pt'etre aider :
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dx81_c/directx_cpp/Input/CPP_Ref/Ifaces/IDirectInputDevice8/idirectinputdevice8_getdevicestate.asp



++
0
cali70 Messages postés 71 Date d'inscription mercredi 29 septembre 2004 Statut Membre Dernière intervention 19 mars 2008
16 nov. 2005 à 14:30
DWORD keyboardCoopFlags = DISCL_NONEXCLUSIVE|DISCL_FOREGROUND;

IDirectInput8* mDInput;


IDirectInputDevice8* mKeyboard;



char mKeyboardState[256];


ZeroMemory(mKeyboardState,
sizeof(mKeyboardState));



// Init DirectInput.


DirectInput8Create(appInstance, DIRECTINPUT_VERSION,IID_IDirectInput8, (
void**)&mDInput, 0);


mDInput->CreateDevice(GUID_SysKeyboard, &mKeyboard, 0);


mKeyboard->SetDataFormat(&c_dfDIKeyboard);


mKeyboard->SetCooperativeLevel(hwnd, keyboardCoopFlags);


mKeyboard->Acquire();

HRESULT hr = mKeyboard->GetDeviceState(
sizeof(mKeyboardState), (
void**)&mKeyboardState);



if( FAILED(hr) )


{



// Keyboard lost, zero out keyboard data structure.


ZeroMemory(mKeyboardState,
sizeof(mKeyboardState));



// Try to acquire for next time.


hr = mKeyboard->Acquire();


}

J'espere que ca t'aidera...
0
Rejoignez-nous