Package com.ardor3d.input

Examples of com.ardor3d.input.MouseState


        public LwjglMouseIterator() {}

        @Override
        protected MouseState computeNext() {
            if (_nextState != null) {
                final MouseState rVal = _nextState;
                _nextState = null;
                return rVal;
            }

            if (!Mouse.next()) {
                return endOfData();
            }

            final EnumMap<MouseButton, ButtonState> buttons = Maps.newEnumMap(MouseButton.class);

            if (Mouse.getButtonCount() > 0) {
                final boolean down = Mouse.isButtonDown(0);
                processButtonForClick(MouseButton.LEFT, down);
                buttons.put(MouseButton.LEFT, down ? ButtonState.DOWN : ButtonState.UP);
            }
            if (Mouse.getButtonCount() > 1) {
                final boolean down = Mouse.isButtonDown(1);
                processButtonForClick(MouseButton.RIGHT, down);
                buttons.put(MouseButton.RIGHT, down ? ButtonState.DOWN : ButtonState.UP);
            }
            if (Mouse.getButtonCount() > 2) {
                final boolean down = Mouse.isButtonDown(2);
                processButtonForClick(MouseButton.MIDDLE, down);
                buttons.put(MouseButton.MIDDLE, down ? ButtonState.DOWN : ButtonState.UP);
            }

            final MouseState nextState = new MouseState(Mouse.getEventX(), Mouse.getEventY(), Mouse.getEventDX(), Mouse
                    .getEventDY(), Mouse.getEventDWheel(), buttons, null);

            if (nextState.getDx() != 0.0 || nextState.getDy() != 0.0) {
                _clickArmed.clear();
                _clicks.clear();
                _sendClickState = false;
            }

            if (_sendClickState) {
                _nextState = nextState;
                _sendClickState = false;
                return new MouseState(nextState.getX(), nextState.getY(), nextState.getDx(), nextState.getDy(),
                        nextState.getDwheel(), buttons, EnumMultiset.create(_clicks));
            } else {
                return nextState;
            }
        }
View Full Code Here


        addNewState(mouseEvent, mouseEvent.count, _lastState.getButtonStates(), null);
    }

    private void initState(final MouseEvent mouseEvent) {
        if (_lastState == null) {
            _lastState = new MouseState(mouseEvent.x, getArdor3DY(mouseEvent), 0, 0, 0, null, null);
        }
    }
View Full Code Here

    }

    private void addNewState(final MouseEvent mouseEvent, final int wheelDX,
            final EnumMap<MouseButton, ButtonState> buttons, final Multiset<MouseButton> clicks) {

        final MouseState newState = new MouseState(mouseEvent.x, getArdor3DY(mouseEvent), getDX(mouseEvent),
                getDY(mouseEvent), wheelDX, buttons, clicks);

        _upcomingEvents.add(newState);
        _lastState = newState;
    }
View Full Code Here

            // Test boolean to allow us to ignore first mouse event. First event can wildly vary based on platform.
            private boolean firstPing = true;

            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                final MouseState mouse = inputStates.getCurrent().getMouseState();
                if (mouse.getDx() != 0 || mouse.getDy() != 0) {
                    if (!firstPing) {
                        move(_xSpeed * mouse.getDx(), _ySpeed * mouse.getDy());
                    } else {
                        firstPing = false;
                    }
                }

                if (mouse.getDwheel() != 0) {
                    zoom(_zoomSpeed * mouse.getDwheel());
                }
            }
        };

        final Predicate<TwoInputStates> predicate = Predicates.or(scrollWheelMoved, dragOnly ? dragged
View Full Code Here

            // Test boolean to allow us to ignore first mouse event. First event can wildly vary based on platform.
            private boolean firstPing = true;

            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                final MouseState mouse = inputStates.getCurrent().getMouseState();
                if (mouse.getDx() != 0 || mouse.getDy() != 0) {
                    if (!firstPing) {
                        FirstPersonControl.this.rotate(source.getCanvasRenderer().getCamera(), -mouse.getDx(),
                                -mouse.getDy());
                    } else {
                        firstPing = false;
                    }
                }
            }
View Full Code Here

            // exit without adding an event to our queue
            return;
        }

        // save our old "last state."
        final MouseState _savedState = _lastState;

        // Add our latest state info to the queue
        addNewState(me, _lastState.getButtonStates(), null);

        // If we have a valid move... should always be the case, but occasionally something slips through.
View Full Code Here

        }
    }

    private void initState(final MouseEvent mouseEvent) {
        if (_lastState == null) {
            _lastState = new MouseState(mouseEvent.getX(), getArdor3DY(mouseEvent), 0, 0, 0, null, null);
        }
    }
View Full Code Here

        }
    }

    private void addNewState(final MouseEvent mouseEvent, final EnumMap<MouseButton, ButtonState> enumMap,
            final Multiset<MouseButton> clicks) {
        final MouseState newState = new MouseState(mouseEvent.getX(), getArdor3DY(mouseEvent), getDX(mouseEvent),
                getDY(mouseEvent), (int) (mouseEvent.isShiftDown() ? mouseEvent.getRotation()[0]
                        : mouseEvent.getRotation()[1]), enumMap, clicks);

        synchronized (JoglNewtMouseWrapper.this) {
            _upcomingEvents.add(newState);
View Full Code Here

        final InputState current = inputStates.getCurrent();

        // Mouse checks.
        if (!isIgnoreMouseInputOnGrabbed() || _mouseManager == null
                || _mouseManager.getGrabbed() != GrabbedState.GRABBED) {
            final MouseState previousMState = inputStates.getPrevious().getMouseState();
            final MouseState currentMState = current.getMouseState();
            if (previousMState != currentMState) {

                // Check for presses.
                if (currentMState.hasButtonState(ButtonState.DOWN)) {
                    final EnumSet<MouseButton> pressed = currentMState.getButtonsPressedSince(previousMState);
                    if (!pressed.isEmpty()) {
                        for (final MouseButton button : pressed) {
                            consumed |= fireMouseButtonPressed(button, current);
                        }
                    }
                }

                // Check for releases.
                if (previousMState.hasButtonState(ButtonState.DOWN)) {
                    final EnumSet<MouseButton> released = currentMState.getButtonsReleasedSince(previousMState);
                    if (!released.isEmpty()) {
                        for (final MouseButton button : released) {
                            consumed |= fireMouseButtonReleased(button, current);
                        }
                    }
                }

                // Check for mouse movement
                if (currentMState.getDx() != 0 || currentMState.getDy() != 0) {
                    consumed |= fireMouseMoved(currentMState.getX(), currentMState.getY(), current);
                }

                // Check for wheel change
                if (currentMState.getDwheel() != 0) {
                    consumed |= fireMouseWheelMoved(currentMState.getDwheel(), current);
                }
            }
        }
        return consumed || _dragListener != null;
    }
View Full Code Here

        // Make sure we have something to modify
        if (manager.getSpatialTarget() == null) {
            return;
        }
        // Make sure we are dragging.
        final MouseState current = inputStates.getCurrent().getMouseState();
        final MouseState previous = inputStates.getPrevious().getMouseState();

        if (current.getButtonState(_dragButton) != ButtonState.DOWN) {
            if (_lastInputWidget != null) {
                _lastInputWidget.processInput(source, inputStates, inputConsumed, manager);
                _lastInputWidget = null;
            }
            return;
        }

        if (_lastInputWidget == null) {
            final Camera camera = source.getCanvasRenderer().getCamera();
            final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY());
            findPick(oldMouse, camera);
            if (_results.getNumber() <= 0) {
                return;
            }
View Full Code Here

TOP

Related Classes of com.ardor3d.input.MouseState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.