Commit 2d1843f9 authored by Alexander Krause's avatar Alexander Krause

fixed unintentional rotation activation

parent b043fe24
......@@ -28,6 +28,7 @@ namespace ExplorVizGestureControl.Gestures
private const int MOUSEEVENTF_WHEEL = 0x0800;
private GestureTimer scrollTimer;
private GestureTimer rotationActivationTimer;
private GestureTimer selectionTimer;
internal static GestureTimer delayTimer;
......@@ -37,6 +38,7 @@ namespace ExplorVizGestureControl.Gestures
private Dictionary<string, double> dynamicValues = new Dictionary<string, double>();
private float rightHandAnchorLength;
private float leftHandAnchorLength;
private float leftHandAnchorY;
private int selectionStatus = 0;
......@@ -58,6 +60,7 @@ namespace ExplorVizGestureControl.Gestures
scrollTimer = new GestureTimer(dynamicValues["zoomVelocity"]);
delayTimer = new GestureTimer(2000);
selectionTimer = new GestureTimer(500);
rotationActivationTimer = new GestureTimer(500);
}
#endregion
......@@ -92,40 +95,71 @@ namespace ExplorVizGestureControl.Gestures
if (key.Equals("zoomVelocity")) scrollTimer.changeTimerCycle(value);
}
private bool anchorSet = false;
private void HandleRotation()
{
if (gripActive || zoomingActive) return;
if (GestureDatabase.LeftHandClosed())
{
if (!rotationActivationTimer.busy && !anchorSet)
{
rotationActivationTimer.startTimer();
}
if (!rotationActive)
if (!anchorSet)
{
if (GestureDatabase.HandsAboveSpineBase("left"))
{
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
leftHandAnchorY = Math.Abs(GestureDatabase.Joints[(int)JointType.HandLeft].Y);
leftHandAnchorLength = GestureDatabase.CalculateVectorLength(GestureDatabase.Joints[(int)JointType.HandLeft]);
anchorSet = true;
}
else return;
}
float vLength = GestureDatabase.CalculateVectorLength(GestureDatabase.Joints[(int)JointType.HandLeft]);
// Check for intentional / non-intentional rotation
if (!rotationActivationTimer.busy && !rotationActive)
{
if (Math.Abs(leftHandAnchorLength - vLength) < 0.015f)
{
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
rotationActive = true;
}
else { return; }
else
{
anchorSet = false;
return;
}
}
float distanceXHands = GestureDatabase.Joints[(int)JointType.HandLeft].X - GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].X;
float distanceYHands = GestureDatabase.Joints[(int)JointType.HandLeft].Y - GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].Y;
if (rotationActive)
{
float distanceXHands = GestureDatabase.Joints[(int)JointType.HandLeft].X - GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].X;
float distanceYHands = GestureDatabase.Joints[(int)JointType.HandLeft].Y - GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].Y;
int yDetection = 0;
float currentlyHandLeftY = Math.Abs(GestureDatabase.Joints[(int)JointType.HandLeft].Y);
int yDetection = 0;
float currentlyHandLeftY = Math.Abs(GestureDatabase.Joints[(int)JointType.HandLeft].Y);
if (Math.Abs(currentlyHandLeftY - leftHandAnchorY) > (float)dynamicValues["rotationYActivation"]) yDetection = (int)dynamicValues["rotationVelocityY"];
if (Math.Abs(currentlyHandLeftY - leftHandAnchorY) > (float)dynamicValues["rotationYActivation"]) yDetection = (int)dynamicValues["rotationVelocityY"];
int moveX = (int)(distanceXHands * dynamicValues["rotationVelocityX"]);
int moveY = (int)(distanceYHands * yDetection);
int moveX = (int)(distanceXHands * dynamicValues["rotationVelocityX"]);
int moveY = (int)(distanceYHands * yDetection);
Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y) + new Size(moveX, -moveY);
Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y) + new Size(moveX, -moveY);
}
else return;
}
else if (rotationActive)
{
{
rotationActivationTimer.startTimer();
rotationActive = false;
anchorSet = false;
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
}
}
......@@ -220,7 +254,7 @@ namespace ExplorVizGestureControl.Gestures
Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y) + new Size(moveX, -moveY);
}
else if (gripActive)
{
{
selectionStatus = 0;
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
gripActive = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment