summaryrefslogtreecommitdiffhomepage
path: root/src/gestures.c
diff options
context:
space:
mode:
authorRay <[email protected]>2015-07-28 17:38:37 +0200
committerRay <[email protected]>2015-07-28 17:38:37 +0200
commit8b3a82688e82922819d24494c08e24570c03bdc4 (patch)
tree1df1379dfc4948477b664023d2ce0100d83d1783 /src/gestures.c
parenta59433e7a3b22d5ded7505689fb44f1927194077 (diff)
parent067b884f395b7b6d4c179cb3d58b0d17a02950ec (diff)
downloadraylib-8b3a82688e82922819d24494c08e24570c03bdc4.tar.gz
raylib-8b3a82688e82922819d24494c08e24570c03bdc4.zip
Merge pull request #24 from raysan5/develop
Integrate Develop branch
Diffstat (limited to 'src/gestures.c')
-rw-r--r--src/gestures.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/gestures.c b/src/gestures.c
index 13209b32..ad8ac9f6 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -24,7 +24,6 @@
**********************************************************************************************/
#include "raylib.h"
-#include "raymath.h"
#include "utils.h"
#include <stdlib.h> // malloc(), free()
@@ -126,16 +125,17 @@ static float pinchDelta = 0;
// Detected gesture
static int currentGesture = GESTURE_NONE;
+unsigned int enabledGestures = 0; // TODO: Currently not in use...
static Vector2 touchPosition;
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
//----------------------------------------------------------------------------------
-extern void ProcessMotionEvent(GestureEvent event);
extern void ResetGestures(void);
extern Vector2 GetRawPosition(void);
+static void ProcessMotionEvent(GestureEvent event);
static float CalculateAngle(Vector2 initialPosition, Vector2 actualPosition, float magnitude);
static float OnPinch();
static void SetDualInput(GestureEvent event);
@@ -185,40 +185,45 @@ int GetGestureType(void)
return currentGesture;
}
+void SetGesturesEnabled(unsigned int gestureFlags)
+{
+ enabledGestures = gestureFlags;
+}
+
// Get drag intensity (pixels per frame)
-float GetDragIntensity(void)
+float GetGestureDragIntensity(void)
{
return intensity;
}
// Get drag angle
// NOTE: Angle in degrees, horizontal-right is 0, counterclock-wise
-float GetDragAngle(void)
+float GetGestureDragAngle(void)
{
return angle;
}
// Get drag vector (between initial and final position)
-Vector2 GetDragVector(void)
+Vector2 GetGestureDragVector(void)
{
return dragVector;
}
// Hold time measured in frames
-int GetHoldDuration(void)
+int GetGestureHoldDuration(void)
{
return 0;
}
// Get magnitude between two pinch points
-float GetPinchDelta(void)
+float GetGesturePinchDelta(void)
{
return pinchDelta;
}
-// Get angle beween two pinch points
+// Get angle beween two pinch points
// NOTE: Angle in degrees, horizontal-right is 0, counterclock-wise
-float GetPinchAngle(void)
+float GetGesturePinchAngle(void)
{
return 0;
}
@@ -260,7 +265,7 @@ extern void InitAndroidGestures(struct android_app *app)
//----------------------------------------------------------------------------------
// Module specific Functions Definition
//----------------------------------------------------------------------------------
-extern void ProcessMotionEvent(GestureEvent event)
+static void ProcessMotionEvent(GestureEvent event)
{
// Resets
dragVector = (Vector2){ 0, 0 };
@@ -354,7 +359,7 @@ extern void ProcessMotionEvent(GestureEvent event)
{
lastDragPosition = endDragPosition;
- endDragPosition = GetRawPosition();
+ endDragPosition = touchPosition;
//endDragPosition.x = AMotionEvent_getX(event, 0);
//endDragPosition.y = AMotionEvent_getY(event, 0);
@@ -417,7 +422,6 @@ extern void ProcessMotionEvent(GestureEvent event)
//--------------------------------------------------------------------
}
-
static float CalculateAngle(Vector2 initialPosition, Vector2 actualPosition, float magnitude)
{
float angle;
@@ -564,6 +568,18 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
{
//int32_t key = AKeyEvent_getKeyCode(event);
//int32_t AKeyEvent_getMetaState(event);
+
+ int32_t code = AKeyEvent_getKeyCode((const AInputEvent *)event);
+
+ // If we are in active mode, we eat the back button and move into pause mode.
+ // If we are already in pause mode, we allow the back button to be handled by the OS, which means we'll be shut down.
+ /*
+ if ((code == AKEYCODE_BACK) && mActiveMode)
+ {
+ setActiveMode(false);
+ return 1;
+ }
+ */
}
int32_t action = AMotionEvent_getAction(event);
@@ -585,7 +601,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
ProcessMotionEvent(gestureEvent);
- return 0;
+ return 0; // return 1;
}
#endif