5 #pragma comment(lib, "sdl.lib")
6 #pragma comment(lib, "sdlmain.lib")
20 // =======================================================================
22 // =======================================================================
24 void Sys_Shutdown (void)
27 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
34 void Sys_Error (const char *error, ...)
37 char string[MAX_INPUTLINE];
39 // change stdin to non blocking
41 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
44 va_start (argptr,error);
45 dpvsnprintf (string, sizeof (string), error, argptr);
48 Con_Printf ("Quake Error: %s\n", string);
54 void Sys_PrintToTerminal(const char *text)
57 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
58 int origflags = fcntl (1, F_GETFL, 0);
59 fcntl (1, F_SETFL, origflags & ~FNDELAY);
65 int written = (int)write(1, text, (int)strlen(text));
67 break; // sorry, I cannot do anything about this error - without an output
71 fcntl (1, F_SETFL, origflags);
73 //fprintf(stdout, "%s", text);
76 char *Sys_ConsoleInput(void)
78 if (cls.state == ca_dedicated)
80 static char text[MAX_INPUTLINE];
111 if (len == sizeof (text))
116 struct timeval timeout;
118 FD_SET(0, &fdset); // stdin
121 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
123 len = read (0, text, sizeof(text));
126 // rip off the \n and terminate
136 char *Sys_GetClipboardData (void)
142 if (OpenClipboard (NULL) != 0)
144 HANDLE hClipboardData;
146 if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0)
148 if ((cliptext = (char *)GlobalLock (hClipboardData)) != 0)
151 allocsize = GlobalSize (hClipboardData) + 1;
152 data = (char *)Z_Malloc (allocsize);
153 strlcpy (data, cliptext, allocsize);
154 GlobalUnlock (hClipboardData);
165 void Sys_InitConsole (void)
169 int main (int argc, char *argv[])
171 signal(SIGFPE, SIG_IGN);
174 com_argv = (const char **)argv;
178 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
181 // we don't know which systems we'll want to init, yet...
189 qboolean sys_supportsdlgetticks = true;
190 unsigned int Sys_SDL_GetTicks (void)
192 return SDL_GetTicks();
194 void Sys_SDL_Delay (unsigned int milliseconds)
196 SDL_Delay(milliseconds);