From d20ba5d17969a109b5acc73c71a31237de9985ec Mon Sep 17 00:00:00 2001 From: kanjitalk755 Date: Tue, 6 Oct 2020 15:38:35 +0900 Subject: [PATCH] test a pref item swap_opt_cmd --- BasiliskII/src/SDL/video_sdl2.cpp | 43 ++++++++++--------------------- BasiliskII/src/prefs_items.cpp | 7 +++++ SheepShaver/src/prefs_items.cpp | 7 +++++ 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/BasiliskII/src/SDL/video_sdl2.cpp b/BasiliskII/src/SDL/video_sdl2.cpp index ba724a08..06717ec2 100644 --- a/BasiliskII/src/SDL/video_sdl2.cpp +++ b/BasiliskII/src/SDL/video_sdl2.cpp @@ -2017,6 +2017,14 @@ static bool is_hotkey_down(SDL_Keysym const & ks) (cmd_down || (ks.mod & KMOD_GUI) || !(hotkey & 4)); } +static bool swap_opt_cmd() { + static bool f, c; + if (!f) { + f = true; + c = PrefsFindBool("swap_opt_cmd"); + } + return c; +} /* * Translate key event to Mac keycode, returns CODE_INVALID if no keycode was found @@ -2092,17 +2100,8 @@ static int kc_decode(SDL_Keysym const & ks, bool key_down) case SDLK_RCTRL: return 0x36; case SDLK_LSHIFT: return 0x38; case SDLK_RSHIFT: return 0x38; -#ifdef __APPLE__ - case SDLK_LALT: return 0x3a; - case SDLK_RALT: return 0x3a; - case SDLK_LGUI: return 0x37; - case SDLK_RGUI: return 0x37; -#else - case SDLK_LALT: return 0x37; - case SDLK_RALT: return 0x37; - case SDLK_LGUI: return 0x3a; - case SDLK_RGUI: return 0x3a; -#endif + case SDLK_LALT: case SDLK_RALT: return swap_opt_cmd() ? 0x37 : 0x3a; + case SDLK_LGUI: case SDLK_RGUI: return swap_opt_cmd() ? 0x3a : 0x37; case SDLK_MENU: return 0x32; case SDLK_CAPSLOCK: return 0x39; case SDLK_NUMLOCKCLEAR: return 0x47; @@ -2320,17 +2319,10 @@ static void handle_events(void) #endif if (code == 0x36) ctrl_down = true; -#ifdef __APPLE__ - if (code == 0x3a) + if (code == (swap_opt_cmd() ? 0x37 : 0x3a)) opt_down = true; - if (code == 0x37) + if (code == (swap_opt_cmd() ? 0x3a : 0x37)) cmd_down = true; -#else - if (code == 0x37) - opt_down = true; - if (code == 0x3a) - cmd_down = true; -#endif } else { if (code == 0x31) @@ -2354,17 +2346,10 @@ static void handle_events(void) #endif if (code == 0x36) ctrl_down = false; -#ifdef __APPLE__ - if (code == 0x3a) + if (code == (swap_opt_cmd() ? 0x37 : 0x3a)) opt_down = false; - if (code == 0x37) + if (code == (swap_opt_cmd() ? 0x3a : 0x37)) cmd_down = false; -#else - if (code == 0x37) - opt_down = false; - if (code == 0x3a) - cmd_down = false; -#endif } break; } diff --git a/BasiliskII/src/prefs_items.cpp b/BasiliskII/src/prefs_items.cpp index d6e531f8..7ee0f670 100644 --- a/BasiliskII/src/prefs_items.cpp +++ b/BasiliskII/src/prefs_items.cpp @@ -79,6 +79,7 @@ prefs_desc common_prefs_items[] = { {"dayofs", TYPE_INT32, 0, "day offset"}, {"mag_rate", TYPE_INT32, 0, "rate of magnification"}, {"gammaramp", TYPE_STRING, false, "gamma ramp (on, off or fullscreen)"}, + {"swap_opt_cmd", TYPE_BOOLEAN, false, "swap option and command key"}, {NULL, TYPE_END, false, NULL} // End of list }; @@ -118,4 +119,10 @@ void AddPrefsDefaults(void) #endif PrefsAddInt32("keyboardtype", 5); + +#ifdef __APPLE__ + PrefsAddBool("swap_opt_cmd", false); +#else + PrefsAddBool("swap_opt_cmd", true); +#endif } diff --git a/SheepShaver/src/prefs_items.cpp b/SheepShaver/src/prefs_items.cpp index 5897affa..5afc9e2b 100644 --- a/SheepShaver/src/prefs_items.cpp +++ b/SheepShaver/src/prefs_items.cpp @@ -67,6 +67,7 @@ prefs_desc common_prefs_items[] = { {"dayofs", TYPE_INT32, 0, "day offset"}, {"mag_rate", TYPE_INT32, 0, "rate of magnification"}, {"gammaramp", TYPE_STRING, false, "gamma ramp (on, off or fullscreen)"}, + {"swap_opt_cmd", TYPE_BOOLEAN, false, "swap option and command key"}, {NULL, TYPE_END, false, NULL} // End of list }; @@ -101,4 +102,10 @@ void AddPrefsDefaults(void) PrefsAddBool("jit68k", false); PrefsAddInt32("keyboardtype", 5); + + #ifdef __APPLE__ + PrefsAddBool("swap_opt_cmd", false); + #else + PrefsAddBool("swap_opt_cmd", true); + #endif }