Beispiel #1
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;
    }
Beispiel #2
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;
	}
Beispiel #3
0
void GuiManager::HandleEvent(std::shared_ptr<Event> e) {
    if(mGuiSystem == nullptr)
        return;

    // inject the events into the gui system
    auto mygui_inputmgr = MyGUI::InputManager::getInstancePtr();
    if(mygui_inputmgr == nullptr) {
        return;
    }

    if(e->GetType() == "DT_MOUSEEVENT") {
        std::shared_ptr<MouseEvent> m = std::dynamic_pointer_cast<MouseEvent>(e);
        if(m->GetAction() ==  MouseEvent::MOVED) {
            mygui_inputmgr->injectMouseMove(m->GetMouseState().X.abs,
                                           m->GetMouseState().Y.abs,
                                           m->GetMouseState().Z.abs);
        } else if(m->GetAction() ==  MouseEvent::PRESSED) {
            mygui_inputmgr->injectMousePress(m->GetMouseState().X.abs,
                                             m->GetMouseState().Y.abs,
                                        MyGUI::MouseButton::Enum(m->GetButton()));
        } else if(m->GetAction() ==  MouseEvent::RELEASED) {
            mygui_inputmgr->injectMouseRelease(m->GetMouseState().X.abs,
                                               m->GetMouseState().Y.abs,
                                        MyGUI::MouseButton::Enum(m->GetButton()));
        }
    } else if(e->GetType() == "DT_KEYBOARDEVENT") {
        std::shared_ptr<KeyboardEvent> k = std::dynamic_pointer_cast<KeyboardEvent>(e);
        if(k->GetAction() == KeyboardEvent::PRESSED) {
            mygui_inputmgr->injectKeyPress(MyGUI::KeyCode::Enum(k->GetCode()),
                                           k->GetText());
        } else if(k->GetAction() == KeyboardEvent::RELEASED) {
            mygui_inputmgr->injectKeyRelease(MyGUI::KeyCode::Enum(k->GetCode()));
        }
    }
}
Beispiel #4
0
	bool MGUI_System::InjectKeyEvent(DWORD uMsg, WPARAM wParam,LPARAM lParam)
	{
		bool inject = false;

		if (WM_KEYDOWN == uMsg)
		{
			bool repeat = (lParam & (1 >> 30)) != 0;
			if (!repeat)
			{
				int scan_code = MGUI_Input::VirtualKeyToScanCode(wParam);
				int text = MGUI_Input::VirtualKeyToText(wParam);
				
				if (injectKeyPress(MyGUI::KeyCode::Enum(scan_code), (MyGUI::Char)text))
					inject = 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();
}