From f0c03f833154852f5dcbd71606bac5d772775559 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 18 Nov 2001 22:08:24 +0000 Subject: [PATCH] minor cleanups of Sys_ConsoleInput. Cleaning it up properly will take more work, but this removes most of the redundant instantces. nq-sdl (or -sgl) -dedicated won't have console input, nor will dedicated servers that don't load a console plugin. --- libs/console/console.c | 7 +-- nq/source/sys_unix.c | 2 +- qw/source/cl_sys_sdl.c | 12 ----- qw/source/cl_sys_unix.c | 25 --------- qw/source/cl_sys_win.c | 114 ---------------------------------------- qw/source/sv_sys_unix.c | 2 +- 6 files changed, 3 insertions(+), 159 deletions(-) diff --git a/libs/console/console.c b/libs/console/console.c index e8b7ebe99..dd5c7b3b6 100644 --- a/libs/console/console.c +++ b/libs/console/console.c @@ -111,10 +111,5 @@ Con_ProcessInput (void) if (con_module) con_module->functions->console->pC_ProcessInput (); else - while (1) { - const char *cmd = Sys_ConsoleInput (); - if (!cmd) - break; - Cbuf_AddText (cmd); - } + Con_Printf ("no input for you\n"); } diff --git a/nq/source/sys_unix.c b/nq/source/sys_unix.c index b9d13e8c3..050c2c14b 100644 --- a/nq/source/sys_unix.c +++ b/nq/source/sys_unix.c @@ -126,7 +126,7 @@ Sys_ConsoleInput (void) len = read (0, text, sizeof (text)); if (len < 1) return NULL; - text[len - 1] = 0; // rip off the /n and terminate + text[len - 1] = 0; // rip off the \n and terminate return text; } diff --git a/qw/source/cl_sys_sdl.c b/qw/source/cl_sys_sdl.c index 3ce94d40e..68d85d454 100644 --- a/qw/source/cl_sys_sdl.c +++ b/qw/source/cl_sys_sdl.c @@ -130,18 +130,6 @@ Sys_DebugLog (const char *file, const char *fmt, ...) close (fd); }; -/* - Sys_ConsoleInput - - Checks for a complete line of text typed in at the console, then forwards - it to the host command processor -*/ -const char * -Sys_ConsoleInput (void) -{ - return NULL; -} - #ifndef USE_INTEL_ASM void Sys_HighFPPrecision (void) diff --git a/qw/source/cl_sys_unix.c b/qw/source/cl_sys_unix.c index a44f51810..ae4026631 100644 --- a/qw/source/cl_sys_unix.c +++ b/qw/source/cl_sys_unix.c @@ -113,31 +113,6 @@ floating_point_exception_handler (int whatever) signal (SIGFPE, floating_point_exception_handler); } -/* - Sys_ConsoleInput - - Checks for a complete line of text typed in at the console, then forwards - it to the host command processor -*/ -const char * -Sys_ConsoleInput (void) -{ -#if 0 - static char text[256]; - int len; - - if (cls.state == ca_dedicated) { - len = read (0, text, sizeof (text)); - if (len < 1) - return NULL; - text[len - 1] = 0; // rip off the /n and terminate - - return text; - } -#endif - return NULL; -} - #ifndef USE_INTEL_ASM void Sys_HighFPPrecision (void) diff --git a/qw/source/cl_sys_win.c b/qw/source/cl_sys_win.c index 9fbb887f9..ec8910144 100644 --- a/qw/source/cl_sys_win.c +++ b/qw/source/cl_sys_win.c @@ -154,120 +154,6 @@ Sys_DebugLog (const char *file, const char *fmt, ...) close (fd); }; -/* - Sys_ConsoleInput - - Checks for a complete line of text typed in at the console, then forwards - it to the host command processor -*/ -const char * -Sys_ConsoleInput (void) -{ - char *clipText, *textCopied; - static char text[256]; - int ch, i; // , count; - static int len; - DWORD numread, numevents, dummy; - HANDLE th; - INPUT_RECORD recs[1024]; - - for (;;) { - if (!GetNumberOfConsoleInputEvents (hinput, &numevents)) - Sys_Error ("Error getting # of console events"); - - if (numevents <= 0) - break; - - if (!ReadConsoleInput (hinput, recs, 1, &numread)) - Sys_Error ("Error reading console input"); - - if (numread != 1) - Sys_Error ("Couldn't read console input"); - - if (recs[0].EventType == KEY_EVENT) { - if (!recs[0].Event.KeyEvent.bKeyDown) { - ch = recs[0].Event.KeyEvent.uChar.AsciiChar; - - switch (ch) { - case '\r': - WriteFile (houtput, "\r\n", 2, &dummy, NULL); - - if (len) { - text[len] = 0; - len = 0; - return text; - } - break; - - case '\b': - WriteFile (houtput, "\b \b", 3, &dummy, NULL); - if (len) { - len--; - putch ('\b'); - } - break; - - default: - Con_Printf ("Stupid: %ld\n", - recs[0].Event.KeyEvent.dwControlKeyState); - if ( - ((ch == 'V' || ch == 'v') - && (recs[0].Event.KeyEvent. - dwControlKeyState & (LEFT_CTRL_PRESSED | - RIGHT_CTRL_PRESSED))) - || - ((recs - [0].Event.KeyEvent. - dwControlKeyState & SHIFT_PRESSED) - && (recs[0].Event.KeyEvent.wVirtualKeyCode == - VK_INSERT))) { - if (OpenClipboard (NULL)) { - th = GetClipboardData (CF_TEXT); - if (th) { - clipText = GlobalLock (th); - if (clipText) { - textCopied = - malloc (GlobalSize (th) + 1); - if (!textCopied) - Sys_Error ("Sys_ConsoleInput: " - "Memory Allocation Failure\n"); - strcpy (textCopied, clipText); - // Substitutes a NULL for every token - strtok (textCopied, "\n\r\b"); - i = strlen (textCopied); - if (i + len >= 256) - i = 256 - len; - if (i > 0) { - textCopied[i] = 0; - text[len] = 0; - strncat (text, textCopied, - sizeof (text) - - strlen (text)); - len += dummy; - WriteFile (houtput, textCopied, i, - &dummy, NULL); - } - free (textCopied); - } - GlobalUnlock (th); - } - CloseClipboard (); - } - } else if (ch >= ' ') { - WriteFile (houtput, &ch, 1, &dummy, NULL); - text[len] = ch; - len = (len + 1) & 0xff; - } - - break; - - } - } - } - } - return NULL; -} - void SleepUntilInput (int time) { diff --git a/qw/source/sv_sys_unix.c b/qw/source/sv_sys_unix.c index f99e56214..9cd7edc30 100644 --- a/qw/source/sv_sys_unix.c +++ b/qw/source/sv_sys_unix.c @@ -97,7 +97,7 @@ Sys_ConsoleInput (void) } if (len < 1) return NULL; - text[len - 1] = 0; // rip off the /n and terminate + text[len - 1] = 0; // rip off the \n and terminate return text; }