test a pref item swap_opt_cmd

This commit is contained in:
kanjitalk755 2020-10-06 15:38:35 +09:00
parent dd9cfec0e7
commit d20ba5d179
3 changed files with 28 additions and 29 deletions

View File

@ -2017,6 +2017,14 @@ static bool is_hotkey_down(SDL_Keysym const & ks)
(cmd_down || (ks.mod & KMOD_GUI) || !(hotkey & 4)); (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 * 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_RCTRL: return 0x36;
case SDLK_LSHIFT: return 0x38; case SDLK_LSHIFT: return 0x38;
case SDLK_RSHIFT: return 0x38; case SDLK_RSHIFT: return 0x38;
#ifdef __APPLE__ case SDLK_LALT: case SDLK_RALT: return swap_opt_cmd() ? 0x37 : 0x3a;
case SDLK_LALT: return 0x3a; case SDLK_LGUI: case SDLK_RGUI: return swap_opt_cmd() ? 0x3a : 0x37;
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_MENU: return 0x32; case SDLK_MENU: return 0x32;
case SDLK_CAPSLOCK: return 0x39; case SDLK_CAPSLOCK: return 0x39;
case SDLK_NUMLOCKCLEAR: return 0x47; case SDLK_NUMLOCKCLEAR: return 0x47;
@ -2320,17 +2319,10 @@ static void handle_events(void)
#endif #endif
if (code == 0x36) if (code == 0x36)
ctrl_down = true; ctrl_down = true;
#ifdef __APPLE__ if (code == (swap_opt_cmd() ? 0x37 : 0x3a))
if (code == 0x3a)
opt_down = true; opt_down = true;
if (code == 0x37) if (code == (swap_opt_cmd() ? 0x3a : 0x37))
cmd_down = true; cmd_down = true;
#else
if (code == 0x37)
opt_down = true;
if (code == 0x3a)
cmd_down = true;
#endif
} else { } else {
if (code == 0x31) if (code == 0x31)
@ -2354,17 +2346,10 @@ static void handle_events(void)
#endif #endif
if (code == 0x36) if (code == 0x36)
ctrl_down = false; ctrl_down = false;
#ifdef __APPLE__ if (code == (swap_opt_cmd() ? 0x37 : 0x3a))
if (code == 0x3a)
opt_down = false; opt_down = false;
if (code == 0x37) if (code == (swap_opt_cmd() ? 0x3a : 0x37))
cmd_down = false; cmd_down = false;
#else
if (code == 0x37)
opt_down = false;
if (code == 0x3a)
cmd_down = false;
#endif
} }
break; break;
} }

View File

@ -79,6 +79,7 @@ prefs_desc common_prefs_items[] = {
{"dayofs", TYPE_INT32, 0, "day offset"}, {"dayofs", TYPE_INT32, 0, "day offset"},
{"mag_rate", TYPE_INT32, 0, "rate of magnification"}, {"mag_rate", TYPE_INT32, 0, "rate of magnification"},
{"gammaramp", TYPE_STRING, false, "gamma ramp (on, off or fullscreen)"}, {"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 {NULL, TYPE_END, false, NULL} // End of list
}; };
@ -118,4 +119,10 @@ void AddPrefsDefaults(void)
#endif #endif
PrefsAddInt32("keyboardtype", 5); PrefsAddInt32("keyboardtype", 5);
#ifdef __APPLE__
PrefsAddBool("swap_opt_cmd", false);
#else
PrefsAddBool("swap_opt_cmd", true);
#endif
} }

View File

@ -67,6 +67,7 @@ prefs_desc common_prefs_items[] = {
{"dayofs", TYPE_INT32, 0, "day offset"}, {"dayofs", TYPE_INT32, 0, "day offset"},
{"mag_rate", TYPE_INT32, 0, "rate of magnification"}, {"mag_rate", TYPE_INT32, 0, "rate of magnification"},
{"gammaramp", TYPE_STRING, false, "gamma ramp (on, off or fullscreen)"}, {"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 {NULL, TYPE_END, false, NULL} // End of list
}; };
@ -101,4 +102,10 @@ void AddPrefsDefaults(void)
PrefsAddBool("jit68k", false); PrefsAddBool("jit68k", false);
PrefsAddInt32("keyboardtype", 5); PrefsAddInt32("keyboardtype", 5);
#ifdef __APPLE__
PrefsAddBool("swap_opt_cmd", false);
#else
PrefsAddBool("swap_opt_cmd", true);
#endif
} }