From bb2d24b0811c66872999ad0c6e84d2b1db3f4819 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Tue, 12 Oct 2004 16:21:22 +0000 Subject: [PATCH] small keyboard fix. typerate handling (Moe) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2022 --- src/hardware/keyboard.cpp | 17 ++++++++++++++--- src/ints/bios_keyboard.cpp | 12 ++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/hardware/keyboard.cpp b/src/hardware/keyboard.cpp index 203d8bca..9ebbfeae 100644 --- a/src/hardware/keyboard.cpp +++ b/src/hardware/keyboard.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: keyboard.cpp,v 1.28 2004-09-10 22:15:20 harekiet Exp $ */ +/* $Id: keyboard.cpp,v 1.29 2004-10-12 16:21:22 qbix79 Exp $ */ #include #include @@ -136,7 +136,7 @@ static void write_p60(Bitu port,Bitu val,Bitu iolen) { break; case 0xf5: /* Reset keyboard and disable scanning */ LOG(LOG_KEYBOARD,LOG_NORMAL)("Reset, disable scanning"); - keyb.scanning=false; + keyb.scanning=false; KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ break; case 0xf6: /* Reset keyboard and enable scanning */ @@ -153,7 +153,18 @@ static void write_p60(Bitu port,Bitu val,Bitu iolen) { case CMD_SETOUTPORT: MEM_A20_Enable((val & 2)>0); break; - case CMD_SETTYPERATE: + case CMD_SETTYPERATE: + { + static const int delay[] = { 250, 500, 750, 1000 }; + static const int repeat[] = + { 33,37,42,46,50,54,58,63,67,75,83,92,100, + 109,118,125,133,149,167,182,200,217,233, + 250,270,303,333,370,400,435,476,500 }; + keyb.repeat.pause = delay[(val>>5)&3]; + keyb.repeat.rate = repeat[val&0x1f]; + keyb.command=CMD_NONE; + } + /* Fallthrough! as setleds does what we want */ case CMD_SETLEDS: keyb.command=CMD_NONE; KEYBOARD_ClrBuffer(); diff --git a/src/ints/bios_keyboard.cpp b/src/ints/bios_keyboard.cpp index 581adcfd..8e30c843 100644 --- a/src/ints/bios_keyboard.cpp +++ b/src/ints/bios_keyboard.cpp @@ -400,11 +400,19 @@ static Bitu INT16_Handler(void) { reg_al=mem_readb(BIOS_KEYBOARD_FLAGS1); break; case 0x03: /* SET TYPEMATIC RATE AND DELAY */ - LOG(LOG_BIOS,LOG_ERROR)("INT16:Unhandled Typematic Rate Call %2X BX=%X",reg_al,reg_bx); + if (reg_al == 0x00) { // set default delay and rate + IO_Write(0x60,0xf3); + IO_Write(0x60,0x20); // 500 msec delay, 30 cps + } else if (reg_al == 0x05) { // set repeat rate and delay + IO_Write(0x60,0xf3); + IO_Write(0x60,(reg_bh&3)<<5|(reg_bl&0x1f)); + } else { + LOG(LOG_BIOS,LOG_ERROR)("INT16:Unhandled Typematic Rate Call %2X BX=%X",reg_al,reg_bx); + } break; case 0x05: /* STORE KEYSTROKE IN KEYBOARD BUFFER */ //TODO make add_key bool :) - add_key(reg_ax); + add_key(reg_cx); reg_al=0; break; case 0x12: /* GET EXTENDED SHIFT STATES */