Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions include/SDL3/SDL_hints.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,28 @@ extern "C" {
*/
#define SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION"

/**
* A variable controlling whether the Apple TV remote's touchpad swipe gesture
* recognizers are installed.
*
* On tvOS SDL installs UISwipeGestureRecognizers so that swipes on the remote's
* touchpad generate arrow-key events, which is convenient for apps that do not
* process touch directly. These recognizers cancel the underlying touches when
* they fire, which interferes with apps that implement their own handling of the
* remote touchpad's touch events.
*
* The variable can be set to the following values:
*
* - "0": The swipe gesture recognizers are not installed; raw touch events are
* delivered without being cancelled.
* - "1": The swipe gesture recognizers are installed. (default)
*
* This hint should be set before a window is created.
*
* \since This hint is available since SDL 3.5.0.
*/
#define SDL_HINT_APPLE_TV_REMOTE_SWIPE_GESTURES "SDL_APPLE_TV_REMOTE_SWIPE_GESTURES"

/**
* Specify the default ALSA audio device name.
*
Expand Down
35 changes: 19 additions & 16 deletions src/video/uikit/SDL_uikitview.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,25 @@ - (instancetype)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {
#ifdef SDL_PLATFORM_TVOS
// 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];
// Apple TV Remote touchpad swipe gestures. These cancel the touches they
// recognize, so let apps that handle touch directly turn them off.
if (SDL_GetHintBoolean(SDL_HINT_APPLE_TV_REMOTE_SWIPE_GESTURES, true)) {
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

#if !defined(SDL_PLATFORM_TVOS)
Expand Down
Loading