本文整理汇总了C++中Keyboard::EncodeWindowsScanCode方法的典型用法代码示例。如果您正苦于以下问题:C++ Keyboard::EncodeWindowsScanCode方法的具体用法?C++ Keyboard::EncodeWindowsScanCode怎么用?C++ Keyboard::EncodeWindowsScanCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Keyboard
的用法示例。
在下文中一共展示了Keyboard::EncodeWindowsScanCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WaitForMultipleObjects
WordPtr BURGER_API Burger::Keyboard::WindowsKeyboardThread(void *pData)
{
// Get the pointer to the class instance
Keyboard *pThis = static_cast<Keyboard *>(pData);
DWORD uEventCode;
for (;;) {
// Sleep until an event occurred from DirectInput (Or shutdown)
uEventCode = WaitForMultipleObjects(2,&pThis->m_pKeyboardEvent,FALSE,INFINITE);
// Was the quit flag set for shutdown?
if (pThis->m_bQuit) {
break;
}
if (uEventCode==WAIT_OBJECT_0) {
// Buffer to receive the keyboard events
DIDEVICEOBJECTDATA KeyboardData[DIRECTINPUT_KEYBOARDBUFFERSIZE];
// Maximum number of entries to read!
DWORD uCount = DIRECTINPUT_KEYBOARDBUFFERSIZE;
IDirectInputDevice8W *pKeyboardDevice = pThis->m_pKeyboardDevice;
// Let's get the data from the keyboard device
HRESULT hResult = pKeyboardDevice->GetDeviceData(sizeof(DIDEVICEOBJECTDATA),KeyboardData,&uCount,0);
if (hResult<0) {
// Try getting the keyboard again
if (hResult == DIERR_INPUTLOST) {
hResult = pKeyboardDevice->Acquire();
if (hResult>=0) {
// The keyboard was reacquired, pull the data
uCount = DIRECTINPUT_KEYBOARDBUFFERSIZE;
hResult = pKeyboardDevice->GetDeviceData(sizeof(DIDEVICEOBJECTDATA),KeyboardData,&uCount,0);
} else {
pThis->m_bDirectInput8Acquired = FALSE;
}
} else {
pThis->m_bDirectInput8Acquired = FALSE;
}
}
// Was there any data read?
if (hResult>=0) {
Word i = uCount;
if (i) {
if (pThis->m_bRepeatActive) {
CancelWaitableTimer(pThis->m_pKeyboardTimerEvent);
pThis->m_bRepeatActive = FALSE;
}
Word bEnableTimer = FALSE;
const DIDEVICEOBJECTDATA *pObject = KeyboardData;
KeyEvent_t NewEvent;
do {
if (!pThis->EncodeWindowsScanCode(&NewEvent,pObject->dwOfs)) {
// Overwrite the time stamp
NewEvent.m_uMSTimeStamp = Tick::ReadMilliseconds();
bEnableTimer = (pObject->dwData&0x80)>>7;
if (bEnableTimer) {
NewEvent.m_uEvent = EVENT_KEYDOWN;
} else {
NewEvent.m_uEvent = EVENT_KEYUP;
}
NewEvent.m_uWhich = 0;
pThis->PostKeyEvent(&NewEvent);
}
++pObject;
} while (--i);
// Last key was a keypress of an ascii code
if (bEnableTimer && NewEvent.m_uAscii) {
// Start the auto-repeat timer
LARGE_INTEGER Time;
Time.QuadPart = static_cast<Int64>(pThis->m_uInitialDelay)*-10000LL;
SetWaitableTimer(pThis->m_pKeyboardTimerEvent,&Time,0,NULL,NULL,0);
pThis->m_bRepeatActive = TRUE;
}
}
}