uikit: Patched to compile, added to Xcode project.

This commit is contained in:
Ryan C. Gordon 2024-12-27 15:12:28 -05:00
parent 774e38d073
commit f6143da617
3 changed files with 43 additions and 32 deletions

View file

@ -530,6 +530,8 @@
F3FD042E2C9B755700824C4C /* SDL_hidapi_nintendo.h in Headers */ = {isa = PBXBuildFile; fileRef = F3FD042C2C9B755700824C4C /* SDL_hidapi_nintendo.h */; };
F3FD042F2C9B755700824C4C /* SDL_hidapi_steam_hori.c in Sources */ = {isa = PBXBuildFile; fileRef = F3FD042D2C9B755700824C4C /* SDL_hidapi_steam_hori.c */; };
FA73671D19A540EF004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; platformFilters = (ios, maccatalyst, macos, tvos, watchos, ); };
000012E88BE7D71B274A0000 /* SDL_uikitpen.h in Headers */ = {isa = PBXBuildFile; fileRef = 000063D3D80F97ADC7770000 /* SDL_uikitpen.h */; };
0000A877C7DB9FA935FC0000 /* SDL_uikitpen.m in Sources */ = {isa = PBXBuildFile; fileRef = 000053D344416737F6050000 /* SDL_uikitpen.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -1092,6 +1094,8 @@
F59C710600D5CB5801000001 /* SDL.info */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SDL.info; sourceTree = "<group>"; };
F5A2EF3900C6A39A01000001 /* BUGS.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = BUGS.txt; path = ../../BUGS.txt; sourceTree = SOURCE_ROOT; };
FA73671C19A540EF004122E4 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; };
000063D3D80F97ADC7770000 /* SDL_uikitpen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_uikitpen.h; path = SDL_uikitpen.h; sourceTree = "<group>"; };
000053D344416737F6050000 /* SDL_uikitpen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_uikitpen.m; path = SDL_uikitpen.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -1682,6 +1686,8 @@
A7D8A62523E2513D00DCD162 /* SDL_uikitvulkan.m */,
A7D8A62723E2513D00DCD162 /* SDL_uikitwindow.h */,
A7D8A61A23E2513D00DCD162 /* SDL_uikitwindow.m */,
000063D3D80F97ADC7770000 /* SDL_uikitpen.h */,
000053D344416737F6050000 /* SDL_uikitpen.m */,
);
path = uikit;
sourceTree = "<group>";
@ -3020,6 +3026,7 @@
0000AEB9AE90228CA2D60000 /* SDL_asyncio.c in Sources */,
00004D0B73767647AD550000 /* SDL_asyncio_generic.c in Sources */,
0000A03C0F32C43816F40000 /* SDL_asyncio_windows_ioring.c in Sources */,
0000A877C7DB9FA935FC0000 /* SDL_uikitpen.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View file

@ -34,16 +34,16 @@
- (void)setSDLWindow:(SDL_Window *)window;
- (SDL_Window *)getSDLWindow;
#if !defined(SDL_PLATFORM_TVOS)
#if defined(__IPHONE_13_0)
- (void)pencilHovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0));
#endif
#if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
#if 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));
- (void)indirectPointerHovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.4));
- (void)updateIndirectPointerFromTouch:(UITouch *)touch;
- (void)updateIndirectPointerButtonState:(UITouch *)touch fromEvent:(UIEvent *)event;
#endif
#endif
- (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize;

View file

@ -49,7 +49,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
SDL_TouchID directTouchId;
SDL_TouchID indirectTouchId;
#if defined(__IPHONE_13_4)
#if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
UIPointerInteraction *indirectPointerInteraction API_AVAILABLE(ios(13.4));
#endif
}
@ -85,8 +85,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
#ifndef SDL_PLATFORM_TVOS
self.multipleTouchEnabled = YES;
SDL_AddTouch(directTouchId, SDL_TOUCH_DEVICE_DIRECT, "");
#endif
#if defined(__IPHONE_13_0)
if (@available(iOS 13.0, *)) {
UIHoverGestureRecognizer *pencilRecognizer = [[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(pencilHovering:)];
@ -95,7 +94,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
}
#endif
#if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
#if defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) {
indirectPointerInteraction = [[UIPointerInteraction alloc] initWithDelegate:self];
[self addInteraction:indirectPointerInteraction];
@ -105,6 +104,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
[self addGestureRecognizer:indirectPointerRecognizer];
}
#endif
#endif // !defined(SDL_PLATFORM_TVOS)
}
return self;
@ -171,7 +171,9 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
return sdlwindow;
}
#if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
#if !defined(SDL_PLATFORM_TVOS)
#if defined(__IPHONE_13_4)
- (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4))
{
return [UIPointerRegion regionWithRect:self.bounds identifier:nil];
@ -251,7 +253,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
}
}
#endif // !defined(SDL_PLATFORM_TVOS) && __IPHONE_13_4
#endif // __IPHONE_13_4
#if defined(__IPHONE_13_0)
@ -293,6 +295,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
}
#endif // defined(__IPHONE_13_0)
#endif // !defined(SDL_PLATFORM_TVOS)
- (SDL_TouchDeviceType)touchTypeForTouch:(UITouch *)touch
{
@ -345,8 +348,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches) {
BOOL handled = NO;
#if !defined(SDL_PLATFORM_TVOS)
#if defined(__IPHONE_13_0)
if (@available(iOS 13.0, *)) {
if (touch.type == UITouchTypePencil) {
@ -356,38 +358,37 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
}
#endif
#if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
#if defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) {
if (touch.type == UITouchTypeIndirectPointer) {
[self indirectPointerPressed:touch fromEvent:event];
handled = YES;
continue;
}
}
#endif
if (!handled) {
SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch];
SDL_TouchID touchId = [self touchIdForType:touchType];
float pressure = [self pressureForTouch:touch];
#endif // !defined(SDL_PLATFORM_TVOS)
if (SDL_AddTouch(touchId, touchType, "") < 0) {
continue;
}
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; ?
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]),
touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow,
true, locationInView.x, locationInView.y, pressure);
if (SDL_AddTouch(touchId, touchType, "") < 0) {
continue;
}
// FIXME, need to send: int clicks = (int) touch.tapCount; ?
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]),
touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow,
true, locationInView.x, locationInView.y, pressure);
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches) {
BOOL handled = NO;
#if !defined(SDL_PLATFORM_TVOS)
#if defined(__IPHONE_13_0)
if (@available(iOS 13.0, *)) {
if (touch.type == UITouchTypePencil) {
@ -397,7 +398,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
}
#endif
#if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
#if defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) {
if (touch.type == UITouchTypeIndirectPointer) {
[self indirectPointerReleased:touch fromEvent:event];
@ -405,6 +406,8 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
}
}
#endif
#endif // !defined(SDL_PLATFORM_TVOS)
SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch];
SDL_TouchID touchId = [self touchIdForType:touchType];
float pressure = [self pressureForTouch:touch];
@ -430,8 +433,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches) {
BOOL handled = NO;
#if !defined(SDL_PLATFORM_TVOS)
#if defined(__IPHONE_13_0)
if (@available(iOS 13.0, *)) {
if (touch.type == UITouchTypePencil) {
@ -441,7 +443,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
}
#endif
#if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
#if defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) {
if (touch.type == UITouchTypeIndirectPointer) {
[self indirectPointerMoving:touch];
@ -449,6 +451,8 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
}
}
#endif
#endif // !defined(SDL_PLATFORM_TVOS)
SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch];
SDL_TouchID touchId = [self touchIdForType:touchType];
float pressure = [self pressureForTouch:touch];