16 // =======================================================================
18 // =======================================================================
20 void Sys_Shutdown (void)
23 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
30 void Sys_Error (const char *error, ...)
35 // change stdin to non blocking
37 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
40 va_start (argptr,error);
41 dpvsnprintf (string, sizeof (string), error, argptr);
44 Con_Printf ("Quake Error: %s\n", string);
50 void Sys_PrintToTerminal(const char *text)
52 fprintf(stdout, "%s", text);
55 double Sys_DoubleTime (void)
57 static int first = true;
58 static double oldtime = 0.0, curtime = 0.0;
60 newtime = (double) SDL_GetTicks() / 1000.0;
69 if (newtime < oldtime)
71 // warn if it's significant
72 if (newtime - oldtime < -0.01)
73 Con_Printf("Sys_DoubleTime: time stepped backwards (went from %f to %f, difference %f)\n", oldtime, newtime, newtime - oldtime);
76 curtime += newtime - oldtime;
82 char *Sys_ConsoleInput(void)
84 if (cls.state == ca_dedicated)
86 static char text[256];
117 if (len == sizeof (text))
122 struct timeval timeout;
124 FD_SET(0, &fdset); // stdin
127 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
129 len = read (0, text, sizeof(text));
132 // rip off the \n and terminate
142 void Sys_Sleep(int milliseconds)
144 if (milliseconds < 1)
146 SDL_Delay(milliseconds);
149 char *Sys_GetClipboardData (void)
155 if (OpenClipboard (NULL) != 0)
157 HANDLE hClipboardData;
159 if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0)
161 if ((cliptext = GlobalLock (hClipboardData)) != 0)
163 data = malloc (GlobalSize(hClipboardData)+1);
164 strcpy (data, cliptext);
165 GlobalUnlock (hClipboardData);
176 void Sys_InitConsole (void)
180 void Sys_Init_Commands (void)
184 int main (int argc, char *argv[])
186 double frameoldtime, framenewtime;
188 signal(SIGFPE, SIG_IGN);
191 com_argv = (const char **)argv;
194 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
199 frameoldtime = Sys_DoubleTime () - 0.1;
202 // find time spent rendering last frame
203 framenewtime = Sys_DoubleTime ();
205 Host_Frame (framenewtime - frameoldtime);
207 frameoldtime = framenewtime;