From a9c19f0710bbd4578681716c7fb53cba1e348444 Mon Sep 17 00:00:00 2001 From: Ove Kaaven Date: Sat, 29 Jul 2000 11:30:28 +0000 Subject: [PATCH] Let Int09 routines remember a keystroke's ASCII code, if available. --- include/miscemu.h | 4 ++-- loader/dos/dosvm.c | 4 ++-- msdos/int09.c | 32 ++++++++++++++++++++++---------- msdos/ioports.c | 2 +- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/include/miscemu.h b/include/miscemu.h index cd9482b612..7be24a6730 100644 --- a/include/miscemu.h +++ b/include/miscemu.h @@ -174,8 +174,8 @@ extern void IO_outport( int port, int count, DWORD value ); /* msdos/int09.c */ extern void WINAPI INT_Int09Handler(CONTEXT86*); -extern void WINAPI INT_Int09SendScan(BYTE); -extern BYTE WINAPI INT_Int09ReadScan(void); +extern void WINAPI INT_Int09SendScan(BYTE scan,BYTE ascii); +extern BYTE WINAPI INT_Int09ReadScan(BYTE*ascii); /* msdos/int10.c */ extern void WINAPI INT_Int10Handler(CONTEXT86*); diff --git a/loader/dos/dosvm.c b/loader/dos/dosvm.c index 7ccefa4352..34851e4d3f 100644 --- a/loader/dos/dosvm.c +++ b/loader/dos/dosvm.c @@ -341,9 +341,9 @@ void DOSVM_ProcessMessage(LPDOSTASK lpDosTask,MSG *msg) /* FIXME: some keys (function keys) have * extended bit set even when they shouldn't, * should check for them */ - INT_Int09SendScan(0xE0); + INT_Int09SendScan(0xE0,0); } - INT_Int09SendScan(scan); + INT_Int09SendScan(scan,0); break; } } diff --git a/msdos/int09.c b/msdos/int09.c index 34e440d57c..0ed10dc27c 100644 --- a/msdos/int09.c +++ b/msdos/int09.c @@ -15,7 +15,7 @@ DEFAULT_DEBUG_CHANNEL(int) typedef struct { - BYTE queuelen,queue[15]; + BYTE queuelen,queue[15],ascii[15]; } KBDSYSTEM; /********************************************************************** @@ -25,15 +25,21 @@ typedef struct { */ void WINAPI INT_Int09Handler( CONTEXT86 *context ) { - BYTE scan = INT_Int09ReadScan(); + BYTE ascii, scan = INT_Int09ReadScan(&ascii); UINT vkey = MapVirtualKeyA(scan&0x7f, 1); BYTE ch[2]; int cnt, c2; TRACE("scan=%02x\n",scan); if (!(scan & 0x80)) { - /* as in TranslateMessage, windows/input.c */ - cnt = ToAscii(vkey, scan, QueueKeyStateTable, (LPWORD)ch, 0); + if (ascii) { + /* we already have an ASCII code, no translation necessary */ + ch[0] = ascii; + cnt = 1; + } else { + /* as in TranslateMessage, windows/input.c */ + cnt = ToAscii(vkey, scan, QueueKeyStateTable, (LPWORD)ch, 0); + } if (cnt>0) { for (c2=0; c2queuelen) + if (--sys->queuelen) { memmove(sys->queue,sys->queue+1,sys->queuelen); + memmove(sys->ascii,sys->ascii+1,sys->queuelen); + } } } -void WINAPI INT_Int09SendScan( BYTE scan ) +void WINAPI INT_Int09SendScan( BYTE scan, BYTE ascii ) { KBDSYSTEM *sys = (KBDSYSTEM *)DOSVM_GetSystemData(0x09); if (!sys) { @@ -69,16 +77,20 @@ void WINAPI INT_Int09SendScan( BYTE scan ) DOSVM_SetSystemData(0x09,sys); } /* add scancode to queue */ - sys->queue[sys->queuelen++] = scan; + sys->queue[sys->queuelen] = scan; + sys->ascii[sys->queuelen++] = ascii; /* tell app to read it by triggering IRQ 1 (int 09) */ DOSVM_QueueEvent(1,DOS_PRIORITY_KEYBOARD,KbdRelay,NULL); } -BYTE WINAPI INT_Int09ReadScan( void ) +BYTE WINAPI INT_Int09ReadScan( BYTE*ascii ) { KBDSYSTEM *sys = (KBDSYSTEM *)DOSVM_GetSystemData(0x09); - if (sys) + if (sys) { + if (ascii) *ascii = sys->ascii[0]; return sys->queue[0]; - else + } else { + if (ascii) *ascii = 0; return 0; + } } diff --git a/msdos/ioports.c b/msdos/ioports.c index 24d01342ae..a965d02fb0 100644 --- a/msdos/ioports.c +++ b/msdos/ioports.c @@ -324,7 +324,7 @@ DWORD IO_inport( int port, int size ) break; } case 0x60: - res = INT_Int09ReadScan(); + res = INT_Int09ReadScan(NULL); #if 0 /* what's this port got to do with parport ? */ res = (DWORD)parport_8255[0]; #endif