Skip to content
This repository has been archived by the owner on Nov 13, 2022. It is now read-only.
Tor (torbuntu) edited this page Apr 17, 2021 · 3 revisions

Leikr supports Keyboard, Mouse and USB Gamepad Controllers

Version: 1.0.7

Input System Objects
Keyboard This object can be passed to non main classes to get the keyboard input methods.
Mouse This object can be passed to non main classes to get the mouse input methods.
ControllerA, ControllerB Controller objects for getting controller input in non main classes.
See Helper

input handling

Note: All input to key(String key) method must be a String in the Start Case (initial letter capitalized) otherwise true will be returned regardless.

To use the button names, just pass it into any method asking for a String for a button ID:

if ( button("Up")) { doSomething() } 

Note: If you use an @Override method for controllers, you must add an import to the top of your main file

import org.mini2Dx.core.input.*
Input API
boolean button(String button) Returns true or false if the given button name is pressed for a single controller.
boolean button(String button, int player) Returns true or false if the given button ID is pressed for the given player (0 or 1).
boolean key(String key) Returns true or false if the given keyboard key is pressed. This polls continuously so is good for player controls. Examples: X, Z, Enter, Space, Left, Right, Up, Down
boolean keyUp(String key) Returns boolean if the given key is not pressed
boolean keyPress(String key) Returns true or false if the given keyboard key is pressed. Checks one time, best used for menus or non-continuous polling. Examples: X, Z, Enter, Space, Left, Right, Up, Down
boolean mouseClick() Returns boolean if mouse button pressed
float mouseX() Returns the X position of the mouse
float mouseY() Returns the Y position of the mouse
Input Overrides
@Override public boolean keyDown(int keyCode) Override this method to receive an event if a key is pressed down.
@Override public boolean keyUp(int keyCode) Override this method to receive an event if a key is released.
@Override public boolean keyTyped(char character) Override this method to receive an event of which character is typed on a keyboard.
@Override public boolean touchDown(int screenX, int screenY, int pointer, int button)
@Override public boolean touchUp(int screenX, int screenY, int pointer, int button)
@Override public boolean touchDragged(int screenX, int screenY, int pointer)
@Override public boolean mouseMoved(int screenX, int screenY)
@Override public boolean scrolled(int amount)