Interface InputDevice

  • All Known Implementing Classes:
    AWTInput, GDXInput, TeaInputDevice

    public interface InputDevice
    Used to poll the status of the platform's input devices. Depending on the device, this may consist of a mouse, keyboard, or touch screen. Attempting to access an input device that is not available will result in a UnsupportedOperationException.

    Mouse, touch, and keyboard events all use the concepts of "pressed" and "released". They are considered "pressed" during the entire lifespan of the event. In contrast, the "released" state is only active for a single frame after the event has ended.

    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      java.util.List<Point2D> getPointers()
      Returns the current locations of all currently active pointers.
      boolean isKeyboardAvailable()
      Returns true if the current device has a hardware keyboard.
      boolean isKeyPressed​(KeyCode keyCode)
      Returns true if the key with the specified key code was pressed during the current frame.
      boolean isKeyReleased​(KeyCode keyCode)
      Returns true if the key with the specified key code was released during the current frame.
      boolean isPointerPressed​(Rect area)
      Returns true if any of the currently active pointers have been pressed and located within the specified area during the current frame.
      boolean isPointerReleased​(Rect area)
      Returns true if any of the currently active pointers were released and located within the specified area during the current frame.
      boolean isTouchAvailable()
      Returns if the current device supports touch input.
      java.lang.String requestTextInput​(java.lang.String label, java.lang.String initialValue)
      Deprecated.
      Although this method is necessary for the reasons outlined above, it does lead to user experience issues due to the mix of user interface elements provided by the renderer and those from the native platform.
    • Method Detail

      • getPointers

        java.util.List<Point2D> getPointers()
        Returns the current locations of all currently active pointers. When using a mouse, this will always return a list with a single element. For touch controls, the list could also have multiple elements (during multi-touch gestures) or the list could be empty (unlike mouse events, touch coordinates are only available during the event itself).
      • isPointerPressed

        boolean isPointerPressed​(Rect area)
        Returns true if any of the currently active pointers have been pressed and located within the specified area during the current frame.
      • isPointerReleased

        boolean isPointerReleased​(Rect area)
        Returns true if any of the currently active pointers were released and located within the specified area during the current frame.
      • isKeyboardAvailable

        boolean isKeyboardAvailable()
        Returns true if the current device has a hardware keyboard.
      • isKeyPressed

        boolean isKeyPressed​(KeyCode keyCode)
        Returns true if the key with the specified key code was pressed during the current frame.
      • isKeyReleased

        boolean isKeyReleased​(KeyCode keyCode)
        Returns true if the key with the specified key code was released during the current frame.
      • requestTextInput

        @Deprecated
        java.lang.String requestTextInput​(java.lang.String label,
                                          java.lang.String initialValue)
        Deprecated.
        Although this method is necessary for the reasons outlined above, it does lead to user experience issues due to the mix of user interface elements provided by the renderer and those from the native platform.
        Shows a dialog window requesting the user to enter text. This method exists only because text fields, unlike other input elements such as buttons, cannot be emulated by the renderer without losing common functionality such as copy/paste. Text input must therefore be delegated to the platform so that a native text field can be used.