diff --git a/CHANGELOG b/CHANGELOG index c10b2ad8f..030da4c7a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -60,6 +60,11 @@ interfaces are adjusted accordingly too. (Wengier) - Config option "usescancodes=auto" now implies false for PC-98 mode in SDL1 builds. (Wengier) + - Config option "pc-98 force ibm keyboard layout" now + defaults to "auto", which implies "true" if a U.S. + keyboard layout is detected and implies "false" + otherwise. Also fixed some input keys for the PC-98 + mode. (Wengier & maron2000) - For PC-98 mode, if both FONT.ROM and FREECG98.BMP are not found in the directory, then DOSBox-X will now use internal Japanese font (also used by DOS/V diff --git a/contrib/windows/installer/dosbox-x.reference.setup.conf b/contrib/windows/installer/dosbox-x.reference.setup.conf index 53e6aef53..14ed32cc0 100644 --- a/contrib/windows/installer/dosbox-x.reference.setup.conf +++ b/contrib/windows/installer/dosbox-x.reference.setup.conf @@ -619,6 +619,7 @@ monochrome_pal = green #DOSBOX-X-ADV:# 1: Enable # pc-98 force ibm keyboard layout: Force to use a default keyboard layout like IBM US-English for PC-98 emulation. # Will only work with apps and games using BIOS for keyboard. +# Possible values: true, false, 1, 0, auto. #DOSBOX-X-ADV:# pc-98 show graphics layer on initialize: If PC-98 mode and INT 33h emulation is enabled, the graphics layer will be automatically enabled #DOSBOX-X-ADV:# at driver startup AND when INT 33h AX=0 is called. This is NEC MOUSE.COM behavior and default #DOSBOX-X-ADV:# enabled. To emulate other drivers like QMOUSE that do not follow this behavior, set to false. @@ -648,7 +649,7 @@ pc-98 bus mouse = true #DOSBOX-X-ADV:pc-98 timer always cycles = auto #DOSBOX-X-ADV:pc-98 timer master frequency = 0 #DOSBOX-X-ADV:pc-98 allow 4 display partition graphics = -1 -pc-98 force ibm keyboard layout = false +pc-98 force ibm keyboard layout = auto #DOSBOX-X-ADV:pc-98 show graphics layer on initialize = true [dosv] diff --git a/dosbox-x.reference.conf b/dosbox-x.reference.conf index f4b4bdb5e..a7c9988f6 100644 --- a/dosbox-x.reference.conf +++ b/dosbox-x.reference.conf @@ -277,6 +277,7 @@ monochrome_pal = green # pc-98 bus mouse: Enable PC-98 bus mouse emulation. Disabling this option does not disable INT 33h emulation. # pc-98 force ibm keyboard layout: Force to use a default keyboard layout like IBM US-English for PC-98 emulation. # Will only work with apps and games using BIOS for keyboard. +# Possible values: true, false, 1, 0, auto. # # Advanced options (see full configuration reference file [dosbox-x.reference.full.conf] for more details): # -> pc-98 int 1b fdc timer wait; pc-98 pic init to read isr; pc-98 fm board irq; pc-98 fm board io port; pc-98 sound bios; pc-98 load sound bios rom file; pc-98 buffer page flip; pc-98 enable 256-color planar; pc-98 enable 188 user cg; pc-98 start gdc at 5mhz; pc-98 allow scanline effect; pc-98 video mode; pc-98 timer always cycles; pc-98 timer master frequency; pc-98 allow 4 display partition graphics; pc-98 show graphics layer on initialize @@ -288,7 +289,7 @@ pc-98 enable 16-color = true pc-98 enable grcg = true pc-98 enable egc = true pc-98 bus mouse = true -pc-98 force ibm keyboard layout = false +pc-98 force ibm keyboard layout = auto [dosv] # dosv: Enable DOS/V emulation and specify which version to emulate. This option is intended for diff --git a/dosbox-x.reference.full.conf b/dosbox-x.reference.full.conf index a6b469ac2..a8fabaf3a 100644 --- a/dosbox-x.reference.full.conf +++ b/dosbox-x.reference.full.conf @@ -603,6 +603,7 @@ monochrome_pal = green # 1: Enable # pc-98 force ibm keyboard layout: Force to use a default keyboard layout like IBM US-English for PC-98 emulation. # Will only work with apps and games using BIOS for keyboard. +# Possible values: true, false, 1, 0, auto. # pc-98 show graphics layer on initialize: If PC-98 mode and INT 33h emulation is enabled, the graphics layer will be automatically enabled # at driver startup AND when INT 33h AX=0 is called. This is NEC MOUSE.COM behavior and default # enabled. To emulate other drivers like QMOUSE that do not follow this behavior, set to false. @@ -628,7 +629,7 @@ pc-98 video mode = pc-98 timer always cycles = auto pc-98 timer master frequency = 0 pc-98 allow 4 display partition graphics = -1 -pc-98 force ibm keyboard layout = false +pc-98 force ibm keyboard layout = auto pc-98 show graphics layer on initialize = true [dosv] diff --git a/src/dosbox.cpp b/src/dosbox.cpp index 66371d706..12c0dd715 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -1992,10 +1992,11 @@ void DOSBOX_SetupConfigSections(void) { " 0: Disable\n" " 1: Enable"); - Pbool = secprop->Add_bool("pc-98 force ibm keyboard layout",Property::Changeable::WhenIdle,false); - Pbool->Set_help("Force to use a default keyboard layout like IBM US-English for PC-98 emulation.\n" + Pstring = secprop->Add_string("pc-98 force ibm keyboard layout",Property::Changeable::WhenIdle,"auto"); + Pstring->Set_values(truefalseautoopt); + Pstring->Set_help("Force to use a default keyboard layout like IBM US-English for PC-98 emulation.\n" "Will only work with apps and games using BIOS for keyboard."); - Pbool->SetBasic(true); + Pstring->SetBasic(true); /* Explanation: NEC's mouse driver MOUSE.COM enables the graphics layer on startup and when INT 33h AX=0 is called. * Some games by "Orange House" assume this behavior and do not make any effort on their diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 806e05d74..fe6a9792b 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -1121,6 +1121,15 @@ void KeyboardLayoutDetect(void) { LOG_MSG("Host keyboard layout is now %s (%s)", DKM_to_string(host_keyboard_layout), DKM_to_descriptive_string(host_keyboard_layout)); + + if (IS_PC98_ARCH) { + Section_prop * pc98_section = static_cast(control->GetSection("pc98")); + const char *layoutstr = pc98_section->Get_string("pc-98 force ibm keyboard layout"); + if (!strcasecmp(layoutstr, "auto")) { + pc98_force_ibm_layout = host_keyboard_layout == DKM_US; + mainMenu.get_item("pc98_use_uskb").check(pc98_force_ibm_layout).refresh_item(mainMenu); + } + } } void SetMapperKeyboardLayout(const unsigned int dkm) { diff --git a/src/hardware/keyboard.cpp b/src/hardware/keyboard.cpp index 5bf539ddf..dd735042a 100644 --- a/src/hardware/keyboard.cpp +++ b/src/hardware/keyboard.cpp @@ -34,6 +34,7 @@ #include #include "8255.h" #include "jfont.h" +#include "keymap.h" #if defined(_MSC_VER) # pragma warning(disable:4244) /* const fmath::local::uint64_t to double possible loss of data */ @@ -51,7 +52,9 @@ static void KEYBOARD_SetPort60(uint16_t val); void KEYBOARD_AddBuffer(uint16_t data); static void KEYBOARD_Add8042Response(uint8_t data); void KEYBOARD_SetLEDs(uint8_t bits); +void KeyboardLayoutDetect(void); +extern unsigned int host_keyboard_layout; bool enable_pc98_bus_mouse = true; static unsigned int aux_warning = 0; @@ -1253,9 +1256,9 @@ void KEYBOARD_PC98_AddKey(KBD_KEYS keytype,bool pressed) { case KBD_o: ret=0x18;break; // o O ラ case KBD_p: ret=0x19;break; // p P セ case KBD_atsign: ret=0x1A;break; // @ ~ ゙ - case KBD_leftbracket: ret=0x1A;break; // @ ~ ゙ - case KBD_rightbracket: ret=0x1B;break; // [ { ゚ 「 - case KBD_enter: ret=0x1C; break; // ENTER/RETURN + case KBD_leftbracket: ret=pc98_force_ibm_layout?0x1B:0x1A;break; // @ ~ ゙ + case KBD_rightbracket: ret=pc98_force_ibm_layout?0x28:0x1B;break; // [ { ゚ 「 / ] } ム 」 + case KBD_enter: ret=0x1C;break; // ENTER/RETURN case KBD_kpenter: ret=0x1C;break; // ENTER/RETURN (KEYPAD) case KBD_a: ret=0x1D;break; // a A チ case KBD_s: ret=0x1E;break; // s S ト @@ -1269,9 +1272,8 @@ void KEYBOARD_PC98_AddKey(KBD_KEYS keytype,bool pressed) { case KBD_semicolon: ret=0x26;break; // ; + レ case KBD_quote: ret=0x27;break; // : * ケ American US keyboard layout hack case KBD_colon: ret=0x27;break; // : * ケ -// case KBD_rightbracket: ret=0x28;break; // ] } ム 」 - case KBD_backslash: ret=0x28;break; // ] } ム 」 - case KBD_z: ret=0x29;break; // z Z ツ ッ + case KBD_backslash: ret=pc98_force_ibm_layout?0x0D:0x28;break; // ¥ | ー + case KBD_z: ret=0x29;break; // z Z ツ ッ case KBD_x: ret=0x2A;break; // x X サ case KBD_c: ret=0x2B;break; // c C ソ case KBD_v: ret=0x2C;break; // v V ヒ @@ -1282,11 +1284,9 @@ void KEYBOARD_PC98_AddKey(KBD_KEYS keytype,bool pressed) { case KBD_period: ret=0x31;break; // . > ル 。 case KBD_slash: ret=0x32;break; // / ? メ ・ case KBD_jp_ro: ret=0x33;break; // _ ロ - case KBD_jp_backslash: ret=0x33;break; // _ ロ - case KBD_space: ret=0x34;break; // SPACEBAR + case KBD_space: ret=0x34;break; // SPACEBAR case KBD_xfer: ret=0x35;break; // XFER - case KBD_jp_henkan: ret=0x35;break; // XFER - case KBD_pageup: ret=0x36;break; // ROLL UP + case KBD_pageup: ret=0x36;break; // ROLL UP case KBD_pagedown: ret=0x37;break; // ROLL DOWN case KBD_insert: ret=0x38;break; // INS case KBD_delete: ret=0x39;break; // DEL @@ -1296,8 +1296,7 @@ void KEYBOARD_PC98_AddKey(KBD_KEYS keytype,bool pressed) { case KBD_down: ret=0x3D;break; // DOWN ARROW case KBD_home: ret=0x3E;break; // HOME / CLR case KBD_help: ret=0x3F;break; // HELP - case KBD_end: ret=0x3F;break; // HELP - case KBD_kpminus: ret=0x40;break; // - (KEYPAD) + case KBD_kpminus: ret=0x40;break; // - (KEYPAD) case KBD_kpdivide: ret=0x41;break; // / (KEYPAD) case KBD_kp7: ret=0x42;break; // 7 (KEYPAD) case KBD_kp8: ret=0x43;break; // 8 (KEYPAD) @@ -1315,16 +1314,14 @@ void KEYBOARD_PC98_AddKey(KBD_KEYS keytype,bool pressed) { case KBD_kpcomma: ret=0x4F;break; // , (KEYPAD) case KBD_kpperiod: ret=0x50;break; // . (KEYPAD) case KBD_nfer: ret=0x51;break; // NFER - case KBD_jp_muhenkan: ret=0x51;break; // NFER - case KBD_vf1: ret=0x52;break; // vf・1 + case KBD_vf1: ret=0x52;break; // vf・1 case KBD_vf2: ret=0x53;break; // vf・2 case KBD_vf3: ret=0x54;break; // vf・3 case KBD_vf4: ret=0x55;break; // vf・4 case KBD_vf5: ret=0x56;break; // vf・5 case KBD_stop: ret=0x60;break; // STOP case KBD_copy: ret=0x61;break; // COPY - case KBD_printscreen: ret=0x61;break; // COPY - case KBD_f1: ret=0x62;break; // f・1 + case KBD_f1: ret=0x62;break; // f・1 case KBD_f2: ret=0x63;break; // f・2 case KBD_f3: ret=0x64;break; // f・3 case KBD_f4: ret=0x65;break; // f・4 @@ -1367,6 +1364,11 @@ void KEYBOARD_PC98_AddKey(KBD_KEYS keytype,bool pressed) { } return; + case KBD_jp_backslash: if (!pc98_force_ibm_layout) {ret=0x33;break;} // _ ロ + case KBD_jp_henkan: if (!pc98_force_ibm_layout) {ret=0x35;break;} // XFER + case KBD_end: if (!pc98_force_ibm_layout) {ret=0x3F;break;} // HELP + case KBD_jp_muhenkan: if (!pc98_force_ibm_layout) {ret=0x51;break;} // NFER + case KBD_printscreen: if (!pc98_force_ibm_layout) {ret=0x61;break;} // COPY default: return; } @@ -1617,9 +1619,9 @@ void KEYBOARD_AddKey1(KBD_KEYS keytype,bool pressed) { case KBD_jp_hiragana:ret=0x70;break;/*also Katakana */ case KBD_jp_backslash:ret=0x73;break;/*JP 106-key: _ \ or ろ (ro) <-- WARNING: UTF-8 unicode */ case KBD_jp_yen:ret=0x7d;break;/*JP 106-key: | ¥ (yen) or ー (prolonged sound mark) <-- WARNING: UTF-8 unicode */ - case KBD_colon:ret = 0x28; break; /*JP106-key : or * same postion with Quote key */ - case KBD_caret:ret = 0x0d; break; /*JP106-key ^ or ~ same postion with Equals key */ - case KBD_atsign:ret = 0x1a; break; /*JP106-key @ or ` same postion with Left-bracket key */ + case KBD_colon:if (!pc98_force_ibm_layout) {ret = 0x28; break;} /*JP106-key : or * same postion with Quote key */ + case KBD_caret:if (!pc98_force_ibm_layout) {ret = 0x0d; break;} /*JP106-key ^ or ~ same postion with Equals key */ + case KBD_atsign:if (!pc98_force_ibm_layout) {ret = 0x1a; break;} /*JP106-key @ or ` same postion with Left-bracket key */ default: LOG(LOG_MISC, LOG_WARN)("Unsupported key press %lu", (unsigned long)keytype); return; @@ -2466,11 +2468,17 @@ void KEYBOARD_OnEnterPC98(Section *sec) { WriteHandler_8255prn_PC98[i].Uninstall(); } - pc98_force_ibm_layout = pc98_section->Get_bool("pc-98 force ibm keyboard layout"); - if(pc98_force_ibm_layout) + const char *layoutstr = pc98_section->Get_string("pc-98 force ibm keyboard layout"); + if (!strcasecmp(layoutstr, "true")||!strcasecmp(layoutstr, "1")) { + pc98_force_ibm_layout = true; + mainMenu.get_item("pc98_use_uskb").check(true).refresh_item(mainMenu); + } else if (!strcasecmp(layoutstr, "false")||!strcasecmp(layoutstr, "0")) { + pc98_force_ibm_layout = false; + mainMenu.get_item("pc98_use_uskb").check(false).refresh_item(mainMenu); + } else + KeyboardLayoutDetect(); + if (pc98_force_ibm_layout) LOG_MSG("Forcing PC-98 keyboard to use IBM US-English like default layout"); - mainMenu.get_item("pc98_use_uskb").check(pc98_force_ibm_layout).refresh_item(mainMenu); - } if (!IS_PC98_ARCH) {