Ejemplo n.º 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;
	}
Ejemplo n.º 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;
    }
Ejemplo n.º 3
0
void Console::eventButtonPressed(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char)
{
	switch (_key.getValue())
	{
		case MyGUI::KeyCode::ArrowUp:
		{
			if (HistoryCursor > iText)
				HistoryCursor = 0;

			if (sTextHistory[HistoryCursor] != "")
				m_Console_TextBox->setCaption(sTextHistory[HistoryCursor]);

			HistoryCursor++;
		}
		break;

		case MyGUI::KeyCode::ArrowDown:
		{
			if (HistoryCursor < 0)
				HistoryCursor = iText;

			if (sTextHistory[HistoryCursor] != "")
				m_Console_TextBox->setCaption(sTextHistory[HistoryCursor]);	

			HistoryCursor--;
		}
		break;
	}
}
Ejemplo n.º 4
0
//-------------------------------------------------------------------------------------
void TWaitForm::KeyEvent(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char)
{
  switch(_key.getValue())
  {
  case MyGUI::KeyCode::Return:
    //sl_Enter(_sender);
    break;
  default:;
  }
}
Ejemplo n.º 5
0
//-------------------------------------------------------------------------------------
void TClientMain_Test::KeyEvent(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char)
{
  switch(_key.getValue())
  {
    case MyGUI::KeyCode::Return:
      sl_Enter(_sender);
      break;
    default:;
  }
}
Ejemplo n.º 6
0
void HotkeyManager::injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text)
{
	/*
		被翻译成下面的字符串,不区分大小写
		Shift+Ctrl+Alt+X,不区分左右Shift和Ctrl,Alt
	*/
	Game* g = Game::getSingletonPtr();
	if( g )
	{
		string hotkey;

		//_key不能是Shift,Ctrl,Alt其中之一
		if( _key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightShift) ||
			_key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftShift) ||
			_key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightControl) ||
			_key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftControl) ||
			_key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightAlt) ||
			_key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftAlt) )
			return;

		if( g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightShift)) ||
			g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftShift))
			)
		{
			hotkey += "shift+";
		}
		if( g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightControl)) ||
			g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftControl))
			)
		{
			hotkey += "ctrl+";
		}
		if( g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightAlt)) ||
			g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftAlt))
			)
		{
			hotkey += "alt+";
		}
		//注意:正确的话,ScanCodeToText返回小写字传串
		hotkey += ScanCodeToText(_key.getValue());

		for( HotkeyTable::iterator it = mHotkeys.begin();it!=mHotkeys.end();++it )
		{
			if( it->mSHotkey == hotkey )
			{
				MyGUI::Widget* p = MyGUI::Gui::getInstance().findWidget<MyGUI::Widget>(it->mName,false);
				if( p )
					p->eventMouseButtonClick( p );
			}
		}
	}
}
Ejemplo n.º 7
0
void LuaControlet::injectKeyRelease(MyGUI::KeyCode _key)
{
	LuaManager::getSingleton().callEventInt("eventKeyRelease",_key.getValue());
}
Ejemplo n.º 8
0
void LuaControlet::injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text)
{
	LuaManager::getSingleton().callEvent2Int("eventKeyPress",_key.getValue(),(int)_text);
}