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.
This commit is contained in:
Bill Currie 2001-11-18 22:08:24 +00:00
parent 46835e79fe
commit f0c03f8331
6 changed files with 3 additions and 159 deletions

View file

@ -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");
}

View file

@ -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;
}

View file

@ -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)

View file

@ -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)

View file

@ -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)
{

View file

@ -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;
}