예제 #1
0
 void GLUTInput::pushSpecialUpInput(unsigned char key)
 {
     KeyInput keyInput;
     keyInput.setKey(convertSpecialCharacter(key));
     keyInput.setType(KeyInput::RELEASED);
     mKeyInputQueue.push(keyInput);
 }
예제 #2
0
 void GLUTInput::pushKeyDownInput(unsigned char key)
 {
     KeyInput keyInput;
     keyInput.setKey(convertKeyCharacter(key));
     keyInput.setType(KeyInput::PRESSED);
	 mKeyInputQueue.push(keyInput);
 }
예제 #3
0
    void FocusHandler::checkHotKey(const KeyInput &keyInput)
    {
        int keyin = keyInput.getKey().getValue();

        for (int i = 0; i < (int)mWidgets.size(); ++i)
        {
            int hotKey = mWidgets[i]->getHotKey();

            if (hotKey == 0)
            {
                continue;
            }

            if ((isascii(keyin) && tolower(keyin) == hotKey) || keyin == hotKey)
            {
                if (keyInput.getType() == KeyInput::PRESS)
                {
                    mWidgets[i]->hotKeyPress();
                    if (mWidgets[i]->isFocusable())
                    {
                        this->requestFocus(mWidgets[i]);
                    }
                }
                else
                {
                    mWidgets[i]->hotKeyRelease();
                }
                break;
            }
        }
    }
예제 #4
0
void SDLInput::convertKeyEventToKey(const SDL_Event &event, KeyInput &keyInput)
{
    keyInput.setKey(Key(convertKeyCharacter(event)));
    const int actionId = inputManager.getActionByKey(event);
    if (actionId >= 0)
        keyInput.setActionId(actionId);
}
예제 #5
0
	void KeyParameterDefinition::load(const ActionInstance *actionInstance)
	{
		const SubParameter &key = actionInstance->subParameter(name().original(), "key");
		if(key.isCode())
			mKeyEdit->codeLineEdit()->setFromSubParameter(key);
		else
		{
			KeyInput keyInput;
			
			keyInput.fromPortableText(key.value().toString(), actionInstance->subParameter(name().original(), "isQtKey").value().toBool());
			
			mKeyEdit->setKeyInput(keyInput);
		}
	}
GameObject* DefaultGameObjectFactory::CreatePlayer1() {
    GameObject* player = new GameObject();

    SetupPlayer1(player);

    Position position = player->position();
    Rotation rotation = player->rotation();

    btTransform transform;
    transform.setIdentity();
    transform.setOrigin(btVector3(position.x, position.y, position.z));
    transform.setRotation(
        btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w));
    BulletBasicPhysics* physics = new BulletBasicPhysics();
    physics->set_transform(transform);

    int mask = kBall;
    btRigidBody* rigid_body = CreatePlayer1RigidBody(player, physics);
    dynamic_world_->addRigidBody(rigid_body, kPad, mask);

    physics->set_rigid_body(rigid_body);
    physics->set_world(dynamic_world_);

    btTypedConstraint* constraint = CreatePlayer1Constraint(rigid_body);
    dynamic_world_->addConstraint(constraint, true);

    OIS::KeyCode keys[KeyInput::kCommandSize] = {
        OIS::KC_UP, OIS::KC_DOWN, OIS::KC_LEFT, OIS::KC_RIGHT, OIS::KC_RETURN,
        OIS::KC_ESCAPE, OIS::KC_P, OIS::KC_SPACE
    };
    KeyInput* input = new KeyInput(keyboard_);
    for (int i = 0; i < KeyInput::kCommandSize; i++) {
        input->set_command(static_cast<KeyInput::Command>(i), keys[i]);
    }

    player->set_input(input);
    player->set_physics(physics);
    Ogre::SceneNode* node = scene_manager_->getSceneNode("pad_1");
    GraphicsComponent* graphics = new OgreBasicGraphics(node);
    player->set_graphics(graphics);

    return player;
}
예제 #7
0
파일: widget.cpp 프로젝트: AMDmi3/Wyrmgus
    bool Widget::_keyInputMessage(const KeyInput& keyInput)
    {
        if (mFocusHandler == NULL)
        {
            //throw GCN_EXCEPTION("No focushandler set (did you add the widget to the gui?).");
            assert(!"No focushandler set (did you add the widget to the gui?).");
        }

        if (!mEnabled || (mFocusHandler->getModalFocused() != NULL &&
                          !hasModalFocus()))
        {
            return false;
        }

        KeyListenerIterator iter;
        bool keyProcessed = false;

        switch(keyInput.getType())
        {
          case KeyInput::PRESS:
              for (iter = mKeyListeners.begin(); iter != mKeyListeners.end(); ++iter)
              {
                  if ((*iter)->keyPress(keyInput.getKey()))
                  {
                      keyProcessed = true;
                  }
              }
              break;

          case KeyInput::RELEASE:
              for (iter = mKeyListeners.begin(); iter != mKeyListeners.end(); ++iter)
              {
                  if ((*iter)->keyRelease(keyInput.getKey()))
                  {
                      keyProcessed = true;
                  }
              }
              break;
        }

        return keyProcessed;
    }
예제 #8
0
void
ShlDS::WrapForSwapScreens(YSLib::UI::IWidget& wgt, KeyInput& mask)
{
    using namespace YSLib::UI;

    FetchEvent<KeyDown>(wgt).Add([&, this](KeyEventArgs&& e) {
        if(e.Strategy != RoutedEventArgs::Bubble && mask.any()
                && (platform_ex::FetchKeyState() & mask) == mask)
        {
            SwapScreens();
            e.Handled = true;
        }
    }, 0xE0);
}
예제 #9
0
    void DirectX3DInput:: dispatchMessage(HWND window, MSG message)
    {
        KeyInput keyInput;
        MouseInput mouseInput;
        WPARAM wParam = message.wParam;
        LPARAM lParam = message.lParam;

        switch (message.message)
        {
            case WM_SYSKEYDOWN:
            case WM_KEYDOWN:
                {
                    unsigned char kbstate[256];
	                GetKeyboardState(kbstate);
                    keyInput.setKey(Key(convertKeyCharacter(wParam, lParam, kbstate)));
                    keyInput.setType(KeyInput::Pressed);
                    keyInput.setShiftPressed(kbstate[VK_SHIFT] & 0x80);
	                keyInput.setControlPressed(kbstate[VK_CONTROL] & 0x80);
	                keyInput.setAltPressed(kbstate[VK_MENU] & 0x80);
                    keyInput.setNumericPad(wParam >= VK_NUMPAD0
                                            && wParam <= VK_DIVIDE);

                    mKeyInputQueue.push(keyInput);
                }
                break;
            case WM_SYSKEYUP:
            case WM_KEYUP:
                {
                    unsigned char kbstate[256];
	                GetKeyboardState(kbstate);
                    keyInput.setKey(Key(convertKeyCharacter(wParam, lParam, kbstate)));
                    keyInput.setType(KeyInput::Released);
                    keyInput.setShiftPressed(kbstate[VK_SHIFT] & 0x80);
	                keyInput.setControlPressed(kbstate[VK_CONTROL] & 0x80);
	                keyInput.setAltPressed(kbstate[VK_MENU] & 0x80);
                    keyInput.setNumericPad(wParam >= VK_NUMPAD0
                                            && wParam <= VK_DIVIDE);

                    mKeyInputQueue.push(keyInput);
                }
                break;
            case WM_LBUTTONDOWN:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
               
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Left);
                    mouseInput.setType(MouseInput::Pressed);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = true;
                    SetCapture(window);
                    break;
                }
            case WM_MBUTTONDOWN:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                   
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Middle);
                    mouseInput.setType(MouseInput::Pressed);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = true;
                    SetCapture(window);
                    break;
                }
            case WM_RBUTTONDOWN:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                   
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Right);
                    mouseInput.setType(MouseInput::Pressed);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = true;
                    SetCapture(window);
                    break;
                }
            case WM_LBUTTONUP:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                   
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Left);
                    mouseInput.setType(MouseInput::Released);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = false;
                    ReleaseCapture();
                    break;
                }
            case WM_MBUTTONUP:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                   
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Middle);
                    mouseInput.setType(MouseInput::Released);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = false;
                    ReleaseCapture();
                    break;
                }
            case WM_RBUTTONUP:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                  
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Right);
                    mouseInput.setType(MouseInput::Released);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = false;
                    ReleaseCapture();
                    break;
                }
            case WM_MOUSEMOVE:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                    /*
                    POINT point = {x,y};
                    ScreenToClient(hWnd, &point);
                   
                    RECT rect; 
                    GetClientRect(hWnd, &rect);*/
                    /*
                    if (!mMouseDown
                        && mMouseInWindow
                        && (point.x < 0 
                            || point.y < 0 
                            || point.x > rect.right 
                            || point.y > rect.bottom))
                    {
                        mouseInput.setX(-1);
                        mouseInput.setY(-1);
                        mouseInput.setButton(MouseInput::Empty);
                        mouseInput.setType(MouseInput::Moved);
                        mouseInput.setTimeStamp(GetTickCount());
                   
                        mMouseInputQueue.push(mouseInput);
                        mMouseInWindow = false;
                    }
                    else if (mMouseDown
                              || (point.x >= 0 
                                    && point.y >= 0 
                                    && point.x < rect.right 
                                    && point.y < rect.bottom))
                    {
                        mouseInput.setX(point.x);
                        mouseInput.setY(point.y);
                        mouseInput.setButton(MouseInput::Empty);
                        mouseInput.setType(MouseInput::Moved);
                        mouseInput.setTimeStamp(GetTickCount());
                   
                        mMouseInputQueue.push(mouseInput);
                    }
                    
                    mMouseInWindow = point.x >= 0 
                                        && point.y >= 0 
                                        && point.x < rect.right 
                                        && point.y < rect.bottom;
                */
                        mouseInput.setX(x);
                        mouseInput.setY(y);
                        mouseInput.setButton(MouseInput::Empty);
                        mouseInput.setType(MouseInput::Moved);
                        mouseInput.setTimeStamp(GetTickCount());
                   
                        mMouseInputQueue.push(mouseInput);
                    break;
                }
            // For some reason WM_MOUSEWHEEL isn't defined at some systems
            // (including mine), but 0x020A should be equal to the WM_MOUSEWHEEL
            // value.
            case 0x020A: // WM_MOUSEWHEEL         
                int mouseZ = (short)HIWORD(wParam);
                int x = (int)((signed short)(LOWORD(lParam)));
                int y = (int)((signed short)(HIWORD(lParam)));
                POINT point = {x,y};
                ScreenToClient(window, &point);

                RECT rect; 
                GetClientRect(window, &rect);

                if (point.x < 0 
                    || point.y < 0 
                    || point.x > rect.right 
                    || point.y > rect.bottom)
                {
                    break;
                }

                // Mouse wheels doesn't have to move 120 units anymore, new
                // mouses can move less than 120, therefore we need to check
                // that the mouse has at least moved 120 units before we push
                // an input event.
                if (mLastMouseZ + mouseZ >= 120)
                {
                    mMouseInputQueue.push(MouseInput(MouseInput::Empty,
                                                     MouseInput::WheelMovedUp,
                                                     point.x,
                                                     point.y,
                                                     GetTickCount()));
                    mLastMouseZ = 0;
                }
                else if (mLastMouseZ + mouseZ <= -120)
                {     
                    mMouseInputQueue.push(MouseInput(MouseInput::Empty,
                                                     MouseInput::WheelMovedDown,
                                                     point.x,
                                                     point.y,
                                                     GetTickCount()));
                    mLastMouseZ = 0;
                }
                else
                {
                    mLastMouseZ += mouseZ;
                }

                break;
        } // end switch
    }
LRESULT MainWindow::HandleMessage( UINT uMsg, WPARAM wParam, LPARAM lParam ) const
{
	switch ( uMsg )
	{
		case WM_CREATE:
		{
			// SetTimer( MainWindow::GetInstance()->Window(), 337, 20, NULL );
		}
			return 0;

		case WM_SOCKET:
		{
			NetworkManager::GetInstance()->HandleMessage( wParam, lParam );
		}
			return 0;

		case WM_SIZE:
		{
			RECT rect;
			GetWindowRect( m_HandleOfWindow, &rect );

			LONG width = static_cast<LONG>( LOWORD( lParam ) );
			LONG height = static_cast<LONG>( HIWORD( lParam ) );

			Renderer::GetInstance()->ResizeWindow( width, height );
			InvalidateRect( m_HandleOfWindow, NULL, FALSE );
			// Log( " 사이즈 : %d %d \n", width, height );
		}
			return 0;

		case WM_DESTROY:
		{
			if ( GameManager::GetInstance()->Process() )
			{
				// 창이 강제 제거 되었을 때(창 닫기 등)
				// 여기서 이 이벤트를 발생시켜서 RunGame()의 루프에서 빠져나오게 해야
				// 안전하게 리소스가 해제 되면서 메모리 릭을 피할 수 있다.
				GameManager::GetInstance()->Stop();
			}
			PostQuitMessage( 0 );
		}
			return 0;

		case WM_SYSKEYDOWN:
		case WM_KEYDOWN:
		{
			KeyInput key;
			key.SetKeyValue( static_cast<unsigned char>( wParam ) );
			key.SetKeyStatus( KeyStatusType::KEY_DOWN );
			if ( InputDispatcher::GetInstance()->IsPressed( key ) )
			{
				key.SetKeyStatus( KeyStatusType::KEY_PRESSED );
			}

			InputDispatcher::GetInstance()->EventKeyInput( key );
			InputDispatcher::GetInstance()->DispatchKeyInput();
		}
			return 0;

		case WM_SYSKEYUP:
		case WM_KEYUP:
		{
			KeyInput key;
			key.SetKeyValue( static_cast<unsigned char>( wParam ) );
			key.SetKeyStatus( KeyStatusType::KEY_UP );

			InputDispatcher::GetInstance()->EventKeyInput( key );
			InputDispatcher::GetInstance()->DispatchKeyInput();
		}
			return 0;

		case WM_ERASEBKGND:
			return 1;

		//마우스 클릭 상태
		case WM_LBUTTONDOWN:
		{
			MouseManager::GetInstance()->SetLeftClick(true);
		}
			return 0;

		case WM_LBUTTONUP:
		{
			MouseManager::GetInstance()->SetLeftClick(false);
			SoundManager::GetInstance()->PlaySound(SOUND_SYSTEM_MOUSE_CLICK);
		}
			return 0;

		case WM_RBUTTONDOWN:
		{
			MouseManager::GetInstance()->SetRightClick(true);
		}
			return 0;

		case WM_RBUTTONUP:
		{
			MouseManager::GetInstance()->SetRightClick(false);
			SoundManager::GetInstance()->PlaySound(SOUND_SYSTEM_MOUSE_CLICK);
		}
			return 0;

		case WM_MOVE:
		{
			int LocationX = LOWORD( lParam );
			int LocationY = HIWORD( lParam );
			MouseManager::GetInstance()->SetWndLocation( LocationX, LocationY );
		}
			return 0;

		case WM_SETFOCUS:
		{
			BringWindowToTop( m_HandleOfWindow );
			MouseManager::GetInstance()->SetGameCursorMode( true );
			ShowCursor( false );
		}
			return 0;

		case WM_KILLFOCUS:
		{
			InputDispatcher::GetInstance()->ClearList();
			MouseManager::GetInstance()->MoveHiddenCursorToMousePos();
			MouseManager::GetInstance()->SetGameCursorMode( false );
			ShowCursor( true );
		}
			return 0;

		case WM_MOUSEMOVE:
		{
			int MouseX = LOWORD( lParam );
			int MouseY = HIWORD( lParam );
			MouseManager::GetInstance()->MoveMousePosition( MouseX, MouseY );
			//MouseManager::GetInstance()->MoveHiddenCursorToCenter();

		}
			return 0;

		case WM_MOUSEWHEEL:
		{
			CameraController::GetInstance()->ChangeMouseZoomStatus( static_cast<short>( HIWORD( wParam ) ) );
		}
			return 0;

		default:
			return DefWindowProc( m_HandleOfWindow, uMsg, wParam, lParam );
	}

	return 0;
}
예제 #11
0
void SDLInput::pushInput(const SDL_Event &event)
{
    BLOCK_START("SDLInput::pushInput")
    KeyInput keyInput;
    MouseInput mouseInput;

    switch (event.type)
    {
        case SDL_KEYDOWN:
        {
            keyInput.setType(KeyEventType::PRESSED);
            convertKeyEventToKey(event, keyInput);
            mKeyInputQueue.push(keyInput);
            break;
        }

        case SDL_KEYUP:
        {
            keyInput.setType(KeyEventType::RELEASED);
            convertKeyEventToKey(event, keyInput);
            mKeyInputQueue.push(keyInput);
            break;
        }

#ifdef USE_SDL2
        case SDL_TEXTINPUT:
            keyInput.setType(KeyEventType::PRESSED);
            keyInput.setKey(Key(Key::TEXTINPUT));
            keyInput.setText(event.text.text);
            mKeyInputQueue.push(keyInput);
            break;

        case SDL_MOUSEWHEEL:
        {
            const int y = event.wheel.y;
            if (y)
            {
                mouseInput.setX(gui->getLastMouseX());
                mouseInput.setY(gui->getLastMouseY());
#ifdef ANDROID
                mouseInput.setReal(0, 0);
#endif
                mouseInput.setButton(MouseButton::WHEEL);
                if (y > 0)
                    mouseInput.setType(MouseEventType::WHEEL_MOVED_UP);
                else
                    mouseInput.setType(MouseEventType::WHEEL_MOVED_DOWN);
                mouseInput.setTimeStamp(SDL_GetTicks());
                mMouseInputQueue.push(mouseInput);
            }

            break;
        }
#endif

#ifdef ANDROID
#ifndef USE_SDL2
        case SDL_ACCELEROMETER:
            break;
#endif
#endif

        case SDL_MOUSEBUTTONDOWN:
        {
            mMouseDown = true;
            const int scale = mainGraphics->getScale();
            const int x = event.button.x / scale;
            const int y = event.button.y / scale;
            mouseInput.setX(x);
            mouseInput.setY(y);
#ifdef ANDROID
#ifdef USE_SDL2
            mouseInput.setReal(x, y);
#else
            mouseInput.setReal(event.button.realx / scale,
                event.button.realy / scale);
#endif
#endif
            mouseInput.setButton(convertMouseButton(event.button.button));

#ifndef USE_SDL2
            if (event.button.button == SDL_BUTTON_WHEELDOWN)
                mouseInput.setType(MouseEventType::WHEEL_MOVED_DOWN);
            else if (event.button.button == SDL_BUTTON_WHEELUP)
                mouseInput.setType(MouseEventType::WHEEL_MOVED_UP);
            else
#endif
                mouseInput.setType(MouseEventType::PRESSED);
            mouseInput.setTimeStamp(SDL_GetTicks());
            mMouseInputQueue.push(mouseInput);
            break;
        }
        case SDL_MOUSEBUTTONUP:
        {
            mMouseDown = false;
            const int scale = mainGraphics->getScale();
            const int x = event.button.x / scale;
            const int y = event.button.y / scale;
            mouseInput.setX(x);
            mouseInput.setY(y);
#ifdef ANDROID
#ifdef USE_SDL2
            mouseInput.setReal(x, y);
#else
            mouseInput.setReal(event.button.realx / scale,
                event.button.realy / scale);
#endif
#endif
            mouseInput.setButton(convertMouseButton(event.button.button));
            mouseInput.setType(MouseEventType::RELEASED);
            mouseInput.setTimeStamp(SDL_GetTicks());
            mMouseInputQueue.push(mouseInput);
            break;
        }
        case SDL_MOUSEMOTION:
        {
            const int scale = mainGraphics->getScale();
            const int x = event.motion.x / scale;
            const int y = event.motion.y / scale;
            mouseInput.setX(x);
            mouseInput.setY(y);
#ifdef ANDROID
#ifdef USE_SDL2
            mouseInput.setReal(x, y);
#else
            mouseInput.setReal(event.motion.realx / scale,
                event.motion.realy / scale);
#endif
#endif
            mouseInput.setButton(MouseButton::EMPTY);
            mouseInput.setType(MouseEventType::MOVED);
            mouseInput.setTimeStamp(SDL_GetTicks());
            mMouseInputQueue.push(mouseInput);
            break;
        }
#ifndef USE_SDL2
        case SDL_ACTIVEEVENT:
            /*
             * This occurs when the mouse leaves the window and the Gui-chan
             * application loses its mousefocus.
             */
            if ((event.active.state & SDL_APPMOUSEFOCUS) && !event.active.gain)
            {
                mMouseInWindow = false;

                if (!mMouseDown)
                {
                    mouseInput.setX(-1);
                    mouseInput.setY(-1);
                    mouseInput.setButton(MouseButton::EMPTY);
                    mouseInput.setType(MouseEventType::MOVED);
                    mMouseInputQueue.push(mouseInput);
                }
            }

            if ((event.active.state & SDL_APPMOUSEFOCUS) && event.active.gain)
                mMouseInWindow = true;
            break;
#endif
        default:
            break;
    }  // end switch
    BLOCK_END("SDLInput::pushInput")
}
예제 #12
0
파일: gui.cpp 프로젝트: doveiya/isilme
    void Gui::handleKeyInput()
    {
        while (!mInput->isKeyQueueEmpty())
        {
            KeyInput keyInput = mInput->dequeueKeyInput();

            // Save modifiers state
            mShiftPressed = keyInput.isShiftPressed();
            mMetaPressed = keyInput.isMetaPressed();
            mControlPressed = keyInput.isControlPressed();
            mAltPressed = keyInput.isAltPressed();

            KeyEvent keyEventToGlobalKeyListeners(WidgetPtr(),
                                                  mShiftPressed,
                                                  mControlPressed,
                                                  mAltPressed,
                                                  mMetaPressed,
                                                  keyInput.getType(),
                                                  keyInput.isNumericPad(),
                                                  keyInput.getKey());

            distributeKeyEventToGlobalKeyListeners(keyEventToGlobalKeyListeners);

            // If a global key listener consumes the event it will not be
            // sent further to the source of the event.
            if (keyEventToGlobalKeyListeners.isConsumed())
            {
                continue;
            }

            bool keyEventConsumed = false;
            
            // Send key inputs to the focused widgets
            if (mFocusHandler->GetFocused() != NULL)
            {
                KeyEvent keyEvent(GetKeyEventSource(),
                                  mShiftPressed,
                                  mControlPressed,
                                  mAltPressed,
                                  mMetaPressed,
                                  keyInput.getType(),
                                  keyInput.isNumericPad(),
                                  keyInput.getKey());
                

                if (!mFocusHandler->GetFocused()->IsFocusable())
                {
                    mFocusHandler->FocusNone();
                }
                else
                {                    
                    distributeKeyEvent(keyEvent);                    
                }

                keyEventConsumed = keyEvent.isConsumed();
            }

            // If the key event hasn't been consumed and
            // tabbing is enable check for tab press and
            // change focus.
            if (!keyEventConsumed
                && mTabbing
                && keyInput.getKey().getValue() == Key::TAB
                && keyInput.getType() == KeyInput::PRESSED)
            {
                if (keyInput.isShiftPressed())
                {
                    mFocusHandler->TabPrevious();
                }
                else
                {
                    mFocusHandler->TabNext();
                }
            }                           
                
        } // end while
    }
예제 #13
0
    void SDLInput::pushInput(SDL_Event event)
    {
        KeyInput keyInput;
        MouseInput mouseInput;
    
        switch (event.type)
        {
          case SDL_KEYDOWN:
              keyInput.setKey(convertKeyCharacter(event.key.keysym));
              keyInput.setType(KeyInput::PRESS);        
              mKeyInputQueue.push(keyInput);
              break;

          case SDL_KEYUP:
              keyInput.setKey(convertKeyCharacter(event.key.keysym));
              keyInput.setType(KeyInput::RELEASE);
              mKeyInputQueue.push(keyInput);
              break;

          case SDL_MOUSEBUTTONDOWN:
              mMouseDown = true;
              mouseInput.x = event.button.x;
              mouseInput.y = event.button.y;
              mouseInput.setButton(convertMouseButton(event.button.button));
              mouseInput.setType(MouseInput::PRESS);
              mouseInput.setTimeStamp(SDL_GetTicks());
              mMouseInputQueue.push(mouseInput);
              break;

          case SDL_MOUSEBUTTONUP:
              mMouseDown = false;        
              mouseInput.x = event.button.x;
              mouseInput.y = event.button.y;
              mouseInput.setButton(convertMouseButton(event.button.button));
              mouseInput.setType(MouseInput::RELEASE);
              mouseInput.setTimeStamp(SDL_GetTicks());
              mMouseInputQueue.push(mouseInput);
              break;
        
          case SDL_MOUSEMOTION:
              mouseInput.x = event.button.x;
              mouseInput.y = event.button.y;
              mouseInput.setButton(MouseInput::EMPTY);
              mouseInput.setType(MouseInput::MOTION);
              mouseInput.setTimeStamp(SDL_GetTicks());
              mMouseInputQueue.push(mouseInput);
              break;
        
          case SDL_ACTIVEEVENT:
              /* 
               * This occurs when the mouse leaves the window and the Gui-chan
               * application loses its mousefocus.
               */
              if ((event.active.state & SDL_APPMOUSEFOCUS)
                  && !event.active.gain)
              {
                  mMouseInWindow = false;
          
                  if (!mMouseDown)
                  {
                      mouseInput.x = -1;
                      mouseInput.y = -1;
                      mouseInput.setButton(MouseInput::EMPTY);
                      mouseInput.setType(MouseInput::MOTION);
                      mMouseInputQueue.push(mouseInput);
                  }
              }

              if ((event.active.state & SDL_APPMOUSEFOCUS)
                  && event.active.gain)
              {
                  mMouseInWindow = true;
              }
              break;
        
        } // end switch
    }
예제 #14
0
파일: sdlinput.cpp 프로젝트: ArkBriar/rlvm
    void SDLInput::pushInput(SDL_Event event)
    {
        KeyInput keyInput;
        MouseInput mouseInput;

        switch (event.type)
        {
            case SDL_KEYDOWN:
            {
                int value = convertSDLEventToGuichanKeyValue(event);

                if (value == -1)
                {
                    value = (int)event.key.keysym.unicode;
                } 
               
                keyInput.setKey(Key(value));
                keyInput.setType(KeyInput::PRESSED);
                keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT);
                keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL);
                keyInput.setAltPressed(event.key.keysym.mod & KMOD_ALT);
                keyInput.setMetaPressed(event.key.keysym.mod & KMOD_META);
                keyInput.setNumericPad(event.key.keysym.sym >= SDLK_KP0
                                     && event.key.keysym.sym <= SDLK_KP_EQUALS);

                mKeyInputQueue.push(keyInput);
                break;
            }

            case SDL_KEYUP:
            {
                int value = convertSDLEventToGuichanKeyValue(event);

                if (value == -1)
                {
                    value = (int)event.key.keysym.sym;
                } 

                keyInput.setKey(Key(value));
                keyInput.setType(KeyInput::RELEASED);
                keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT);
                keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL);
                keyInput.setAltPressed(event.key.keysym.mod & KMOD_ALT);
                keyInput.setMetaPressed(event.key.keysym.mod & KMOD_META);
                keyInput.setNumericPad(event.key.keysym.sym >= SDLK_KP0
                                     && event.key.keysym.sym <= SDLK_KP_EQUALS);

                mKeyInputQueue.push(keyInput);
                break;
            }

            case SDL_MOUSEBUTTONDOWN:
                mMouseDown = true;
                mouseInput.setX(event.button.x);
                mouseInput.setY(event.button.y);
                mouseInput.setButton(convertMouseButton(event.button.button));

                if (event.button.button == SDL_BUTTON_WHEELDOWN)
                {
                  mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN);
                }
                else if (event.button.button == SDL_BUTTON_WHEELUP)
                {
                  mouseInput.setType(MouseInput::WHEEL_MOVED_UP);
                }
                else
                {
                  mouseInput.setType(MouseInput::PRESSED);
                }
                mouseInput.setTimeStamp(SDL_GetTicks());
                mMouseInputQueue.push(mouseInput);
                break;

            case SDL_MOUSEBUTTONUP:
                mMouseDown = false;
                mouseInput.setX(event.button.x);
                mouseInput.setY(event.button.y);
                mouseInput.setButton(convertMouseButton(event.button.button));
                mouseInput.setType(MouseInput::RELEASED);
                mouseInput.setTimeStamp(SDL_GetTicks());
                mMouseInputQueue.push(mouseInput);
                break;

            case SDL_MOUSEMOTION:
                mouseInput.setX(event.button.x);
                mouseInput.setY(event.button.y);
                mouseInput.setButton(MouseInput::EMPTY);
                mouseInput.setType(MouseInput::MOVED);
                mouseInput.setTimeStamp(SDL_GetTicks());
                mMouseInputQueue.push(mouseInput);
                break;

            case SDL_ACTIVEEVENT:
                /*
                * This occurs when the mouse leaves the window and the Gui-chan
                * application loses its mousefocus.
                */
                if ((event.active.state & SDL_APPMOUSEFOCUS)
                  && !event.active.gain)
                {
                  mMouseInWindow = false;

                  if (!mMouseDown)
                  {
                      mouseInput.setX(-1);
                      mouseInput.setY(-1);
                      mouseInput.setButton(MouseInput::EMPTY);
                      mouseInput.setType(MouseInput::MOVED);
                      mMouseInputQueue.push(mouseInput);
                  }
                }

                if ((event.active.state & SDL_APPMOUSEFOCUS)
                  && event.active.gain)
                {
                  mMouseInWindow = true;
                }
                break;

        } // end switch
    }