Package arc.backend.android
Class AndroidInput
java.lang.Object
arc.Input
arc.backend.android.AndroidInput
- All Implemented Interfaces:
android.view.View.OnGenericMotionListener
,android.view.View.OnKeyListener
,android.view.View.OnTouchListener
public class AndroidInput
extends Input
implements android.view.View.OnKeyListener, android.view.View.OnTouchListener, android.view.View.OnGenericMotionListener
An implementation of the
Input
interface for Android.-
Nested Class Summary
Nested classes/interfaces inherited from class arc.Input
Input.Orientation, Input.Peripheral, Input.TextInput
-
Field Summary
Modifier and TypeFieldDescriptionprotected final float[]
protected final float[]
protected final float[]
protected final Input.Orientation
protected final float[]
protected final android.os.Vibrator
Fields inherited from class arc.Input
caughtKeys, devices, inputMultiplexer, keyboard, mouseReturn, useKeyboard
-
Constructor Summary
ConstructorDescriptionAndroidInput
(AndroidApplication activity, android.content.Context context, android.view.View view, AndroidApplicationConfiguration config) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addKeyListener
(android.view.View.OnKeyListener listener) void
Stops the vibratorint
deltaX()
int
deltaX
(int pointer) int
deltaY()
int
deltaY
(int pointer) long
int
float
float
getPressure
(int pointer) Returns the pressure of the given pointer, where 0 is untouched.int
void
getRotationMatrix
(float[] matrix) Returns the rotation matrix describing the devices rotation as per SensorManager#getRotationMatrix(float[], float[], float[], float[]).void
getTextInput
(Input.TextInput info) System dependent method to input a string of text.boolean
handleGenericMotion
(android.view.MotionEvent event) void
handleTouch
(android.view.MotionEvent event, AndroidInput input) boolean
isPeripheralAvailable
(Input.Peripheral peripheral) Queries whether aInput.Peripheral
is currently available.boolean
boolean
isTouched
(int pointer) Whether the screen is currently touched by the pointer with the given index.boolean
int
lookUpPointerIndex
(int pointerId) int
mouseX()
int
mouseX
(int pointer) Returns the x coordinate in screen coordinates of the given pointer.int
mouseY()
int
mouseY
(int pointer) Returns the y coordinate in screen coordinates of the given pointer.void
onDrop
(int x, int y) boolean
onGenericMotion
(android.view.View view, android.view.MotionEvent event) boolean
onKey
(android.view.View v, int keyCode, android.view.KeyEvent e) void
onPause()
void
onResume()
void
onTap
(int x, int y) boolean
onTouch
(android.view.View view, android.view.MotionEvent event) protected void
postTap
(int x, int y) 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 arc.Input
addProcessor, alt, axis, axis, axisTap, ctrl, getDevices, getInputMultiplexer, getInputProcessors, getKeyboard, getTouches, isCatch, keyDown, keyDown, keyRelease, keyRelease, keyTap, keyTap, mouse, mouseScreen, mouseWorld, mouseWorld, mouseWorldX, mouseWorldY, removeProcessor, setCatch, setUseKeyboard, shift, useKeyboard
-
Field Details
-
accelerometerValues
protected final float[] accelerometerValues -
gyroscopeValues
protected final float[] gyroscopeValues -
vibrator
protected final android.os.Vibrator vibrator -
magneticFieldValues
protected final float[] magneticFieldValues -
rotationVectorValues
protected final float[] rotationVectorValues -
nativeOrientation
-
-
Constructor Details
-
AndroidInput
public AndroidInput(AndroidApplication activity, android.content.Context context, android.view.View view, AndroidApplicationConfiguration config)
-
-
Method Details
-
getAccelerometer
- Overrides:
getAccelerometer
in classInput
- Returns:
- The acceleration force in m/s^2 applied to the device, including the force of gravity
-
getGyroscope
- Overrides:
getGyroscope
in classInput
- Returns:
- The rate of rotation in rad/s.
-
getOrientation
- Overrides:
getOrientation
in classInput
- Returns:
- the device's orientation in degrees in the format (pitch, roll, azimuth) corresponding to x,y,z.
-
getTextInput
Description copied from class:Input
System dependent method to input a string of text. A dialog box will be created with the given title and the given text as a message for the user. Once the dialog has been closed the consumer be called on the rendering thread.- Overrides:
getTextInput
in classInput
-
mouseX
public int mouseX() -
mouseY
public int mouseY() -
mouseX
public int mouseX(int pointer) Description copied from class:Input
Returns the x coordinate in screen coordinates of the given pointer. Pointers are indexed from 0 to n. The pointer id identifies the order in which the fingers went down on the screen, e.g. 0 is the first finger, 1 is the second and so on. When two fingers are touched down and the first one is lifted the second one keeps its index. If another finger is placed on the touch screen the first free index will be used. -
mouseY
public int mouseY(int pointer) Description copied from class:Input
Returns the y coordinate in screen coordinates of the given pointer. Pointers are indexed from 0 to n. The pointer id identifies the order in which the fingers went down on the screen, e.g. 0 is the first finger, 1 is the second and so on. When two fingers are touched down and the first one is lifted the second one keeps its index. If another finger is placed on the touch screen the first free index will be used. -
isTouched
public boolean isTouched(int pointer) Description copied from class:Input
Whether the screen is currently touched by the pointer with the given index. Pointers are indexed from 0 to n. The pointer id identifies the order in which the fingers went down on the screen, e.g. 0 is the first finger, 1 is the second and so on. When two fingers are touched down and the first one is lifted the second one keeps its index. If another finger is placed on the touch screen the first free index will be used. -
getPressure
public float getPressure()- Overrides:
getPressure
in classInput
- Returns:
- the pressure of the first pointer
-
getPressure
public float getPressure(int pointer) Description copied from class:Input
Returns the pressure of the given pointer, where 0 is untouched. On Android it should be up to 1.0, but it can go above that slightly and its not consistent between devices. On iOS 1.0 is the normal touch and significantly more of hard touch. Check relevant manufacturer documentation for details. Check availability withInput.isPeripheralAvailable(Peripheral)
. If not supported, returns 1.0 when touched.- Overrides:
getPressure
in classInput
- Parameters:
pointer
- the pointer id.- Returns:
- the pressure
-
isTouched
public boolean isTouched() -
onTouch
public boolean onTouch(android.view.View view, android.view.MotionEvent event) - Specified by:
onTouch
in interfaceandroid.view.View.OnTouchListener
-
handleTouch
-
onTap
public void onTap(int x, int y) -
onDrop
public void onDrop(int x, int y) -
postTap
protected void postTap(int x, int y) -
onKey
public boolean onKey(android.view.View v, int keyCode, android.view.KeyEvent e) - Specified by:
onKey
in interfaceandroid.view.View.OnKeyListener
-
setOnscreenKeyboardVisible
public void setOnscreenKeyboardVisible(boolean visible) Description copied from class:Input
Sets the on-screen keyboard visible if available. Only applicable on mobile.- Overrides:
setOnscreenKeyboardVisible
in classInput
- Parameters:
visible
- visible or not
-
vibrate
public void vibrate(int milliseconds) Description copied from class:Input
Vibrates for the given amount of time. Note that you'll need the permission<uses-permission android:name="android.permission.VIBRATE" />
in your manifest file in order for this to work. -
vibrate
public void vibrate(long[] pattern, int repeat) Description copied from class:Input
Vibrate with a given pattern. Pass in an array of ints that are the times at which to turn on or off the vibrator. The first one is how long to wait before turning it on, and then after that it alternates. If you want to repeat, pass the index into the pattern at which to start the repeat. -
cancelVibrate
public void cancelVibrate()Description copied from class:Input
Stops the vibrator- Overrides:
cancelVibrate
in classInput
-
justTouched
public boolean justTouched()- Specified by:
justTouched
in classInput
- Returns:
- whether a new touch down event just occurred.
-
getRotationMatrix
public void getRotationMatrix(float[] matrix) Returns the rotation matrix describing the devices rotation as per SensorManager#getRotationMatrix(float[], float[], float[], float[]). Does not manipulate the matrix if the platform does not have an accelerometer and compass, or a rotation vector sensor.- Overrides:
getRotationMatrix
in classInput
-
isPeripheralAvailable
Description copied from class:Input
Queries whether aInput.Peripheral
is currently available. In case of Android and theInput.Peripheral.hardwareKeyboard
this returns the whether the keyboard is currently slid out or not.- Overrides:
isPeripheralAvailable
in classInput
- Parameters:
peripheral
- theInput.Peripheral
- Returns:
- whether the peripheral is available or not.
-
getFreePointerIndex
public int getFreePointerIndex() -
lookUpPointerIndex
public int lookUpPointerIndex(int pointerId) -
getRotation
public int getRotation()- Overrides:
getRotation
in classInput
- Returns:
- the rotation of the device with respect to its native orientation.
-
getNativeOrientation
- Overrides:
getNativeOrientation
in classInput
- Returns:
- the native orientation of the device.
-
deltaX
public int deltaX() -
deltaX
public int deltaX(int pointer) -
deltaY
public int deltaY() -
deltaY
public int deltaY(int pointer) -
getCurrentEventTime
public long getCurrentEventTime()- Specified by:
getCurrentEventTime
in classInput
- Returns:
- the time of the event currently reported to the
InputProcessor
.
-
addKeyListener
public void addKeyListener(android.view.View.OnKeyListener listener) -
onPause
public void onPause() -
onResume
public void onResume() -
onGenericMotion
public boolean onGenericMotion(android.view.View view, android.view.MotionEvent event) - Specified by:
onGenericMotion
in interfaceandroid.view.View.OnGenericMotionListener
-
handleGenericMotion
public boolean handleGenericMotion(android.view.MotionEvent event)
-