[Commits] SDL: Added a hint SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS ...

libsdl.org revision control commits-owner at libsdl.org
Wed Jan 17 17:15:25 PST 2018


details:   https://hg.libsdl.org/SDL/rev/c3446901fc1c
changeset: 11831:c3446901fc1c
user:      Sam Lantinga <slouken at libsdl.org>
date:      Wed Jan 17 17:24:15 2018 -0800
description:
Added a hint SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS to prevent turning Apple TV remote swipes into arrow key events

diffstat:

 include/SDL_hints.h             |  10 ++++++++++
 src/video/uikit/SDL_uikitview.m |  29 ++++++++++++++++-------------
 2 files changed, 26 insertions(+), 13 deletions(-)

diffs (70 lines):

diff -r a01af1a724b3 -r c3446901fc1c include/SDL_hints.h
--- a/include/SDL_hints.h	Tue Jan 16 21:29:32 2018 +0100
+++ b/include/SDL_hints.h	Wed Jan 17 17:24:15 2018 -0800
@@ -356,6 +356,16 @@
 #define SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION"
 
 /**
+ * \brief  A variable controlling whether the Apple TV remote swipes are
+ *         translated into arrow key events
+ *
+ *  This variable can be set to the following values:
+ *    "0"       - Swipes are not translated into arrow key events
+ *    "1"       - Swipes are translated into arrow key events (the default)
+ */
+#define SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS "SDL_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS"
+
+/**
  *  \brief  A variable controlling whether the Android / iOS built-in
  *  accelerometer should be listed as a joystick device, rather than listing
  *  actual joysticks only.
diff -r a01af1a724b3 -r c3446901fc1c src/video/uikit/SDL_uikitview.m
--- a/src/video/uikit/SDL_uikitview.m	Tue Jan 16 21:29:32 2018 +0100
+++ b/src/video/uikit/SDL_uikitview.m	Wed Jan 17 17:24:15 2018 -0800
@@ -24,6 +24,7 @@
 
 #include "SDL_uikitview.h"
 
+#include "SDL_hints.h"
 #include "../../events/SDL_mouse_c.h"
 #include "../../events/SDL_touch_c.h"
 #include "../../events/SDL_events_c.h"
@@ -42,23 +43,25 @@
 - (instancetype)initWithFrame:(CGRect)frame
 {
     if ((self = [super initWithFrame:frame])) {
-        /* Apple TV Remote touchpad swipe gestures. */
 #if TARGET_OS_TV
-        UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
-        swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
-        [self addGestureRecognizer:swipeUp];
+        if (SDL_GetHintBoolean(SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS, SDL_TRUE)) {
+            /* Apple TV Remote touchpad swipe gestures. */
+            UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
+            swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
+            [self addGestureRecognizer:swipeUp];
 
-        UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
-        swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
-        [self addGestureRecognizer:swipeDown];
+            UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
+            swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
+            [self addGestureRecognizer:swipeDown];
 
-        UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
-        swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
-        [self addGestureRecognizer:swipeLeft];
+            UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
+            swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
+            [self addGestureRecognizer:swipeLeft];
 
-        UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
-        swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
-        [self addGestureRecognizer:swipeRight];
+            UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
+            swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
+            [self addGestureRecognizer:swipeRight];
+        }
 #endif
 
         self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;


More information about the commits mailing list