Added a hint SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS to prevent turning Apple TV remote swipes into arrow key events
authorSam Lantinga <slouken@libsdl.org>
Wed, 17 Jan 2018 17:24:15 -0800
changeset 11831c3446901fc1c
parent 11830 a01af1a724b3
child 11832 a01e2b1aaaed
Added a hint SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS to prevent turning Apple TV remote swipes into arrow key events
include/SDL_hints.h
src/video/uikit/SDL_uikitview.m
     1.1 --- a/include/SDL_hints.h	Tue Jan 16 21:29:32 2018 +0100
     1.2 +++ b/include/SDL_hints.h	Wed Jan 17 17:24:15 2018 -0800
     1.3 @@ -356,6 +356,16 @@
     1.4  #define SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION"
     1.5  
     1.6  /**
     1.7 + * \brief  A variable controlling whether the Apple TV remote swipes are
     1.8 + *         translated into arrow key events
     1.9 + *
    1.10 + *  This variable can be set to the following values:
    1.11 + *    "0"       - Swipes are not translated into arrow key events
    1.12 + *    "1"       - Swipes are translated into arrow key events (the default)
    1.13 + */
    1.14 +#define SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS "SDL_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS"
    1.15 +
    1.16 +/**
    1.17   *  \brief  A variable controlling whether the Android / iOS built-in
    1.18   *  accelerometer should be listed as a joystick device, rather than listing
    1.19   *  actual joysticks only.
     2.1 --- a/src/video/uikit/SDL_uikitview.m	Tue Jan 16 21:29:32 2018 +0100
     2.2 +++ b/src/video/uikit/SDL_uikitview.m	Wed Jan 17 17:24:15 2018 -0800
     2.3 @@ -24,6 +24,7 @@
     2.4  
     2.5  #include "SDL_uikitview.h"
     2.6  
     2.7 +#include "SDL_hints.h"
     2.8  #include "../../events/SDL_mouse_c.h"
     2.9  #include "../../events/SDL_touch_c.h"
    2.10  #include "../../events/SDL_events_c.h"
    2.11 @@ -42,23 +43,25 @@
    2.12  - (instancetype)initWithFrame:(CGRect)frame
    2.13  {
    2.14      if ((self = [super initWithFrame:frame])) {
    2.15 -        /* Apple TV Remote touchpad swipe gestures. */
    2.16  #if TARGET_OS_TV
    2.17 -        UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
    2.18 -        swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
    2.19 -        [self addGestureRecognizer:swipeUp];
    2.20 +        if (SDL_GetHintBoolean(SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS, SDL_TRUE)) {
    2.21 +            /* Apple TV Remote touchpad swipe gestures. */
    2.22 +            UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
    2.23 +            swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
    2.24 +            [self addGestureRecognizer:swipeUp];
    2.25  
    2.26 -        UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
    2.27 -        swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
    2.28 -        [self addGestureRecognizer:swipeDown];
    2.29 +            UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
    2.30 +            swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
    2.31 +            [self addGestureRecognizer:swipeDown];
    2.32  
    2.33 -        UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
    2.34 -        swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
    2.35 -        [self addGestureRecognizer:swipeLeft];
    2.36 +            UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
    2.37 +            swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
    2.38 +            [self addGestureRecognizer:swipeLeft];
    2.39  
    2.40 -        UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
    2.41 -        swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
    2.42 -        [self addGestureRecognizer:swipeRight];
    2.43 +            UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
    2.44 +            swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
    2.45 +            [self addGestureRecognizer:swipeRight];
    2.46 +        }
    2.47  #endif
    2.48  
    2.49          self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;