Java Code Examples for com.jme3.input.event.MouseMotionEvent#setTime()

The following examples show how to use com.jme3.input.event.MouseMotionEvent#setTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlfwMouseInputVR.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void onCursorPos(long window, double xpos, double ypos) {
    int x = (int) Math.round(xpos);
    int y = context.getSettings().getHeight() - (int) Math.round(ypos);

    if (mouseX == 0) {
        mouseX = x;
    }

    if (mouseY == 0) {
        mouseY = y;
    }

    xDelta = x - mouseX;
    yDelta = y - mouseY;
    mouseX = x;
    mouseY = y;

    if (xDelta != 0 || yDelta != 0) {
        final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(x, y, xDelta, yDelta, mouseWheel, 0);
        mouseMotionEvent.setTime(getInputTimeNanos());
        mouseMotionEvents.add(mouseMotionEvent);
    }
}
 
Example 2
Source File: GlfwMouseInput.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void onCursorPos(final long window, final double xpos, final double ypos) {

        int xDelta;
        int yDelta;
        int x = (int) Math.round(xpos);
        int y = currentHeight - (int) Math.round(ypos);

        xDelta = x - mouseX;
        yDelta = y - mouseY;
        mouseX = x;
        mouseY = y;

        if (xDelta != 0 || yDelta != 0) {
            final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(x, y, xDelta, yDelta, mouseWheel, 0);
            mouseMotionEvent.setTime(getInputTimeNanos());
            mouseMotionEvents.add(mouseMotionEvent);
        }
    }
 
Example 3
Source File: AWTMouseInput.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void onCursorPos(double xpos, double ypos) {

        int xDelta;
        int yDelta;
        int x = (int) Math.round(xpos);
        int y = context.getHeight() - (int) Math.round(ypos);

        if (mouseX == 0) mouseX = x;
        if (mouseY == 0) mouseY = y;

        xDelta = x - mouseX;
        yDelta = y - mouseY;

        mouseX = x;
        mouseY = y;

        if (xDelta == 0 && yDelta == 0) return;

        final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(x, y, xDelta, yDelta, mouseWheel, 0);
        mouseMotionEvent.setTime(getInputTimeNanos());

        EXECUTOR.addToExecute(new Runnable() {

          @Override
          public void run() {
            mouseMotionEvents.add(mouseMotionEvent);
          }
          
        });
    }
 
Example 4
Source File: GlfwMouseInputVR.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void onWheelScroll(long window, double xOffset, double yOffset) {
    mouseWheel += yOffset;

    final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(mouseX, mouseY, 0, 0, mouseWheel, (int) Math.round(yOffset));
    mouseMotionEvent.setTime(getInputTimeNanos());
    mouseMotionEvents.add(mouseMotionEvent);
}
 
Example 5
Source File: AWTMouseInput.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void onWheelScroll(final double xOffset, final double yOffset) {

        mouseWheel += yOffset;

        final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(mouseX, mouseY, 0, 0, mouseWheel, (int) Math.round(yOffset));
        mouseMotionEvent.setTime(getInputTimeNanos());

        EXECUTOR.addToExecute(new Runnable() {

          @Override
          public void run() {
            mouseMotionEvents.add(mouseMotionEvent);
          }
          
        });
    }
 
Example 6
Source File: GlfwMouseInput.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void onWheelScroll(final long window, final double xOffset, final double yOffset) {
    mouseWheel += yOffset;
    final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(mouseX, mouseY, 0, 0, mouseWheel, (int) Math.round(yOffset));
    mouseMotionEvent.setTime(getInputTimeNanos());
    mouseMotionEvents.add(mouseMotionEvent);
}