4 #pragma comment(lib, "sdl.lib")
5 #pragma comment(lib, "sdlmain.lib")
21 // =======================================================================
23 // =======================================================================
25 void Sys_Shutdown (void)
28 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
35 void Sys_Error (const char *error, ...)
38 char string[MAX_INPUTLINE];
40 // change stdin to non blocking
42 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
45 va_start (argptr,error);
46 dpvsnprintf (string, sizeof (string), error, argptr);
49 Con_Printf ("Quake Error: %s\n", string);
55 void Sys_PrintToTerminal(const char *text)
58 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
59 int origflags = fcntl (1, F_GETFL, 0);
60 fcntl (1, F_SETFL, origflags & ~FNDELAY);
66 int written = (int)write(1, text, (int)strlen(text));
68 break; // sorry, I cannot do anything about this error - without an output
72 fcntl (1, F_SETFL, origflags);
74 //fprintf(stdout, "%s", text);
77 char *Sys_ConsoleInput(void)
79 if (cls.state == ca_dedicated)
81 static char text[MAX_INPUTLINE];
112 if (len == sizeof (text))
117 struct timeval timeout;
119 FD_SET(0, &fdset); // stdin
122 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
124 len = read (0, text, sizeof(text));
127 // rip off the \n and terminate
137 char *Sys_GetClipboardData (void)
143 if (OpenClipboard (NULL) != 0)
145 HANDLE hClipboardData;
147 if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0)
149 if ((cliptext = (char *)GlobalLock (hClipboardData)) != 0)
152 allocsize = GlobalSize (hClipboardData) + 1;
153 data = (char *)Z_Malloc (allocsize);
154 strlcpy (data, cliptext, allocsize);
155 GlobalUnlock (hClipboardData);
166 void Sys_InitConsole (void)
170 int main (int argc, char *argv[])
172 signal(SIGFPE, SIG_IGN);
175 com_argv = (const char **)argv;
179 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
182 // we don't know which systems we'll want to init, yet...
190 qboolean sys_supportsdlgetticks = true;
191 unsigned int Sys_SDL_GetTicks (void)
193 return SDL_GetTicks();
195 void Sys_SDL_Delay (unsigned int milliseconds)
197 SDL_Delay(milliseconds);