|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.badlogic.gdx.input.RemoteInput
public class RemoteInput
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
Nested Class Summary | |
---|---|
static interface |
RemoteInput.RemoteInputListener
|
Nested classes/interfaces inherited from interface com.badlogic.gdx.Input |
---|
Input.Buttons, Input.Keys, Input.Orientation, Input.Peripheral, Input.TextInputListener |
Field Summary | |
---|---|
static int |
DEFAULT_PORT
|
String[] |
ips
|
Constructor Summary | |
---|---|
RemoteInput()
|
|
RemoteInput(int port)
|
|
RemoteInput(int port,
RemoteInput.RemoteInputListener listener)
|
|
RemoteInput(RemoteInput.RemoteInputListener listener)
|
Method Summary | |
---|---|
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)
|
InputProcessor |
getInputProcessor()
|
String[] |
getIPs()
|
Input.Orientation |
getNativeOrientation()
|
float |
getPitch()
The pitch is the angle of the device's orientation around the x-axis. |
void |
getPlaceholderTextInput(Input.TextInputListener listener,
String title,
String placeholder)
System dependent method to input a string of text. |
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,
String title,
String text)
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 |
isConnected()
|
boolean |
isCursorCatched()
|
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 |
setCursorImage(Pixmap pixmap,
int xHotspot,
int yHotspot)
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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int DEFAULT_PORT
public final String[] ips
Constructor Detail |
---|
public RemoteInput()
public RemoteInput(RemoteInput.RemoteInputListener listener)
public RemoteInput(int port)
public RemoteInput(int port, RemoteInput.RemoteInputListener listener)
Method Detail |
---|
public void run()
run
in interface Runnable
public boolean isConnected()
public float getAccelerometerX()
getAccelerometerX
in interface Input
public float getAccelerometerY()
getAccelerometerY
in interface Input
public float getAccelerometerZ()
getAccelerometerZ
in interface Input
public int getX()
getX
in interface Input
public int getX(int pointer)
Input
getX
in interface Input
pointer
- the pointer id.
public int getY()
getY
in interface Input
public int getY(int pointer)
Input
getY
in interface Input
pointer
- the pointer id.
public boolean isTouched()
isTouched
in interface Input
public boolean justTouched()
justTouched
in interface Input
public boolean isTouched(int pointer)
Input
isTouched
in interface Input
pointer
- the pointer
public boolean isButtonPressed(int button)
Input
Input.Buttons
. On Android only the Button#LEFT
constant is meaningful.
isButtonPressed
in interface Input
button
- the button to check.
public boolean isKeyPressed(int key)
Input
isKeyPressed
in interface Input
key
- The key code as found in Input.Keys
.
public void getTextInput(Input.TextInputListener listener, String title, String text)
Input
Input.TextInputListener
will be called on the rendering
thread.
getTextInput
in interface Input
listener
- The TextInputListener.title
- The title of the text input dialog.text
- The message presented to the user.public void getPlaceholderTextInput(Input.TextInputListener listener, String title, String placeholder)
Input
Input.TextInputListener
will be called on the
rendering thread.
getPlaceholderTextInput
in interface Input
listener
- The TextInputListener.title
- The title of the text input dialog.placeholder
- The placeholder text presented to the user.public void setOnscreenKeyboardVisible(boolean visible)
Input
setOnscreenKeyboardVisible
in interface Input
visible
- visible or notpublic void vibrate(int milliseconds)
Input
in your manifest file in order for this to work.
vibrate
in interface Input
milliseconds
- the number of milliseconds to vibrate.public void vibrate(long[] pattern, int repeat)
Input
vibrate
in interface Input
pattern
- an array of longs of times to turn the vibrator on or off.repeat
- the index into pattern at which to repeat, or -1 if you don't want to repeat.public void cancelVibrate()
Input
cancelVibrate
in interface Input
public float getAzimuth()
Input
getAzimuth
in interface Input
public float getPitch()
Input
getPitch
in interface Input
public float getRoll()
Input
getRoll
in interface Input
public void setCatchBackKey(boolean catchBack)
Input
setCatchBackKey
in interface Input
catchBack
- whether to catch the back buttonpublic void setInputProcessor(InputProcessor processor)
Input
InputProcessor
that will receive all touch and key input events. It will be called before the
ApplicationListener.render()
method each frame.
setInputProcessor
in interface Input
processor
- the InputProcessorpublic InputProcessor getInputProcessor()
getInputProcessor
in interface Input
InputProcessor
or null.public String[] getIPs()
RemoteSender
or gdx-remote should connect to. Most likely the LAN addresses if behind a NAT.public boolean isPeripheralAvailable(Input.Peripheral peripheral)
Input
Input.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 Input
peripheral
- the Input.Peripheral
public int getRotation()
getRotation
in interface Input
public Input.Orientation getNativeOrientation()
getNativeOrientation
in interface Input
public void setCursorCatched(boolean catched)
Input
setCursorCatched
in interface Input
catched
- whether to catch or not to catch the mouse cursorpublic boolean isCursorCatched()
isCursorCatched
in interface Input
public int getDeltaX()
getDeltaX
in interface Input
public int getDeltaX(int pointer)
getDeltaX
in interface Input
public int getDeltaY()
getDeltaY
in interface Input
public int getDeltaY(int pointer)
getDeltaY
in interface Input
public void setCursorPosition(int x, int y)
Input
setCursorPosition
in interface Input
x
- the x-positiony
- the y-positionpublic void setCursorImage(Pixmap pixmap, int xHotspot, int yHotspot)
Input
Pixmap
.
The Pixmap must be in RGBA8888 format, width & height must be powers-of-two greater than zero (not necessarily equal), and alpha transparency must be single-bit (i.e., 0x00 or 0xFF only).
To revert to the default operating system cursor, pass in a null Pixmap; xHotspot & yHotspot are ignored in this case.
setCursorImage
in interface Input
pixmap
- the mouse cursor image as a Pixmap
, or null to revert to the default operating system cursorxHotspot
- the x location of the hotspot pixel within the cursor image (origin top-left corner)yHotspot
- the y location of the hotspot pixel within the cursor image (origin top-left corner)public void setCatchMenuKey(boolean catchMenu)
Input
setCatchMenuKey
in interface Input
catchMenu
- whether to catch the back buttonpublic long getCurrentEventTime()
getCurrentEventTime
in interface Input
InputProcessor
.public void getRotationMatrix(float[] matrix)
Input
getRotationMatrix
in interface Input
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |