early-access version 1617
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
#if SDL_VIDEO_DRIVER_UIKIT
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_system.h"
|
||||
#include "SDL_main.h"
|
||||
@@ -43,20 +42,12 @@ static int forward_argc;
|
||||
static char **forward_argv;
|
||||
static int exit_status;
|
||||
|
||||
#if defined(SDL_MAIN_NEEDED) && !defined(IOS_DYLIB)
|
||||
/* SDL is being built as a static library, include main() */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return SDL_UIKitRunApp(argc, argv, SDL_main);
|
||||
}
|
||||
#endif /* SDL_MAIN_NEEDED && !IOS_DYLIB */
|
||||
|
||||
int SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* store arguments */
|
||||
forward_main = mainFunction;
|
||||
forward_main = mainFunction;
|
||||
forward_argc = argc;
|
||||
forward_argv = (char **)malloc((argc+1) * sizeof(char *));
|
||||
for (i = 0; i < argc; i++) {
|
||||
|
@@ -25,6 +25,14 @@
|
||||
|
||||
extern void UIKit_PumpEvents(_THIS);
|
||||
|
||||
extern void SDL_InitGCKeyboard(void);
|
||||
extern SDL_bool SDL_HasGCKeyboard(void);
|
||||
extern void SDL_QuitGCKeyboard(void);
|
||||
|
||||
extern void SDL_InitGCMouse(void);
|
||||
extern SDL_bool SDL_HasGCMouse(void);
|
||||
extern void SDL_QuitGCMouse(void);
|
||||
|
||||
#endif /* SDL_uikitevents_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
256
externals/SDL/src/video/uikit/SDL_uikitevents.m
vendored
256
externals/SDL/src/video/uikit/SDL_uikitevents.m
vendored
@@ -30,6 +30,13 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 140000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 140000) || (__MAC_OS_VERSION_MAX_ALLOWED > 1500000)
|
||||
#import <GameController/GameController.h>
|
||||
|
||||
#define ENABLE_GCKEYBOARD
|
||||
#define ENABLE_GCMOUSE
|
||||
#endif
|
||||
|
||||
static BOOL UIKit_EventPumpEnabled = YES;
|
||||
|
||||
void
|
||||
@@ -70,6 +77,255 @@ UIKit_PumpEvents(_THIS)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_GCKEYBOARD
|
||||
|
||||
static SDL_bool keyboard_connected = SDL_FALSE;
|
||||
static id keyboard_connect_observer = nil;
|
||||
static id keyboard_disconnect_observer = nil;
|
||||
|
||||
static void OnGCKeyboardConnected(GCKeyboard *keyboard) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
|
||||
{
|
||||
keyboard_connected = SDL_TRUE;
|
||||
keyboard.keyboardInput.keyChangedHandler = ^(GCKeyboardInput *keyboard, GCControllerButtonInput *key, GCKeyCode keyCode, BOOL pressed)
|
||||
{
|
||||
SDL_SendKeyboardKey(pressed ? SDL_PRESSED : SDL_RELEASED, (SDL_Scancode)keyCode);
|
||||
};
|
||||
|
||||
dispatch_queue_t queue = dispatch_queue_create( "org.libsdl.input.keyboard", DISPATCH_QUEUE_SERIAL );
|
||||
dispatch_set_target_queue( queue, dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0 ) );
|
||||
keyboard.handlerQueue = queue;
|
||||
}
|
||||
|
||||
static void OnGCKeyboardDisconnected(GCKeyboard *keyboard) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
|
||||
{
|
||||
keyboard.keyboardInput.keyChangedHandler = nil;
|
||||
keyboard_connected = SDL_FALSE;
|
||||
}
|
||||
|
||||
void SDL_InitGCKeyboard(void)
|
||||
{
|
||||
@autoreleasepool {
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
|
||||
keyboard_connect_observer = [center addObserverForName:GCKeyboardDidConnectNotification
|
||||
object:nil
|
||||
queue:nil
|
||||
usingBlock:^(NSNotification *note) {
|
||||
GCKeyboard *keyboard = note.object;
|
||||
OnGCKeyboardConnected(keyboard);
|
||||
}];
|
||||
|
||||
keyboard_disconnect_observer = [center addObserverForName:GCKeyboardDidDisconnectNotification
|
||||
object:nil
|
||||
queue:nil
|
||||
usingBlock:^(NSNotification *note) {
|
||||
GCKeyboard *keyboard = note.object;
|
||||
OnGCKeyboardDisconnected(keyboard);
|
||||
}];
|
||||
|
||||
if (GCKeyboard.coalescedKeyboard != nil) {
|
||||
OnGCKeyboardConnected(GCKeyboard.coalescedKeyboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool SDL_HasGCKeyboard(void)
|
||||
{
|
||||
return keyboard_connected;
|
||||
}
|
||||
|
||||
void SDL_QuitGCKeyboard(void)
|
||||
{
|
||||
@autoreleasepool {
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
|
||||
if (keyboard_connect_observer) {
|
||||
[center removeObserver:keyboard_connect_observer name:GCKeyboardDidConnectNotification object:nil];
|
||||
keyboard_connect_observer = nil;
|
||||
}
|
||||
|
||||
if (keyboard_disconnect_observer) {
|
||||
[center removeObserver:keyboard_disconnect_observer name:GCKeyboardDidDisconnectNotification object:nil];
|
||||
keyboard_disconnect_observer = nil;
|
||||
}
|
||||
|
||||
if (GCKeyboard.coalescedKeyboard != nil) {
|
||||
OnGCKeyboardDisconnected(GCKeyboard.coalescedKeyboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void SDL_InitGCKeyboard(void)
|
||||
{
|
||||
}
|
||||
|
||||
SDL_bool SDL_HasGCKeyboard(void)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
void SDL_QuitGCKeyboard(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* ENABLE_GCKEYBOARD */
|
||||
|
||||
|
||||
#ifdef ENABLE_GCMOUSE
|
||||
|
||||
static int mice_connected = 0;
|
||||
static id mouse_connect_observer = nil;
|
||||
static id mouse_disconnect_observer = nil;
|
||||
|
||||
static int SetGCMouseRelativeMode(SDL_bool enabled)
|
||||
{
|
||||
/* We'll always send relative motion and we can't warp, so nothing to do here */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void OnGCMouseButtonChanged(SDL_MouseID mouseID, Uint8 button, BOOL pressed)
|
||||
{
|
||||
SDL_SendMouseButton(SDL_GetMouseFocus(), mouseID, pressed ? SDL_PRESSED : SDL_RELEASED, button);
|
||||
}
|
||||
|
||||
static void OnGCMouseConnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
|
||||
{
|
||||
SDL_MouseID mouseID = mice_connected;
|
||||
|
||||
mouse.mouseInput.leftButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed)
|
||||
{
|
||||
OnGCMouseButtonChanged(mouseID, SDL_BUTTON_LEFT, pressed);
|
||||
};
|
||||
mouse.mouseInput.middleButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed)
|
||||
{
|
||||
OnGCMouseButtonChanged(mouseID, SDL_BUTTON_MIDDLE, pressed);
|
||||
};
|
||||
mouse.mouseInput.rightButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed)
|
||||
{
|
||||
OnGCMouseButtonChanged(mouseID, SDL_BUTTON_RIGHT, pressed);
|
||||
};
|
||||
|
||||
int auxiliary_button = SDL_BUTTON_X1;
|
||||
for (GCControllerButtonInput *button in mouse.mouseInput.auxiliaryButtons) {
|
||||
button.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed)
|
||||
{
|
||||
OnGCMouseButtonChanged(mouseID, auxiliary_button, pressed);
|
||||
};
|
||||
++auxiliary_button;
|
||||
}
|
||||
|
||||
mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput *mouse, float deltaX, float deltaY)
|
||||
{
|
||||
SDL_SendMouseMotion(SDL_GetMouseFocus(), mouseID, SDL_TRUE, (int)deltaX, -(int)deltaY);
|
||||
};
|
||||
|
||||
dispatch_queue_t queue = dispatch_queue_create( "org.libsdl.input.mouse", DISPATCH_QUEUE_SERIAL );
|
||||
dispatch_set_target_queue( queue, dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0 ) );
|
||||
mouse.handlerQueue = queue;
|
||||
|
||||
++mice_connected;
|
||||
}
|
||||
|
||||
static void OnGCMouseDisconnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
|
||||
{
|
||||
--mice_connected;
|
||||
|
||||
mouse.mouseInput.mouseMovedHandler = nil;
|
||||
|
||||
mouse.mouseInput.leftButton.pressedChangedHandler = nil;
|
||||
mouse.mouseInput.middleButton.pressedChangedHandler = nil;
|
||||
mouse.mouseInput.rightButton.pressedChangedHandler = nil;
|
||||
|
||||
for (GCControllerButtonInput *button in mouse.mouseInput.auxiliaryButtons) {
|
||||
button.pressedChangedHandler = nil;
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_InitGCMouse(void)
|
||||
{
|
||||
@autoreleasepool {
|
||||
/* There is a bug where mouse accumulates duplicate deltas over time in iOS 14.0 */
|
||||
if (@available(iOS 14.1, tvOS 14.1, *)) {
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
|
||||
mouse_connect_observer = [center addObserverForName:GCMouseDidConnectNotification
|
||||
object:nil
|
||||
queue:nil
|
||||
usingBlock:^(NSNotification *note) {
|
||||
GCMouse *mouse = note.object;
|
||||
OnGCMouseConnected(mouse);
|
||||
}];
|
||||
|
||||
mouse_disconnect_observer = [center addObserverForName:GCMouseDidDisconnectNotification
|
||||
object:nil
|
||||
queue:nil
|
||||
usingBlock:^(NSNotification *note) {
|
||||
GCMouse *mouse = note.object;
|
||||
OnGCMouseDisconnected(mouse);
|
||||
}];
|
||||
|
||||
for (GCMouse *mouse in [GCMouse mice]) {
|
||||
OnGCMouseConnected(mouse);
|
||||
}
|
||||
|
||||
SDL_GetMouse()->SetRelativeMouseMode = SetGCMouseRelativeMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool SDL_HasGCMouse(void)
|
||||
{
|
||||
return (mice_connected > 0);
|
||||
}
|
||||
|
||||
void SDL_QuitGCMouse(void)
|
||||
{
|
||||
@autoreleasepool {
|
||||
if (@available(iOS 14.1, tvOS 14.1, *)) {
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
|
||||
if (mouse_connect_observer) {
|
||||
[center removeObserver:mouse_connect_observer name:GCMouseDidConnectNotification object:nil];
|
||||
mouse_connect_observer = nil;
|
||||
}
|
||||
|
||||
if (mouse_disconnect_observer) {
|
||||
[center removeObserver:mouse_disconnect_observer name:GCMouseDidDisconnectNotification object:nil];
|
||||
mouse_disconnect_observer = nil;
|
||||
}
|
||||
|
||||
for (GCMouse *mouse in [GCMouse mice]) {
|
||||
OnGCMouseDisconnected(mouse);
|
||||
}
|
||||
|
||||
SDL_GetMouse()->SetRelativeMouseMode = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void SDL_InitGCMouse(void)
|
||||
{
|
||||
}
|
||||
|
||||
SDL_bool SDL_HasGCMouse(void)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
void SDL_QuitGCMouse(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* ENABLE_GCMOUSE */
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_UIKIT */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -85,10 +85,10 @@ UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messageboxdata, in
|
||||
}
|
||||
|
||||
action = [UIAlertAction actionWithTitle:@(sdlButton->text)
|
||||
style:style
|
||||
handler:^(UIAlertAction *action) {
|
||||
clickedindex = (int)(sdlButton - messageboxdata->buttons);
|
||||
}];
|
||||
style:style
|
||||
handler:^(UIAlertAction *action) {
|
||||
clickedindex = (int)(sdlButton - messageboxdata->buttons);
|
||||
}];
|
||||
[alert addAction:action];
|
||||
|
||||
if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
|
||||
@@ -151,7 +151,6 @@ UIKit_ShowMessageBoxAlertView(const SDL_MessageBoxData *messageboxdata, int *but
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
|
||||
int i;
|
||||
int clickedindex = messageboxdata->numbuttons;
|
||||
const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
|
||||
UIAlertView *alert = [[UIAlertView alloc] init];
|
||||
SDLAlertViewDelegate *delegate = [[SDLAlertViewDelegate alloc] init];
|
||||
|
||||
@@ -177,9 +176,9 @@ UIKit_ShowMessageBoxAlertView(const SDL_MessageBoxData *messageboxdata, int *but
|
||||
|
||||
alert.delegate = nil;
|
||||
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) {
|
||||
clickedindex = messageboxdata->numbuttons - 1 - clickedindex;
|
||||
}
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) {
|
||||
clickedindex = messageboxdata->numbuttons - 1 - clickedindex;
|
||||
}
|
||||
*buttonid = messageboxdata->buttons[clickedindex].buttonid;
|
||||
return YES;
|
||||
#else
|
||||
|
@@ -49,8 +49,8 @@
|
||||
|
||||
SDL_MetalView UIKit_Metal_CreateView(_THIS, SDL_Window * window);
|
||||
void UIKit_Metal_DestroyView(_THIS, SDL_MetalView view);
|
||||
|
||||
void UIKit_Metal_GetDrawableSize(SDL_Window * window, int * w, int * h);
|
||||
void *UIKit_Metal_GetLayer(_THIS, SDL_MetalView view);
|
||||
void UIKit_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h);
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) */
|
||||
|
||||
|
@@ -34,7 +34,6 @@
|
||||
#import "SDL_uikitwindow.h"
|
||||
#import "SDL_uikitmetalview.h"
|
||||
|
||||
#include "SDL_assert.h"
|
||||
|
||||
@implementation SDL_uikitmetalview
|
||||
|
||||
@@ -110,8 +109,15 @@ UIKit_Metal_DestroyView(_THIS, SDL_MetalView view)
|
||||
}
|
||||
}}
|
||||
|
||||
void *
|
||||
UIKit_Metal_GetLayer(_THIS, SDL_MetalView view)
|
||||
{ @autoreleasepool {
|
||||
SDL_uikitview *uiview = (__bridge SDL_uikitview *)view;
|
||||
return (__bridge void *)uiview.layer;
|
||||
}}
|
||||
|
||||
void
|
||||
UIKit_Metal_GetDrawableSize(SDL_Window * window, int * w, int * h)
|
||||
UIKit_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
|
@@ -43,6 +43,8 @@
|
||||
extern SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen);
|
||||
|
||||
extern int UIKit_InitModes(_THIS);
|
||||
extern int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event);
|
||||
extern void UIKit_DelDisplay(UIScreen *uiscreen);
|
||||
extern void UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
|
||||
extern int UIKit_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
|
||||
extern int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
|
67
externals/SDL/src/video/uikit/SDL_uikitmodes.m
vendored
67
externals/SDL/src/video/uikit/SDL_uikitmodes.m
vendored
@@ -22,7 +22,6 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_UIKIT
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_system.h"
|
||||
#include "SDL_uikitmodes.h"
|
||||
|
||||
@@ -181,6 +180,44 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface SDL_DisplayWatch : NSObject
|
||||
@end
|
||||
|
||||
@implementation SDL_DisplayWatch
|
||||
|
||||
+ (void)start
|
||||
{
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[center addObserver:self selector:@selector(screenConnected:)
|
||||
name:UIScreenDidConnectNotification object:nil];
|
||||
[center addObserver:self selector:@selector(screenDisconnected:)
|
||||
name:UIScreenDidDisconnectNotification object:nil];
|
||||
}
|
||||
|
||||
+ (void)stop
|
||||
{
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[center removeObserver:self
|
||||
name:UIScreenDidConnectNotification object:nil];
|
||||
[center removeObserver:self
|
||||
name:UIScreenDidDisconnectNotification object:nil];
|
||||
}
|
||||
|
||||
+ (void)screenConnected:(NSNotification*)notification
|
||||
{
|
||||
UIScreen *uiscreen = [notification object];
|
||||
UIKit_AddDisplay(uiscreen, SDL_TRUE);
|
||||
}
|
||||
|
||||
+ (void)screenDisconnected:(NSNotification*)notification
|
||||
{
|
||||
UIScreen *uiscreen = [notification object];
|
||||
UIKit_DelDisplay(uiscreen);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
static int
|
||||
UIKit_AllocateDisplayModeData(SDL_DisplayMode * mode,
|
||||
@@ -265,8 +302,8 @@ UIKit_AddDisplayMode(SDL_VideoDisplay * display, int w, int h, UIScreen * uiscre
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
UIKit_AddDisplay(UIScreen *uiscreen)
|
||||
int
|
||||
UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event)
|
||||
{
|
||||
UIScreenMode *uiscreenmode = uiscreen.currentMode;
|
||||
CGSize size = uiscreen.bounds.size;
|
||||
@@ -302,11 +339,27 @@ UIKit_AddDisplay(UIScreen *uiscreen)
|
||||
}
|
||||
|
||||
display.driverdata = (void *) CFBridgingRetain(data);
|
||||
SDL_AddVideoDisplay(&display);
|
||||
SDL_AddVideoDisplay(&display, send_event);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
UIKit_DelDisplay(UIScreen *uiscreen)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) {
|
||||
SDL_DisplayData *data = (__bridge SDL_DisplayData *)SDL_GetDisplayDriverData(i);
|
||||
|
||||
if (data && data.uiscreen == uiscreen) {
|
||||
CFRelease(SDL_GetDisplayDriverData(i));
|
||||
SDL_DelVideoDisplay(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
UIKit_IsDisplayLandscape(UIScreen *uiscreen)
|
||||
{
|
||||
@@ -326,13 +379,15 @@ UIKit_InitModes(_THIS)
|
||||
{
|
||||
@autoreleasepool {
|
||||
for (UIScreen *uiscreen in [UIScreen screens]) {
|
||||
if (UIKit_AddDisplay(uiscreen) < 0) {
|
||||
if (UIKit_AddDisplay(uiscreen, SDL_FALSE) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#if !TARGET_OS_TV
|
||||
SDL_OnApplicationDidChangeStatusBarOrientation();
|
||||
#endif
|
||||
|
||||
[SDL_DisplayWatch start];
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -466,6 +521,8 @@ UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
|
||||
void
|
||||
UIKit_QuitModes(_THIS)
|
||||
{
|
||||
[SDL_DisplayWatch stop];
|
||||
|
||||
/* Release Objective-C objects, so higher level doesn't free() them. */
|
||||
int i, j;
|
||||
@autoreleasepool {
|
||||
|
18
externals/SDL/src/video/uikit/SDL_uikitvideo.m
vendored
18
externals/SDL/src/video/uikit/SDL_uikitvideo.m
vendored
@@ -52,12 +52,6 @@ static void UIKit_VideoQuit(_THIS);
|
||||
|
||||
/* DUMMY driver bootstrap functions */
|
||||
|
||||
static int
|
||||
UIKit_Available(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void UIKit_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
@autoreleasepool {
|
||||
@@ -102,6 +96,7 @@ UIKit_CreateDevice(int devindex)
|
||||
device->DestroyWindow = UIKit_DestroyWindow;
|
||||
device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
|
||||
device->GetDisplayUsableBounds = UIKit_GetDisplayUsableBounds;
|
||||
device->GetDisplayDPI = UIKit_GetDisplayDPI;
|
||||
|
||||
#if SDL_IPHONE_KEYBOARD
|
||||
device->HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
|
||||
@@ -139,6 +134,8 @@ UIKit_CreateDevice(int devindex)
|
||||
#if SDL_VIDEO_METAL
|
||||
device->Metal_CreateView = UIKit_Metal_CreateView;
|
||||
device->Metal_DestroyView = UIKit_Metal_DestroyView;
|
||||
device->Metal_GetLayer = UIKit_Metal_GetLayer;
|
||||
device->Metal_GetDrawableSize = UIKit_Metal_GetDrawableSize;
|
||||
#endif
|
||||
|
||||
device->gl_config.accelerated = 1;
|
||||
@@ -149,7 +146,7 @@ UIKit_CreateDevice(int devindex)
|
||||
|
||||
VideoBootStrap UIKIT_bootstrap = {
|
||||
UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
|
||||
UIKit_Available, UIKit_CreateDevice
|
||||
UIKit_CreateDevice
|
||||
};
|
||||
|
||||
|
||||
@@ -161,12 +158,19 @@ UIKit_VideoInit(_THIS)
|
||||
if (UIKit_InitModes(_this) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_InitGCKeyboard();
|
||||
SDL_InitGCMouse();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
UIKit_VideoQuit(_THIS)
|
||||
{
|
||||
SDL_QuitGCKeyboard();
|
||||
SDL_QuitGCMouse();
|
||||
|
||||
UIKit_QuitModes(_this);
|
||||
}
|
||||
|
||||
|
@@ -25,12 +25,21 @@
|
||||
|
||||
#include "SDL_touch.h"
|
||||
|
||||
#if !TARGET_OS_TV && defined(__IPHONE_13_4)
|
||||
@interface SDL_uikitview : UIView <UIPointerInteractionDelegate>
|
||||
#else
|
||||
@interface SDL_uikitview : UIView
|
||||
#endif
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame;
|
||||
|
||||
- (void)setSDLWindow:(SDL_Window *)window;
|
||||
|
||||
#if !TARGET_OS_TV && defined(__IPHONE_13_4)
|
||||
- (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4));
|
||||
- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4));
|
||||
#endif
|
||||
|
||||
- (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize;
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
|
||||
|
294
externals/SDL/src/video/uikit/SDL_uikitview.m
vendored
294
externals/SDL/src/video/uikit/SDL_uikitview.m
vendored
@@ -29,12 +29,18 @@
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#import "SDL_uikitappdelegate.h"
|
||||
#import "SDL_uikitmodes.h"
|
||||
#import "SDL_uikitwindow.h"
|
||||
#include "SDL_uikitappdelegate.h"
|
||||
#include "SDL_uikitevents.h"
|
||||
#include "SDL_uikitmodes.h"
|
||||
#include "SDL_uikitwindow.h"
|
||||
|
||||
/* The maximum number of mouse buttons we support */
|
||||
#define MAX_MOUSE_BUTTONS 5
|
||||
|
||||
/* This is defined in SDL_sysjoystick.m */
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||
#endif
|
||||
|
||||
@implementation SDL_uikitview {
|
||||
SDL_Window *sdlwindow;
|
||||
@@ -63,6 +69,16 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
|
||||
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
|
||||
[self addGestureRecognizer:swipeRight];
|
||||
#elif defined(__IPHONE_13_4)
|
||||
if (@available(iOS 13.4, *)) {
|
||||
UIPanGestureRecognizer *mouseWheelRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(mouseWheelGesture:)];
|
||||
mouseWheelRecognizer.allowedScrollTypesMask = UIScrollTypeMaskDiscrete;
|
||||
mouseWheelRecognizer.allowedTouchTypes = @[ @(UITouchTypeIndirectPointer) ];
|
||||
mouseWheelRecognizer.cancelsTouchesInView = NO;
|
||||
mouseWheelRecognizer.delaysTouchesBegan = NO;
|
||||
mouseWheelRecognizer.delaysTouchesEnded = NO;
|
||||
[self addGestureRecognizer:mouseWheelRecognizer];
|
||||
}
|
||||
#endif
|
||||
|
||||
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
@@ -75,6 +91,12 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||
self.multipleTouchEnabled = YES;
|
||||
SDL_AddTouch(directTouchId, SDL_TOUCH_DEVICE_DIRECT, "");
|
||||
#endif
|
||||
|
||||
#if !TARGET_OS_TV && defined(__IPHONE_13_4)
|
||||
if (@available(iOS 13.4, *)) {
|
||||
[self addInteraction:[[UIPointerInteraction alloc] initWithDelegate:self]];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -136,6 +158,29 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||
sdlwindow = window;
|
||||
}
|
||||
|
||||
#if !TARGET_OS_TV && defined(__IPHONE_13_4)
|
||||
- (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4)){
|
||||
if (request != nil && !SDL_HasGCMouse()) {
|
||||
CGPoint origin = self.bounds.origin;
|
||||
CGPoint point = request.location;
|
||||
|
||||
point.x -= origin.x;
|
||||
point.y -= origin.y;
|
||||
|
||||
SDL_SendMouseMotion(sdlwindow, 0, 0, (int)point.x, (int)point.y);
|
||||
}
|
||||
return [UIPointerRegion regionWithRect:self.bounds identifier:nil];
|
||||
}
|
||||
|
||||
- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4)){
|
||||
if (SDL_ShowCursor(-1)) {
|
||||
return nil;
|
||||
} else {
|
||||
return [UIPointerStyle hiddenPointerStyle];
|
||||
}
|
||||
}
|
||||
#endif /* !TARGET_OS_TV && __IPHONE_13_4 */
|
||||
|
||||
- (SDL_TouchDeviceType)touchTypeForTouch:(UITouch *)touch
|
||||
{
|
||||
#ifdef __IPHONE_9_0
|
||||
@@ -187,38 +232,110 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
for (UITouch *touch in touches) {
|
||||
SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch];
|
||||
SDL_TouchID touchId = [self touchIdForType:touchType];
|
||||
float pressure = [self pressureForTouch:touch];
|
||||
BOOL handled = NO;
|
||||
|
||||
if (SDL_AddTouch(touchId, touchType, "") < 0) {
|
||||
continue;
|
||||
#if !TARGET_OS_TV && defined(__IPHONE_13_4)
|
||||
if (@available(iOS 13.4, *)) {
|
||||
if (touch.type == UITouchTypeIndirectPointer) {
|
||||
if (!SDL_HasGCMouse()) {
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) {
|
||||
if ((event.buttonMask & SDL_BUTTON(i)) != 0) {
|
||||
Uint8 button;
|
||||
|
||||
switch (i) {
|
||||
case 1:
|
||||
button = SDL_BUTTON_LEFT;
|
||||
break;
|
||||
case 2:
|
||||
button = SDL_BUTTON_RIGHT;
|
||||
break;
|
||||
case 3:
|
||||
button = SDL_BUTTON_MIDDLE;
|
||||
break;
|
||||
default:
|
||||
button = (Uint8)i;
|
||||
break;
|
||||
}
|
||||
SDL_SendMouseButton(sdlwindow, 0, SDL_PRESSED, button);
|
||||
}
|
||||
}
|
||||
}
|
||||
handled = YES;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!handled) {
|
||||
SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch];
|
||||
SDL_TouchID touchId = [self touchIdForType:touchType];
|
||||
float pressure = [self pressureForTouch:touch];
|
||||
|
||||
/* FIXME, need to send: int clicks = (int) touch.tapCount; ? */
|
||||
if (SDL_AddTouch(touchId, touchType, "") < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
||||
SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch), sdlwindow,
|
||||
SDL_TRUE, locationInView.x, locationInView.y, pressure);
|
||||
/* FIXME, need to send: int clicks = (int) touch.tapCount; ? */
|
||||
|
||||
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
||||
SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch), sdlwindow,
|
||||
SDL_TRUE, locationInView.x, locationInView.y, pressure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
for (UITouch *touch in touches) {
|
||||
SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch];
|
||||
SDL_TouchID touchId = [self touchIdForType:touchType];
|
||||
float pressure = [self pressureForTouch:touch];
|
||||
BOOL handled = NO;
|
||||
|
||||
if (SDL_AddTouch(touchId, touchType, "") < 0) {
|
||||
continue;
|
||||
#if !TARGET_OS_TV && defined(__IPHONE_13_4)
|
||||
if (@available(iOS 13.4, *)) {
|
||||
if (touch.type == UITouchTypeIndirectPointer) {
|
||||
if (!SDL_HasGCMouse()) {
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) {
|
||||
if ((event.buttonMask & SDL_BUTTON(i)) != 0) {
|
||||
Uint8 button;
|
||||
|
||||
switch (i) {
|
||||
case 1:
|
||||
button = SDL_BUTTON_LEFT;
|
||||
break;
|
||||
case 2:
|
||||
button = SDL_BUTTON_RIGHT;
|
||||
break;
|
||||
case 3:
|
||||
button = SDL_BUTTON_MIDDLE;
|
||||
break;
|
||||
default:
|
||||
button = (Uint8)i;
|
||||
break;
|
||||
}
|
||||
SDL_SendMouseButton(sdlwindow, 0, SDL_RELEASED, button);
|
||||
}
|
||||
}
|
||||
}
|
||||
handled = YES;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!handled) {
|
||||
SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch];
|
||||
SDL_TouchID touchId = [self touchIdForType:touchType];
|
||||
float pressure = [self pressureForTouch:touch];
|
||||
|
||||
/* FIXME, need to send: int clicks = (int) touch.tapCount; ? */
|
||||
if (SDL_AddTouch(touchId, touchType, "") < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
||||
SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch), sdlwindow,
|
||||
SDL_FALSE, locationInView.x, locationInView.y, pressure);
|
||||
/* FIXME, need to send: int clicks = (int) touch.tapCount; ? */
|
||||
|
||||
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
||||
SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch), sdlwindow,
|
||||
SDL_FALSE, locationInView.x, locationInView.y, pressure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,51 +347,78 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
for (UITouch *touch in touches) {
|
||||
SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch];
|
||||
SDL_TouchID touchId = [self touchIdForType:touchType];
|
||||
float pressure = [self pressureForTouch:touch];
|
||||
BOOL handled = NO;
|
||||
|
||||
if (SDL_AddTouch(touchId, touchType, "") < 0) {
|
||||
continue;
|
||||
#if !TARGET_OS_TV && defined(__IPHONE_13_4)
|
||||
if (@available(iOS 13.4, *)) {
|
||||
if (touch.type == UITouchTypeIndirectPointer) {
|
||||
/* Already handled in pointerInteraction callback */
|
||||
handled = YES;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!handled) {
|
||||
SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch];
|
||||
SDL_TouchID touchId = [self touchIdForType:touchType];
|
||||
float pressure = [self pressureForTouch:touch];
|
||||
|
||||
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
||||
SDL_SendTouchMotion(touchId, (SDL_FingerID)((size_t)touch), sdlwindow,
|
||||
locationInView.x, locationInView.y, pressure);
|
||||
if (SDL_AddTouch(touchId, touchType, "") < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
||||
SDL_SendTouchMotion(touchId, (SDL_FingerID)((size_t)touch), sdlwindow,
|
||||
locationInView.x, locationInView.y, pressure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_OS_TV || defined(__IPHONE_9_1)
|
||||
- (SDL_Scancode)scancodeFromPressType:(UIPressType)presstype
|
||||
- (SDL_Scancode)scancodeFromPress:(UIPress*)press
|
||||
{
|
||||
switch (presstype) {
|
||||
case UIPressTypeUpArrow:
|
||||
return SDL_SCANCODE_UP;
|
||||
case UIPressTypeDownArrow:
|
||||
return SDL_SCANCODE_DOWN;
|
||||
case UIPressTypeLeftArrow:
|
||||
return SDL_SCANCODE_LEFT;
|
||||
case UIPressTypeRightArrow:
|
||||
return SDL_SCANCODE_RIGHT;
|
||||
case UIPressTypeSelect:
|
||||
/* HIG says: "primary button behavior" */
|
||||
return SDL_SCANCODE_RETURN;
|
||||
case UIPressTypeMenu:
|
||||
/* HIG says: "returns to previous screen" */
|
||||
return SDL_SCANCODE_ESCAPE;
|
||||
case UIPressTypePlayPause:
|
||||
/* HIG says: "secondary button behavior" */
|
||||
return SDL_SCANCODE_PAUSE;
|
||||
default:
|
||||
return SDL_SCANCODE_UNKNOWN;
|
||||
#ifdef __IPHONE_13_4
|
||||
if ([press respondsToSelector:@selector((key))]) {
|
||||
if (press.key != nil) {
|
||||
return (SDL_Scancode)press.key.keyCode;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
/* Presses from Apple TV remote */
|
||||
if (!SDL_AppleTVRemoteOpenedAsJoystick) {
|
||||
switch (press.type) {
|
||||
case UIPressTypeUpArrow:
|
||||
return SDL_SCANCODE_UP;
|
||||
case UIPressTypeDownArrow:
|
||||
return SDL_SCANCODE_DOWN;
|
||||
case UIPressTypeLeftArrow:
|
||||
return SDL_SCANCODE_LEFT;
|
||||
case UIPressTypeRightArrow:
|
||||
return SDL_SCANCODE_RIGHT;
|
||||
case UIPressTypeSelect:
|
||||
/* HIG says: "primary button behavior" */
|
||||
return SDL_SCANCODE_RETURN;
|
||||
case UIPressTypeMenu:
|
||||
/* HIG says: "returns to previous screen" */
|
||||
return SDL_SCANCODE_ESCAPE;
|
||||
case UIPressTypePlayPause:
|
||||
/* HIG says: "secondary button behavior" */
|
||||
return SDL_SCANCODE_PAUSE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* !SDL_JOYSTICK_DISABLED */
|
||||
|
||||
return SDL_SCANCODE_UNKNOWN;
|
||||
}
|
||||
|
||||
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
|
||||
{
|
||||
if (!SDL_AppleTVRemoteOpenedAsJoystick) {
|
||||
if (!SDL_HasGCKeyboard()) {
|
||||
for (UIPress *press in presses) {
|
||||
SDL_Scancode scancode = [self scancodeFromPressType:press.type];
|
||||
SDL_Scancode scancode = [self scancodeFromPress:press];
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, scancode);
|
||||
}
|
||||
}
|
||||
@@ -283,9 +427,9 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||
|
||||
- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
|
||||
{
|
||||
if (!SDL_AppleTVRemoteOpenedAsJoystick) {
|
||||
if (!SDL_HasGCKeyboard()) {
|
||||
for (UIPress *press in presses) {
|
||||
SDL_Scancode scancode = [self scancodeFromPressType:press.type];
|
||||
SDL_Scancode scancode = [self scancodeFromPress:press];
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
@@ -294,9 +438,9 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||
|
||||
- (void)pressesCancelled:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
|
||||
{
|
||||
if (!SDL_AppleTVRemoteOpenedAsJoystick) {
|
||||
if (!SDL_HasGCKeyboard()) {
|
||||
for (UIPress *press in presses) {
|
||||
SDL_Scancode scancode = [self scancodeFromPressType:press.type];
|
||||
SDL_Scancode scancode = [self scancodeFromPress:press];
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
@@ -308,35 +452,57 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||
/* This is only called when the force of a press changes. */
|
||||
[super pressesChanged:presses withEvent:event];
|
||||
}
|
||||
|
||||
#endif /* TARGET_OS_TV || defined(__IPHONE_9_1) */
|
||||
|
||||
-(void)mouseWheelGesture:(UIPanGestureRecognizer *)gesture
|
||||
{
|
||||
if (gesture.state == UIGestureRecognizerStateBegan ||
|
||||
gesture.state == UIGestureRecognizerStateChanged ||
|
||||
gesture.state == UIGestureRecognizerStateEnded) {
|
||||
CGPoint velocity = [gesture velocityInView:self];
|
||||
|
||||
if (velocity.x > 0.0f) {
|
||||
velocity.x = -1.0;
|
||||
} else if (velocity.x < 0.0f) {
|
||||
velocity.x = 1.0f;
|
||||
}
|
||||
if (velocity.y > 0.0f) {
|
||||
velocity.y = -1.0;
|
||||
} else if (velocity.y < 0.0f) {
|
||||
velocity.y = 1.0f;
|
||||
}
|
||||
if (velocity.x != 0.0f || velocity.y != 0.0f) {
|
||||
SDL_SendMouseWheel(sdlwindow, 0, velocity.x, velocity.y, SDL_MOUSEWHEEL_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_OS_TV
|
||||
-(void)swipeGesture:(UISwipeGestureRecognizer *)gesture
|
||||
{
|
||||
/* Swipe gestures don't trigger begin states. */
|
||||
if (gesture.state == UIGestureRecognizerStateEnded) {
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
if (!SDL_AppleTVRemoteOpenedAsJoystick) {
|
||||
/* Send arrow key presses for now, as we don't have an external API
|
||||
* which better maps to swipe gestures. */
|
||||
switch (gesture.direction) {
|
||||
case UISwipeGestureRecognizerDirectionUp:
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_UP);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_UP);
|
||||
SDL_SendKeyboardKeyAutoRelease(SDL_SCANCODE_UP);
|
||||
break;
|
||||
case UISwipeGestureRecognizerDirectionDown:
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DOWN);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DOWN);
|
||||
SDL_SendKeyboardKeyAutoRelease(SDL_SCANCODE_DOWN);
|
||||
break;
|
||||
case UISwipeGestureRecognizerDirectionLeft:
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LEFT);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LEFT);
|
||||
SDL_SendKeyboardKeyAutoRelease(SDL_SCANCODE_LEFT);
|
||||
break;
|
||||
case UISwipeGestureRecognizerDirectionRight:
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RIGHT);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RIGHT);
|
||||
SDL_SendKeyboardKeyAutoRelease(SDL_SCANCODE_RIGHT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* !SDL_JOYSTICK_DISABLED */
|
||||
}
|
||||
}
|
||||
#endif /* TARGET_OS_TV */
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#if SDL_VIDEO_DRIVER_UIKIT
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
@@ -317,8 +316,7 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
||||
}
|
||||
|
||||
if (scancode != SDL_SCANCODE_UNKNOWN) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, scancode);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
SDL_SendKeyboardKeyAutoRelease(scancode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +340,7 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
||||
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {}
|
||||
completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
|
||||
self->rotatingOrientation = NO;
|
||||
}];
|
||||
}];
|
||||
}
|
||||
#else
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
||||
@@ -411,36 +409,38 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
||||
{
|
||||
NSUInteger len = changeText.length;
|
||||
if (len > 0) {
|
||||
/* Go through all the characters in the string we've been sent and
|
||||
* convert them to key presses */
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
unichar c = [changeText characterAtIndex:i];
|
||||
SDL_Scancode code;
|
||||
Uint16 mod;
|
||||
if (!SDL_HardwareKeyboardKeyPressed()) {
|
||||
/* Go through all the characters in the string we've been sent and
|
||||
* convert them to key presses */
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
unichar c = [changeText characterAtIndex:i];
|
||||
SDL_Scancode code;
|
||||
Uint16 mod;
|
||||
|
||||
if (c < 127) {
|
||||
/* Figure out the SDL_Scancode and SDL_keymod for this unichar */
|
||||
code = unicharToUIKeyInfoTable[c].code;
|
||||
mod = unicharToUIKeyInfoTable[c].mod;
|
||||
} else {
|
||||
/* We only deal with ASCII right now */
|
||||
code = SDL_SCANCODE_UNKNOWN;
|
||||
mod = 0;
|
||||
}
|
||||
if (c < 127) {
|
||||
/* Figure out the SDL_Scancode and SDL_keymod for this unichar */
|
||||
code = unicharToUIKeyInfoTable[c].code;
|
||||
mod = unicharToUIKeyInfoTable[c].mod;
|
||||
} else {
|
||||
/* We only deal with ASCII right now */
|
||||
code = SDL_SCANCODE_UNKNOWN;
|
||||
mod = 0;
|
||||
}
|
||||
|
||||
if (mod & KMOD_SHIFT) {
|
||||
/* If character uses shift, press shift down */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
||||
}
|
||||
if (mod & KMOD_SHIFT) {
|
||||
/* If character uses shift, press shift */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
||||
}
|
||||
|
||||
/* send a keydown and keyup even for the character */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
||||
/* send a keydown and keyup even for the character */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
||||
|
||||
if (mod & KMOD_SHIFT) {
|
||||
/* If character uses shift, press shift back up */
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||
if (mod & KMOD_SHIFT) {
|
||||
/* If character uses shift, release shift */
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_SendKeyboardText([changeText UTF8String]);
|
||||
@@ -491,8 +491,7 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
||||
changeText = nil;
|
||||
if (textField.markedTextRange == nil) {
|
||||
/* it wants to replace text with nothing, ie a delete */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_BACKSPACE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_BACKSPACE);
|
||||
SDL_SendKeyboardKeyAutoRelease(SDL_SCANCODE_BACKSPACE);
|
||||
}
|
||||
if (textField.text.length < 16) {
|
||||
textField.text = obligateForBackspace;
|
||||
@@ -506,8 +505,7 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
||||
/* Terminates the editing session */
|
||||
- (BOOL)textFieldShouldReturn:(UITextField*)_textField
|
||||
{
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RETURN);
|
||||
SDL_SendKeyboardKeyAutoRelease(SDL_SCANCODE_RETURN);
|
||||
if (keyboardVisible &&
|
||||
SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, SDL_FALSE)) {
|
||||
SDL_StopTextInput();
|
||||
|
@@ -30,7 +30,6 @@
|
||||
|
||||
#include "SDL_uikitvideo.h"
|
||||
#include "SDL_uikitwindow.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_uikitvulkan.h"
|
||||
@@ -243,7 +242,7 @@ SDL_bool UIKit_Vulkan_CreateSurface(_THIS,
|
||||
|
||||
void UIKit_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h)
|
||||
{
|
||||
UIKit_Metal_GetDrawableSize(window, w, h);
|
||||
UIKit_Metal_GetDrawableSize(_this, window, w, h);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
13
externals/SDL/src/video/uikit/SDL_uikitwindow.m
vendored
13
externals/SDL/src/video/uikit/SDL_uikitwindow.m
vendored
@@ -25,7 +25,6 @@
|
||||
#include "SDL_syswm.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_pixels_c.h"
|
||||
@@ -162,14 +161,14 @@ UIKit_CreateWindow(_THIS, SDL_Window *window)
|
||||
@autoreleasepool {
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_DisplayData *data = (__bridge SDL_DisplayData *) display->driverdata;
|
||||
|
||||
/* SDL currently puts this window at the start of display's linked list. We rely on this. */
|
||||
SDL_assert(_this->windows == window);
|
||||
SDL_Window *other;
|
||||
|
||||
/* We currently only handle a single window per display on iOS */
|
||||
if (window->next != NULL) {
|
||||
return SDL_SetError("Only one window allowed per display.");
|
||||
}
|
||||
for (other = _this->windows; other; other = other->next) {
|
||||
if (other != window && SDL_GetDisplayForWindow(other) == display) {
|
||||
return SDL_SetError("Only one window allowed per display.");
|
||||
}
|
||||
}
|
||||
|
||||
/* If monitor has a resolution of 0x0 (hasn't been explicitly set by the
|
||||
* user, so it's in standby), try to force the display to a resolution
|
||||
|
Reference in New Issue
Block a user