added pref item "hotkey"

added MB notation pref item "ramsize"
This commit is contained in:
kanjitalk755 2018-06-27 19:13:30 +09:00
parent 52fe2290fe
commit 700b57d758
11 changed files with 96 additions and 10 deletions

View File

@ -48,6 +48,7 @@
#include <SDL_thread.h>
#include <errno.h>
#include <vector>
#include <string>
#ifdef WIN32
#include <malloc.h> /* alloca() */
@ -120,6 +121,8 @@ static const bool use_vosf = false; // VOSF not possible
#endif
static bool ctrl_down = false; // Flag: Ctrl key pressed
static bool opt_down = false; // Flag: Opt key pressed
static bool cmd_down = false; // Flag: Cmd key pressed
static bool caps_on = false; // Flag: Caps Lock on
static bool quit_full_screen = false; // Flag: DGA close requested from redraw thread
static bool emerg_quit = false; // Flag: Ctrl-Esc pressed, emergency quit requested from MacOS thread
@ -532,6 +535,18 @@ static void set_window_name(int name)
SDL_SetWindowTitle(sdl_window, str);
}
static void set_window_name_grabbed() {
if (!sdl_window) return;
int hotkey = PrefsFindInt32("hotkey");
if (!hotkey) hotkey = 1;
std::string s = GetString(STR_WINDOW_TITLE_GRABBED0);
if (hotkey & 1) s += GetString(STR_WINDOW_TITLE_GRABBED1);
if (hotkey & 2) s += GetString(STR_WINDOW_TITLE_GRABBED2);
if (hotkey & 4) s += GetString(STR_WINDOW_TITLE_GRABBED3);
s += GetString(STR_WINDOW_TITLE_GRABBED4);
SDL_SetWindowTitle(sdl_window, s.c_str());
}
// Set mouse grab mode
static void set_grab_mode(bool grab)
{
@ -1024,7 +1039,7 @@ void driver_base::adapt_to_video_mode() {
SDL_ShowCursor(hardware_cursor);
// Set window name/class
set_window_name(mouse_grabbed ? (int)STR_WINDOW_TITLE_GRABBED : (int)STR_WINDOW_TITLE);
mouse_grabbed ? set_window_name_grabbed() : set_window_name((int)STR_WINDOW_TITLE);
// Everything went well
init_ok = true;
@ -1118,7 +1133,7 @@ void driver_base::grab_mouse(void)
if (!mouse_grabbed) {
mouse_grabbed = true;
update_mouse_grab();
set_window_name(STR_WINDOW_TITLE_GRABBED);
set_window_name_grabbed();
disable_mouse_accel();
ADBSetRelMouseMode(true);
}
@ -1856,9 +1871,13 @@ static bool is_modifier_key(SDL_KeyboardEvent const & e)
return false;
}
static bool is_ctrl_down(SDL_Keysym const & ks)
static bool is_hotkey_down(SDL_Keysym const & ks)
{
return ctrl_down || (ks.mod & KMOD_CTRL);
int hotkey = PrefsFindInt32("hotkey");
if (!hotkey) hotkey = 1;
return (ctrl_down || (ks.mod & KMOD_CTRL) || !(hotkey & 1)) &&
(opt_down || (ks.mod & KMOD_ALT) || !(hotkey & 2)) &&
(cmd_down || (ks.mod & KMOD_GUI) || !(hotkey & 4));
}
@ -1920,8 +1939,8 @@ static int kc_decode(SDL_Keysym const & ks, bool key_down)
case SDLK_PERIOD: case SDLK_GREATER: return 0x2f;
case SDLK_SLASH: case SDLK_QUESTION: return 0x2c;
case SDLK_TAB: if (is_ctrl_down(ks)) {if (!key_down) drv->suspend(); return -2;} else return 0x30;
case SDLK_RETURN: if (is_ctrl_down(ks)) {if (!key_down) toggle_fullscreen = true; return -2;} else return 0x24;
case SDLK_TAB: if (is_hotkey_down(ks)) {if (!key_down) drv->suspend(); return -2;} else return 0x30;
case SDLK_RETURN: if (is_hotkey_down(ks)) {if (!key_down) toggle_fullscreen = true; return -2;} else return 0x24;
case SDLK_SPACE: return 0x31;
case SDLK_BACKSPACE: return 0x33;
@ -1936,7 +1955,7 @@ 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;
#if (defined(__APPLE__) && defined(__MACH__))
#ifdef __APPLE__
case SDLK_LALT: return 0x3a;
case SDLK_RALT: return 0x3a;
case SDLK_LGUI: return 0x37;
@ -1956,9 +1975,9 @@ static int kc_decode(SDL_Keysym const & ks, bool key_down)
case SDLK_LEFT: return 0x3b;
case SDLK_RIGHT: return 0x3c;
case SDLK_ESCAPE: if (is_ctrl_down(ks)) {if (!key_down) { quit_full_screen = true; emerg_quit = true; } return -2;} else return 0x35;
case SDLK_ESCAPE: if (is_hotkey_down(ks)) {if (!key_down) { quit_full_screen = true; emerg_quit = true; } return -2;} else return 0x35;
case SDLK_F1: if (is_ctrl_down(ks)) {if (!key_down) SysMountFirstFloppy(); return -2;} else return 0x7a;
case SDLK_F1: if (is_hotkey_down(ks)) {if (!key_down) SysMountFirstFloppy(); return -2;} else return 0x7a;
case SDLK_F2: return 0x78;
case SDLK_F3: return 0x63;
case SDLK_F4: return 0x76;
@ -2043,7 +2062,7 @@ static int SDLCALL on_sdl_event_generated(void *userdata, SDL_Event * event)
SDL_Keysym const & ks = event->key.keysym;
switch (ks.sym) {
case SDLK_F5: {
if (is_ctrl_down(ks)) {
if (is_hotkey_down(ks)) {
drv->toggle_mouse_grab();
return EVENT_DROP_FROM_QUEUE;
}
@ -2164,6 +2183,18 @@ static void handle_events(void)
ADBKeyDown(code);
if (code == 0x36)
ctrl_down = true;
#ifdef __APPLE__
if (code == 0x3a)
opt_down = true;
if (code == 0x37)
cmd_down = true;
#else
if (code == 0x37)
opt_down = true;
if (code == 0x3a)
cmd_down = true;
#endif
} else {
if (code == 0x31)
drv->resume(); // Space wakes us up
@ -2191,6 +2222,17 @@ static void handle_events(void)
ADBKeyUp(code);
if (code == 0x36)
ctrl_down = false;
#ifdef __APPLE__
if (code == 0x3a)
opt_down = false;
if (code == 0x37)
cmd_down = false;
#else
if (code == 0x37)
opt_down = false;
if (code == 0x3a)
cmd_down = false;
#endif
}
break;
}

View File

@ -568,6 +568,9 @@ int main(int argc, char **argv)
// Read RAM size
RAMSize = PrefsFindInt32("ramsize") & 0xfff00000; // Round down to 1MB boundary
if (RAMSize <= 1000) {
RAMSize *= 1024 * 1024;
}
if (RAMSize < 1024*1024) {
WarningAlert(GetString(STR_SMALL_RAM_WARN));
RAMSize = 1024*1024;

View File

@ -320,6 +320,9 @@ int main(int argc, char **argv)
// Read RAM size
RAMSize = PrefsFindInt32("ramsize") & 0xfff00000; // Round down to 1MB boundary
if (RAMSize <= 1000) {
RAMSize *= 1024 * 1024;
}
if (RAMSize < 1024*1024) {
WarningAlert(GetString(STR_SMALL_RAM_WARN));
RAMSize = 1024*1024;

View File

@ -214,6 +214,11 @@ enum {
STR_WINDOW_TITLE = 4000,
STR_WINDOW_TITLE_FROZEN,
STR_WINDOW_TITLE_GRABBED,
STR_WINDOW_TITLE_GRABBED0,
STR_WINDOW_TITLE_GRABBED1,
STR_WINDOW_TITLE_GRABBED2,
STR_WINDOW_TITLE_GRABBED3,
STR_WINDOW_TITLE_GRABBED4,
STR_WINDOW_MENU = 4050,
STR_WINDOW_ITEM_ABOUT,
STR_WINDOW_ITEM_REFRESH,

View File

@ -72,6 +72,7 @@ prefs_desc common_prefs_items[] = {
{"keycodefile",TYPE_STRING,"Keycode file"},
{"mousewheelmode",TYPE_BOOLEAN,"Use WheelMode"},
{"mousewheellines",TYPE_INT32,"wheel line nb"},
{"hotkey",TYPE_INT32,false,"hotkey modifier"},
{NULL, TYPE_END, false, NULL} // End of list
};

View File

@ -227,6 +227,16 @@ user_string_def common_strings[] = {
{STR_WINDOW_TITLE, "Basilisk II"},
{STR_WINDOW_TITLE_FROZEN, "Basilisk II *** FROZEN ***"},
{STR_WINDOW_TITLE_GRABBED, "Basilisk II (mouse grabbed, press Ctrl-F5 to release)"},
{STR_WINDOW_TITLE_GRABBED0, "Basilisk II (mouse grabbed, press "},
{STR_WINDOW_TITLE_GRABBED1, "Ctrl-"},
#ifdef __APPLE__
{STR_WINDOW_TITLE_GRABBED2, "Opt-"},
{STR_WINDOW_TITLE_GRABBED3, "Cmd-"},
#else
{STR_WINDOW_TITLE_GRABBED2, "Alt-"},
{STR_WINDOW_TITLE_GRABBED3, "Win-"},
#endif
{STR_WINDOW_TITLE_GRABBED4, "F5 to release)"},
{STR_WINDOW_MENU, "Basilisk II"},
{STR_WINDOW_ITEM_ABOUT, "About Basilisk II" ELLIPSIS},
{STR_WINDOW_ITEM_REFRESH, "Refresh Rate"},

View File

@ -941,6 +941,9 @@ int main(int argc, char **argv)
// Create area for Mac RAM
RAMSize = PrefsFindInt32("ramsize");
if (RAMSize <= 1000) {
RAMSize *= 1024 * 1024;
}
if (RAMSize < 8*1024*1024) {
WarningAlert(GetString(STR_SMALL_RAM_WARN));
RAMSize = 8*1024*1024;

View File

@ -303,6 +303,9 @@ int main(int argc, char **argv)
// Create area for Mac RAM
RAMSize = PrefsFindInt32("ramsize");
if (RAMSize <= 1000) {
RAMSize *= 1024 * 1024;
}
if (RAMSize < 8*1024*1024) {
WarningAlert(GetString(STR_SMALL_RAM_WARN));
RAMSize = 8*1024*1024;

View File

@ -167,6 +167,11 @@ enum {
STR_WINDOW_TITLE = 4000,
STR_WINDOW_TITLE_FROZEN,
STR_WINDOW_TITLE_GRABBED,
STR_WINDOW_TITLE_GRABBED0,
STR_WINDOW_TITLE_GRABBED1,
STR_WINDOW_TITLE_GRABBED2,
STR_WINDOW_TITLE_GRABBED3,
STR_WINDOW_TITLE_GRABBED4,
STR_WINDOW_MENU = 4050,
STR_WINDOW_ITEM_ABOUT,
STR_WINDOW_ITEM_REFRESH,

View File

@ -59,6 +59,7 @@ prefs_desc common_prefs_items[] = {
{"jit68k", TYPE_BOOLEAN, false, "enable 68k DR emulator"},
{"keyboardtype", TYPE_INT32, false, "hardware keyboard type"},
{"hardcursor", TYPE_BOOLEAN, false, "hardware mouse cursor"},
{"hotkey", TYPE_INT32, false, "hotkey modifier"},
{NULL, TYPE_END, false, NULL} // End of list
};

View File

@ -173,6 +173,16 @@ user_string_def common_strings[] = {
{STR_WINDOW_TITLE, "SheepShaver"},
{STR_WINDOW_TITLE_FROZEN, "SheepShaver *** FROZEN ***"},
{STR_WINDOW_TITLE_GRABBED, "SheepShaver (mouse grabbed, press Ctrl-F5 to release)"},
{STR_WINDOW_TITLE_GRABBED0, "SheepShaver (mouse grabbed, press "},
{STR_WINDOW_TITLE_GRABBED1, "Ctrl-"},
#ifdef __APPLE__
{STR_WINDOW_TITLE_GRABBED2, "Opt-"},
{STR_WINDOW_TITLE_GRABBED3, "Cmd-"},
#else
{STR_WINDOW_TITLE_GRABBED2, "Alt-"},
{STR_WINDOW_TITLE_GRABBED3, "Win-"},
#endif
{STR_WINDOW_TITLE_GRABBED4, "F5 to release)"},
{STR_WINDOW_MENU, "SheepShaver"},
{STR_WINDOW_ITEM_ABOUT, "About SheepShaver" ELLIPSIS},
{STR_WINDOW_ITEM_REFRESH, "Refresh Rate"},