本文整理汇总了C++中GHOST_SystemWin32::hardKey方法的典型用法代码示例。如果您正苦于以下问题:C++ GHOST_SystemWin32::hardKey方法的具体用法?C++ GHOST_SystemWin32::hardKey怎么用?C++ GHOST_SystemWin32::hardKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GHOST_SystemWin32
的用法示例。
在下文中一共展示了GHOST_SystemWin32::hardKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const& raw)
{
int keyDown=0;
char vk;
GHOST_SystemWin32 * system = (GHOST_SystemWin32 *)getSystem();
GHOST_TKey key = system->hardKey(window, raw, &keyDown, &vk);
GHOST_EventKey* event;
if (key != GHOST_kKeyUnknown) {
char utf8_char[6] = {0} ;
wchar_t utf16[2]={0};
BYTE state[256];
GetKeyboardState((PBYTE)state);
if(ToUnicodeEx(vk, 0, state, utf16, 2, 0, system->m_keylayout))
WideCharToMultiByte(CP_UTF8, 0,
(wchar_t*)utf16, 1,
(LPSTR) utf8_char, 5,
NULL,NULL); else *utf8_char = 0;
if(!keyDown) utf8_char[0] = '\0';
event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, (*utf8_char & 0x80)?'?':*utf8_char, utf8_char);
#ifdef GHOST_DEBUG
std::cout << ascii << std::endl;
#endif
}
else {
event = 0;
}
return event;
}
示例2:
GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const& raw)
{
int keyDown=0;
char vk;
GHOST_SystemWin32 * system = (GHOST_SystemWin32 *)getSystem();
GHOST_TKey key = system->hardKey(window, raw, &keyDown, &vk);
GHOST_EventKey* event;
if (key != GHOST_kKeyUnknown) {
char ascii = '\0';
unsigned short utf16[2]={0};
BYTE state[256];
GetKeyboardState((PBYTE)state);
if(ToAsciiEx(vk, 0, state, utf16, 0, system->m_keylayout))
WideCharToMultiByte(CP_ACP, 0x00000400,
(wchar_t*)utf16, 1,
(LPSTR) &ascii, 1,
NULL,NULL);
event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, ascii);
#ifdef GHOST_DEBUG
std::cout << ascii << std::endl;
#endif
}
else {
event = 0;
}
return event;
}
示例3: if
GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const& raw)
{
int keyDown = 0;
char vk;
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
GHOST_TKey key = system->hardKey(window, raw, &keyDown, &vk);
GHOST_EventKey *event;
if (key != GHOST_kKeyUnknown) {
char utf8_char[6] = {0};
char ascii = 0;
wchar_t utf16[3] = {0};
BYTE state[256] = {0};
int r;
GetKeyboardState((PBYTE)state);
// don't call ToUnicodeEx on dead keys as it clears the buffer and so won't allow diacritical composition.
if (MapVirtualKeyW(vk,2) != 0) {
// todo: ToUnicodeEx can respond with up to 4 utf16 chars (only 2 here). Could be up to 24 utf8 bytes.
if ((r = ToUnicodeEx(vk, raw.data.keyboard.MakeCode, state, utf16, 2, 0, system->m_keylayout))) {
if ((r > 0 && r < 3)) {
utf16[r] = 0;
conv_utf_16_to_8(utf16, utf8_char, 6);
}
else if (r == -1) {
utf8_char[0] = '\0';
}
}
}
if (!keyDown) {
utf8_char[0] = '\0';
ascii = '\0';
}
else {
ascii = utf8_char[0] & 0x80 ? '?' : utf8_char[0];
}
event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, key, ascii, utf8_char);
#ifdef GHOST_DEBUG
std::cout << ascii << std::endl;
#endif
}
else {
event = 0;
}
return event;
}