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


C++ Keyboard::AddCharacterToInputQueue方法代码示例

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


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

示例1: WindowsMessageHandlingProcedure

//-----------------------------------------------------------------------------------------------
LRESULT CALLBACK WindowsMessageHandlingProcedure( HWND windowHandle, UINT wmMessageCode, WPARAM wParam, LPARAM lParam )
{
	static const float ONE_OVER_WHEEL_DELTA = 1.f / WHEEL_DELTA;
	unsigned char asKey = (unsigned char) wParam;
	float normalizedMouseWheelDelta;
	switch( wmMessageCode )
	{
		case WM_CLOSE:
		case WM_DESTROY:
		case WM_QUIT:
			g_isQuitting = true;
			return 0;

		case WM_ACTIVATE:
			if( wParam == WA_INACTIVE )
			{
				ShowCursor( true );
				gameActive = false;
			}
			else
			{
				ShowCursor( false );
				gameActive = true;
			}
			return 0;

		case WM_CHAR:
			switch( asKey )
			{
			case '`': //(Absorbed because it's the command console key)
			case '~': //(Absorbed because it's the command console key)
			case 0x0A: // Line Feed
			case VK_BACK:
			case VK_ESCAPE:
			case VK_RETURN:
			case VK_TAB:
				return 0; //Do nothing with the special characters (handle these with regular input)

			default:
				g_keyboard.AddCharacterToInputQueue( asKey );
				return 0;
			}

		case WM_KEYDOWN:
			switch( asKey )
			{
			case VK_ESCAPE:
			default:
				g_keyboard.SetKeyDown( asKey );
				return 0;
			}

			break;

		case WM_KEYUP:
			switch( asKey )
			{
			case VK_LBUTTON:
			case VK_RBUTTON:
			case VK_MBUTTON:
			case VK_XBUTTON1:
			case VK_XBUTTON2:
				g_mouse.SetButtonUp( asKey );
				return 0;
			default:
				g_keyboard.SetKeyUp( asKey );
				return 0;
			}
			break;
		case WM_LBUTTONDOWN:
			g_mouse.SetButtonDown( VK_LBUTTON );
			break;
		case WM_LBUTTONUP:
			g_mouse.SetButtonUp( VK_LBUTTON );
			break;
		case WM_RBUTTONDOWN:
			g_mouse.SetButtonDown( VK_RBUTTON );
			break;
		case WM_RBUTTONUP:
			g_mouse.SetButtonUp( VK_RBUTTON );
			break;
		case WM_MOUSEWHEEL:
			normalizedMouseWheelDelta = static_cast< float >( GET_WHEEL_DELTA_WPARAM( wParam ) ) * ONE_OVER_WHEEL_DELTA;
			g_mouse.SetWheelDelta( normalizedMouseWheelDelta );
			break;
	}

	return DefWindowProc( windowHandle, wmMessageCode, wParam, lParam );
}
开发者ID:vingenuity,项目名称:ClothPhysics,代码行数:90,代码来源:main_Win32.cpp


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