2 #include <io.h> // Include this BEFORE darkplaces.h because it uses strncpy which trips DP_STATIC_ASSERT
10 #include <android/log.h>
14 * Include this BEFORE darkplaces.h because it breaks wrapping
15 * _Static_assert. Cloudwalk has no idea how or why so don't ask.
19 #include "darkplaces.h"
23 #pragma comment(lib, "sdl2.lib")
24 #pragma comment(lib, "sdl2main.lib")
30 // =======================================================================
32 // =======================================================================
34 void Sys_Shutdown (void)
37 Sys_AllowProfiling(false);
40 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
46 // Sys_Error early in startup might screw with automated
47 // workflows or something if we show the dialog by default.
48 static qbool nocrashdialog = true;
49 void Sys_SDL_Dialog(const char *title, const char *string)
52 SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, string, NULL);
55 void Sys_Print(const char *text)
58 if (developer.integer > 0)
60 __android_log_write(ANDROID_LOG_DEBUG, sys.argv[0], text);
66 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
67 // this is because both go to /dev/tty by default!
69 int origflags = fcntl (sys.outfd, F_GETFL, 0);
70 fcntl (sys.outfd, F_SETFL, origflags & ~O_NONBLOCK);
77 fs_offset_t written = (fs_offset_t)write(sys.outfd, text, (int)strlen(text));
79 break; // sorry, I cannot do anything about this error - without an output
83 fcntl (sys.outfd, F_SETFL, origflags);
86 //fprintf(stdout, "%s", text);
90 char *Sys_GetClipboardData (void)
95 cliptext = SDL_GetClipboardText();
96 if (cliptext != NULL) {
98 allocsize = min(MAX_INPUTLINE, strlen(cliptext) + 1);
99 data = (char *)Z_Malloc (allocsize);
100 strlcpy (data, cliptext, allocsize);
107 void Sys_SDL_Init(void)
109 // we don't know which systems we'll want to init, yet...
111 Sys_Error("SDL_Init failed: %s\n", SDL_GetError());
113 // COMMANDLINEOPTION: sdl: -nocrashdialog disables "Engine Error" crash dialog boxes
114 if(!Sys_CheckParm("-nocrashdialog"))
115 nocrashdialog = false;
118 qbool sys_supportsdlgetticks = true;
119 unsigned int Sys_SDL_GetTicks (void)
121 return SDL_GetTicks();
123 void Sys_SDL_Delay (unsigned int milliseconds)
125 SDL_Delay(milliseconds);