Commit a2fed57c authored by rswindell's avatar rswindell
Browse files

Changed usage of inkey() - no need to model bioskey().

inkey() is now just a macro for getch() on non-Win32 platforms.
Win32 inkey() implementation now uses ReadConsoleInput() instead of getch() in
an attempt to support ex-ASCII input.
Win32 uifcini32() now disables Ctrl-C handling by the OS (processed input).
parent f3e295ce
......@@ -128,24 +128,58 @@ int kbwait(void) {
return(FALSE);
}
int inkey(int mode)
#ifdef _WIN32
int inkey()
{
int c;
char str[128];
INPUT_RECORD input;
DWORD num=0;
if(mode)
return(kbwait());
c=getch();
#ifdef _WIN32
if(!c)
c=(getch()<<8);
while(1) {
if(!ReadConsoleInput(GetStdHandle(STD_INPUT_HANDLE), &input, 1, &num)
|| !num || input.EventType!=KEY_EVENT)
continue;
if(!input.Event.KeyEvent.bKeyDown)
continue;
#if 0
sprintf(str,"keydown=%d\n",input.Event.KeyEvent.bKeyDown);
OutputDebugString(str);
sprintf(str,"repeat=%d\n",input.Event.KeyEvent.wRepeatCount);
OutputDebugString(str);
sprintf(str,"keycode=%x\n",input.Event.KeyEvent.wVirtualKeyCode);
OutputDebugString(str);
sprintf(str,"scancode=%x\n",input.Event.KeyEvent.wVirtualScanCode);
OutputDebugString(str);
sprintf(str,"ascii=%d\n",input.Event.KeyEvent.uChar.AsciiChar);
OutputDebugString(str);
sprintf(str,"dwControlKeyState=%lx\n",input.Event.KeyEvent.dwControlKeyState);
OutputDebugString(str);
#endif
return(c);
if(input.Event.KeyEvent.uChar.AsciiChar)
return(input.Event.KeyEvent.uChar.AsciiChar);
return(input.Event.KeyEvent.wVirtualScanCode<<8);
}
return(0);
}
#else
#define inkey() getch()
#endif
int uifcini32(uifcapi_t* uifcapi)
{
int i;
struct text_info txtinfo;
#ifdef _WIN32
DWORD conmode;
#endif
if(uifcapi==NULL || uifcapi->size!=sizeof(uifcapi_t))
return(-1);
......@@ -216,6 +250,9 @@ int uifcini32(uifcapi_t* uifcapi)
textmode(C80); /* set mode to 80x25*/
gettextinfo(&txtinfo);
}
if(GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &conmode))
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), conmode&=~ENABLE_PROCESSED_INPUT);
#endif
api->scrn_len=txtinfo.screenheight;
......@@ -680,8 +717,8 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
#endif
timedisplay();
i=0;
if(inkey(1)) {
i=inkey(0);
if(kbwait()) {
i=inkey();
if(i==KEY_BACKSPACE || i==BS)
i=ESC;
if(i>255) {
......@@ -1336,11 +1373,11 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
}
strcpy(str,outstr);
#if 0
while(inkey(1)==0) {
while(kbwait()==0) {
mswait(1);
}
#endif
f=inkey(0);
f=inkey();
if(f == CR
|| (f >= 0xff && f != KEY_DC)
......@@ -1364,12 +1401,12 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
if(i>j) j=i;
str[j]=0;
getstrupd(left, top, width, str, i, &soffset);
if(f || inkey(1))
if(f || kbwait())
{
if(f)
ch=f;
else
ch=inkey(0);
ch=inkey();
if(lastkey != NULL)
*lastkey=ch;
f=0;
......@@ -1903,8 +1940,8 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
else {
while(i==0) {
puttext(left+1+pad,top+2+pad,left+width-2-pad,top+height-1-pad,p);
if(inkey(1)) {
switch(inkey(0)) {
if(kbwait()) {
switch(inkey()) {
case KEY_HOME: /* home */
p=textbuf;
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment