当前位置: 首页>>代码示例>>C++>>正文


C++ GHOST_SystemWin32::hardKey方法代码示例

本文整理汇总了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;
}
开发者ID:ruesp83,项目名称:Blender---AMA,代码行数:34,代码来源:GHOST_SystemWin32.cpp

示例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;
}
开发者ID:faebser,项目名称:ghost,代码行数:31,代码来源:GHOST_SystemWin32.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:50,代码来源:


注:本文中的GHOST_SystemWin32::hardKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。