Added a hint SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS to prevent turning Apple TV remote swipes into arrow key events

This commit is contained in:
Sam Lantinga 2018-01-17 17:24:15 -08:00
parent 61261e59bc
commit 9338a619f8
2 changed files with 26 additions and 13 deletions

View File

@ -355,6 +355,16 @@ extern "C" {
*/ */
#define SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION" #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 * \brief A variable controlling whether the Android / iOS built-in
* accelerometer should be listed as a joystick device, rather than listing * accelerometer should be listed as a joystick device, rather than listing

View File

@ -24,6 +24,7 @@
#include "SDL_uikitview.h" #include "SDL_uikitview.h"
#include "SDL_hints.h"
#include "../../events/SDL_mouse_c.h" #include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_touch_c.h" #include "../../events/SDL_touch_c.h"
#include "../../events/SDL_events_c.h" #include "../../events/SDL_events_c.h"
@ -42,8 +43,9 @@
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
{ {
if ((self = [super initWithFrame:frame])) { if ((self = [super initWithFrame:frame])) {
/* Apple TV Remote touchpad swipe gestures. */
#if TARGET_OS_TV #if TARGET_OS_TV
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:)]; UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp; swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
[self addGestureRecognizer:swipeUp]; [self addGestureRecognizer:swipeUp];
@ -59,6 +61,7 @@
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)]; UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight; swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[self addGestureRecognizer:swipeRight]; [self addGestureRecognizer:swipeRight];
}
#endif #endif
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;