4 #pragma comment(lib, "sdl.lib")
5 #pragma comment(lib, "sdlmain.lib")
18 // =======================================================================
20 // =======================================================================
22 void Sys_Shutdown (void)
25 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
32 void Sys_Error (const char *error, ...)
35 char string[MAX_INPUTLINE];
37 // change stdin to non blocking
39 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
42 va_start (argptr,error);
43 dpvsnprintf (string, sizeof (string), error, argptr);
46 Con_Printf ("Quake Error: %s\n", string);
52 void Sys_PrintToTerminal(const char *text)
55 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
56 int origflags = fcntl (1, F_GETFL, 0);
57 fcntl (1, F_SETFL, origflags & ~FNDELAY);
63 int written = (int)write(1, text, (int)strlen(text));
65 break; // sorry, I cannot do anything about this error - without an output
69 fcntl (1, F_SETFL, origflags);
71 //fprintf(stdout, "%s", text);
74 char *Sys_ConsoleInput(void)
76 if (cls.state == ca_dedicated)
78 static char text[MAX_INPUTLINE];
109 if (len == sizeof (text))
114 struct timeval timeout;
116 FD_SET(0, &fdset); // stdin
119 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
121 len = read (0, text, sizeof(text));
124 // rip off the \n and terminate
134 char *Sys_GetClipboardData (void)
140 if (OpenClipboard (NULL) != 0)
142 HANDLE hClipboardData;
144 if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0)
146 if ((cliptext = (char *)GlobalLock (hClipboardData)) != 0)
149 allocsize = GlobalSize (hClipboardData) + 1;
150 data = (char *)Z_Malloc (allocsize);
151 strlcpy (data, cliptext, allocsize);
152 GlobalUnlock (hClipboardData);
163 void Sys_InitConsole (void)
167 int main (int argc, char *argv[])
169 signal(SIGFPE, SIG_IGN);
172 com_argv = (const char **)argv;
176 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
179 // we don't know which systems we'll want to init, yet...
187 qboolean sys_supportsdlgetticks = true;
188 unsigned int Sys_SDL_GetTicks (void)
190 return SDL_GetTicks();
192 void Sys_SDL_Delay (unsigned int milliseconds)
194 SDL_Delay(milliseconds);