Computer Chess Club Archives


Search

Terms

Messages

Subject: NT and stdin?

Author: Inmann Werner

Date: 03:11:19 11/03/99


Hello to all, "understanding" NT.

I am getting crazy in trying my program to get run under NT!!!!
Never done NT and not knowing it anyway.

I isolated the problem (hope so)

I read incoming "keystrokes" (Winboard) after detecting that there are
keystrokes in a loop with

getkey(charac)
int *charac;
{
int rr;
char bu[81];

NM2:
rr=read(fileno(stdin),&bu,1);
if (rr<=0) goto NM2;
*charac=bu[0];
return(0);
}

ok, a litte "crazy" code, but nice working with win95/98 and Linux.
But with NT, if do the loop calling getkey, the first character of each text is
always a "W"!!!!!!!

Example debug File
WO         or
W2E4
.....

to ask, if keystrokes are available I use the "simple" routine from crafty.
it should not change anything?!?!?


checkkey()
{
static int init = 0, pipe;
static HANDLE inh;
DWORD dw;

  if (!init)
  {
		init = 1;
		inh = GetStdHandle(STD_INPUT_HANDLE);
		pipe = !GetConsoleMode(inh, &dw);
		if (!pipe)
		{
			  SetConsoleMode(inh, dw & ~(ENABLE_MOUSE_INPUT|ENABLE_WINDOW_INPUT));
			  FlushConsoleInputBuffer(inh);
		}
  }

  if (pipe)
  {
		if (!PeekNamedPipe(inh, NULL, 0, NULL, &dw, NULL))
		{
		  return 0;
		}
		return(dw);
  }else
  {
		GetNumberOfConsoleInputEvents(inh, &dw);
		return dw <= 1 ? 0 : dw;
  }
  return(0);
}

*************************

any suggestion??
(I use Watcom C Compiler)

Werner




This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.