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);
56 void Sys_PrintToTerminal(const char *text)
61 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
62 // this is because both go to /dev/tty by default!
64 int origflags = fcntl (outfd, F_GETFL, 0);
65 fcntl (outfd, F_SETFL, origflags & ~FNDELAY);
72 fs_offset_t written = (fs_offset_t)write(outfd, text, strlen(text));
74 break; // sorry, I cannot do anything about this error - without an output
78 fcntl (outfd, F_SETFL, origflags);
81 //fprintf(stdout, "%s", text);
84 char *Sys_ConsoleInput(void)
86 // if (cls.state == ca_dedicated)
88 static char text[MAX_INPUTLINE];
119 if (len == sizeof (text))
124 struct timeval timeout;
126 FD_SET(0, &fdset); // stdin
129 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
131 len = read (0, text, sizeof(text));
134 // rip off the \n and terminate
144 char *Sys_GetClipboardData (void)
150 if (OpenClipboard (NULL) != 0)
152 HANDLE hClipboardData;
154 if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0)
156 if ((cliptext = (char *)GlobalLock (hClipboardData)) != 0)
159 allocsize = GlobalSize (hClipboardData) + 1;
160 data = (char *)Z_Malloc (allocsize);
161 strlcpy (data, cliptext, allocsize);
162 GlobalUnlock (hClipboardData);
173 void Sys_InitConsole (void)
177 int main (int argc, char *argv[])
179 signal(SIGFPE, SIG_IGN);
182 com_argv = (const char **)argv;
185 // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
186 if(COM_CheckParm("-noterminal"))
188 // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
189 else if(COM_CheckParm("-stderr"))
195 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
198 // we don't know which systems we'll want to init, yet...
206 qboolean sys_supportsdlgetticks = true;
207 unsigned int Sys_SDL_GetTicks (void)
209 return SDL_GetTicks();
211 void Sys_SDL_Delay (unsigned int milliseconds)
213 SDL_Delay(milliseconds);