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


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

本文整理汇总了C++中GHOST_SystemWin32::retrieveModifierKeys方法的典型用法代码示例。如果您正苦于以下问题:C++ GHOST_SystemWin32::retrieveModifierKeys方法的具体用法?C++ GHOST_SystemWin32::retrieveModifierKeys怎么用?C++ GHOST_SystemWin32::retrieveModifierKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GHOST_SystemWin32的用法示例。


在下文中一共展示了GHOST_SystemWin32::retrieveModifierKeys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const& raw, int *keyDown, char *vk)
{
	GHOST_TKey key = GHOST_kKeyUnknown;


	if (!keyDown)
		return GHOST_kKeyUnknown;


	GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();

	GHOST_ModifierKeys modifiers;
	system->retrieveModifierKeys(modifiers);

	// RI_KEY_BREAK doesn't work for sticky keys release, so we also
	// check for the up message
	unsigned int msg = raw.data.keyboard.Message;
	*keyDown = !(raw.data.keyboard.Flags & RI_KEY_BREAK) && msg != WM_KEYUP && msg != WM_SYSKEYUP;

	key = this->convertKey(window, raw.data.keyboard.VKey, raw.data.keyboard.MakeCode, (raw.data.keyboard.Flags & (RI_KEY_E1 | RI_KEY_E0)));
	
	// extra handling of modifier keys: don't send repeats out from GHOST
	if (key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt)
	{
		bool changed = false;
		GHOST_TModifierKeyMask modifier;
		switch (key) {
			case GHOST_kKeyLeftShift:
			{
				changed = (modifiers.get(GHOST_kModifierKeyLeftShift) != (bool)*keyDown);
				modifier = GHOST_kModifierKeyLeftShift;
			}
			break;
			case GHOST_kKeyRightShift:
			{
				changed = (modifiers.get(GHOST_kModifierKeyRightShift) != (bool)*keyDown);
				modifier = GHOST_kModifierKeyRightShift;
			}
			break;
			case GHOST_kKeyLeftControl:
			{
				changed = (modifiers.get(GHOST_kModifierKeyLeftControl) != (bool)*keyDown);
				modifier = GHOST_kModifierKeyLeftControl;
			}
			break;
			case GHOST_kKeyRightControl:
			{
				changed = (modifiers.get(GHOST_kModifierKeyRightControl) != (bool)*keyDown);
				modifier = GHOST_kModifierKeyRightControl;
			}
			break;
			case GHOST_kKeyLeftAlt:
			{
				changed = (modifiers.get(GHOST_kModifierKeyLeftAlt) != (bool)*keyDown);
				modifier = GHOST_kModifierKeyLeftAlt;
			}
			break;
			case GHOST_kKeyRightAlt:
			{
				changed = (modifiers.get(GHOST_kModifierKeyRightAlt) != (bool)*keyDown);
				modifier = GHOST_kModifierKeyRightAlt;
			}
			break;
			default: break;
		}
		
		if (changed)
		{
			modifiers.set(modifier, (bool)*keyDown);
			system->storeModifierKeys(modifiers);
		}
		else {
			key = GHOST_kKeyUnknown;
		}
	}
	

	if (vk) *vk = raw.data.keyboard.VKey;

	return key;
}
开发者ID:,项目名称:,代码行数:81,代码来源:

示例2: if

GHOST_TKey GHOST_SystemWin32::convertKey(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam) const
{
	GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
	bool isExtended = (lParam&(1<<24))?true:false;
	
	GHOST_TKey key;
	GHOST_ModifierKeys oldModifiers, newModifiers;
	system->retrieveModifierKeys(oldModifiers);
	system->getModifierKeys(newModifiers);

	//std::cout << wParam << " " << system->m_curKeyStatus[wParam] << " shift pressed: " << system->shiftPressed() << std::endl;

	if ((wParam >= '0') && (wParam <= '9')) {
		// VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39)
		key = (GHOST_TKey)(wParam - '0' + GHOST_kKey0);
	}
	else if ((wParam >= 'A') && (wParam <= 'Z')) {
		// VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A)
		key = (GHOST_TKey)(wParam - 'A' + GHOST_kKeyA);
	}
	else if ((wParam >= VK_F1) && (wParam <= VK_F24)) {
		key = (GHOST_TKey)(wParam - VK_F1 + GHOST_kKeyF1);
	}
	else {
		switch (wParam) {
		case VK_RETURN:
			key = isExtended?GHOST_kKeyNumpadEnter:GHOST_kKeyEnter;
			break;

		case VK_BACK:     key = GHOST_kKeyBackSpace;		break;
		case VK_TAB:      key = GHOST_kKeyTab;				break;
		case VK_ESCAPE:   key = GHOST_kKeyEsc;				break;
		case VK_SPACE:    key = GHOST_kKeySpace;			break;
		case VK_PRIOR:    key = GHOST_kKeyUpPage;			break;
		case VK_NEXT:     key = GHOST_kKeyDownPage;			break;
		case VK_END:      key = GHOST_kKeyEnd;				break;
		case VK_HOME:
			{
				if(system->m_curKeyStatus[VK_NUMPAD7] && system->shiftPressed())
					key = GHOST_kKeyNumpad7;
				else
					key = GHOST_kKeyHome;
			}
			break;
		case VK_INSERT:   key = GHOST_kKeyInsert;			break;
		case VK_DELETE:   key = GHOST_kKeyDelete;			break;
		case VK_LEFT:     key = GHOST_kKeyLeftArrow;		break;
		case VK_RIGHT:    key = GHOST_kKeyRightArrow;		break;
		case VK_UP:       key = GHOST_kKeyUpArrow;			break;
		case VK_DOWN:     key = GHOST_kKeyDownArrow;		break;
		case VK_NUMPAD0:  key = GHOST_kKeyNumpad0;			break;
		case VK_NUMPAD1:  key = GHOST_kKeyNumpad1;			break;
		case VK_NUMPAD2:  key = GHOST_kKeyNumpad2;			break;
		case VK_NUMPAD3:  key = GHOST_kKeyNumpad3;			break;
		case VK_NUMPAD4:  key = GHOST_kKeyNumpad4;			break;
		case VK_NUMPAD5:  key = GHOST_kKeyNumpad5;			break;
		case VK_NUMPAD6:  key = GHOST_kKeyNumpad6;			break;
		case VK_NUMPAD7:  key = GHOST_kKeyNumpad7;			break;
		case VK_NUMPAD8:  key = GHOST_kKeyNumpad8;			break;
		case VK_NUMPAD9:  key = GHOST_kKeyNumpad9;			break;
		case VK_SNAPSHOT: key = GHOST_kKeyPrintScreen;		break;
		case VK_PAUSE:    key = GHOST_kKeyPause;			break;
		case VK_MULTIPLY: key = GHOST_kKeyNumpadAsterisk;	 break;
		case VK_SUBTRACT: key = GHOST_kKeyNumpadMinus;		break;
		case VK_DECIMAL:  key = GHOST_kKeyNumpadPeriod;		break;
		case VK_DIVIDE:   key = GHOST_kKeyNumpadSlash;		break;
		case VK_ADD:      key = GHOST_kKeyNumpadPlus;		break;

		case VK_SEMICOLON:		key = GHOST_kKeySemicolon;		break;
		case VK_EQUALS:			key = GHOST_kKeyEqual;			break;
		case VK_COMMA:			key = GHOST_kKeyComma;			break;
		case VK_MINUS:			key = GHOST_kKeyMinus;			break;
		case VK_PERIOD:			key = GHOST_kKeyPeriod;			break;
		case VK_SLASH:			key = GHOST_kKeySlash;			break;
		case VK_BACK_QUOTE:		key = GHOST_kKeyAccentGrave;	break;
		case VK_OPEN_BRACKET:	key = GHOST_kKeyLeftBracket;	break;
		case VK_BACK_SLASH:		key = GHOST_kKeyBackslash;		break;
		case VK_CLOSE_BRACKET:	key = GHOST_kKeyRightBracket;	break;
		case VK_QUOTE:			key = GHOST_kKeyQuote;			break;
		case VK_GR_LESS:		key = GHOST_kKeyGrLess;			break;

		case VK_SHIFT:
			{
				bool lchanged = oldModifiers.get(GHOST_kModifierKeyLeftShift) != newModifiers.get(GHOST_kModifierKeyLeftShift);
				if(lchanged) {
					key = GHOST_kKeyLeftShift;
				} else {
					bool rchanged = oldModifiers.get(GHOST_kModifierKeyRightShift) != newModifiers.get(GHOST_kModifierKeyRightShift);
					if(rchanged) {
						key = GHOST_kKeyRightShift;
					} else {
						key = GHOST_kKeyUnknown;
					}
				}
			}
			break;
		case VK_CONTROL:
			{
				bool lchanged = oldModifiers.get(GHOST_kModifierKeyLeftControl) != newModifiers.get(GHOST_kModifierKeyLeftControl);
				if(lchanged) {
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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