Example #1
0
	bool InputManager::keyPressed(const OIS::KeyEvent& _arg)
	{
		MyGUI::Char text = (MyGUI::Char)_arg.text;
		MyGUI::KeyCode key = MyGUI::KeyCode::Enum(_arg.key);
		int scan_code = key.toValue();

		if (scan_code > 70 && scan_code < 84)
		{
			static MyGUI::Char nums[13] = { 55, 56, 57, 45, 52, 53, 54, 43, 49, 50, 51, 48, 46 };
			text = nums[scan_code-71];
		}
		else if (key == MyGUI::KeyCode::Divide)
		{
			text = '/';
		}
		else
		{
#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
			text = (MyGUI::Char)translateWin32Text((int)key.toValue());
#endif
		}

		injectKeyPress(key, text);
		return true;
	}
Example #2
0
    bool DiInputManager::keyPressed(const OIS::KeyEvent& _arg)
    {
        MyGUI::Char text = (MyGUI::Char)_arg.text;
        MyGUI::KeyCode key = MyGUI::KeyCode::Enum(_arg.key);
#if DEMI_PLATFORM == DEMI_PLATFORM_WIN32
        int scan_code = key.toValue();

        if (scan_code > 70 && scan_code < 84)
        {
            static MyGUI::Char nums[13] = { 55, 56, 57, 45, 52, 53, 54, 43, 49, 50, 51, 48, 46 };
            text = nums[scan_code - 71];
        }
        else if (key == MyGUI::KeyCode::Divide)
            text = '/';
        else
            text = translateWin32Text(key);
        injectKeyPress(key, text);
#else
        injectKeyPress(key, text);
#endif

        for (auto it = mKeyPresses.begin(); it != mKeyPresses.end(); ++it)
            if (it->second)
                it->second(_arg);

        return true;
    }
void MyGUIRenderClick::PerformRendering(unsigned int uiFrameID)
{
 	NiRenderer* pkRenderer = NiRenderer::GetRenderer();
 	NIASSERT(pkRenderer);
 	if(!pkRenderer) return;
// 	pkRenderer->SetScreenSpaceCameraData();
//   	pkRenderer->BeginUsingRenderTargetGroup(m_spRenderTargetGroup,
//   		NiRenderer::CLEAR_ALL);

	// 处理输入
	NiInputMousePtr pMouse;
	NiInputKeyboardPtr pKeyboard;
	if(m_pInputService->GetInputSystem())
	{
		pMouse = m_pInputService->GetInputSystem()->GetMouse();
		pKeyboard = m_pInputService->GetInputSystem()->GetKeyboard();

		if (pMouse)
		{
			POINT point;
			GetCursorPos(&point);
			ScreenToClient(hWnd, &point);
			m_nCursorX = point.x;
			m_nCursorY = point.y;
			
			if (m_nCursorX < 0)
				m_nCursorX = 0;
			else if (m_nCursorX >= 1280)
				m_nCursorX = 1280 - 1;

			if (m_nCursorY < 0)
				m_nCursorY = 0;
			else if (m_nCursorY >= 720)
				m_nCursorY = 720 - 1;

			injectMouseMove(m_nCursorX, m_nCursorY, 0);

			unsigned int ui;
			for (ui = NiInputMouse::NIM_LEFT; ui < NiInputMouse::NIM_NUM_BUTTONS; ui++)
			{
				if (pMouse->ButtonWasPressed((NiInputMouse::Button)ui))
				{
					injectMousePress(m_nCursorX, m_nCursorY, MyGUI::MouseButton(MyGUI::MouseButton::Enum(ui)));
				}
				else if (pMouse->ButtonWasReleased((NiInputMouse::Button)ui))
				{
					injectMouseRelease(m_nCursorX, m_nCursorY, MyGUI::MouseButton(MyGUI::MouseButton::Enum(ui)));
				}
			}
		}

		if (pKeyboard)
		{
			unsigned int ui;
			for (ui = NiInputKeyboard::KEY_ESCAPE; ui < NiInputKeyboard::KEY_TOTAL_COUNT; ui++)
			{
				if (pKeyboard->KeyWasPressed((NiInputKeyboard::KeyCode)ui))
				{
					MyGUI::KeyCode key = MyGUI::KeyCode(MyGUI::KeyCode::Enum(ui));
					MyGUI::Char text;
					int scan_code = ui;

					if (scan_code > 70 && scan_code < 84)
					{
						static MyGUI::Char nums[13] = { 55, 56, 57, 45, 52, 53, 54, 43, 49, 50, 51, 48, 46 };
						text = nums[scan_code-71];
					}
					else if (key == MyGUI::KeyCode::Divide)
					{
						text = '/';
					}
					else
					{
						text = translateWin32Text(key);
					}

					injectKeyPress(key, text);
				}
				else if (pKeyboard->KeyWasReleased((NiInputKeyboard::KeyCode)ui))
				{
					injectKeyRelease(MyGUI::KeyCode(MyGUI::KeyCode::Enum(ui)));
				}
			}
		}
	}
	

	run();

// 	m_pDevice->SetTexture(0, ppTexture);
// 	m_pDevice->SetStreamSource(0, mpBuffer, 0, sizeof(MyGUI::Vertex))
// 	// count in vertexes, triangle_list = vertexes / 3
// 	m_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, _count / 3);

//	pkRenderer->EndUsingRenderTargetGroup();
}