Differentiating TAP from a quick DOWN/MOVE/UP

Has anyone thought about how to write a listener that needs to know when a TAP happens as well as a DOWN/MOVE/UP sequence?

I would like to have different actions based on if the user drags (ie move the camera based on a drag) or taps (ie select an object or aim a weapon). However, I get the DOWN event, then the MOVE event (very small move), then the UP event, then the TAP event. I need to ignore the MOVE event if a TAP comes later.

I know I could add a delay for the DOWN, MOVE, and UP events to check to see if a TAP happens after or a tolerance for MOVE, but I was wondering if there was a better way.

yh i remember having this issue a few months back when i was experimenting with android. I had a gun shooting as a mouse click event, and then the standard flycam moving around (all the built-in stuff). If you panned around, then removed your finger, it would shoot. On the PC you have have 2 different mouse clicks (left and right), perhaps left click could be translated to tap and right click to drag (this probably has nothing to do with what your asking though sorry :P).

I was actually more interested in the opposite case. I don’t want to move the camera if a TAP event is fired so that the action for the TAP can occur without the camera jiggling :slight_smile:

Did you try to listen to the scroll event instead of the move event?

the thing is Down, Move and up are raw events, tap and scroll are generated by gesture detection…

I always found the tap event a bit lagish…

1 Like


Great suggestion. At first glance, I don’t see any combinations of TAP and SCROLL within the same gesture. SCROLL appears to be the right way to go.

I’ll use SCROLL to move the camera and TAP to fire.

Just as a thought, should SCROLL be used instead of MOVE for the analog mouse simulation? I see a lot of MOVE events with deltaX and deltaY = 0, but looking at InputManager, it looks like the event shouldn’t be logged if they are 0. I’m going to look to see why the MOVE events are being generated with deltaX and deltaY = 0.


private void onMouseMotionEventQueued(MouseMotionEvent evt) {

// for (int i = 0; i < rawListeners.size(); i++){

// rawListeners.get(i).onMouseMotionEvent(evt);

// }

if (evt.getDX() != 0) {

float val = Math.abs(evt.getDX()) / 1024f;

invokeAnalogsAndActions(MouseAxisTrigger.mouseAxisHash(MouseInput.AXIS_X, evt.getDX() < 0), val, false);


if (evt.getDY() != 0) {

float val = Math.abs(evt.getDY()) / 1024f;

invokeAnalogsAndActions(MouseAxisTrigger.mouseAxisHash(MouseInput.AXIS_Y, evt.getDY() < 0), val, false);


if (evt.getDeltaWheel() != 0) {

float val = Math.abs(evt.getDeltaWheel()) / 100f;

invokeAnalogsAndActions(MouseAxisTrigger.mouseAxisHash(MouseInput.AXIS_WHEEL, evt.getDeltaWheel() < 0), val, false);




I found out why I’m getting MOVE events with no deltaX or deltaY. The onTouch event is generated no matter what on the MOVE event.

I made a change to AndroidInput to only create the onTouch event for the MOVE event if there is actually a non-0 deltaX or deltaY.

@nehon Do you see any issue with me committing this? It only removes the unnecessary MOVE events that are currently being generated with no actual movement.


This patch file was generated by NetBeans IDE

Following Index: paths are relative to: D:UserspotterecDocumentsjMonkeyProjectsjME3_Reposrcandroidcomjme3inputandroid

This patch can be applied using context Tools: Patch action on respective folder.

It uses platform neutral UTF-8 encoding and n newlines.

Above lines and this line are ignored by the patching process.

Index: AndroidInput.java

— AndroidInput.java Base (BASE)

+++ AndroidInput.java Locally Modified (Based On LOCAL)

@@ -267,14 +267,19 @@

lastPos = new Vector2f(event.getX§, view.getHeight() - event.getY§);

lastPositions.put(event.getPointerId§, lastPos);



  •                float dX = event.getX(p) - lastPos.x;<br />
  •                float dY = view.getHeight() - event.getY(p) - lastPos.y;<br />
  •                if (dX != 0 || dY != 0) {<br />

touch = getNextFreeTouchEvent();

  •                touch.set(Type.MOVE, event.getX(p), view.getHeight() - event.getY(p), event.getX(p) - lastPos.x, view.getHeight() - event.getY(p) - lastPos.y);<br />
  •                    touch.set(Type.MOVE, event.getX(p), view.getHeight() - event.getY(p), dX, dY);<br />





lastPos.set(event.getX§, view.getHeight() - event.getY§);


  •            }<br />

bWasHandled = true;


case MotionEvent.ACTION_OUTSIDE:



oh cool, that’s great Eric.

Go ahead and commit :wink: