diff --git a/src/86box.c b/src/86box.c index ff7e1ad08..fbccb4b79 100644 --- a/src/86box.c +++ b/src/86box.c @@ -219,6 +219,8 @@ int sound_muted = 0; /* (C) Is soun int jumpered_internal_ecp_dma = 0; /* (C) Jumpered internal EPC DMA */ int inhibit_multimedia_keys; /* (G) Inhibit multimedia keys on Windows. */ int force_10ms; /* (C) Force 10ms CPU frame intervals. */ +int vmm_disabled = 0; /* (G) disable built-in manager */ +char vmm_path_cfg[1024] = { '\0' }; /* (G) VMs path (unless -E is used)*/ int other_ide_present = 0; /* IDE controllers from non-IDE cards are present */ @@ -258,7 +260,7 @@ struct accelKey def_acc_keys[NUM_ACCELS] = { }; char vmm_path[1024] = { '\0'}; /* TEMPORARY - VM manager path to scan for VMs */ -int vmm_enabled = 0; +int start_vmm = 1; /* Statistics. */ extern int mmuflush; @@ -631,7 +633,7 @@ pc_show_usage(char *s) #ifdef _WIN32 "-D or --debug\t\t\t- force debug output logging\n" #endif -#if 1 +#ifndef USE_SDL_UI "-E or --vmmpath\t\t- vm manager path\n" #endif "-F or --fullscreen\t\t- start in fullscreen mode\n" @@ -707,9 +709,6 @@ pc_init(int argc, char *argv[]) time_t now; int c; int lvmp = 0; -#ifdef DEPRECATE_USAGE - int deprecated = 1; -#endif #ifdef ENABLE_NG int ng = 0; #endif @@ -775,7 +774,7 @@ usage: } else if (!strcasecmp(argv[c], "--debug") || !strcasecmp(argv[c], "-D")) { force_debug = 1; #endif -//#ifdef ENABLE_NG +#ifndef USE_SDL_UI } else if (!strcasecmp(argv[c], "--vmmpath") || !strcasecmp(argv[c], "-E")) { /* Using this variable for vm manager path @@ -786,7 +785,7 @@ usage: memcpy(vmm_path, vp, sizeof(vmm_path)); else memcpy(vmm_path, vp, strlen(vp) + 1); - //#endif +#endif } else if (!strcasecmp(argv[c], "--fullscreen") || !strcasecmp(argv[c], "-F")) { start_in_fullscreen = 1; } else if (!strcasecmp(argv[c], "--logfile") || !strcasecmp(argv[c], "-L")) { @@ -799,9 +798,7 @@ usage: goto usage; ppath = argv[++c]; -#ifdef DEPRECATE_USAGE - deprecated = 0; -#endif + start_vmm = 0; } else if (!strcasecmp(argv[c], "--rompath") || !strcasecmp(argv[c], "-R")) { if ((c + 1) == argc) goto usage; @@ -813,9 +810,7 @@ usage: goto usage; cfg = argv[++c]; -#ifdef DEPRECATE_USAGE - deprecated = 0; -#endif + start_vmm = 0; } else if (!strcasecmp(argv[c], "--global") || !strcasecmp(argv[c], "-O")) { if ((c + 1) == argc || plat_dir_check(argv[c + 1])) goto usage; @@ -924,21 +919,12 @@ usage: else cfg = argv[c++]; -#ifdef DEPRECATE_USAGE - deprecated = 0; -#endif + start_vmm = 0; } if (c != argc) goto usage; -#ifdef DEPRECATE_USAGE - if (deprecated) - pc_show_usage("Running 86Box without a specified VM path and/or configuration\n" - "file has been deprected. Please specify one or use a manager\n" - "(Avalonia 86 is recommended).\n\n"); -#endif - path_slash(usr_path); path_slash(rom_path); @@ -1094,24 +1080,44 @@ usage: pclog("#\n# %ls v%ls logfile, created %s\n#\n", EMU_NAME_W, EMU_VERSION_FULL_W, temp); - pclog("# VM: %s\n#\n", vm_name); - pclog("# Emulator path: %s\n", exe_path); - pclog("# Userfiles path: %s\n", usr_path); - for (rom_path_t *rom_path = &rom_paths; rom_path != NULL; rom_path = rom_path->next) { - pclog("# ROM path: %s\n", rom_path->path); - } + pclog("# Emulator path: %s\n", exe_path); pclog("# Global configuration file: %s\n", global_cfg_path); - pclog("# Configuration file: %s\n#\n\n", cfg_path); - if (strlen(vmm_path) != 0) { - vmm_enabled = 1; - pclog("# VM Manager enabled. Path: %s\n", vmm_path); - } /* Load the global configuration file. */ config_load_global(); + config_save_global(); // hack + + /* Determine whether to start the VM manager. */ +#ifndef USE_SDL_UI + if (vmm_disabled) +#endif + { + start_vmm = 0; + } + +#ifndef USE_SDL_UI + if (strlen(vmm_path) != 0) { + /* -E specified on the command line. */ + start_vmm = 1; + } else { + strncpy(vmm_path, vmm_path_cfg, sizeof(vmm_path) - 1); + } + + if (start_vmm) { + pclog("# VM Manager enabled. Path: %s\n", vmm_path); + strncpy(usr_path, vmm_path, sizeof(usr_path) - 1); + } else +#endif + { + pclog("# VM: %s\n#\n", vm_name); + pclog("# Configuration file: %s\n#\n\n", cfg_path); + pclog("# Userfiles path: %s\n", usr_path); + + for (rom_path_t *rom_path = &rom_paths; rom_path != NULL; rom_path = rom_path->next) { + pclog("# ROM path: %s\n", rom_path->path); + } - if (!vmm_enabled) { /* * We are about to read the configuration file, which MAY * put data into global variables (the hard- and floppy diff --git a/src/config.c b/src/config.c index 25f287eef..7f4279a02 100644 --- a/src/config.c +++ b/src/config.c @@ -136,6 +136,14 @@ load_global(void) mouse_sensitivity = 0.1; else if (mouse_sensitivity > 2.0) mouse_sensitivity = 2.0; + + vmm_disabled = ini_section_get_int(cat, "vmm_disabled", 0); + + p = ini_section_get_string(cat, "vmm_path", NULL); + if (p != NULL) + strncpy(vmm_path_cfg, p, sizeof(vmm_path_cfg) - 1); + else + plat_get_vmm_dir(vmm_path_cfg, sizeof(vmm_path_cfg)); } /* Load "General" section. */ @@ -2015,12 +2023,10 @@ config_load_global(void) if (global == NULL) { global = ini_new(); - lang_id = plat_language_code(DEFAULT_LANGUAGE); - config_log("Global config file not present or invalid!\n"); - } else { - load_global(); } + + load_global(); } /* Load the specified or a default configuration file. */ @@ -2200,6 +2206,16 @@ save_global(void) ini_section_set_double(cat, "mouse_sensitivity", mouse_sensitivity); else ini_section_delete_var(cat, "mouse_sensitivity"); + + if (vmm_disabled != 0) + ini_section_set_int(cat, "vmm_disabled", vmm_disabled); + else + ini_section_delete_var(cat, "vmm_disabled"); + + if (vmm_path_cfg[0] != 0) + ini_section_set_string(cat, "vmm_path", vmm_path_cfg); + else + ini_section_delete_var(cat, "vmm_path"); } /* Save "General" section. */ diff --git a/src/include/86box/86box.h b/src/include/86box/86box.h index de66f8a0f..bde3dc2b5 100644 --- a/src/include/86box/86box.h +++ b/src/include/86box/86box.h @@ -116,12 +116,12 @@ extern uint64_t instru_run_ms; #define window_y monitor_settings[0].mon_window_y #define window_w monitor_settings[0].mon_window_w #define window_h monitor_settings[0].mon_window_h -extern int inhibit_multimedia_keys; /* (C) Inhibit multimedia keys on Windows. */ +extern int inhibit_multimedia_keys; /* (G) Inhibit multimedia keys on Windows. */ extern int window_remember; extern int vid_resize; /* (C) allow resizing */ extern int invert_display; /* (C) invert the display */ extern int suppress_overscan; /* (C) suppress overscans */ -extern int lang_id; /* (C) language id */ +extern int lang_id; /* (G) language id */ extern int scale; /* (C) screen scale factor */ extern int dpi_scale; /* (C) DPI scaling of the emulated screen */ extern int vid_api; /* (C) video renderer */ @@ -160,9 +160,9 @@ extern int fpu_type; /* (C) fpu type */ extern int fpu_softfloat; /* (C) fpu uses softfloat */ extern int time_sync; /* (C) enable time sync */ extern int hdd_format_type; /* (C) hard disk file format */ -extern int confirm_reset; /* (C) enable reset confirmation */ -extern int confirm_exit; /* (C) enable exit confirmation */ -extern int confirm_save; /* (C) enable save confirmation */ +extern int confirm_reset; /* (G) enable reset confirmation */ +extern int confirm_exit; /* (G) enable exit confirmation */ +extern int confirm_save; /* (G) enable save confirmation */ extern int enable_discord; /* (C) enable Discord integration */ extern int force_10ms; /* (C) force 10ms CPU frame interval */ extern int jumpered_internal_ecp_dma; /* (C) Jumpered internal EPC DMA */ @@ -177,7 +177,7 @@ extern int sound_muted; /* (C) Is sound muted? */ extern int do_auto_pause; /* (C) Auto-pause the emulator on focus loss */ extern int auto_paused; extern int force_constant_mouse; /* (C) Force constant updating of the mouse */ -extern double mouse_sensitivity; /* (C) Mouse sensitivity scale */ +extern double mouse_sensitivity; /* (G) Mouse sensitivity scale */ #ifdef _Atomic extern _Atomic double mouse_x_error; /* Mouse error accumulator - Y */ extern _Atomic double mouse_y_error; /* Mouse error accumulator - Y */ @@ -185,6 +185,8 @@ extern _Atomic double mouse_y_error; /* Mouse error accumulator - Y */ extern int pit_mode; /* (C) force setting PIT mode */ extern int fm_driver; /* (C) select FM sound driver */ extern int hook_enabled; /* (C) Keyboard hook is enabled */ +extern int vmm_disabled; /* (G) disable built-in manager */ +extern char vmm_path_cfg[1024]; /* (G) VMs path (unless -E is used) */ extern char exe_path[2048]; /* path (dir) of executable */ extern char usr_path[1024]; /* path (dir) of user data */ @@ -193,7 +195,7 @@ extern char global_cfg_path[1024]; /* full path of global config file */ extern int open_dir_usr_path; /* default file open dialog directory of usr_path */ extern char uuid[MAX_UUID_LEN]; /* UUID or machine identifier */ extern char vmm_path[1024]; /* VM Manager path to scan (temporary) */ -extern int vmm_enabled; +extern int start_vmm; #ifndef USE_NEW_DYNAREC extern FILE *stdlog; /* file to log output to */ #endif diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index ef06b3429..7b8a34857 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -146,6 +146,7 @@ extern void plat_get_exe_name(char *s, int size); extern void plat_get_global_config_dir(char *outbuf, size_t len); extern void plat_get_global_data_dir(char *outbuf, size_t len); extern void plat_get_temp_dir(char *outbuf, uint8_t len); +extern void plat_get_vmm_dir(char *outbuf, size_t len); extern void plat_init_rom_paths(void); extern int plat_dir_check(char *path); extern int plat_dir_create(char *path); diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 374b0f4fb..3dd63389e 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -584,7 +584,7 @@ main(int argc, char *argv[]) return 0; } - if (!vmm_enabled) + if (!start_vmm) #ifdef Q_OS_MACOS qt_set_sequence_auto_mnemonic(false); #else @@ -625,22 +625,23 @@ main(int argc, char *argv[]) return 6; } - if (!vmm_enabled) - pc_init_modules(); - - if (vmm_enabled) { + if (start_vmm) { // VMManagerMain vmm; // // Hackish until there is a proper solution // QApplication::setApplicationName("86Box VM Manager"); // QApplication::setApplicationDisplayName("86Box VM Manager"); // vmm.show(); // vmm.exec(); - const auto vmm_main_window = new VMManagerMainWindow(); - vmm_main_window->show(); + QTimer::singleShot(0, [] { + const auto vmm_main_window = new VMManagerMainWindow(); + vmm_main_window->show(); + }); QApplication::exec(); return 0; } + pc_init_modules(); + // UUID / copy / move detection if(!util::compareUuid()) { QMessageBox movewarnbox; diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index ee2e40d1d..d8aca89d4 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -694,6 +694,13 @@ plat_get_temp_dir(char *outbuf, const uint8_t len) strncpy(outbuf, dir.canonicalPath().toUtf8().constData(), len); } +void +plat_get_vmm_dir(char *outbuf, const size_t len) +{ + const auto path = QDir::home().filePath("86Box VMs"); + strncpy(outbuf, path.toUtf8().constData(), len); +} + void plat_init_rom_paths(void) { diff --git a/src/qt/qt_styleoverride.cpp b/src/qt/qt_styleoverride.cpp index adfae0734..1319f0dae 100644 --- a/src/qt/qt_styleoverride.cpp +++ b/src/qt/qt_styleoverride.cpp @@ -42,7 +42,7 @@ StyleOverride::styleHint( QStyleHintReturn *returnData) const { /* Disable using menu with alt key */ - if (!vmm_enabled && (!kbd_req_capture || mouse_capture) && (hint == QStyle::SH_MenuBar_AltKeyNavigation)) + if (!start_vmm && (!kbd_req_capture || mouse_capture) && (hint == QStyle::SH_MenuBar_AltKeyNavigation)) return 0; return QProxyStyle::styleHint(hint, option, widget, returnData); diff --git a/src/qt/qt_vmmanager_preferences.cpp b/src/qt/qt_vmmanager_preferences.cpp index b03c66aa4..91cbcb7fd 100644 --- a/src/qt/qt_vmmanager_preferences.cpp +++ b/src/qt/qt_vmmanager_preferences.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "qt_progsettings.hpp" #include "qt_vmmanager_preferences.hpp" @@ -37,7 +38,7 @@ VMManagerPreferences(QWidget *parent) : ui(new Ui::VMManagerPreferences) connect(ui->dirSelectButton, &QPushButton::clicked, this, &VMManagerPreferences::chooseDirectoryLocation); const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General); - const auto configSystemDir = config->getStringValue("system_directory"); + const auto configSystemDir = QString(vmm_path_cfg); if(!configSystemDir.isEmpty()) { // Prefer this one ui->systemDirectory->setText(configSystemDir); @@ -91,8 +92,8 @@ void VMManagerPreferences::accept() { const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General); - config->setStringValue("system_directory", ui->systemDirectory->text()); + strncpy(vmm_path_cfg, ui->systemDirectory->text().toUtf8().constData(), sizeof(vmm_path_cfg) - 1); lang_id = ui->comboBoxLanguage->currentData().toInt(); config_save_global(); diff --git a/src/unix/unix.c b/src/unix/unix.c index a28c4fc47..d35543548 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -901,6 +901,14 @@ plat_get_temp_dir(char *outbuf, uint8_t len) path_slash(outbuf); } +void +plat_get_vmm_dir(char *outbuf, const size_t len) +{ + // Return empty string. SDL 86Box does not have a VM manager + if (len > 0) + outbuf[0] = 0; +} + bool process_media_commands_3(uint8_t *id, char *fn, uint8_t *wp, int cmdargc) {