diff options
author | Memphiz <memphis@machzwo.de> | 2012-05-02 12:48:11 -0700 |
---|---|---|
committer | Memphiz <memphis@machzwo.de> | 2012-05-02 12:48:11 -0700 |
commit | aa048db6778b793a0ebeee45bec89afb416cd98c (patch) | |
tree | f4960c85e238865abbda65ae464db11ea0beda45 | |
parent | c8f3706f03e91ff2d641235cdb7faa0a6c56f27e (diff) | |
parent | 8c6b0dc75c33d4807cd20aa863a6972b691314e2 (diff) |
Merge pull request #867 from Memphiz/gesture
Some gesture modifications for iOS
-rw-r--r-- | language/English/strings.xml | 2 | ||||
-rw-r--r-- | language/German/strings.xml | 2 | ||||
-rw-r--r-- | xbmc/osx/IOSExternalTouchController.mm | 20 | ||||
-rw-r--r-- | xbmc/osx/ios/XBMCController.mm | 122 |
4 files changed, 112 insertions, 34 deletions
diff --git a/language/English/strings.xml b/language/English/strings.xml index 41f49ec9fd..cc3d9d7117 100644 --- a/language/English/strings.xml +++ b/language/English/strings.xml @@ -2380,7 +2380,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> diff --git a/language/German/strings.xml b/language/German/strings.xml index 1647991093..e23fa5fdd3 100644 --- a/language/German/strings.xml +++ b/language/German/strings.xml @@ -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> diff --git a/xbmc/osx/IOSExternalTouchController.mm b/xbmc/osx/IOSExternalTouchController.mm index 4b6972504d..8f18a4f3c9 100644 --- a/xbmc/osx/IOSExternalTouchController.mm +++ b/xbmc/osx/IOSExternalTouchController.mm @@ -204,6 +204,15 @@ const CGFloat timeFadeSecs = 2.0; [[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 @@ const CGFloat timeFadeSecs = 2.0; } } //-------------------------------------------------------------- +- (IBAction)handleSingleFingerSingleLongTap:(UIGestureRecognizer *)sender +{ + if([self wakeUpFromSleep]) + { + if (sender.state == UIGestureRecognizerStateEnded) + { + [self handleDoubleFingerSingleTap:sender]; + } + } +} +//-------------------------------------------------------------- - (IBAction)handleSingleFingerSingleTap:(UIGestureRecognizer *)sender { if([self wakeUpFromSleep]) diff --git a/xbmc/osx/ios/XBMCController.mm b/xbmc/osx/ios/XBMCController.mm index 7a393e27eb..b5efc74a07 100644 --- a/xbmc/osx/ios/XBMCController.mm +++ b/xbmc/osx/ios/XBMCController.mm @@ -157,6 +157,15 @@ IOSEAGLView *m_glView; 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 @@ IOSEAGLView *m_glView; //-------------------------------------------------------------- - (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 @@ IOSEAGLView *m_glView; 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 @@ IOSEAGLView *m_glView; //-------------------------------------------------------------- - (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)); + } } } //-------------------------------------------------------------- |