Exemplo n.º 1
0
        public BindableButton registerBindButton(SimpleUri bindId, String displayName, BindButtonEvent @event)
        {
            BindableButtonImpl bind = new BindableButtonImpl(bindId, displayName, @event);

            buttonLookup.put(bindId, bind);
            buttonBinds.add(bind);
            return(bind);
        }
Exemplo n.º 2
0
 public void clearBinds()
 {
     buttonLookup.Clear();
     buttonBinds.Clear();
     axisLookup.Clear();
     axisBinds.Clear();
     keyBinds.Clear();
     mouseButtonBinds.Clear();
     mouseWheelUpBind   = null;
     mouseWheelDownBind = null;
 }
Exemplo n.º 3
0
 public void linkBindButtonToMouseWheel(int direction, SimpleUri bindId)
 {
     if (direction > 0)
     {
         mouseWheelDownBind = buttonLookup.get(bindId);
     }
     else if (direction < 0)
     {
         mouseWheelUpBind = buttonLookup.get(bindId);
     }
 }
Exemplo n.º 4
0
        private void processKeyboardInput(float delta)
        {
            for (InputAction action : keyboard.getInputQueue())
            {
                bool consumed = sendKeyEvent(action.getInput(), action.getInputChar(), action.getState(), delta);

                // Update bind
                BindableButtonImpl bind = keyBinds.get(action.getInput().getId());
                if (bind != null && action.getState() != ButtonState.REPEAT)
                {
                    bind.updateBindState(
                        action.getInput(),
                        (action.getState() == ButtonState.DOWN),
                        delta, getInputEntities(),
                        targetSystem.getTarget(),
                        targetSystem.getTargetBlockPosition(),
                        targetSystem.getHitPosition(),
                        targetSystem.getHitNormal(),
                        consumed
                        );
                }
            }
        }
Exemplo n.º 5
0
        private void processMouseInput(float delta)
        {
            if (!engine.hasFocus())
            {
                return;
            }

            Vector2i deltaMouse = mouse.getDelta();

            //process mouse movement x axis
            if (deltaMouse.x != 0)
            {
                MouseAxisEvent @event = new MouseXAxisEvent(deltaMouse.x * config.getInput().getMouseSensitivity(), delta);
                setupTarget(@event);
                for (EntityRef entity : getInputEntities())
                {
                    entity.send(@event);
                    if (@event.isConsumed())
                    {
                        break;
                    }
                }
            }

            //process mouse movement y axis
            if (deltaMouse.y != 0)
            {
                MouseAxisEvent @event = new MouseYAxisEvent(deltaMouse.y * config.getInput().getMouseSensitivity(), delta);
                setupTarget(@event);
                for (EntityRef entity : getInputEntities())
                {
                    entity.send(@event);
                    if (@event.isConsumed())
                    {
                        break;
                    }
                }
            }

            //process mouse clicks
            for (InputAction action : mouse.getInputQueue())
            {
                switch (action.getInput().getType())
                {
                case MOUSE_BUTTON:
                    int id = action.getInput().getId();
                    if (id != -1)
                    {
                        MouseInput button   = MouseInput.find(action.getInput().getType(), action.getInput().getId());
                        bool       consumed = sendMouseEvent(button, action.getState().isDown(), action.getMousePosition(), delta);

                        BindableButtonImpl bind = mouseButtonBinds.get(button);
                        if (bind != null)
                        {
                            bind.updateBindState(
                                action.getInput(),
                                action.getState().isDown(),
                                delta,
                                getInputEntities(),
                                targetSystem.getTarget(),
                                targetSystem.getTargetBlockPosition(),
                                targetSystem.getHitPosition(),
                                targetSystem.getHitNormal(),
                                consumed
                                );
                        }
                    }
                    break;

                case MOUSE_WHEEL:
                    int dir = action.getInput().getId();
                    if (dir != 0 && action.getTurns() != 0)
                    {
                        bool consumed = sendMouseWheelEvent(action.getMousePosition(), dir * action.getTurns(), delta);

                        BindableButtonImpl bind = (dir == 1) ? mouseWheelUpBind : mouseWheelDownBind;
                        if (bind != null)
                        {
                            for (int i = 0; i < action.getTurns(); ++i)
                            {
                                bind.updateBindState(
                                    action.getInput(),
                                    true,
                                    delta,
                                    getInputEntities(),
                                    targetSystem.getTarget(),
                                    targetSystem.getTargetBlockPosition(),
                                    targetSystem.getHitPosition(),
                                    targetSystem.getHitNormal(),
                                    consumed
                                    );
                                bind.updateBindState(
                                    action.getInput(),
                                    false,
                                    delta,
                                    getInputEntities(),
                                    targetSystem.getTarget(),
                                    targetSystem.getTargetBlockPosition(),
                                    targetSystem.getHitPosition(),
                                    targetSystem.getHitNormal(),
                                    consumed
                                    );
                            }
                        }
                    }
                    break;

                case KEY:
                    break;
                }
            }
        }
Exemplo n.º 6
0
        public void linkBindButtonToMouse(MouseInput mouseButton, SimpleUri bindId)
        {
            BindableButtonImpl bindInfo = buttonLookup.get(bindId);

            mouseButtonBinds.put(mouseButton, bindInfo);
        }
Exemplo n.º 7
0
        public void linkBindButtonToKey(int key, SimpleUri bindId)
        {
            BindableButtonImpl bindInfo = buttonLookup.get(bindId);

            keyBinds.put(key, bindInfo);
        }