Update rcore_ios.c

This commit is contained in:
blueloveTH 2024-03-27 20:37:44 +08:00
parent e6afac85e6
commit e5ecddfe0e

View File

@ -301,15 +301,16 @@ Vector2 GetWindowScaleDPI(void)
// Set clipboard text content // Set clipboard text content
void SetClipboardText(const char *text) void SetClipboardText(const char *text)
{ {
TRACELOG(LOG_WARNING, "SetClipboardText() not implemented on target platform"); UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = [NSString stringWithUTF8String:text];
} }
// Get clipboard text content // Get clipboard text content
// NOTE: returned string is allocated and freed by GLFW
const char *GetClipboardText(void) const char *GetClipboardText(void)
{ {
TRACELOG(LOG_WARNING, "GetClipboardText() not implemented on target platform"); UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
return NULL; NSString *clipboard = pasteboard.string;
return clipboard.UTF8String;
} }
// Show mouse cursor // Show mouse cursor
@ -372,12 +373,8 @@ double GetTime(void)
// Ref: https://github.com/raysan5/raylib/issues/686 // Ref: https://github.com/raysan5/raylib/issues/686
void OpenURL(const char *url) void OpenURL(const char *url)
{ {
// Security check to (partially) avoid malicious code on target platform NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:url]];
if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character"); [[UIApplication sharedApplication] openURL:nsurl options:@{} completionHandler:nil];
else
{
TRACELOG(LOG_WARNING, "OpenURL() not implemented on target platform");
}
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -578,9 +575,8 @@ int InitPlatform(void)
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully"); TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully");
TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); TRACELOG(LOG_INFO, " > Render size: %i x %i", GetRenderWidth(), GetRenderHeight());
TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);
TRACELOG(LOG_INFO, " > GL: %s", glGetString(GL_VERSION));
TRACELOG(LOG_INFO, " > EGL: %s", eglQueryString(platform.device, EGL_VERSION)); TRACELOG(LOG_INFO, " > EGL: %s", eglQueryString(platform.device, EGL_VERSION));
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------