com.jme3.input.event.JoyButtonEvent Java Examples

The following examples show how to use com.jme3.input.event.JoyButtonEvent. 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: AndroidJoyInput.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void update() {
    if (sensorJoyInput != null) {
        sensorJoyInput.update();
    }

    if (listener != null) {
        InputEvent inputEvent;

        while ((inputEvent = eventQueue.poll()) != null) {
            if (inputEvent instanceof JoyAxisEvent) {
                listener.onJoyAxisEvent((JoyAxisEvent)inputEvent);
            } else if (inputEvent instanceof JoyButtonEvent) {
                listener.onJoyButtonEvent((JoyButtonEvent)inputEvent);
            }
        }
    }

}
 
Example #2
Source File: GlfwJoystickInput.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void update() {
    for (final Map.Entry<Integer, GlfwJoystick> entry : joysticks.entrySet()) {

        // Axes
        final FloatBuffer axisValues = glfwGetJoystickAxes(entry.getKey());

        // if a joystick is added or removed, the callback reloads the joysticks.
        // when the callback is called and reloads the joystick, this iterator may already have started iterating.
        // To avoid a NullPointerException we null-check the axisValues and bytebuffer objects.
        // If the joystick it's iterating over no-longer exists it will return null.

        if (axisValues != null) {
            for (final JoystickAxis axis : entry.getValue().getAxes()) {
                final float value = axisValues.get(axis.getAxisId());
                listener.onJoyAxisEvent(new JoyAxisEvent(axis, value));
            }
        }

        // Buttons
        final ByteBuffer byteBuffer = glfwGetJoystickButtons(entry.getKey());

        if (byteBuffer != null) {
            for (final JoystickButton button : entry.getValue().getButtons()) {
                final boolean pressed = byteBuffer.get(button.getButtonId()) == GLFW_PRESS;

                if (joyButtonPressed.get(button) != pressed) {
                    joyButtonPressed.put(button, pressed);
                    listener.onJoyButtonEvent(new JoyButtonEvent(button, pressed));
                }
            }
        }
    }
}
 
Example #3
Source File: InputManager.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void onJoyButtonEventQueued(JoyButtonEvent evt) {
//        for (int i = 0; i < rawListeners.size(); i++){
//            rawListeners.get(i).onJoyButtonEvent(evt);
//        }

        int hash = JoyButtonTrigger.joyButtonHash(evt.getJoyIndex(), evt.getButtonIndex());
        invokeActions(hash, evt.isPressed());
        invokeTimedActions(hash, evt.getTime(), evt.isPressed());
    }
 
Example #4
Source File: InputManager.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Callback from RawInputListener. Do not use.
 */
public void onJoyButtonEvent(JoyButtonEvent evt) {
    if (!eventsPermitted) {
        throw new UnsupportedOperationException("JoyInput has raised an event at an illegal time.");
    }

    inputQueue.add(evt);
}
 
Example #5
Source File: DefaultRawInputListener.java    From Lemur with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void onJoyButtonEvent( JoyButtonEvent evt ) {
}
 
Example #6
Source File: TestJoystick.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void onJoyButtonEvent(JoyButtonEvent evt) {
    setViewedJoystick( evt.getButton().getJoystick() );
    gamepad.setButtonValue( evt.getButton(), evt.isPressed() ); 
}
 
Example #7
Source File: InputSystemJme.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void onJoyButtonEvent(JoyButtonEvent evt) {
}
 
Example #8
Source File: TestSoftwareMouse.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void onJoyButtonEvent(JoyButtonEvent evt) {
}
 
Example #9
Source File: TestBitmapFont.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void onJoyButtonEvent(JoyButtonEvent evt) { }
 
Example #10
Source File: AbstractCameraController.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void onJoyButtonEvent(JoyButtonEvent jbe) {
}
 
Example #11
Source File: RawInputListener.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Invoked on joystick button presses.
 * 
 * @param evt 
 */
public void onJoyButtonEvent(JoyButtonEvent evt);