4 #pragma comment(lib, "sdl.lib")
5 #pragma comment(lib, "sdlmain.lib")
16 #include <android/log.h>
19 #define FNDELAY O_NDELAY
29 // =======================================================================
31 // =======================================================================
33 void Sys_Shutdown (void)
36 Sys_AllowProfiling(false);
39 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
46 void Sys_Error (const char *error, ...)
49 char string[MAX_INPUTLINE];
51 // change stdin to non blocking
53 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
56 va_start (argptr,error);
57 dpvsnprintf (string, sizeof (string), error, argptr);
60 Con_Printf ("Quake Error: %s\n", string);
67 void Sys_PrintToTerminal(const char *text)
70 if (developer.integer > 0)
72 __android_log_write(ANDROID_LOG_DEBUG, com_argv[0], text);
78 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
79 // this is because both go to /dev/tty by default!
81 int origflags = fcntl (outfd, F_GETFL, 0);
82 fcntl (outfd, F_SETFL, origflags & ~FNDELAY);
89 fs_offset_t written = (fs_offset_t)write(outfd, text, (int)strlen(text));
91 break; // sorry, I cannot do anything about this error - without an output
95 fcntl (outfd, F_SETFL, origflags);
98 //fprintf(stdout, "%s", text);
102 char *Sys_ConsoleInput(void)
104 // if (cls.state == ca_dedicated)
106 static char text[MAX_INPUTLINE];
137 if (len == sizeof (text))
142 struct timeval timeout;
144 FD_SET(0, &fdset); // stdin
147 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
149 len = read (0, text, sizeof(text));
152 // rip off the \n and terminate
162 char *Sys_GetClipboardData (void)
168 if (OpenClipboard (NULL) != 0)
170 HANDLE hClipboardData;
172 if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0)
174 if ((cliptext = (char *)GlobalLock (hClipboardData)) != 0)
177 allocsize = GlobalSize (hClipboardData) + 1;
178 data = (char *)Z_Malloc (allocsize);
179 strlcpy (data, cliptext, allocsize);
180 GlobalUnlock (hClipboardData);
191 void Sys_InitConsole (void)
195 int main (int argc, char *argv[])
197 signal(SIGFPE, SIG_IGN);
200 Sys_AllowProfiling(true);
204 com_argv = (const char **)argv;
207 // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
208 if(COM_CheckParm("-noterminal"))
210 // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
211 else if(COM_CheckParm("-stderr"))
217 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
220 // we don't know which systems we'll want to init, yet...
228 qboolean sys_supportsdlgetticks = true;
229 unsigned int Sys_SDL_GetTicks (void)
231 return SDL_GetTicks();
233 void Sys_SDL_Delay (unsigned int milliseconds)
235 SDL_Delay(milliseconds);