xbmc/xbmc — pull request #2135 by Montellese (2013-01-29 18:39:56+00:00)
Title: Generic & user-mappable touch input system

These commits change the way we handle touch input on Android and ideally also on other touch enabled platforms (with the help of other devs). Right now every touch enabled platform has its own touch input handling logic and maps whatever touch event to some platform specific action. This means that a lot of logic is duplicated and hardcoded.

This PR is meant to improve the touch input system with two changes:

1. The touch input system used by Android has been reworked into a generic implementation based on interfaces which can be implemented by any platform. There's a lower level (ITouchInputHandler) responsible for handling "raw" touch events (touch down/up/move/...) and interpreting those touch events to detect gestures etc. On platforms with builtin gesture recognition (like iOS) the lower level implementation would basically just forward whatever the builtin logic provides to the proper callbacks of the higher level. The higher level (ITouchActionHandler) can be platform specific but ideally doesn't have to be. It is responsible to translate touch actions like "single tap", "single long press", "rotate", "swipe left" etc into XBMC specific actions. There's a generic implementation for both levels but every platform can provide its own implementation or extension of either (or both) levels which offers maximum flexibility.
2. The touch actions translated into XBMC specific actions by the higher level are user-mappable through touchscreen.xml. Available tags right now are <tap>, <longpress>, <doubletap>, <doublelongpress>, <pan>, <swipe direction="left/right/up/down">, <zoom> and <rotate> and can be mapped to any existing xbmc action in the same way keyboard- or remote-mapping works.

As I only have an android phone with touch support I was only able to implement this for android but I hope that @Memphiz (or someone else) will look into adopting this for iOS and someone else into adopting this for Windows 7/8 touch. The interfaces of ITouchInputHandler might be a bit android-specific and I'm open to any suggestions to make it more generic. ITouchActionHandler is just a list of methods representing touch actions but obviously can also be extended if necessary.

Last but not least the generic implementation of ITouchInputHandler (CGenericTouchInputHandler) has been refactored to use implementations of the IGenericTouchGestureDetector interface to detect complex touch gestures like swipe, rotate and zoom. That cleans up CGenericTouchInputHandler a bit and should make it easier to add any other touch gestures.

As always I'm open for feedback on the idea, concept and the implementation. Furthermore I really hope that devs with touch devices running other platforms will look into this and see if it can be used to unify XBMC's touch input system. I'd be willing to do the work for Windows 7/8, WP8 and Ubuntu (or whatever linux OS has touch capable devices) if I could get my hands on a device.