com.jme3.input.android
Class AndroidInput

java.lang.Object
  extended by com.jme3.input.android.AndroidInput
All Implemented Interfaces:
android.view.GestureDetector.OnDoubleTapListener, android.view.GestureDetector.OnGestureListener, android.view.ScaleGestureDetector.OnScaleGestureListener, android.view.View.OnKeyListener, android.view.View.OnTouchListener, Input, TouchInput

public class AndroidInput
extends java.lang.Object
implements TouchInput, android.view.View.OnTouchListener, android.view.View.OnKeyListener, android.view.GestureDetector.OnGestureListener, android.view.GestureDetector.OnDoubleTapListener, android.view.ScaleGestureDetector.OnScaleGestureListener

AndroidInput is one of the main components that connect jme with android. Is derived from GLSurfaceView and handles all Inputs


Field Summary
 boolean dontSendHistory
           
 boolean keyboardEventsEnabled
           
 boolean mouseEventsEnabled
           
 boolean mouseEventsInvertX
           
 boolean mouseEventsInvertY
           
 
Fields inherited from interface com.jme3.input.TouchInput
ALL, KEYCODE_BACK, KEYCODE_HOME, KEYCODE_MENU, KEYCODE_SEARCH, KEYCODE_VOLUME_DOWN, KEYCODE_VOLUME_UP
 
Constructor Summary
AndroidInput(android.view.View view)
           
 
Method Summary
 void destroy()
          Ceases listening to events from the device.
 long getInputTimeNanos()
           
 boolean getSimulateMouse()
          Get if mouse events are generated
 void initialize()
          Initializes the native side to listen into events from the device.
 boolean isInitialized()
           
 boolean isMouseEventsEnabled()
          Deprecated. Use getSimulateMouse();
 boolean isMouseEventsInvertX()
           
 boolean isMouseEventsInvertY()
           
 boolean isSimulateMouse()
           
 void loadSettings(AppSettings settings)
           
 boolean onDoubleTap(android.view.MotionEvent event)
           
 boolean onDoubleTapEvent(android.view.MotionEvent event)
           
 boolean onDown(android.view.MotionEvent event)
           
 boolean onFling(android.view.MotionEvent event, android.view.MotionEvent event2, float vx, float vy)
           
 boolean onKey(android.view.View view, int keyCode, android.view.KeyEvent event)
          onKey gets called from android thread on key events
 void onLongPress(android.view.MotionEvent event)
           
 boolean onScale(android.view.ScaleGestureDetector scaleGestureDetector)
           
 boolean onScaleBegin(android.view.ScaleGestureDetector scaleGestureDetector)
           
 void onScaleEnd(android.view.ScaleGestureDetector scaleGestureDetector)
           
 boolean onScroll(android.view.MotionEvent e1, android.view.MotionEvent e2, float distanceX, float distanceY)
           
 void onShowPress(android.view.MotionEvent event)
           
 boolean onSingleTapConfirmed(android.view.MotionEvent event)
           
 boolean onSingleTapUp(android.view.MotionEvent event)
           
 boolean onTouch(android.view.View view, android.view.MotionEvent event)
          onTouch gets called from android thread on touchpad events
 void setInputListener(RawInputListener listener)
          Sets the input listener to receive events from this device.
 void setMouseEventsEnabled(boolean mouseEventsEnabled)
          Deprecated. 
 void setMouseEventsInvertX(boolean mouseEventsInvertX)
           
 void setMouseEventsInvertY(boolean mouseEventsInvertY)
           
 void setOmitHistoricEvents(boolean dontSendHistory)
          Set if historic android events should be transmitted, can be used to get better performance and less mem
 void setSimulateKeyboard(boolean simulate)
          Set if keyboard events should be generated
 void setSimulateMouse(boolean simulate)
          Set if mouse events should be generated
 void setView(android.view.View view)
           
 void update()
          Queries the device for input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mouseEventsEnabled

public boolean mouseEventsEnabled

mouseEventsInvertX

public boolean mouseEventsInvertX

mouseEventsInvertY

public boolean mouseEventsInvertY

keyboardEventsEnabled

public boolean keyboardEventsEnabled

dontSendHistory

public boolean dontSendHistory
Constructor Detail

AndroidInput

public AndroidInput(android.view.View view)
Method Detail

setView

public void setView(android.view.View view)

onTouch

public boolean onTouch(android.view.View view,
                       android.view.MotionEvent event)
onTouch gets called from android thread on touchpad events

Specified by:
onTouch in interface android.view.View.OnTouchListener

onKey

public boolean onKey(android.view.View view,
                     int keyCode,
                     android.view.KeyEvent event)
onKey gets called from android thread on key events

Specified by:
onKey in interface android.view.View.OnKeyListener

loadSettings

public void loadSettings(AppSettings settings)

initialize

public void initialize()
Description copied from interface: Input
Initializes the native side to listen into events from the device.

Specified by:
initialize in interface Input

destroy

public void destroy()
Description copied from interface: Input
Ceases listening to events from the device.

Specified by:
destroy in interface Input

isInitialized

public boolean isInitialized()
Specified by:
isInitialized in interface Input
Returns:
True if the device has been initialized and not destroyed.
See Also:
Input.initialize(), Input.destroy()

setInputListener

public void setInputListener(RawInputListener listener)
Description copied from interface: Input
Sets the input listener to receive events from this device. The appropriate events should be dispatched through the callbacks in RawInputListener.

Specified by:
setInputListener in interface Input

getInputTimeNanos

public long getInputTimeNanos()
Specified by:
getInputTimeNanos in interface Input
Returns:
The current absolute time as nanoseconds. This time is expected to be relative to the time given in InputEvents time property.

update

public void update()
Description copied from interface: Input
Queries the device for input. All events should be sent to the RawInputListener set with setInputListener.

Specified by:
update in interface Input
See Also:
Input.setInputListener(com.jme3.input.RawInputListener)

onDown

public boolean onDown(android.view.MotionEvent event)
Specified by:
onDown in interface android.view.GestureDetector.OnGestureListener

onLongPress

public void onLongPress(android.view.MotionEvent event)
Specified by:
onLongPress in interface android.view.GestureDetector.OnGestureListener

onFling

public boolean onFling(android.view.MotionEvent event,
                       android.view.MotionEvent event2,
                       float vx,
                       float vy)
Specified by:
onFling in interface android.view.GestureDetector.OnGestureListener

onSingleTapConfirmed

public boolean onSingleTapConfirmed(android.view.MotionEvent event)
Specified by:
onSingleTapConfirmed in interface android.view.GestureDetector.OnDoubleTapListener

onDoubleTap

public boolean onDoubleTap(android.view.MotionEvent event)
Specified by:
onDoubleTap in interface android.view.GestureDetector.OnDoubleTapListener

onDoubleTapEvent

public boolean onDoubleTapEvent(android.view.MotionEvent event)
Specified by:
onDoubleTapEvent in interface android.view.GestureDetector.OnDoubleTapListener

onScaleBegin

public boolean onScaleBegin(android.view.ScaleGestureDetector scaleGestureDetector)
Specified by:
onScaleBegin in interface android.view.ScaleGestureDetector.OnScaleGestureListener

onScale

public boolean onScale(android.view.ScaleGestureDetector scaleGestureDetector)
Specified by:
onScale in interface android.view.ScaleGestureDetector.OnScaleGestureListener

onScaleEnd

public void onScaleEnd(android.view.ScaleGestureDetector scaleGestureDetector)
Specified by:
onScaleEnd in interface android.view.ScaleGestureDetector.OnScaleGestureListener

onScroll

public boolean onScroll(android.view.MotionEvent e1,
                        android.view.MotionEvent e2,
                        float distanceX,
                        float distanceY)
Specified by:
onScroll in interface android.view.GestureDetector.OnGestureListener

onShowPress

public void onShowPress(android.view.MotionEvent event)
Specified by:
onShowPress in interface android.view.GestureDetector.OnGestureListener

onSingleTapUp

public boolean onSingleTapUp(android.view.MotionEvent event)
Specified by:
onSingleTapUp in interface android.view.GestureDetector.OnGestureListener

setSimulateKeyboard

public void setSimulateKeyboard(boolean simulate)
Description copied from interface: TouchInput
Set if keyboard events should be generated

Specified by:
setSimulateKeyboard in interface TouchInput
Parameters:
simulate - if keyboard events should be generated

setOmitHistoricEvents

public void setOmitHistoricEvents(boolean dontSendHistory)
Description copied from interface: TouchInput
Set if historic android events should be transmitted, can be used to get better performance and less mem

Specified by:
setOmitHistoricEvents in interface TouchInput
Parameters:
dontSendHistory - turn of historic events if true, false else and default
See Also:
http://developer.android.com/reference/android/view/MotionEvent.html#getHistoricalX%28int,%20int%29

isMouseEventsEnabled

@Deprecated
public boolean isMouseEventsEnabled()
Deprecated. Use getSimulateMouse();


setMouseEventsEnabled

@Deprecated
public void setMouseEventsEnabled(boolean mouseEventsEnabled)
Deprecated. 


isMouseEventsInvertY

public boolean isMouseEventsInvertY()

setMouseEventsInvertY

public void setMouseEventsInvertY(boolean mouseEventsInvertY)

isMouseEventsInvertX

public boolean isMouseEventsInvertX()

setMouseEventsInvertX

public void setMouseEventsInvertX(boolean mouseEventsInvertX)

setSimulateMouse

public void setSimulateMouse(boolean simulate)
Description copied from interface: TouchInput
Set if mouse events should be generated

Specified by:
setSimulateMouse in interface TouchInput
Parameters:
simulate - if mouse events should be generated

getSimulateMouse

public boolean getSimulateMouse()
Description copied from interface: TouchInput
Get if mouse events are generated

Specified by:
getSimulateMouse in interface TouchInput

isSimulateMouse

public boolean isSimulateMouse()
Specified by:
isSimulateMouse in interface TouchInput
Returns:
true if mouse event simulation is enabled, false otherwise.