Improved gestures system

This commit is contained in:
raysan5 2016-04-17 11:36:40 +02:00
parent 2e5d898443
commit 17eefed08f
5 changed files with 12 additions and 14 deletions

View File

@ -43,12 +43,11 @@ int main()
// Update
//----------------------------------------------------------------------------------
lastGesture = currentGesture;
currentGesture = GetGestureDetected();
touchPosition = GetTouchPosition(0);
if (CheckCollisionPointRec(touchPosition, touchArea) && IsGestureDetected())
if (CheckCollisionPointRec(touchPosition, touchArea) && (currentGesture != GESTURE_NONE))
{
currentGesture = GetGestureType();
if (currentGesture != lastGesture)
{
// Store gesture string
@ -78,7 +77,6 @@ int main()
}
}
}
else currentGesture = GESTURE_NONE;
//----------------------------------------------------------------------------------
// Draw

View File

@ -1193,7 +1193,7 @@ bool IsMouseButtonPressed(int button)
bool pressed = false;
#if defined(PLATFORM_ANDROID)
if (IsGestureDetected() && (GetGestureType() == GESTURE_TAP)) pressed = true;
if (IsGestureDetected(GESTURE_TAP)) pressed = true;
#else
if ((currentMouseState[button] != previousMouseState[button]) && (currentMouseState[button] == 1)) pressed = true;
#endif
@ -1207,7 +1207,7 @@ bool IsMouseButtonDown(int button)
bool down = false;
#if defined(PLATFORM_ANDROID)
if (IsGestureDetected() && (GetGestureType() == GESTURE_HOLD)) down = true;
if (IsGestureDetected(GESTURE_HOLD)) down = true;
#else
if (GetMouseButtonStatus(button) == 1) down = true;
#endif

View File

@ -292,14 +292,14 @@ void UpdateGestures(void)
}
// Check if a gesture have been detected
bool IsGestureDetected(void)
bool IsGestureDetected(int gesture)
{
if ((enabledGestures & currentGesture) != GESTURE_NONE) return true;
if ((enabledGestures & currentGesture) == gesture) return true;
else return false;
}
// Check gesture type
int GetGestureType(void)
int GetGestureDetected(void)
{
// Get current gesture only if enabled
return (enabledGestures & currentGesture);

View File

@ -92,8 +92,8 @@ extern "C" { // Prevents name mangling of functions
//----------------------------------------------------------------------------------
void ProcessGestureEvent(GestureEvent event); // Process gesture event and translate it into gestures
void UpdateGestures(void); // Update gestures detected (must be called every frame)
bool IsGestureDetected(void); // Check if a gesture have been detected
int GetGestureType(void); // Get latest detected gesture
bool IsGestureDetected(int gesture); // Check if a gesture have been detected
int GetGestureDetected(void); // Get latest detected gesture
void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags
int GetTouchPointsCount(void); // Get touch points count

View File

@ -647,8 +647,8 @@ bool IsButtonReleased(int button); // Detect if an android
//------------------------------------------------------------------------------------
void ProcessGestureEvent(GestureEvent event); // Process gesture event and translate it into gestures
void UpdateGestures(void); // Update gestures detected (called automatically in PollInputEvents())
bool IsGestureDetected(void); // Check if a gesture have been detected
int GetGestureType(void); // Get latest detected gesture
bool IsGestureDetected(int gesture); // Check if a gesture have been detected
int GetGestureDetected(void); // Get latest detected gesture
void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags
int GetTouchPointsCount(void); // Get touch points count