Let Int09 routines remember a keystroke's ASCII code, if available.

This commit is contained in:
Ove Kaaven 2000-07-29 11:30:28 +00:00 committed by Alexandre Julliard
parent eba5752f3a
commit a9c19f0710
4 changed files with 27 additions and 15 deletions

View File

@ -174,8 +174,8 @@ extern void IO_outport( int port, int count, DWORD value );
/* msdos/int09.c */ /* msdos/int09.c */
extern void WINAPI INT_Int09Handler(CONTEXT86*); extern void WINAPI INT_Int09Handler(CONTEXT86*);
extern void WINAPI INT_Int09SendScan(BYTE); extern void WINAPI INT_Int09SendScan(BYTE scan,BYTE ascii);
extern BYTE WINAPI INT_Int09ReadScan(void); extern BYTE WINAPI INT_Int09ReadScan(BYTE*ascii);
/* msdos/int10.c */ /* msdos/int10.c */
extern void WINAPI INT_Int10Handler(CONTEXT86*); extern void WINAPI INT_Int10Handler(CONTEXT86*);

View File

@ -341,9 +341,9 @@ void DOSVM_ProcessMessage(LPDOSTASK lpDosTask,MSG *msg)
/* FIXME: some keys (function keys) have /* FIXME: some keys (function keys) have
* extended bit set even when they shouldn't, * extended bit set even when they shouldn't,
* should check for them */ * should check for them */
INT_Int09SendScan(0xE0); INT_Int09SendScan(0xE0,0);
} }
INT_Int09SendScan(scan); INT_Int09SendScan(scan,0);
break; break;
} }
} }

View File

@ -15,7 +15,7 @@
DEFAULT_DEBUG_CHANNEL(int) DEFAULT_DEBUG_CHANNEL(int)
typedef struct { typedef struct {
BYTE queuelen,queue[15]; BYTE queuelen,queue[15],ascii[15];
} KBDSYSTEM; } KBDSYSTEM;
/********************************************************************** /**********************************************************************
@ -25,15 +25,21 @@ typedef struct {
*/ */
void WINAPI INT_Int09Handler( CONTEXT86 *context ) void WINAPI INT_Int09Handler( CONTEXT86 *context )
{ {
BYTE scan = INT_Int09ReadScan(); BYTE ascii, scan = INT_Int09ReadScan(&ascii);
UINT vkey = MapVirtualKeyA(scan&0x7f, 1); UINT vkey = MapVirtualKeyA(scan&0x7f, 1);
BYTE ch[2]; BYTE ch[2];
int cnt, c2; int cnt, c2;
TRACE("scan=%02x\n",scan); TRACE("scan=%02x\n",scan);
if (!(scan & 0x80)) { if (!(scan & 0x80)) {
/* as in TranslateMessage, windows/input.c */ if (ascii) {
cnt = ToAscii(vkey, scan, QueueKeyStateTable, (LPWORD)ch, 0); /* 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) { if (cnt>0) {
for (c2=0; c2<cnt; c2++) for (c2=0; c2<cnt; c2++)
INT_Int16AddChar(ch[c2], scan); INT_Int16AddChar(ch[c2], scan);
@ -56,12 +62,14 @@ static void KbdRelay( LPDOSTASK lpDosTask, CONTEXT86 *context, void *data )
* we'll remove current scancode from keyboard buffer here, * we'll remove current scancode from keyboard buffer here,
* rather than in ReadScan, because some DOS apps depend on * rather than in ReadScan, because some DOS apps depend on
* the scancode being available for reading multiple times... */ * the scancode being available for reading multiple times... */
if (--sys->queuelen) if (--sys->queuelen) {
memmove(sys->queue,sys->queue+1,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); KBDSYSTEM *sys = (KBDSYSTEM *)DOSVM_GetSystemData(0x09);
if (!sys) { if (!sys) {
@ -69,16 +77,20 @@ void WINAPI INT_Int09SendScan( BYTE scan )
DOSVM_SetSystemData(0x09,sys); DOSVM_SetSystemData(0x09,sys);
} }
/* add scancode to queue */ /* 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) */ /* tell app to read it by triggering IRQ 1 (int 09) */
DOSVM_QueueEvent(1,DOS_PRIORITY_KEYBOARD,KbdRelay,NULL); 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); KBDSYSTEM *sys = (KBDSYSTEM *)DOSVM_GetSystemData(0x09);
if (sys) if (sys) {
if (ascii) *ascii = sys->ascii[0];
return sys->queue[0]; return sys->queue[0];
else } else {
if (ascii) *ascii = 0;
return 0; return 0;
}
} }

View File

@ -324,7 +324,7 @@ DWORD IO_inport( int port, int size )
break; break;
} }
case 0x60: case 0x60:
res = INT_Int09ReadScan(); res = INT_Int09ReadScan(NULL);
#if 0 /* what's this port got to do with parport ? */ #if 0 /* what's this port got to do with parport ? */
res = (DWORD)parport_8255[0]; res = (DWORD)parport_8255[0];
#endif #endif