Some gesture modifications for iOS #867

Merged
merged 5 commits into from May 2, 2012
@@ -2379,7 +2379,7 @@
<string id="34405">1 finger swipe left,right,up,down for cursors</string>
<string id="34406">2 finger swipe left for backspace</string>
<string id="34407">1 finger single tap for enter</string>
- <string id="34408">2 finger single tap for contextmenu</string>
+ <string id="34408">2 finger single tap or 1 finger long press for contextmenu</string>
<string id="35000">Peripherals</string>
@@ -2373,7 +2373,7 @@
<string id="34404">Benutze folgende Gesten zur Navigation:</string>
<string id="34405">1 Finger: links,rechts,hoch,runter wischen (cursor Tasten)</string>
<string id="34406">2 Finger: links wischen für Backspace</string>
- <string id="34407">1 Finger: tippen für Enter</string>
+ <string id="34407">1 Finger: tippen für Enter (oder lange für Context Menü)</string>
<string id="34408">2 Finger: tippen für Context Menü</string>
@@ -204,6 +204,15 @@ - (void)createGestureRecognizers
[[self view] addGestureRecognizer:doubleFingerSingleTap];
[doubleFingerSingleTap release];
+ //1 finger single long tab - right mouse - alernative
+ UITapGestureRecognizer *singleFingerSingleLongTap = [[UILongPressGestureRecognizer alloc]
+ initWithTarget:self action:@selector(handleSingleFingerSingleLongTap:)];
+ singleFingerSingleLongTap.delaysTouchesBegan = YES;
+ singleFingerSingleLongTap.delaysTouchesEnded = YES;
+ singleFingerSingleLongTap.numberOfTouchesRequired = 1;
+ [self.view addGestureRecognizer:singleFingerSingleLongTap];
+ [singleFingerSingleLongTap release];
+
//1 finger single tab - left mouse
UITapGestureRecognizer *singleFingerSingleTap = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSingleFingerSingleTap:)];
@@ -301,6 +310,17 @@ - (IBAction)handleDoubleFingerSingleTap:(UIGestureRecognizer *)sender
}
}
//--------------------------------------------------------------
+- (IBAction)handleSingleFingerSingleLongTap:(UIGestureRecognizer *)sender
+{
+ if([self wakeUpFromSleep])
+ {
+ if (sender.state == UIGestureRecognizerStateEnded)
+ {
+ [self handleDoubleFingerSingleTap:sender];
+ }
+ }
+}
+//--------------------------------------------------------------
- (IBAction)handleSingleFingerSingleTap:(UIGestureRecognizer *)sender
{
if([self wakeUpFromSleep])
@@ -157,6 +157,15 @@ - (void)createGestureRecognizers
doubleFingerSingleTap.numberOfTouchesRequired = 2;
[self.view addGestureRecognizer:doubleFingerSingleTap];
[doubleFingerSingleTap release];
+
+ //1 finger single long tab - right mouse - alernative
+ UITapGestureRecognizer *singleFingerSingleLongTap = [[UILongPressGestureRecognizer alloc]
+ initWithTarget:self action:@selector(handleSingleFingerSingleLongTap:)];
+ singleFingerSingleLongTap.delaysTouchesBegan = YES;
+ singleFingerSingleLongTap.delaysTouchesEnded = YES;
+ [self.view addGestureRecognizer:singleFingerSingleLongTap];
+ [singleFingerSingleLongTap release];
+
//double finger swipe left for backspace ... i like this fast backspace feature ;)
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc]
@@ -268,33 +277,75 @@ - (IBAction)handlePan:(UIPanGestureRecognizer *)sender
//--------------------------------------------------------------
- (IBAction)handleSwipeLeft:(UISwipeGestureRecognizer *)sender
{
- [self sendKey:XBMCK_BACKSPACE];
+ if( [m_glView isXBMCAlive] )//NO GESTURES BEFORE WE ARE UP AND RUNNING
+ {
+ [self sendKey:XBMCK_BACKSPACE];
+ }
}
//--------------------------------------------------------------
- (IBAction)handleDoubleFingerSingleTap:(UIGestureRecognizer *)sender
{
- CGPoint point = [sender locationOfTouch:0 inView:m_glView];
+ if( [m_glView isXBMCAlive] )//NO GESTURES BEFORE WE ARE UP AND RUNNING
+ {
+ CGPoint point = [sender locationOfTouch:0 inView:m_glView];
+ point.x *= screenScale;
+ point.y *= screenScale;
+ //NSLog(@"%s toubleTap", __PRETTY_FUNCTION__);
+
+ XBMC_Event newEvent;
+ memset(&newEvent, 0, sizeof(newEvent));
+
+ newEvent.type = XBMC_MOUSEBUTTONDOWN;
+ newEvent.button.type = XBMC_MOUSEBUTTONDOWN;
+ newEvent.button.button = XBMC_BUTTON_RIGHT;
+ newEvent.button.x = point.x;
+ newEvent.button.y = point.y;
+
+ CWinEventsIOS::MessagePush(&newEvent);
+
+ newEvent.type = XBMC_MOUSEBUTTONUP;
+ newEvent.button.type = XBMC_MOUSEBUTTONUP;
+ CWinEventsIOS::MessagePush(&newEvent);
+
+ memset(&lastEvent, 0x0, sizeof(XBMC_Event));
+ }
+}
+//--------------------------------------------------------------
+- (void)postMouseMotionEvent:(CGPoint)point
+{
+ XBMC_Event newEvent;
+
point.x *= screenScale;
point.y *= screenScale;
- //NSLog(@"%s toubleTap", __PRETTY_FUNCTION__);
-
- XBMC_Event newEvent;
+
memset(&newEvent, 0, sizeof(newEvent));
-
- newEvent.type = XBMC_MOUSEBUTTONDOWN;
- newEvent.button.type = XBMC_MOUSEBUTTONDOWN;
- newEvent.button.button = XBMC_BUTTON_RIGHT;
- newEvent.button.x = point.x;
- newEvent.button.y = point.y;
-
- CWinEventsIOS::MessagePush(&newEvent);
-
- newEvent.type = XBMC_MOUSEBUTTONUP;
- newEvent.button.type = XBMC_MOUSEBUTTONUP;
- CWinEventsIOS::MessagePush(&newEvent);
-
- memset(&lastEvent, 0x0, sizeof(XBMC_Event));
-
+
+ newEvent.type = XBMC_MOUSEMOTION;
+ newEvent.motion.type = XBMC_MOUSEMOTION;
+ newEvent.motion.which = 0;
+ newEvent.motion.state = 0;
+ newEvent.motion.x = point.x;
+ newEvent.motion.y = point.y;
+ newEvent.motion.xrel = 0;
+ newEvent.motion.yrel = 0;
+ CWinEventsIOS::MessagePush(&newEvent);
+}
+//--------------------------------------------------------------
+- (IBAction)handleSingleFingerSingleLongTap:(UIGestureRecognizer *)sender
+{
+ if( [m_glView isXBMCAlive] )//NO GESTURES BEFORE WE ARE UP AND RUNNING
+ {
+ if (sender.state == UIGestureRecognizerStateBegan)
+ {
+ CGPoint point = [sender locationOfTouch:0 inView:m_glView];
+ [self postMouseMotionEvent:point];//selects the current control
+ }
+
+ if (sender.state == UIGestureRecognizerStateEnded)
+ {
+ [self handleDoubleFingerSingleTap:sender];
+ }
+ }
}
//--------------------------------------------------------------
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
@@ -306,6 +357,8 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
if( [touches count] == 1 && [touch tapCount] == 1)
{
lastGesturePoint = [touch locationInView:m_glView];
+ [self postMouseMotionEvent:lastGesturePoint];//selects the current control
+
lastGesturePoint.x *= screenScale;
lastGesturePoint.y *= screenScale;
XBMC_Event newEvent;
@@ -331,20 +384,25 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
//--------------------------------------------------------------
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
- UITouch *touch = [touches anyObject];
-
- if( [touches count] == 1 && [touch tapCount] == 1 )
+ if( [m_glView isXBMCAlive] )//NO GESTURES BEFORE WE ARE UP AND RUNNING
{
- XBMC_Event newEvent = lastEvent;
-
- newEvent.type = XBMC_MOUSEBUTTONUP;
- newEvent.button.type = XBMC_MOUSEBUTTONUP;
- newEvent.button.button = XBMC_BUTTON_LEFT;
- newEvent.button.x = lastGesturePoint.x;
- newEvent.button.y = lastGesturePoint.y;
- CWinEventsIOS::MessagePush(&newEvent);
+ UITouch *touch = [touches anyObject];
- memset(&lastEvent, 0x0, sizeof(XBMC_Event));
+ if( [touches count] == 1 && [touch tapCount] == 1 )
+ {
+ XBMC_Event newEvent = lastEvent;
+
+ newEvent.type = XBMC_MOUSEBUTTONUP;
+ newEvent.button.type = XBMC_MOUSEBUTTONUP;
+ newEvent.button.button = XBMC_BUTTON_LEFT;
+ newEvent.button.x = lastGesturePoint.x;
+ newEvent.button.y = lastGesturePoint.y;
+ CWinEventsIOS::MessagePush(&newEvent);
+
+ [self postMouseMotionEvent:CGPointMake(-1,-1)];//deselects control
+
+ memset(&lastEvent, 0x0, sizeof(XBMC_Event));
+ }
}
}
//--------------------------------------------------------------