public class RemoteInput extends java.lang.Object implements java.lang.Runnable, Input
An Input implementation that receives touch, key, accelerometer and compass events from a remote Android device. Just
instantiate it and specify the port it should listen on for incoming connections (default 8190). Then store the new RemoteInput
instance in Gdx.input. That's it.
On your Android device you can use the gdx-remote application available on the Google Code page as an APK or in SVN (extensions/gdx-remote). Open it, specify the IP address and the port of the PC your libgdx app is running on and then tap away.
The touch coordinates will be translated to the desktop window's coordinate system, no matter the orientation of the device
| Modifier and Type | Class and Description |
|---|---|
static interface |
RemoteInput.RemoteInputListener |
Input.Buttons, Input.Keys, Input.Orientation, Input.Peripheral, Input.TextInputListener| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PORT |
java.lang.String[] |
ips |
| Constructor and Description |
|---|
RemoteInput() |
RemoteInput(int port) |
RemoteInput(int port,
RemoteInput.RemoteInputListener listener) |
RemoteInput(RemoteInput.RemoteInputListener listener) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancelVibrate()
Stops the vibrator
|
float |
getAccelerometerX() |
float |
getAccelerometerY() |
float |
getAccelerometerZ() |
float |
getAzimuth()
The azimuth is the angle of the device's orientation around the z-axis.
|
long |
getCurrentEventTime() |
int |
getDeltaX() |
int |
getDeltaX(int pointer) |
int |
getDeltaY() |
int |
getDeltaY(int pointer) |
float |
getGyroscopeX() |
float |
getGyroscopeY() |
float |
getGyroscopeZ() |
InputProcessor |
getInputProcessor() |
java.lang.String[] |
getIPs() |
Input.Orientation |
getNativeOrientation() |
float |
getPitch()
The pitch is the angle of the device's orientation around the x-axis.
|
float |
getRoll()
The roll is the angle of the device's orientation around the y-axis.
|
int |
getRotation() |
void |
getRotationMatrix(float[] matrix)
Returns the rotation matrix describing the devices rotation as per SensorManager#getRotationMatrix(float[], float[], float[], float[]).
|
void |
getTextInput(Input.TextInputListener listener,
java.lang.String title,
java.lang.String text,
java.lang.String hint)
System dependent method to input a string of text.
|
int |
getX() |
int |
getX(int pointer)
Returns the x coordinate in screen coordinates of the given pointer.
|
int |
getY() |
int |
getY(int pointer)
Returns the y coordinate in screen coordinates of the given pointer.
|
boolean |
isButtonPressed(int button)
Whether a given button is pressed or not.
|
boolean |
isCatchBackKey() |
boolean |
isCatchMenuKey() |
boolean |
isConnected() |
boolean |
isCursorCatched() |
boolean |
isKeyJustPressed(int key)
Returns whether the key has just been pressed.
|
boolean |
isKeyPressed(int key)
Returns whether the key is pressed.
|
boolean |
isPeripheralAvailable(Input.Peripheral peripheral)
Queries whether a
Input.Peripheral is currently available. |
boolean |
isTouched() |
boolean |
isTouched(int pointer)
Whether the screen is currently touched by the pointer with the given index.
|
boolean |
justTouched() |
void |
run() |
void |
setCatchBackKey(boolean catchBack)
Sets whether the BACK button on Android should be caught.
|
void |
setCatchMenuKey(boolean catchMenu)
Sets whether the MENU button on Android should be caught.
|
void |
setCursorCatched(boolean catched)
Only viable on the desktop.
|
void |
setCursorPosition(int x,
int y)
Only viable on the desktop.
|
void |
setInputProcessor(InputProcessor processor)
Sets the
InputProcessor that will receive all touch and key input events. |
void |
setOnscreenKeyboardVisible(boolean visible)
Sets the on-screen keyboard visible if available.
|
void |
vibrate(int milliseconds)
Vibrates for the given amount of time.
|
void |
vibrate(long[] pattern,
int repeat)
Vibrate with a given pattern.
|
public RemoteInput()
public RemoteInput(RemoteInput.RemoteInputListener listener)
public RemoteInput(int port)
public RemoteInput(int port,
RemoteInput.RemoteInputListener listener)
public void run()
run in interface java.lang.Runnablepublic boolean isConnected()
public float getAccelerometerX()
getAccelerometerX in interface Inputpublic float getAccelerometerY()
getAccelerometerY in interface Inputpublic float getAccelerometerZ()
getAccelerometerZ in interface Inputpublic float getGyroscopeX()
getGyroscopeX in interface Inputpublic float getGyroscopeY()
getGyroscopeY in interface Inputpublic float getGyroscopeZ()
getGyroscopeZ in interface Inputpublic int getX()
public int getX(int pointer)
Inputpublic int getY()
public int getY(int pointer)
Inputpublic boolean isTouched()
public boolean justTouched()
justTouched in interface Inputpublic boolean isTouched(int pointer)
Inputpublic boolean isButtonPressed(int button)
InputInput.Buttons. On Android only the Button#LEFT
constant is meaningful before version 4.0.isButtonPressed in interface Inputbutton - the button to check.public boolean isKeyPressed(int key)
InputisKeyPressed in interface Inputkey - The key code as found in Input.Keys.public boolean isKeyJustPressed(int key)
InputisKeyJustPressed in interface Inputkey - The key code as found in Input.Keys.public void getTextInput(Input.TextInputListener listener, java.lang.String title, java.lang.String text, java.lang.String hint)
InputInput.TextInputListener will be called on the rendering
thread.getTextInput in interface Inputlistener - The TextInputListener.title - The title of the text input dialog.text - The message presented to the user.public void setOnscreenKeyboardVisible(boolean visible)
InputsetOnscreenKeyboardVisible in interface Inputvisible - visible or notpublic void vibrate(int milliseconds)
Input in your manifest file in order for this to work.public void vibrate(long[] pattern,
int repeat)
Inputpublic void cancelVibrate()
InputcancelVibrate in interface Inputpublic float getAzimuth()
InputgetAzimuth in interface Inputpublic float getPitch()
InputgetPitch in interface Inputpublic float getRoll()
InputgetRoll in interface Inputpublic void setCatchBackKey(boolean catchBack)
InputsetCatchBackKey in interface InputcatchBack - whether to catch the back buttonpublic boolean isCatchBackKey()
isCatchBackKey in interface Inputpublic void setCatchMenuKey(boolean catchMenu)
InputsetCatchMenuKey in interface InputcatchMenu - whether to catch the menu buttonpublic boolean isCatchMenuKey()
isCatchMenuKey in interface Inputpublic void setInputProcessor(InputProcessor processor)
InputInputProcessor that will receive all touch and key input events. It will be called before the
ApplicationListener.render() method each frame.setInputProcessor in interface Inputprocessor - the InputProcessorpublic InputProcessor getInputProcessor()
getInputProcessor in interface InputInputProcessor or null.public java.lang.String[] getIPs()
RemoteSender or gdx-remote should connect to. Most likely the LAN addresses if behind a NAT.public boolean isPeripheralAvailable(Input.Peripheral peripheral)
InputInput.Peripheral is currently available. In case of Android and the Input.Peripheral.HardwareKeyboard
this returns the whether the keyboard is currently slid out or not.isPeripheralAvailable in interface Inputperipheral - the Input.Peripheralpublic int getRotation()
getRotation in interface Inputpublic Input.Orientation getNativeOrientation()
getNativeOrientation in interface Inputpublic void setCursorCatched(boolean catched)
InputsetCursorCatched in interface Inputcatched - whether to catch or not to catch the mouse cursorpublic boolean isCursorCatched()
isCursorCatched in interface Inputpublic int getDeltaX()
public int getDeltaX(int pointer)
public int getDeltaY()
public int getDeltaY(int pointer)
public void setCursorPosition(int x,
int y)
InputsetCursorPosition in interface Inputx - the x-positiony - the y-positionpublic long getCurrentEventTime()
getCurrentEventTime in interface InputInputProcessor.public void getRotationMatrix(float[] matrix)
InputgetRotationMatrix in interface Input