void KeyboardUpdateState(void) { char tk[256]; ddrval = IDirectInputDevice7_GetDeviceState(lpdid, 256, tk); switch (ddrval) { case DI_OK: memcpy(keys, tk, 256); break; case DIERR_INPUTLOST: case DIERR_NOTACQUIRED: memset(keys, 0, 256); IDirectInputDevice7_Acquire(lpdid); break; } }
bool directinput::GetState(LPDIRECTINPUTDEVICE7 device, DWORD size, LPVOID data) { HRESULT status = IDirectInputDevice7_Poll(device); if(status != DI_OK && status != DI_NOEFFECT) { Acquire(device); status = IDirectInputDevice7_Poll(device); } status = IDirectInputDevice7_GetDeviceState(device, size, data); if(status != DI_OK) { memset(data, 0, size); return false; } return true; }