Added a hint SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS to prevent turning Apple TV remote swipes into arrow key events
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index 1b55f8e..e9a0e7c 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -356,6 +356,16 @@ extern "C" {
#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 --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m
index 63bef0c..e5dc99a 100644
--- a/src/video/uikit/SDL_uikitview.m
+++ b/src/video/uikit/SDL_uikitview.m
@@ -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];
-
- 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 *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
- swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
- [self addGestureRecognizer:swipeRight];
+ 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 *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];
+ }
#endif
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;