Skip to content


Subversion checkout URL

You can clone with
Download ZIP


CHG: [touch] allow generic multi-touch swipes #2483

wants to merge 1 commit into from

2 participants


This allows generic multi-touch swipe detection (to match "Back" from "system/keymaps/touchscreen.xml").

Not sure it's foolproof, though...

@Montellese Montellese was assigned

This would require some extra logic that makes sure that all the swipe gestures are done in the same direction etc. But it might actually work with some small additional changes. I'll take a closer look.


Yeah, very crude and only works on Android because of the index/id confusion/relation exposed in #2482.
On another platform with random id's, this won't work

This one will probably be obsoleted by a gesture rework, but works for me on Android for the moment.


I looked at the code again and noticed two things:

  • Wouldn't it be better to count the number of touches in OnTouchDown() and OnTouchUp() instead of using "index + 1"?
  • I don't think the logic is 100% correct because OnTouchMove() will only be called for the pointer with index 0 so all the checks for the swipe direction etc will only be done for that pointer. The other pointer is completely ignored so you could touch down two fingers but only use one for swiping and the result would be the detection of a two-finger swipe. You could even do two swipes in opposite directions and it would still be recognised as a two-finger swipe in the direction of the primary pointer.

21cee17 works for me and also takes care of the two points I mentioned before i.e. with that code it's not possible to detect a two-finger swipe gesture if the two fingers/pointers move in different directions. Should I queue that one up as a PR and close this one?


Closing in favour of #2514.

@Montellese Montellese closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 22, 2013
  1. @koying
This page is out of date. Refresh to see the latest.
8 xbmc/input/touch/generic/GenericTouchSwipeDetector.cpp
@@ -33,7 +33,7 @@
CGenericTouchSwipeDetector::CGenericTouchSwipeDetector(ITouchActionHandler *handler, float dpi)
: IGenericTouchGestureDetector(handler, dpi),
m_directions(TouchMoveDirectionLeft | TouchMoveDirectionRight | TouchMoveDirectionUp | TouchMoveDirectionDown),
- m_swipeDetected(false)
+ m_swipeDetected(false), m_numtouches(0)
{ }
bool CGenericTouchSwipeDetector::OnTouchDown(unsigned int index, const Pointer &pointer)
@@ -43,12 +43,16 @@ bool CGenericTouchSwipeDetector::OnTouchDown(unsigned int index, const Pointer &
// only handle one-finger swipes
if (index > 0)
+ {
+ m_numtouches = index + 1;
return false;
+ }
// reset all values
m_done = false;
m_swipeDetected = false;
m_directions = TouchMoveDirectionLeft | TouchMoveDirectionRight | TouchMoveDirectionUp | TouchMoveDirectionDown;
+ m_numtouches = 1;
return true;
@@ -78,7 +82,7 @@ bool CGenericTouchSwipeDetector::OnTouchUp(unsigned int index, const Pointer &po
pointer.velocity(velocityX, velocityY, false);
// call the OnSwipe() callback
- OnSwipe((TouchMoveDirection)m_directions, pointer.down.x, pointer.down.y, pointer.current.x, pointer.current.y, velocityX, velocityY, 1);
+ OnSwipe((TouchMoveDirection)m_directions, pointer.down.x, pointer.down.y, pointer.current.x, pointer.current.y, velocityX, velocityY, m_numtouches);
return true;
4 xbmc/input/touch/generic/GenericTouchSwipeDetector.h
@@ -52,4 +52,8 @@ class CGenericTouchSwipeDetector : public IGenericTouchGestureDetector
* \brief Whether a swipe gesture has been detected or not
bool m_swipeDetected;
+ /*!
+ * \brief Number of touches
+ */
+ unsigned int m_numtouches;
Something went wrong with that request. Please try again.