Java Code Examples for com.jme3.input.event.TouchEvent#set()
The following examples show how to use
com.jme3.input.event.TouchEvent#set() .
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 |
@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: AndroidGestureProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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 3
Source File: AndroidGestureProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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 4
Source File: AndroidGestureProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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 5
Source File: AndroidInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@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 6
Source File: AndroidInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@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 7
Source File: AndroidInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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; }
Example 8
Source File: AndroidInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 9
Source File: AndroidInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 10
Source File: AndroidInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 11
Source File: AndroidInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 12
Source File: GdxInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@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 13
Source File: GdxInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@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 14
Source File: IosTouchHandler.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void actionUp(int pointerId, long time, float x, float y) { float jmeX = iosInput.getJmeX(x); float jmeY = iosInput.invertY(iosInput.getJmeY(y)); TouchEvent touch = iosInput.getFreeTouchEvent(); touch.set(TouchEvent.Type.UP, 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.remove(pointerId); processEvent(touch); }
Example 15
Source File: AndroidGestureProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onShowPress(MotionEvent event) { // logger.log(Level.INFO, "onShowPress 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.SHOWPRESS, jmeX, jmeY, 0, 0); touchEvent.setPointerId(touchInput.getPointerId(event)); touchEvent.setTime(event.getEventTime()); touchEvent.setPressure(event.getPressure()); touchInput.addEvent(touchEvent); }
Example 16
Source File: AndroidGestureProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onScaleEnd(ScaleGestureDetector scaleGestureDetector) { // logger.log(Level.INFO, "onScaleEnd"); scaleStartX = gestureDownX; scaleStartY = gestureDownY; TouchEvent touchEvent = touchInput.getFreeTouchEvent(); touchEvent.set(TouchEvent.Type.SCALE_END, 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); }
Example 17
Source File: AndroidInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 18
Source File: AndroidInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 19
Source File: AndroidInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 20
Source File: AndroidGestureProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onLongPress(MotionEvent event) { // logger.log(Level.INFO, "onLongPress 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.LONGPRESSED, jmeX, jmeY, 0, 0); touchEvent.setPointerId(touchInput.getPointerId(event)); touchEvent.setTime(event.getEventTime()); touchEvent.setPressure(event.getPressure()); touchInput.addEvent(touchEvent); }