mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 12:43:19 +02:00
improvements to rotating gesture detection
This commit is contained in:
parent
dca0b05927
commit
fe1a6b8f29
4 changed files with 28 additions and 13 deletions
|
@ -20,7 +20,7 @@ function checkController() {
|
|||
var numberOfTriggers = Controller.getNumberOfTriggers();
|
||||
var numberOfSpatialControls = Controller.getNumberOfSpatialControls();
|
||||
var controllersPerTrigger = numberOfSpatialControls / numberOfTriggers;
|
||||
var triggerToggled=false;
|
||||
var triggerToggled = false;
|
||||
|
||||
// this is expected for hydras
|
||||
if (numberOfTriggers == 2 && controllersPerTrigger == 2) {
|
||||
|
|
|
@ -28,7 +28,6 @@ var PITCH_TOUCH_POINTS = 3;
|
|||
|
||||
function printTouchEvent(eventName, event) {
|
||||
print(eventName);
|
||||
|
||||
print(" event.x,y=" + event.x + ", " + event.y);
|
||||
print(" event.isPressed=" + event.isPressed);
|
||||
print(" event.isMoved=" + event.isMoved);
|
||||
|
|
|
@ -1327,8 +1327,9 @@ void Application::touchUpdateEvent(QTouchEvent* event) {
|
|||
void Application::touchBeginEvent(QTouchEvent* event) {
|
||||
TouchEvent thisEvent(*event); // on touch begin, we don't compare to last event
|
||||
_controllerScriptingInterface.emitTouchBeginEvent(thisEvent); // send events to any registered scripts
|
||||
|
||||
_lastTouchEvent = thisEvent; // and we reset our last event to this event before we call our update
|
||||
touchUpdateEvent(event);
|
||||
_lastTouchEvent = thisEvent;
|
||||
|
||||
// if one of our scripts have asked to capture this event, then stop processing it
|
||||
if (_controllerScriptingInterface.isTouchCaptured()) {
|
||||
|
|
|
@ -336,11 +336,19 @@ TouchEvent::TouchEvent() :
|
|||
{
|
||||
};
|
||||
|
||||
TouchEvent::TouchEvent(const QTouchEvent& event) {
|
||||
TouchEvent::TouchEvent(const QTouchEvent& event) :
|
||||
// these values are not set by initWithQTouchEvent() because they only apply to comparing to other events
|
||||
isPinching(false),
|
||||
isPinchOpening(false),
|
||||
deltaAngle(0.0f),
|
||||
isRotating(false),
|
||||
rotating("none")
|
||||
{
|
||||
initWithQTouchEvent(event);
|
||||
}
|
||||
|
||||
TouchEvent::TouchEvent(const QTouchEvent& event, const TouchEvent& other) {
|
||||
TouchEvent::TouchEvent(const QTouchEvent& event, const TouchEvent& other)
|
||||
{
|
||||
initWithQTouchEvent(event);
|
||||
calculateMetaAttributes(other);
|
||||
}
|
||||
|
@ -430,16 +438,23 @@ void TouchEvent::calculateMetaAttributes(const TouchEvent& other) {
|
|||
isPinching = other.isPinching;
|
||||
isPinchOpening = other.isPinchOpening;
|
||||
}
|
||||
|
||||
|
||||
// determine if the points are rotating...
|
||||
deltaAngle = angle - other.angle;
|
||||
if (other.angle < angle) {
|
||||
isRotating = true;
|
||||
rotating = "clockwise";
|
||||
} else if (other.angle > angle) {
|
||||
isRotating = true;
|
||||
rotating = "counterClockwise";
|
||||
// note: if the number of touch points change between events, then we don't consider ourselves to be rotating
|
||||
if (touchPoints == other.touchPoints) {
|
||||
deltaAngle = angle - other.angle;
|
||||
if (other.angle < angle) {
|
||||
isRotating = true;
|
||||
rotating = "clockwise";
|
||||
} else if (other.angle > angle) {
|
||||
isRotating = true;
|
||||
rotating = "counterClockwise";
|
||||
} else {
|
||||
isRotating = false;
|
||||
rotating = "none";
|
||||
}
|
||||
} else {
|
||||
deltaAngle = 0.0f;
|
||||
isRotating = false;
|
||||
rotating = "none";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue