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) { ...@@ -128,24 +128,58 @@ int kbwait(void) {
return(FALSE); return(FALSE);
} }
int inkey(int mode) #ifdef _WIN32
int inkey()
{ {
int c; char str[128];
INPUT_RECORD input;
DWORD num=0;
if(mode) while(1) {
return(kbwait()); if(!ReadConsoleInput(GetStdHandle(STD_INPUT_HANDLE), &input, 1, &num)
c=getch(); || !num || input.EventType!=KEY_EVENT)
#ifdef _WIN32 continue;
if(!c)
c=(getch()<<8); 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 #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 uifcini32(uifcapi_t* uifcapi)
{ {
int i; int i;
struct text_info txtinfo; struct text_info txtinfo;
#ifdef _WIN32
DWORD conmode;
#endif
if(uifcapi==NULL || uifcapi->size!=sizeof(uifcapi_t)) if(uifcapi==NULL || uifcapi->size!=sizeof(uifcapi_t))
return(-1); return(-1);
...@@ -216,6 +250,9 @@ int uifcini32(uifcapi_t* uifcapi) ...@@ -216,6 +250,9 @@ int uifcini32(uifcapi_t* uifcapi)
textmode(C80); /* set mode to 80x25*/ textmode(C80); /* set mode to 80x25*/
gettextinfo(&txtinfo); gettextinfo(&txtinfo);
} }
if(GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &conmode))
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), conmode&=~ENABLE_PROCESSED_INPUT);
#endif #endif
api->scrn_len=txtinfo.screenheight; api->scrn_len=txtinfo.screenheight;
...@@ -680,8 +717,8 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar ...@@ -680,8 +717,8 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
#endif #endif
timedisplay(); timedisplay();
i=0; i=0;
if(inkey(1)) { if(kbwait()) {
i=inkey(0); i=inkey();
if(i==KEY_BACKSPACE || i==BS) if(i==KEY_BACKSPACE || i==BS)
i=ESC; i=ESC;
if(i>255) { if(i>255) {
...@@ -1336,11 +1373,11 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int ...@@ -1336,11 +1373,11 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
} }
strcpy(str,outstr); strcpy(str,outstr);
#if 0 #if 0
while(inkey(1)==0) { while(kbwait()==0) {
mswait(1); mswait(1);
} }
#endif #endif
f=inkey(0); f=inkey();
if(f == CR if(f == CR
|| (f >= 0xff && f != KEY_DC) || (f >= 0xff && f != KEY_DC)
...@@ -1364,12 +1401,12 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int ...@@ -1364,12 +1401,12 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
if(i>j) j=i; if(i>j) j=i;
str[j]=0; str[j]=0;
getstrupd(left, top, width, str, i, &soffset); getstrupd(left, top, width, str, i, &soffset);
if(f || inkey(1)) if(f || kbwait())
{ {
if(f) if(f)
ch=f; ch=f;
else else
ch=inkey(0); ch=inkey();
if(lastkey != NULL) if(lastkey != NULL)
*lastkey=ch; *lastkey=ch;
f=0; f=0;
...@@ -1903,8 +1940,8 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch ...@@ -1903,8 +1940,8 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
else { else {
while(i==0) { while(i==0) {
puttext(left+1+pad,top+2+pad,left+width-2-pad,top+height-1-pad,p); puttext(left+1+pad,top+2+pad,left+width-2-pad,top+height-1-pad,p);
if(inkey(1)) { if(kbwait()) {
switch(inkey(0)) { switch(inkey()) {
case KEY_HOME: /* home */ case KEY_HOME: /* home */
p=textbuf; p=textbuf;
break; 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