use of com.jme3.input.event.InputEvent in project jmonkeyengine by jMonkeyEngine.
the class IosTouchHandler method generateMouseEvent.
// TODO: Ring Buffer for mouse events?
protected InputEvent generateMouseEvent(TouchEvent event) {
InputEvent inputEvent = null;
int newX;
int newY;
int newDX;
int newDY;
if (iosInput.isMouseEventsInvertX()) {
newX = (int) (iosInput.invertX(event.getX()));
newDX = (int) event.getDeltaX() * -1;
} else {
newX = (int) event.getX();
newDX = (int) event.getDeltaX();
}
if (iosInput.isMouseEventsInvertY()) {
newY = (int) (iosInput.invertY(event.getY()));
newDY = (int) event.getDeltaY() * -1;
} else {
newY = (int) event.getY();
newDY = (int) event.getDeltaY();
}
switch(event.getType()) {
case DOWN:
// Handle mouse down event
inputEvent = new MouseButtonEvent(0, true, newX, newY);
inputEvent.setTime(event.getTime());
break;
case UP:
// Handle mouse up event
inputEvent = new MouseButtonEvent(0, false, newX, newY);
inputEvent.setTime(event.getTime());
break;
case HOVER_MOVE:
case MOVE:
inputEvent = new MouseMotionEvent(newX, newY, newDX, newDY, (int) event.getScaleSpan(), (int) event.getDeltaScaleSpan());
inputEvent.setTime(event.getTime());
break;
}
return inputEvent;
}
use of com.jme3.input.event.InputEvent in project jmonkeyengine by jMonkeyEngine.
the class AndroidTouchInput method generateMouseEvent.
// TODO: Ring Buffer for mouse events?
public InputEvent generateMouseEvent(TouchEvent event) {
InputEvent inputEvent = null;
int newX;
int newY;
int newDX;
int newDY;
// MouseEvents do not support multi-touch, so only evaluate 1 finger pointer events
if (!isSimulateMouse() || numPointers > 1) {
return null;
}
if (isMouseEventsInvertX()) {
newX = (int) (invertX(event.getX()));
newDX = (int) event.getDeltaX() * -1;
} else {
newX = (int) event.getX();
newDX = (int) event.getDeltaX();
}
if (isMouseEventsInvertY()) {
newY = (int) (invertY(event.getY()));
newDY = (int) event.getDeltaY() * -1;
} else {
newY = (int) event.getY();
newDY = (int) event.getDeltaY();
}
switch(event.getType()) {
case DOWN:
// Handle mouse down event
inputEvent = new MouseButtonEvent(0, true, newX, newY);
inputEvent.setTime(event.getTime());
break;
case UP:
// Handle mouse up event
inputEvent = new MouseButtonEvent(0, false, newX, newY);
inputEvent.setTime(event.getTime());
break;
case HOVER_MOVE:
case MOVE:
inputEvent = new MouseMotionEvent(newX, newY, newDX, newDY, (int) event.getScaleSpan(), (int) event.getDeltaScaleSpan());
inputEvent.setTime(event.getTime());
break;
}
return inputEvent;
}
Aggregations