From 56a14f96be877e0e1329de245f5dbb61c196d1b6 Mon Sep 17 00:00:00 2001 From: "K.Ohta" Date: Wed, 8 Feb 2023 02:57:29 +0900 Subject: [PATCH] [OSD][EMU][Qt] Add (and prepare) some signals for messaging EMU->GUI. --- source/src/qt/common/qt_utils.cpp | 122 ++++++++++++++--------------- source/src/qt/osd_base.cpp | 44 +++++++---- source/src/qt/osd_base.h | 156 ++++++++++++++++++++++++-------------- 3 files changed, 188 insertions(+), 134 deletions(-) diff --git a/source/src/qt/common/qt_utils.cpp b/source/src/qt/common/qt_utils.cpp index 57ac00a31..a1a6c4a8e 100644 --- a/source/src/qt/common/qt_utils.cpp +++ b/source/src/qt/common/qt_utils.cpp @@ -82,7 +82,7 @@ void Ui_MainWindow::do_set_mouse_enable(bool flag) emu->disable_mouse(); } emu->unlock_vm(); -#endif +#endif } void Ui_MainWindow::do_toggle_mouse(void) @@ -99,7 +99,7 @@ void Ui_MainWindow::do_toggle_mouse(void) emu->disable_mouse(); } emu->unlock_vm(); -#endif +#endif } void Ui_MainWindow::rise_movie_dialog(void) @@ -115,11 +115,11 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m) GLDrawClass *glv = this->getGraphicsView(); int drvs; - + hRunEmu = m; if(hRunEmu == nullptr) return; OSD_BASE* p_osd = hRunEmu->get_emu()->get_osd(); - + connect(hRunEmu, SIGNAL(message_changed(QString)), this, SLOT(message_status_bar(QString)), Qt::QueuedConnection); connect(hRunEmu, SIGNAL(sig_is_enable_mouse(bool)), this, SLOT(do_set_mouse_enable(bool))); connect(glv, SIGNAL(sig_key_down(uint32_t, uint32_t, bool)), hRunEmu, SLOT(do_key_down(uint32_t, uint32_t, bool))); @@ -129,7 +129,7 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m) if(action_ResetFixedCpu != nullptr) { connect(action_ResetFixedCpu, SIGNAL(triggered()), hRunEmu, SLOT(do_set_emu_thread_to_fixed_cpu_from_action())); - + } for(int i = 0 ; i < 128 ; i++) { if(action_SetFixedCpu[i] == nullptr) break; @@ -138,7 +138,7 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m) } //connect(hRunEmu, SIGNAL(sig_finished()), this, SLOT(delete_emu_thread())); connect(this, SIGNAL(sig_vm_reset()), hRunEmu, SLOT(do_reset())); - + for(int i = 0 ; i < using_flags->get_use_special_reset_num() ; i++) { if(actionSpecial_Reset[i] != nullptr) { connect(actionSpecial_Reset[i], SIGNAL(triggered()), hRunEmu, SLOT(do_special_reset())); @@ -152,7 +152,7 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m) connect(this, SIGNAL(sig_emu_stop_rec_sound()), hRunEmu, SLOT(do_stop_record_sound())); connect(this, SIGNAL(sig_emu_set_display_size(int, int, int, int)), hRunEmu, SLOT(do_set_display_size(int, int, int, int))); connect(this, SIGNAL(sig_emu_thread_to_fixed_cpu(int)), hRunEmu, SLOT(set_emu_thread_to_fixed_cpu(int))); - + if(using_flags->is_use_state()) { for(int i = 0; i < 10; i++) { connect(actionLoad_State[i], SIGNAL(triggered()), hRunEmu, SLOT(do_load_state())); // OK? @@ -167,9 +167,9 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m) connect(p_osd, SIGNAL(sig_ui_floppy_insert_history(int, QString, quint64)), this, SLOT(do_ui_floppy_insert_history(int, QString, quint64)), Qt::QueuedConnection); - connect(p_osd, SIGNAL(sig_floppy_disk_write_protect(int, quint64)), + connect(p_osd, SIGNAL(sig_ui_floppy_write_protect(int, quint64)), this, SLOT(do_ui_write_protect_floppy_disk(int, quint64)), - Qt::QueuedConnection); + Qt::QueuedConnection); drvs = USE_FLOPPY_DISK; for(int ii = 0; ii < drvs; ii++) { @@ -213,7 +213,7 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m) connect(this, SIGNAL(sig_close_cdrom(int)), hRunEmu, SLOT(do_eject_cdrom(int))); //connect(hRunEmu, SIGNAL(sig_change_osd_cdrom(QString)), this, SLOT(do_change_osd_cdrom(QString))); // ToDo: multiple CDs -#endif +#endif #if defined(USE_LASER_DISC) connect(this, SIGNAL(sig_open_laserdisc(int, QString)), hRunEmu, SLOT(do_open_laser_disc(int, QString))); connect(this, SIGNAL(sig_close_laserdisc(int)), hRunEmu, SLOT(do_close_laser_disc(int))); @@ -238,12 +238,12 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m) ); } #endif - + connect(this, SIGNAL(quit_emu_thread()), hRunEmu, SLOT(doExit())); connect(hRunEmu, SIGNAL(sig_mouse_enable(bool)), this, SLOT(do_set_mouse_enable(bool))); - + hRunEmu->set_tape_play(false); #if defined(USE_KEY_LOCKED) || defined(USE_LED_DEVICE) connect(hRunEmu, SIGNAL(sig_send_data_led(quint32)), this, SLOT(do_recv_data_led(quint32)), Qt::QueuedConnection); @@ -252,15 +252,15 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m) connect(this, SIGNAL(sig_start_auto_key(QString)), hRunEmu, SLOT(do_start_auto_key(QString))); connect(this, SIGNAL(sig_stop_auto_key()), hRunEmu, SLOT(do_stop_auto_key())); connect(this, SIGNAL(sig_set_roma_kana(bool)), hRunEmu, SLOT(set_romakana(bool))); -#endif +#endif csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "EmuThread : Start."); objNameStr = QString("EmuThreadClass"); hRunEmu->setObjectName(objNameStr); - + hDrawEmu = new DrawThreadClass((OSD*)(emu->get_osd()), csp_logger, this); emu->set_parent_handler((EmuThreadClass*)hRunEmu, hDrawEmu); - + #ifdef ONE_BOARD_MICRO_COMPUTER QImageReader *reader = new QImageReader(":/background.png"); QImage *result = new QImage(reader->read()); // this acts as a default if the size is not matched @@ -307,7 +307,7 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m) glv, SLOT(resizeGL(int, int)), Qt::QueuedConnection); connect(hRunEmu, SIGNAL(sig_resize_osd(int)), driveData, SLOT(setScreenWidth(int)), Qt::QueuedConnection); connect(hRunEmu, SIGNAL(sig_change_osd(int, int, QString)), driveData, SLOT(updateMessage(int, int, QString)), Qt::QueuedConnection); - + connect(glv, SIGNAL(sig_resize_uibar(int, int)), this, SLOT(resize_statusbar(int, int)), Qt::QueuedConnection); connect(hRunEmu, SIGNAL(sig_resize_uibar(int, int)), @@ -328,22 +328,22 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m) // connect(this, SIGNAL(sig_start_saving_movie()), hRunEmu, SLOT(do_start_record_video())); connect(actionStart_Record_Movie, SIGNAL(triggered()), hRunEmu, SLOT(do_start_record_video())); connect(actionStop_Record_Movie, SIGNAL(triggered()), hRunEmu, SLOT(do_stop_record_video())); - + connect(hSaveMovieThread, SIGNAL(sig_set_state_saving_movie(bool)), this, SLOT(do_set_state_saving_movie(bool))); connect((OSD*)(emu->get_osd()), SIGNAL(sig_save_as_movie(QString, int, int)), hSaveMovieThread, SLOT(do_open(QString, int, int))); connect((OSD*)(emu->get_osd()), SIGNAL(sig_stop_saving_movie()), hSaveMovieThread, SLOT(do_close())); - + actionStop_Record_Movie->setIcon(QIcon(":/icon_process_stop.png")); actionStop_Record_Movie->setVisible(false); - + connect(this, SIGNAL(sig_movie_set_width(int)), hSaveMovieThread, SLOT(do_set_width(int))); connect(this, SIGNAL(sig_movie_set_height(int)), hSaveMovieThread, SLOT(do_set_height(int))); - + connect((OSD*)(emu->get_osd()), SIGNAL(sig_movie_set_width(int)), hSaveMovieThread, SLOT(do_set_width(int))); connect((OSD*)(emu->get_osd()), SIGNAL(sig_movie_set_height(int)), hSaveMovieThread, SLOT(do_set_height(int))); - + connect((OSD*)(emu->get_osd()), SIGNAL(sig_enqueue_audio(int16_t*, int)), hSaveMovieThread, SLOT(enqueue_audio(int16_t *, int))); connect((OSD*)(emu->get_osd()), SIGNAL(sig_enqueue_video(int, int, int, QImage *)), hSaveMovieThread, SLOT(enqueue_video(int, int, int, QImage *)), Qt::DirectConnection); @@ -413,14 +413,14 @@ void Ui_MainWindow::LaunchJoyThread(void) connect(this, SIGNAL(quit_joy_thread()), hRunJoy, SLOT(doExit())); hRunJoy->setObjectName("JoyThread"); hRunJoy->start(); -#endif +#endif } void Ui_MainWindow::StopJoyThread(void) { #if defined(USE_JOYSTICK) emit quit_joy_thread(); -#endif +#endif } void Ui_MainWindow::delete_joy_thread(void) @@ -465,7 +465,7 @@ void Ui_MainWindow::OnMainWindowClosed(void) emit quit_emu_thread(); emit sig_quit_movie_thread(); emit sig_quit_widgets(); - + if(hSaveMovieThread != nullptr) { // When recording movie, stopping will spend a lot of seconds. if(!(hSaveMovieThread->wait(60 * 1000))) { // 60 Sec @@ -475,7 +475,7 @@ void Ui_MainWindow::OnMainWindowClosed(void) delete hSaveMovieThread; hSaveMovieThread = NULL; } - + if(hDrawEmu != nullptr) { if(!(hDrawEmu->wait(1000))) { hDrawEmu->terminate(); @@ -534,7 +534,7 @@ void LostFocus(QWidget *widget) emu->key_lost_focus(); } } - + } // extern "C" void Ui_MainWindow::do_release_emu_resources(void) @@ -549,12 +549,12 @@ extern void DLL_PREFIX_I get_long_full_path_name(_TCHAR* src, _TCHAR* dst); extern _TCHAR* DLL_PREFIX_I get_parent_dir(_TCHAR* file); extern void get_short_filename(_TCHAR *dst, _TCHAR *file, int maxlen); -#if defined(Q_OS_CYGWIN) +#if defined(Q_OS_CYGWIN) #include #endif static void my_util_mkdir(std::string n) { -#if !defined(Q_OS_CYGWIN) +#if !defined(Q_OS_CYGWIN) QDir dir = QDir::current(); dir.mkdir( QString::fromStdString(n)); #else @@ -562,8 +562,8 @@ static void my_util_mkdir(std::string n) if(stat(n.c_str(), &st) != 0) { _mkdir(n.c_str()); // Not found } -#endif -} +#endif +} static void setup_logs(void) { @@ -594,7 +594,7 @@ static void setup_logs(void) } #else cpp_homedir = "."; -#endif +#endif cpp_homedir = cpp_homedir + delim; #if !defined(CSP_OS_WINDOWS) @@ -606,7 +606,7 @@ static void setup_logs(void) cpp_confdir = cpp_confdir + "CommonSourceCodeProject" + delim; my_util_mkdir(cpp_confdir); - + cpp_confdir = cpp_confdir + my_procname + delim; my_util_mkdir(cpp_confdir); //AG_MkPath(cpp_confdir.c_str()); @@ -956,7 +956,7 @@ void SetOptions(QCommandLineParser *cmdparser) SetOptions_Sub(cmdparser); QStringList _cl; - + for(int i = 0; i < 8; i++) { _opt_fds[i] = NULL; _opt_hdds[i] = NULL; @@ -969,7 +969,7 @@ void SetOptions(QCommandLineParser *cmdparser) _opt_cmts[i] = NULL; _opt_lds[i] = NULL; _opt_cds[i] = NULL; - } + } SetFDOptions(cmdparser); SetHDDOptions(cmdparser); @@ -980,7 +980,7 @@ void SetOptions(QCommandLineParser *cmdparser) SetQuickDiskOptions(cmdparser); SetLDOptions(cmdparser); // Temporally disabled. SetCDOptions(cmdparser); - + cmdparser->addOption(*_opt_envver); cmdparser->addOption(*_opt_dump_envver); } @@ -996,7 +996,7 @@ void ProcessCmdLine(QCommandLineParser *cmdparser, QStringList *_l) #else delim = "/"; #endif - ProcessCmdLine_Sub(cmdparser, _l); + ProcessCmdLine_Sub(cmdparser, _l); { char tmps[128]; std::string localstr; @@ -1061,7 +1061,7 @@ void ProcessCmdLine(QCommandLineParser *cmdparser, QStringList *_l) case CONFIG_RENDER_PLATFORM_OPENGL_MAIN: case CONFIG_RENDER_PLATFORM_OPENGL_CORE: QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL, true); - QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); // Enable shared contexts. + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); // Enable shared contexts. QCoreApplication::setAttribute(Qt::AA_UseOpenGLES, false); break; case CONFIG_RENDER_PLATFORM_OPENGL_ES: @@ -1129,16 +1129,16 @@ void OpeningMessage(std::shared_ptrp_logger, std::string archstr) p_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "(C) Toshiya Takeda / Qt Version K.Ohta"); p_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Architecture: %s", archstr.c_str()); p_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Use -h or --help for help."); - + //p_logger->debug_log(AGAR_LOG_INFO, " -? is print help(s)."); p_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Home = %s, Resource directory = %s", cpp_homedir.c_str(), sRssDir.c_str()); // Debug - + p_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Config dir = %s, config_file = %s", cpp_confdir.c_str(), config_fullpath.c_str()); // Debug - + p_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "DIPSW VALUE IS 0x%08x", config.dipswitch); if(virtualMediaList.size() >= 2) { for(int i = 0; i < virtualMediaList.size(); i += 2) { @@ -1194,11 +1194,11 @@ void SetupLogger(std::shared_ptr csp_logger, QObject *parent, std::s csp_logger->set_log_stdout(CSP_LOG_DEBUG, true); csp_logger->set_log_stdout(CSP_LOG_INFO, true); csp_logger->set_log_stdout(CSP_LOG_WARN, true); - + csp_logger->set_state_log(0, config.state_log_to_recording); csp_logger->set_state_log(1, config.state_log_to_syslog); csp_logger->set_state_log(2, config.state_log_to_console); - + for(int ii = 0; ii < _size; ii++) { for(int jj = 0; jj < 8; jj++) { csp_logger->set_device_node_log(ii, 1, jj, config.dev_log_to_syslog[ii][jj]); @@ -1223,7 +1223,7 @@ int MainLoop(int argc, char *argv[]) #else delim = "/"; #endif - + QApplication *GuiMain = NULL; GuiMain = new QApplication(argc, argv); GuiMain->setObjectName(QString::fromUtf8("Gui_Main")); @@ -1255,7 +1255,7 @@ int MainLoop(int argc, char *argv[]) _envvers = QProcessEnvironment::systemEnvironment(); std::shared_ptrp_logger = std::shared_ptr(new CSP_Logger(GuiMain, config.log_to_syslog, config.log_to_console, emustr.c_str())); - set_debug_logger(p_logger); + set_debug_logger(p_logger); SetupLogger(p_logger, GuiMain, emustr, CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1); OpeningMessage(p_logger, archstr); SetupSDL(p_logger); @@ -1297,7 +1297,7 @@ int MainLoop(int argc, char *argv[]) } } } - + // USING_FLAGS_EXT *using_flags = new USING_FLAGS_EXT(&config); // initialize emulation core rMainWindow = new META_MainWindow(using_flags, p_logger); @@ -1308,7 +1308,7 @@ int MainLoop(int argc, char *argv[]) // QMetaObject::connectSlotsByName(rMainWindow); EmuThreadClass *hRunEmu_Real = new EmuThreadClass(rMainWindow, using_flags); OSD_BASE* p_osd = hRunEmu_Real->get_emu()->get_osd(); - + QObject::connect((OSD*)p_osd, SIGNAL(sig_update_device_node_name(int, const _TCHAR *)), rMainWindow, SLOT(do_update_device_node_name(int, const _TCHAR *))); for(int i = 0; i < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1); i++) { @@ -1316,7 +1316,7 @@ int MainLoop(int argc, char *argv[]) } p_logger->set_osd((OSD*)p_osd); p_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "InitInstance() OK."); - + // ToDo: Update raltime. rMainWindow->connect(rMainWindow, SIGNAL(sig_osd_sound_output_device(QString)), (OSD*)p_osd, SLOT(do_set_host_sound_output_device(QString))); rMainWindow->do_update_sound_output_list(); @@ -1324,9 +1324,9 @@ int MainLoop(int argc, char *argv[]) QObject::connect((OSD*)p_osd, SIGNAL(sig_update_sound_output_list()), rMainWindow, SLOT(do_update_sound_output_list())); QObject::connect((OSD*)p_osd, SIGNAL(sig_clear_sound_output_list()), rMainWindow, SLOT(do_clear_sound_output_list())); QObject::connect((OSD*)p_osd, SIGNAL(sig_append_sound_output_list(QString)), rMainWindow, SLOT(do_append_sound_output_list(QString))); - + QObject::connect(rMainWindow, SIGNAL(sig_update_master_volume(int)), (OSD*)p_osd, SLOT(do_update_master_volume(int))); - + QObject::connect(GuiMain, SIGNAL(lastWindowClosed()), rMainWindow, SLOT(on_actionExit_triggered())); @@ -1341,7 +1341,7 @@ int MainLoop(int argc, char *argv[]) // pgl->setFixedSize(pgl->width(), pgl->height()); // main loop rMainWindow->LaunchEmuThread(hRunEmu_Real); - + #if defined(USE_JOYSTICK) rMainWindow->LaunchJoyThread(); #endif @@ -1371,13 +1371,13 @@ void Ui_MainWindow::do_update_inner_fd(int drv, QStringList base, class Action_C } } } -#endif +#endif } void Ui_MainWindow::do_update_inner_bubble(int drv, QStringList base, class Action_Control **action_select_media_list, QStringList lst, int num, bool use_d88_menus) { -#if defined(USE_BUBBLE) +#if defined(USE_BUBBLE) if(use_d88_menus) { for(int ii = 0; ii < using_flags->get_max_b77_banks(); ii++) { if(ii < emu->b77_file[drv].bank_num) { @@ -1393,7 +1393,7 @@ void Ui_MainWindow::do_update_inner_bubble(int drv, QStringList base, class Acti } } } -#endif +#endif } int Ui_MainWindow::GetBubbleBankNum(int drv) @@ -1471,7 +1471,7 @@ void Ui_MainWindow::OnOpenDebugger() // ToDo: Multiple debugger 20221105 K.O if((emu->now_debugging ) || (emu->hDebugger.get() != nullptr)) /* OnCloseDebugger(); */ return; - + if(!(emu->now_debugging && emu->debugger_thread_param.cpu_index == no)) { //emu->close_debugger(); if(vm->get_cpu(no) != NULL && vm->get_cpu(no)->get_debugger() != NULL) { @@ -1483,14 +1483,14 @@ void Ui_MainWindow::OnOpenDebugger() } QString objNameStr = QString("EmuDebugThread"); emu->hDebugger->setObjectName(objNameStr); - + emu->hDebugger->debugger_thread_param.osd = (OSD_BASE *)(emu->get_osd()); emu->hDebugger->debugger_thread_param.emu = emu; emu->hDebugger->debugger_thread_param.vm = vm; emu->hDebugger->debugger_thread_param.cpu_index = no; emu->hDebugger->debugger_thread_param.running = false; emu->hDebugger->debugger_thread_param.request_terminate = false; - + emu->stop_record_sound(); emu->stop_record_video(); //emu->now_debugging = true; @@ -1537,15 +1537,15 @@ QString Ui_MainWindow::get_system_version() QString libcommon_ver; QString libfmgen_ver; QString build_date; - + QString outstr; - + aviover.clear(); common_vmver.clear(); vm_gitver.clear(); osdver.clear(); libcommon_ver.clear(); - + if(hSaveMovieThread != NULL) { aviover = hSaveMovieThread->get_avio_version(); } @@ -1565,13 +1565,13 @@ QString Ui_MainWindow::get_system_version() } } } - + const _TCHAR *pp = get_lib_common_version(); if(pp != NULL) { libcommon_ver = QString::fromUtf8(pp); } libfmgen_ver = QString::fromUtf8(FM::get_libfmgen_version()); - + outstr.clear(); outstr.append(QString::fromUtf8("")); if(!(common_vmver.isEmpty())) { diff --git a/source/src/qt/osd_base.cpp b/source/src/qt/osd_base.cpp index dedae9db1..943878063 100644 --- a/source/src/qt/osd_base.cpp +++ b/source/src/qt/osd_base.cpp @@ -58,9 +58,9 @@ OSD_BASE::OSD_BASE(std::shared_ptr p, std::shared_ptr l max_vm_nodes = 0; p_logger = logger; vm = NULL; - + SupportedFeatures.clear(); - + is_glcontext_shared = false; glContext = NULL; @@ -87,7 +87,7 @@ const _TCHAR *OSD_BASE::get_lib_osd_version() #if defined(__LIBOSD_VERSION) return (const _TCHAR *)__LIBOSD_VERSION; #endif - return p; + return p; } QOpenGLContext *OSD_BASE::get_gl_context() @@ -151,8 +151,8 @@ void OSD_BASE::debug_log(int level, const char *fmt, ...) { char strbuf[4096]; va_list ap; - - va_start(ap, fmt); + + va_start(ap, fmt); vsnprintf(strbuf, 4095, fmt, ap); debug_log(level, 0, strbuf); va_end(ap); @@ -162,8 +162,8 @@ void OSD_BASE::debug_log(int level, int domain_num, const char *fmt, ...) { char strbuf[4096]; va_list ap; - - va_start(ap, fmt); + + va_start(ap, fmt); vsnprintf(strbuf, 4095, fmt, ap); debug_log(level, domain_num, strbuf); va_end(ap); @@ -293,7 +293,7 @@ void OSD_BASE::notify_power_off(void) int OSD_BASE::get_vm_buttons_code(int num) { return 0; -} +} QString OSD_BASE::get_vm_config_name(void) { @@ -528,7 +528,7 @@ double OSD_BASE::get_feature_double_value(const _TCHAR *key) return l.v.fvalue; } } - return std::numeric_limits::quiet_NaN(); // You don't use (0.0 / 0.0). + return std::numeric_limits::quiet_NaN(); // You don't use (0.0 / 0.0). } int64_t OSD_BASE::get_feature_int64_value(const _TCHAR *key) @@ -598,13 +598,13 @@ uint8_t OSD_BASE::get_feature_uint8_value(const _TCHAR *key) void OSD_BASE::start_waiting_in_debugger() { // ToDo: Wait for rising up debugger window. - debug_mutex.lock(); + debug_mutex.lock(); } void OSD_BASE::finish_waiting_in_debugger() { // ToDo: Wait for closing up debugger window. - debug_mutex.unlock(); + debug_mutex.unlock(); } void OSD_BASE::process_waiting_in_debugger() @@ -684,19 +684,27 @@ void OSD_BASE::string_message_from_emu(EMU_MEDIA_TYPE::type_t media_type, int dr // Below are update message to UI. return; // ToDo: Implement } - + // Below are update status to UI. + if(message != nullptr) { + tmps = QString::fromLocal8Bit(message); + } switch(_type) { case EMU_MEDIA_TYPE::FLOPPY_DISK : - if(message != nullptr) { - tmps = QString::fromLocal8Bit(message); - } switch(message_type) { + // From EMU::open_floppy_disk case EMU_MESSAGE_TYPE::MEDIA_MOUNTED : emit sig_ui_floppy_insert_history(drive, tmps, _slot); break; } break; + case EMU_MEDIA_TYPE::TAPE : + switch(message_type) { + case EMU_MESSAGE_TYPE::MEDIA_MOUNTED : + emit sig_ui_tape_play_insert_history(drive, tmps); + break; + } + break; } } @@ -712,8 +720,12 @@ void OSD_BASE::int_message_from_emu(EMU_MEDIA_TYPE::type_t media_type, int drive switch(_type) { case EMU_MEDIA_TYPE::FLOPPY_DISK : switch(message_type) { + // From EMU::close_floppy_disk + case EMU_MESSAGE_TYPE::MEDIA_REMOVED : + emit sig_ui_floppy_close(drive); + break; case EMU_MESSAGE_TYPE::MEDIA_WRITE_PROTECT : - emit sig_floppy_disk_write_protect(drive, data); + emit sig_ui_floppy_write_protect(drive, data); break; } break; diff --git a/source/src/qt/osd_base.h b/source/src/qt/osd_base.h index 60e739dfa..754a2a62f 100644 --- a/source/src/qt/osd_base.h +++ b/source/src/qt/osd_base.h @@ -148,7 +148,7 @@ typedef struct { int read_pos; int read_data_len; int read_buffer_len; - + uint8_t *read_buffer_ptr; uint8_t *out_buffer; } osd_snd_capture_desc_t; @@ -168,10 +168,10 @@ private: qint64 elapsed_us_before_rendered; SOUND_BUFFER_QT *m_audioOutput; SOUND_BUFFER_QT *m_audioInput; - + QAudioFormat m_audioOutputFormat; QAudioFormat m_audioInputFormat; - + #endif uint8_t m_sound_period; protected: @@ -180,21 +180,21 @@ protected: std::shared_ptr using_flags; config_t *p_config; std::shared_ptr p_logger; - + QOpenGLContext *glContext; bool is_glcontext_shared; - + QList SupportedFeatures; - + bool __USE_AUTO_KEY; - + _TCHAR app_path[_MAX_PATH]; QElapsedTimer osd_timer; bool locked_vm; // console - virtual void initialize_console(); + virtual void initialize_console(); virtual void release_console(); - + FILE *hStdIn, *hStdOut; QString console_cmd_str; @@ -207,10 +207,10 @@ protected: void key_down_sub(int code, bool repeat); void key_up_sub(int code); CSP_KeyTables *key_table; - + bool dinput_key_ok; // bool dinput_joy_ok; - + uint8_t keycode_conv[256]; uint8_t key_status[256]; // windows key code mapping uint8_t key_dik_prev[256]; @@ -227,14 +227,14 @@ protected: * 0 - 3: * joystick #1, - #4 (b0 = up, b1 = down, b2 = left, b3 = right, b4- = buttons) * 4 - 11: - * ANALOG #1 - #4 AXIS LEFT X,Y : VALUE 65536 - 0 (RAW VALUE PLUS 32768) + * ANALOG #1 - #4 AXIS LEFT X,Y : VALUE 65536 - 0 (RAW VALUE PLUS 32768) * 12 - 19: * ANALOG #1 - #4 AXIS RIGHT X,Y : VALUE = 65536 - 0 (RAW VALUE PLUS 32768) * 20 - 23: * ANALOG #1 - #4 DIGITAL DIR (b0 = UP, b1 = DOWN, b2 = LEFT, b3 = RIGHT) */ uint32_t joy_status[32]; - + int32_t mouse_status[3]; // x, y, button (b0 = left, b1 = right) bool mouse_enabled; double mouse_ptrx; @@ -243,13 +243,13 @@ protected: double mouse_oldx; double mouse_oldy; //Qt::CursorShape mouse_shape; - + QImage background_image; QImage button_images[N_MAX_BUTTONS]; QImage rec_image_buffer; - + // printer - + // screen void initialize_screen(); void release_screen(); @@ -258,44 +258,44 @@ protected: void release_screen_buffer(bitmap_t *buffer); void rotate_screen_buffer(bitmap_t *source, bitmap_t *dest); virtual scrntype_t *get_buffer(bitmap_t *p, int y); - + void stretch_screen_buffer(bitmap_t *source, bitmap_t *dest); virtual int add_video_frames(); - + bitmap_t vm_screen_buffer; bitmap_t video_screen_buffer; bitmap_t* draw_screen_buffer; int vm_window_width, vm_window_height; int vm_window_width_aspect, vm_window_height_aspect; - + int host_window_width, host_window_height; bool host_window_mode; int base_window_width, base_window_height; int vm_screen_width, vm_screen_height; int draw_screen_width, draw_screen_height; int rec_video_nsec, rec_video_fps_nsec; - + _TCHAR video_file_name[_MAX_PATH]; int rec_video_fps; - + uint64_t dwAVIFileSize; uint64_t lAVIFrames; rec_video_thread_param_t rec_video_thread_param; - + bool first_draw_screen; bool first_invalidate; bool self_invalidate; - + // sound -#if defined(USE_SDL2) +#if defined(USE_SDL2) SDL_AudioDeviceID audio_dev_id; #else int audio_dev_id; #endif SDL_AudioSpec snd_spec_req, snd_spec_presented; void release_sound(); -#if 0 +#if 0 static void audio_capture_callback(void *udata, Uint8 *stream, int len); static void audio_callback(void *udata, Uint8 *stream, int len); void convert_sound_format(uint8_t* dst1, uint8_t* dst2, int16_t* src1, int16_t* src2, int samples1, int samples2); @@ -306,7 +306,7 @@ protected: bool sound_ok, sound_started, now_mute; bool sound_first_half; QStringList sound_device_list; - + _TCHAR sound_file_name[_MAX_PATH]; FILEIO* rec_sound_fio; int rec_sound_bytes; @@ -332,7 +332,7 @@ protected: // video device virtual void initialize_video(); virtual void release_video(); - + bitmap_t dshow_screen_buffer; int direct_show_width, direct_show_height; bool direct_show_mute[2]; @@ -354,7 +354,7 @@ protected: // socket virtual void initialize_socket(); virtual void release_socket(); - + bool is_tcp[SOCKET_MAX]; bool host_mode[SOCKET_MAX]; int socket_delay[SOCKET_MAX]; @@ -362,13 +362,13 @@ protected: // MIDI : Will implement virtual void initialize_midi(); virtual void release_midi(); - + // wrapper int max_vm_nodes; QList device_node_list; void vm_draw_screen(void); Sint16* create_sound(int *extra_frames); - + virtual bool get_use_socket(void); virtual bool get_use_auto_key(void); virtual bool get_dont_keeep_key_pressed(void); @@ -388,7 +388,7 @@ protected: public: OSD_BASE(std::shared_ptr p, std::shared_ptr logger); ~OSD_BASE(); - + // common VM_TEMPLATE* vm; //EMU* emu; @@ -402,15 +402,15 @@ public: std::recursive_timed_mutex log_mutex; int host_cpus; bool now_auto_key; - + virtual void initialize(int rate, int samples, int* presented_rate, int* presented_samples); // sound virtual void initialize_sound(int rate, int samples, int* presented_rate, int* presented_samples); virtual void release(); - + void notify_power_off(); // For USE_NOTIFY_POWER_OFF . - + void power_off(); void suspend(); void restore(); @@ -425,7 +425,7 @@ public: virtual void close_console(); virtual unsigned int get_console_code_page(); virtual bool is_console_closed(); - + void set_console_text_attribute(unsigned short attr); void write_console(const _TCHAR* buffer, unsigned int length); int read_console_input(_TCHAR* buffer, int length); @@ -470,7 +470,7 @@ public: void release_printer(); void open_printer_file(); void close_printer_file(); - + // common screen int get_window_mode_width(int mode); int get_window_mode_height(int mode); @@ -516,9 +516,9 @@ public: { return sound_device_list; } - + int get_sound_device_num(); - + bool now_record_sound; int get_sound_rate(); @@ -554,7 +554,7 @@ public: void show_capture_dev_pin(); void show_capture_dev_source(); void set_capture_dev_channel(int ch); - + // common printer void create_bitmap(bitmap_t *bitmap, int width, int height); void release_bitmap(bitmap_t *bitmap); @@ -565,7 +565,7 @@ public: void clear_bitmap(bitmap_t *bitmap, uint8_t r, uint8_t g, uint8_t b); int get_text_width(bitmap_t *bitmap, font_t *font, const char *text); - + void draw_text_to_bitmap(bitmap_t *bitmap, font_t *font, int x, int y, const _TCHAR *text, uint8_t r, uint8_t g, uint8_t b); void draw_line_to_bitmap(bitmap_t *bitmap, pen_t *pen, int sx, int sy, int ex, int ey); void draw_rectangle_to_bitmap(bitmap_t *bitmap, int x, int y, int width, int height, uint8_t r, uint8_t g, uint8_t b); @@ -598,12 +598,12 @@ public: // Note: Belows maybe make Qt SLOTs. virtual void __FASTCALL notify_timeout_sending_to_midi(int ch); virtual void __FASTCALL notify_timeout_receiving_from_midi(int ch); - + virtual void reset_to_midi(int ch, double timestamp_usec); virtual void initialize_midi_device(bool handshake_from_midi, bool handshake_to_midi, int ch); virtual void __FASTCALL ready_receive_from_midi(int ch, double timestamp_usec); virtual void __FASTCALL ready_send_to_midi(int ch, double timestamp_usec); - + virtual void __FASTCALL request_stop_to_receive_from_midi(int ch, double timestamp_usec); virtual void __FASTCALL request_stop_to_send_to_midi(int ch, double timestamp_usec); @@ -614,7 +614,7 @@ public: _TCHAR *console_input_string(void); void clear_console_input_string(void); - + void lock_vm(void); void unlock_vm(void); void force_unlock_vm(void); @@ -622,24 +622,24 @@ public: virtual const _TCHAR *get_lib_common_vm_version(); const _TCHAR *get_lib_common_vm_git_version(); const _TCHAR *get_lib_osd_version(); - + // Wrapper virtual void set_draw_thread(DrawThreadClass *handler); virtual QString get_vm_config_name(void); virtual void reset_vm_node(void); - + void set_device_name(int id, char *name); - + void set_vm_node(int id, const _TCHAR *name); const _TCHAR *get_vm_node_name(int id); int get_vm_node_size(void); - + int get_key_name_table_size(void); uint32_t get_scancode_by_vk(uint32_t vk); uint32_t get_vk_by_scancode(uint32_t scancode); const _TCHAR *get_key_name_by_scancode(uint32_t scancode); const _TCHAR *get_key_name_by_vk(uint32_t vk); - + // Get #define S to value.You may use inside of VM/ . virtual void set_features(void) {} void add_feature(const _TCHAR *key, double value); @@ -659,7 +659,7 @@ public: int32_t get_feature_int32_value(const _TCHAR *key); int16_t get_feature_int16_value(const _TCHAR *key); int8_t get_feature_int8_value(const _TCHAR *key); - + uint64_t get_feature_uint64_value(const _TCHAR *key); uint32_t get_feature_uint32_value(const _TCHAR *key); uint16_t get_feature_uint16_value(const _TCHAR *key); @@ -686,23 +686,23 @@ public: // Messaging wrapper from EMU:: to OSD:: void __FASTCALL string_message_from_emu(EMU_MEDIA_TYPE::type_t media_type, int drive, EMU_MESSAGE_TYPE::type_t message_type, _TCHAR* message); void __FASTCALL int_message_from_emu(EMU_MEDIA_TYPE::type_t media_type, int drive, EMU_MESSAGE_TYPE::type_t message_type, int64_t data); - + public slots: void enable_mouse(); void disable_mouse(); void toggle_mouse(); - + void upload_bitmap(QImage *p); void set_buttons(); - + int no_draw_screen(); void do_write_inputdata(QString s); void do_set_input_string(QString s); - + void close_debugger_console(); void do_close_debugger_thread(); - + void do_assign_js_setting(int jsnum, int axis_idx, int assigned_value); void do_start_record_video(); virtual void do_decode_movie(int frames); @@ -712,7 +712,7 @@ public slots: virtual int draw_screen(); void do_draw(bool flag); - + void set_dbg_completion_list(std::list *p); void clear_dbg_completion_list(void); void set_hdd_image_name(int drv, _TCHAR *filename); @@ -729,7 +729,7 @@ signals: int sig_resize_vm_lines(int); int sig_put_string_debugger(QString); int sig_console_input_string(QString); - int sig_enqueue_video(int, int, int, QImage *); + int sig_enqueue_video(int, int, int, QImage *); int sig_enqueue_audio(int16_t *data, int size); int sig_movie_set_width(int); int sig_movie_set_height(int); @@ -770,7 +770,49 @@ signals: // To GUI 20230125 K.O int sig_ui_floppy_insert_history(int, QString, quint64); - int sig_floppy_disk_write_protect(int, quint64); + int sig_ui_floppy_close(int); + int sig_ui_floppy_write_protect(int, quint64); + + int sig_ui_quick_disk_insert_history(int, QString); + int sig_ui_quick_disk_close(int); + int sig_ui_quick_disk_write_protect(int, quint64); + + int sig_ui_hard_disk_insert_history(int, QString); + int sig_ui_hard_disk_close(int); + + int sig_ui_cartridge_insert_history(int, QString); + int sig_ui_cartridge_eject(int); + + int sig_ui_tape_play_insert_history(int, QString); + int sig_ui_tape_record_insert_history(int, QString); + int sig_ui_tape_eject(int); + int sig_ui_tape_position(int, int); + int sig_ui_tape_message(int, QString); + + int sig_ui_tape_push_play(int); + int sig_ui_tape_push_stop(int); + int sig_ui_tape_push_fast_forward(int); + int sig_ui_tape_push_fast_rewind(int); + int sig_ui_tape_push_apss_forward(int); + int sig_ui_tape_push_apss_rewind(int); + int sig_ui_tape_push_pause(int, bool); + + int sig_ui_compact_disc_insert_history(int, QString); + int sig_ui_compact_disc_eject(int); + int sig_ui_compact_disc_pause(int); + + int sig_ui_laser_disc_insert_history(int, QString); + int sig_ui_laser_disc_eject(int); + int sig_ui_laser_disc_pause(int); + + int sig_ui_binary_loading_insert_history(int, QString); + int sig_ui_binary_saving_insert_history(int, QString); + int sig_ui_binary_closed(int); + + int sig_ui_bubble_insert_history(int, QString, quint64); + int sig_ui_bubble_close(int); + int sig_ui_bubble_write_protect(int, quint64); + }; QT_END_NAMESPACE -- 2.11.0