com.jme3.input.event.TouchEvent Java Examples

The following examples show how to use com.jme3.input.event.TouchEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AndroidGestureProcessor.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
    public boolean onFling(MotionEvent startEvent, MotionEvent endEvent, float velocityX, float velocityY) {
        // Fling happens only once at the end of the gesture (all fingers up).
        // Fling returns the velocity of the finger movement in pixels/sec.
        // Therefore, the dX and dY values are actually velocity instead of distance values
        // Since this does not track the movement, use the start position and velocity values.

//        logger.log(Level.INFO, "onFling pointerId: {0}, startAction: {1}, startX: {2}, startY: {3}, endAction: {4}, endX: {5}, endY: {6}, velocityX: {7}, velocityY: {8}",
//                new Object[]{touchInput.getPointerId(startEvent), touchInput.getAction(startEvent), startEvent.getX(), startEvent.getY(), touchInput.getAction(endEvent), endEvent.getX(), endEvent.getY(), velocityX, velocityY});

        float jmeX = touchInput.getJmeX(startEvent.getX());
        float jmeY = touchInput.invertY(touchInput.getJmeY(startEvent.getY()));
        TouchEvent touchEvent = touchInput.getFreeTouchEvent();
        touchEvent.set(TouchEvent.Type.FLING, jmeX, jmeY, velocityX, velocityY);
        touchEvent.setPointerId(touchInput.getPointerId(endEvent));
        touchEvent.setTime(endEvent.getEventTime());
        touchEvent.setPressure(endEvent.getPressure());
        touchInput.addEvent(touchEvent);
        return true;
    }
 
Example #2
Source File: IosTouchHandler.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void actionDown(int pointerId, long time, float x, float y) {
    logger.log(Level.FINE, "Inject input pointer: {0}, time: {1}, x: {2}, y: {3}", 
            new Object[]{pointerId, time, x, y});
    float jmeX = iosInput.getJmeX(x);
    float jmeY = iosInput.invertY(iosInput.getJmeY(y));
    TouchEvent touch = iosInput.getFreeTouchEvent();
    touch.set(TouchEvent.Type.DOWN, jmeX, jmeY, 0, 0);
    touch.setPointerId(pointerId);//TODO: pointer ID
    touch.setTime(time);
    touch.setPressure(1.0f);
    //touch.setPressure(event.getPressure(pointerIndex)); //TODO: preassure

    lastPositions.put(pointerId, new Vector2f(jmeX, jmeY));

    processEvent(touch);
}
 
Example #3
Source File: AndroidTouchInput.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void update() {
    if (listener != null) {
        InputEvent inputEvent;

        while ((inputEvent = inputEventQueue.poll()) != null) {
            if (inputEvent instanceof TouchEvent) {
                listener.onTouchEvent((TouchEvent)inputEvent);
            } else if (inputEvent instanceof MouseButtonEvent) {
                listener.onMouseButtonEvent((MouseButtonEvent)inputEvent);
            } else if (inputEvent instanceof MouseMotionEvent) {
                listener.onMouseMotionEvent((MouseMotionEvent)inputEvent);
            } else if (inputEvent instanceof KeyInputEvent) {
                listener.onKeyEvent((KeyInputEvent)inputEvent);
            }
        }
    }
}
 
Example #4
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public boolean onKeyUp (int keyCode, KeyEvent event) 
{       
    TouchEvent evt;        
    evt = getNextFreeTouchEvent();        
    evt.set(TouchEvent.Type.KEY_UP);
    evt.setKeyCode(keyCode);
    evt.setCharacters(event.getCharacters());
    evt.setTime(event.getEventTime());
    
    // Send the event
    processEvent(evt);
    
    // Handle all keys ourself except Volume Up/Down
    if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) || (keyCode == KeyEvent.KEYCODE_MENU) || (keyCode == KeyEvent.KEYCODE_BACK))
        return false;
    else
        return true;
}
 
Example #5
Source File: AndroidGestureProcessor.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
    public boolean onScale(ScaleGestureDetector scaleGestureDetector) {
        // return true or all gestures for this event will be accumulated
//        logger.log(Level.INFO, "onScale");
        scaleStartX = gestureDownX;
        scaleStartY = gestureDownY;
        TouchEvent touchEvent = touchInput.getFreeTouchEvent();
        touchEvent.set(TouchEvent.Type.SCALE_MOVE, scaleStartX, scaleStartY, 0f, 0f);
        touchEvent.setPointerId(0);
        touchEvent.setTime(scaleGestureDetector.getEventTime());
        touchEvent.setScaleSpan(scaleGestureDetector.getCurrentSpan());
        touchEvent.setDeltaScaleSpan(scaleGestureDetector.getCurrentSpan() - scaleGestureDetector.getPreviousSpan());
        touchEvent.setScaleFactor(scaleGestureDetector.getScaleFactor());
        touchEvent.setScaleSpanInProgress(touchInput.getScaleDetector().isInProgress());
        touchInput.addEvent(touchEvent);
        return true;
    }
 
Example #6
Source File: AndroidGestureProcessor.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
    public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector) {
        // Scale uses a focusX and focusY instead of x and y.  Focus is the middle
        // of the fingers.  Therefore, use the x and y values from the Down event
        // so that the x and y values don't jump to the middle position.
        // return true or all gestures for this beginning event will be discarded
//        logger.log(Level.INFO, "onScaleBegin");
        scaleStartX = gestureDownX;
        scaleStartY = gestureDownY;
        TouchEvent touchEvent = touchInput.getFreeTouchEvent();
        touchEvent.set(TouchEvent.Type.SCALE_START, scaleStartX, scaleStartY, 0f, 0f);
        touchEvent.setPointerId(0);
        touchEvent.setTime(scaleGestureDetector.getEventTime());
        touchEvent.setScaleSpan(scaleGestureDetector.getCurrentSpan());
        touchEvent.setDeltaScaleSpan(0f);
        touchEvent.setScaleFactor(scaleGestureDetector.getScaleFactor());
        touchEvent.setScaleSpanInProgress(touchInput.getScaleDetector().isInProgress());
        touchInput.addEvent(touchEvent);

        return true;
    }
 
Example #7
Source File: AndroidGestureProcessor.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
    public boolean onDoubleTapEvent(MotionEvent event) {
        //Notified when an event within a double-tap gesture occurs, including the down, move(s), and up events.
        // this means it will get called multiple times for a single double tap
//        logger.log(Level.INFO, "onDoubleTapEvent pointerId: {0}, action: {1}, x: {2}, y: {3}",
//                new Object[]{touchInput.getPointerId(event), touchInput.getAction(event), event.getX(), event.getY()});
        if (touchInput.getAction(event) == MotionEvent.ACTION_UP) {
            TouchEvent touchEvent = touchInput.getFreeTouchEvent();
            touchEvent.set(TouchEvent.Type.DOUBLETAP, event.getX(), touchInput.invertY(event.getY()), 0, 0);
            touchEvent.setPointerId(touchInput.getPointerId(event));
            touchEvent.setTime(event.getEventTime());
            touchEvent.setPressure(event.getPressure());
            touchInput.addEvent(touchEvent);
        }
        return true;
    }
 
Example #8
Source File: AndroidGestureProcessor.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
    public boolean onDoubleTap(MotionEvent event) {
        //The down motion event of the first tap of the double-tap
        // We could use this event to fire off a double tap event, or use
        // DoubleTapEvent with a check for the UP action
//        logger.log(Level.INFO, "onDoubleTap pointerId: {0}, action: {1}, x: {2}, y: {3}",
//                new Object[]{touchInput.getPointerId(event), touchInput.getAction(event), event.getX(), event.getY()});
        float jmeX = touchInput.getJmeX(event.getX());
        float jmeY = touchInput.invertY(touchInput.getJmeY(event.getY()));
        TouchEvent touchEvent = touchInput.getFreeTouchEvent();
        touchEvent.set(TouchEvent.Type.DOUBLETAP, jmeX, jmeY, 0, 0);
        touchEvent.setPointerId(touchInput.getPointerId(event));
        touchEvent.setTime(event.getEventTime());
        touchEvent.setPressure(event.getPressure());
        touchInput.addEvent(touchEvent);
        return true;
    }
 
Example #9
Source File: IosInputHandler.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void update() {
     logger.log(Level.FINE, "InputEvent update : {0}",
            new Object[]{listener});
   if (listener != null) {
        InputEvent inputEvent;

        while ((inputEvent = inputEventQueue.poll()) != null) {
            if (inputEvent instanceof TouchEvent) {
                listener.onTouchEvent((TouchEvent)inputEvent);
            } else if (inputEvent instanceof MouseButtonEvent) {
                listener.onMouseButtonEvent((MouseButtonEvent)inputEvent);
            } else if (inputEvent instanceof MouseMotionEvent) {
                listener.onMouseMotionEvent((MouseMotionEvent)inputEvent);
            } else if (inputEvent instanceof KeyInputEvent) {
                listener.onKeyEvent((KeyInputEvent)inputEvent);
            }
        }
    }
}
 
Example #10
Source File: AndroidGestureProcessor.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
    public boolean onScroll(MotionEvent startEvent, MotionEvent endEvent, float distX, float distY) {
        // if not scaleInProgess, send scroll events.  This is to avoid sending
        // scroll events when one of the fingers is lifted just before the other one.
        // Avoids sending the scroll for that brief period of time.
        // Return true so that the next event doesn't accumulate the distX and distY values.
        // Apparantly, both distX and distY are negative.
        // Negate distX to get the real value, but leave distY negative to compensate
        // for the fact that jME has y=0 at bottom where Android has y=0 at top.
        if (!touchInput.getScaleDetector().isInProgress()) {
//            logger.log(Level.INFO, "onScroll pointerId: {0}, startAction: {1}, startX: {2}, startY: {3}, endAction: {4}, endX: {5}, endY: {6}, dx: {7}, dy: {8}",
//                    new Object[]{touchInput.getPointerId(startEvent), touchInput.getAction(startEvent), startEvent.getX(), startEvent.getY(), touchInput.getAction(endEvent), endEvent.getX(), endEvent.getY(), distX, distY});

            float jmeX = touchInput.getJmeX(endEvent.getX());
            float jmeY = touchInput.invertY(touchInput.getJmeY(endEvent.getY()));
            TouchEvent touchEvent = touchInput.getFreeTouchEvent();
            touchEvent.set(TouchEvent.Type.SCROLL, jmeX, jmeY, touchInput.getJmeX(-distX), touchInput.getJmeY(distY));
            touchEvent.setPointerId(touchInput.getPointerId(endEvent));
            touchEvent.setTime(endEvent.getEventTime());
            touchEvent.setPressure(endEvent.getPressure());
            touchInput.addEvent(touchEvent);
        }
        return true;
    }
 
Example #11
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public boolean onKeyDown (int keyCode, KeyEvent event) 
{
    TouchEvent evt;
    evt = getNextFreeTouchEvent();
    evt.set(TouchEvent.Type.KEY_DOWN);
    evt.setKeyCode(keyCode);
    evt.setCharacters(event.getCharacters());
    evt.setTime(event.getEventTime());

    // Send the event
    processEvent(evt);
    
    // Handle all keys ourself except Volume Up/Down
    if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) || (keyCode == KeyEvent.KEYCODE_MENU) || (keyCode == KeyEvent.KEYCODE_BACK))
        return false;
    else
        return true;

}
 
Example #12
Source File: AndroidHarness.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Gets called by the InputManager on all touch/drag/scale events
 */
@Override
public void onTouch(String name, TouchEvent evt, float tpf) {
    if (name.equals(ESCAPE_EVENT)) {
        switch (evt.getType()) {
            case KEY_UP:
                this.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        AlertDialog dialog = new AlertDialog.Builder(AndroidHarness.this) // .setIcon(R.drawable.alert_dialog_icon)
                                .setTitle(exitDialogTitle).setPositiveButton("Yes", AndroidHarness.this).setNegativeButton("No", AndroidHarness.this).setMessage(exitDialogMessage).create();
                        dialog.show();
                    }
                });

                break;
            default:
                break;
        }
    }

}
 
Example #13
Source File: AndroidHarness.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Gets called by the InputManager on all touch/drag/scale events
 */
@Override
public void onTouch(String name, TouchEvent evt, float tpf) {
    if (name.equals(ESCAPE_EVENT)) {
        switch (evt.getType()) {
            case KEY_UP:
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        AlertDialog dialog = new AlertDialog.Builder(AndroidHarness.this) // .setIcon(R.drawable.alert_dialog_icon)
                                .setTitle(exitDialogTitle).setPositiveButton("Yes", AndroidHarness.this).setNegativeButton("No", AndroidHarness.this).setMessage(exitDialogMessage).create();
                        dialog.show();
                    }
                });
                break;
            default:
                break;
        }
    }
}
 
Example #14
Source File: AndroidHarnessFragment.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Gets called by the InputManager on all touch/drag/scale events
 */
@Override
public void onTouch(String name, TouchEvent evt, float tpf) {
    if (name.equals(ESCAPE_EVENT)) {
        switch (evt.getType()) {
            case KEY_UP:
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                        builder.setTitle(exitDialogTitle);
                        builder.setPositiveButton("Yes", AndroidHarnessFragment.this);
                        builder.setNegativeButton("No", AndroidHarnessFragment.this);
                        builder.setMessage(exitDialogMessage);

                        AlertDialog dialog = builder.create();
                        dialog.show();
                    }
                });
                break;
            default:
                break;
        }
    }
}
 
Example #15
Source File: InputManager.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Dispatches touch events to touch listeners
 * @param evt The touch event to be dispatched to all onTouch listeners
 */
public void onTouchEventQueued(TouchEvent evt) { 
    ArrayList<Mapping> maps = bindings.get(TouchTrigger.touchHash(evt.getKeyCode()));
    if (maps == null) {
        return;
    }

    int size = maps.size();
    for (int i = size - 1; i >= 0; i--) {
        Mapping mapping = maps.get(i);
        ArrayList<InputListener> listeners = mapping.listeners;
        int listenerSize = listeners.size();
        for (int j = listenerSize - 1; j >= 0; j--) {
            InputListener listener = listeners.get(j);
            if (listener instanceof TouchListener) {
                ((TouchListener) listener).onTouch(mapping.name, evt, frameTPF); 
            }
        }
    }               
}
 
Example #16
Source File: GdxInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
    TouchEvent event = getNextFreeTouchEvent();
    event.set(TouchEvent.Type.UP, screenX, Gdx.graphics.getHeight() - screenY, 0, 0);
    event.setPointerId(pointer);
    event.setTime(System.nanoTime());
    processEvent(event);
    System.err.println("touchUp x = " + screenX + " y = " + screenY);
    return false;
}
 
Example #17
Source File: AndroidApplication.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Gets called by the InputManager on all touch/drag/scale events
 */    
@Override    
public void onTouch(String name, TouchEvent evt, float tpf)  
{
    switch(evt.getType())
    {
            
        case KEY_UP:
            activity.runOnUiThread(new Runnable() 
            {
                @Override
                public void run() 
                {                                                
                    AlertDialog dialog = new AlertDialog.Builder(activity)
                   // .setIcon(R.drawable.alert_dialog_icon)
                    .setTitle("Do you want to exit?")
                    .setPositiveButton("Yes", AndroidApplication.this)
                    .setNegativeButton("No", AndroidApplication.this)
                    .setMessage("Use your home key to bring this app into the background or Exit to terminate it.")
                    .create();    
                    dialog.show();                
                }
            });
                    
                    
            break;
            
       default:
           break;
    }
                    
}
 
Example #18
Source File: GdxInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean zoom(float initialDistance, float distance) {
    System.err.println("zoom "+initialDistance+" "+distance);
    TouchEvent event = getNextFreeTouchEvent();
    event.set(TouchEvent.Type.SCALE_MOVE, initialDistance, distance, 0, 0);
    event.setPointerId(0);
    event.setTime(System.nanoTime());
    processEvent(event);
    return false;
}
 
Example #19
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void processEvent(TouchEvent event) 
{
	synchronized (eventQueue) 
	{
	    eventQueue.push(event);
	}
}
 
Example #20
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void onLongPress(MotionEvent event)
{        
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.LONGPRESSED, event.getX(), this.getHeight() - event.getY(), 0f, 0f);
    touch.setPointerId(0);
    touch.setTime(event.getEventTime());
    processEvent(touch);
}
 
Example #21
Source File: TouchAppState.java    From Lemur with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onTouchEvent(TouchEvent te) {
    if (!isEnabled()) {
        return;
    }
    PointerData pointerData;
    switch (te.getType()) {
        case DOWN:
            pointerData = getPointerData(
                    te.getPointerId(), (int)te.getX(), (int)te.getY());
            if (dispatchButton(pointerData, true)) {
                te.setConsumed();
            }
            break;
        case MOVE:
            pointerData = pointerDataMap.get(te.getPointerId());
            if (pointerData != null) {
                pointerData.lastX = (int)te.getX();
                pointerData.lastY = (int)te.getY();
            }
            break;
        case UP:
            pointerData = pointerDataMap.get(te.getPointerId());
            if (pointerData != null) {
                pointerData.lastX = (int)te.getX();
                pointerData.lastY = (int)te.getY();
                if (dispatchButton(pointerData, false)) {
                    te.setConsumed();
                }
                pointerDataMap.remove(te.getPointerId());
            }
            break;
        default:
            break;
    }
}
 
Example #22
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean onFling(MotionEvent event, MotionEvent event2, float vx, float vy)
{
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.FLING, event.getX(), this.getHeight() - event.getY(), vx, vy);
    touch.setPointerId(0);
    touch.setTime(event.getEventTime());
    processEvent(touch);
    
    return true;
}
 
Example #23
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean onSingleTapConfirmed(MotionEvent event)
{        
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.TAP, event.getX(), this.getHeight() - event.getY(), 0f, 0f);
    touch.setPointerId(0);
    touch.setTime(event.getEventTime());
    processEvent(touch);
    
    return true;
}
 
Example #24
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean onDoubleTap(MotionEvent event)
{
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.DOUBLETAP, event.getX(), this.getHeight() - event.getY(), 0f, 0f);
    touch.setPointerId(0);
    touch.setTime(event.getEventTime());
    processEvent(touch);        
    return true;
}
 
Example #25
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector)
{     
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.SCALE_START, scaleGestureDetector.getFocusX(), scaleGestureDetector.getFocusY(), 0f, 0f);
    touch.setPointerId(0);
    touch.setTime(scaleGestureDetector.getEventTime());
    touch.setScaleSpan(scaleGestureDetector.getCurrentSpan()); 
    touch.setScaleFactor(scaleGestureDetector.getScaleFactor());
    processEvent(touch); 
    
    return true;
}
 
Example #26
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean onScale(ScaleGestureDetector scaleGestureDetector)
{        
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.SCALE_MOVE, scaleGestureDetector.getFocusX(), this.getHeight() - scaleGestureDetector.getFocusY(), 0f, 0f);
    touch.setPointerId(0);
    touch.setTime(scaleGestureDetector.getEventTime());
    touch.setScaleSpan(scaleGestureDetector.getCurrentSpan()); 
    touch.setScaleFactor(scaleGestureDetector.getScaleFactor());
    processEvent(touch); 
         
    return false;
}
 
Example #27
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void onScaleEnd(ScaleGestureDetector scaleGestureDetector)
{        
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.SCALE_END, scaleGestureDetector.getFocusX(), this.getHeight() - scaleGestureDetector.getFocusY(), 0f, 0f);
    touch.setPointerId(0);
    touch.setTime(scaleGestureDetector.getEventTime());
    touch.setScaleSpan(scaleGestureDetector.getCurrentSpan()); 
    touch.setScaleFactor(scaleGestureDetector.getScaleFactor());
    processEvent(touch);      
}
 
Example #28
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) 
{
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.SCROLL, e1.getX(), this.getHeight() - e1.getY(), distanceX, distanceY*(-1));
    touch.setPointerId(0);
    touch.setTime(e1.getEventTime());
    processEvent(touch);
    return false;
}
 
Example #29
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void onShowPress(MotionEvent event) 
{
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.SHOWPRESS, event.getX(), this.getHeight() - event.getY(), 0f, 0f);
    touch.setPointerId(0);
    touch.setTime(event.getEventTime());
    processEvent(touch);
}
 
Example #30
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean onSingleTapUp(MotionEvent event) 
{       
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.TAP, event.getX(), this.getHeight() - event.getY(), 0f, 0f);
    touch.setPointerId(0);
    touch.setTime(event.getEventTime());
    processEvent(touch);
    return true;
}