예제 #1
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()));
        }
    }
}
예제 #2
0
    bool DiInputManager::mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id)
    {
        injectMouseRelease(_arg.state.X.abs, _arg.state.Y.abs, MyGUI::MouseButton::Enum(_id));

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

        return true;
    }
예제 #3
0
	bool InputManager::mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id)
	{
		injectMouseRelease(mCursorX, mCursorY, MyGUI::MouseButton::Enum(_id));
		return true;
	}
예제 #4
0
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();
}
예제 #5
0
	bool MGUI_System::InjectMouseEvent()
	{
		bool inject = false;
		if (IMouse::Instance()->MouseMoved() || IMouse::Instance()->MouseWheel())
		{
			static int pt_z = 0;
			Point2i pt = IMouse::Instance()->GetPosition();
			pt_z += IMouse::Instance()->MouseWheel();

			if (injectMouseMove(pt.x, pt.y, pt_z))
				inject = true;
		}

		if (IMouse::Instance()->KeyDown(MKC_BUTTON0))
		{
			Point2i pt = IMouse::Instance()->GetPosition();
			
			if (injectMousePress(pt.x, pt.y, MyGUI::MouseButton::Left))
				inject = true;
		}

		if (IMouse::Instance()->KeyDown(MKC_BUTTON1))
		{
			Point2i pt = IMouse::Instance()->GetPosition();
			
			if (injectMousePress(pt.x, pt.y, MyGUI::MouseButton::Right))
				inject = true;
		}

		if (IMouse::Instance()->KeyDown(MKC_BUTTON2))
		{
			Point2i pt = IMouse::Instance()->GetPosition();
			
			if (injectMousePress(pt.x, pt.y, MyGUI::MouseButton::Middle))
				inject = true;
		}

		if (IMouse::Instance()->KeyUp(MKC_BUTTON0))
		{
			Point2i pt = IMouse::Instance()->GetPosition();
			
			if (injectMouseRelease(pt.x, pt.y, MyGUI::MouseButton::Left))
				inject = true;
		}

		if (IMouse::Instance()->KeyUp(MKC_BUTTON1))
		{
			Point2i pt = IMouse::Instance()->GetPosition();
			
			if (injectMouseRelease(pt.x, pt.y, MyGUI::MouseButton::Right))
				inject = true;
		}

		if (IMouse::Instance()->KeyUp(MKC_BUTTON2))
		{
			Point2i pt = IMouse::Instance()->GetPosition();

			if (injectMouseRelease(pt.x, pt.y, MyGUI::MouseButton::Middle))
				inject = true;
		}

		return inject;
	}