OSDN Git Service

[UI][Qt][MOUSE] Add mouse sensitivities config.Still not implement GUIs.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 11 Nov 2020 04:19:56 +0000 (13:19 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 11 Nov 2020 04:19:56 +0000 (13:19 +0900)
[UI][Qt][MOUSE] Send global position when capturing.

source/src/config.cpp
source/src/config.h
source/src/qt/CMakeLists.txt
source/src/qt/common/emu_thread_slots.cpp
source/src/qt/common/qt_utils.cpp
source/src/qt/gui/CMakeLists.txt
source/src/qt/gui/emu_thread_tmpl.h
source/src/qt/gui/qt_gldraw.h
source/src/qt/gui/qt_glevents.cpp
source/src/qt/osd_base.h
source/src/qt/osd_input.cpp

index c9fcba9..8340642 100644 (file)
@@ -73,6 +73,8 @@ void initialize_config()
        #if defined(USE_MOUSE_TYPE) && defined(MOUSE_TYPE_DEFAULT)
                config.mouse_type = MOUSE_TYPE_DEFAULT;
        #endif
+               config.mouse_sensitivity_x = 1 << 12; // 1.0
+               config.mouse_sensitivity_y = 1 << 12; // 1.0
        #if defined(USE_JOYSTICK_TYPE) && defined(JOYSTICK_TYPE_DEFAULT)
                config.joystick_type = JOYSTICK_TYPE_DEFAULT;
        #endif
@@ -449,6 +451,8 @@ void load_config(const _TCHAR *config_path)
                        config.joy_to_key_buttons[i] = MyGetPrivateProfileInt(_T("Input"), create_string(_T("JoyToKeyButtons%d"), i + 1), config.joy_to_key_buttons[i], config_path);
                }
        #endif
+               config.mouse_sensitivity_x = MyGetPrivateProfileInt(_T("Control"), _T("MouseSensitivityX"), config.mouse_sensitivity_x, config_path);
+               config.mouse_sensitivity_y = MyGetPrivateProfileInt(_T("Control"), _T("MouseSensitivityY"), config.mouse_sensitivity_y, config_path);
        // debug
        #ifdef USE_FLOPPY_DISK
                config.special_debug_fdc =      MyGetPrivateProfileInt(_T("Debug"), _T("SpecialDebugFDC"), config.special_debug_fdc, config_path);
@@ -820,6 +824,8 @@ void save_config(const _TCHAR *config_path)
                        MyWritePrivateProfileInt(_T("Input"), create_string(_T("JoyToKeyButtons%d"), i + 1), config.joy_to_key_buttons[i], config_path);
                }
        #endif
+               MyWritePrivateProfileInt(_T("Control"), _T("MouseSensitivityX"), config.mouse_sensitivity_x, config_path);
+               MyWritePrivateProfileInt(_T("Control"), _T("MouseSensitivityY"), config.mouse_sensitivity_y, config_path);
 
        // debug
        #ifdef USE_FLOPPY_DISK
@@ -933,7 +939,7 @@ void save_config(const _TCHAR *config_path)
        #endif  
 }
 
-#define STATE_VERSION  6
+#define STATE_VERSION  7
 
 bool process_config_state(void *f, bool loading)
 {
@@ -942,47 +948,63 @@ bool process_config_state(void *f, bool loading)
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
        }
-       #ifdef USE_BOOT_MODE
+       #if defined(USE_FIXED_CONFIG) || defined(USE_BOOT_MODE)
                state_fio->StateValue(config.boot_mode);
        #endif
-       #ifdef USE_CPU_TYPE
+       #if defined(USE_FIXED_CONFIG) || defined(USE_CPU_TYPE)
                state_fio->StateValue(config.cpu_type);
        #endif
-       #ifdef USE_DIPSWITCH
+       #if defined(USE_FIXED_CONFIG) || defined(USE_DIPSWITCH)
                state_fio->StateValue(config.dipswitch);
        #endif
-       #ifdef USE_DEVICE_TYPE
+       #if defined(USE_FIXED_CONFIG) || defined(USE_DEVICE_TYPE)
                state_fio->StateValue(config.device_type);
        #endif
-       #ifdef USE_DRIVE_TYPE
+       #if defined(USE_FIXED_CONFIG) || defined(USE_DRIVE_TYPE)
                state_fio->StateValue(config.drive_type);
        #endif
-       #ifdef USE_KEYBOARD_TYPE
+       #if defined(USE_FIXED_CONFIG) || defined(USE_KEYBOARD_TYPE)
                state_fio->StateValue(config.keyboard_type);
        #endif
-       #ifdef USE_MOUSE_TYPE
+       #if defined(USE_FIXED_CONFIG) || defined(USE_MOUSE_TYPE)
                state_fio->StateValue(config.mouse_type);
        #endif
-       #ifdef USE_JOYSTICK_TYPE
+       #if defined(USE_FIXED_CONFIG) || defined(USE_JOYSTICK_TYPE)
                state_fio->StateValue(config.joystick_type);
        #endif
-       #ifdef USE_SOUND_TYPE
+       #if defined(USE_FIXED_CONFIG) || defined(USE_SOUND_TYPE)
                state_fio->StateValue(config.sound_type);
        #endif
-       #ifdef USE_MONITOR_TYPE
+       #if defined(USE_FIXED_CONFIG) || defined(USE_MONITOR_TYPE)
                state_fio->StateValue(config.monitor_type);
        #endif
-       #ifdef USE_PRINTER_TYPE
+       #if defined(USE_FIXED_CONFIG) || defined(USE_PRINTER_TYPE)
                state_fio->StateValue(config.printer_type);
        #endif
-       #ifdef USE_FLOPPY_DISK
-               for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
+       #if  defined(USE_SHARED_DLL) || defined(USE_FLOPPY_DISK)
+               for(int drv = 0; drv < 16; drv++) {
                        state_fio->StateValue(config.correct_disk_timing[drv]);
                        state_fio->StateValue(config.ignore_disk_crc[drv]);
                }
        #endif
        state_fio->StateValue(config.sound_frequency);
        state_fio->StateValue(config.sound_latency);
+       
+       #if defined(USE_FIXED_CONFIG) || defined(USE_SCANLINE)
+       state_fio->StateValue(config.scan_line);
+       #endif
+       #if defined(USE_SHARED_DLL) || defined(USE_TAPE)
+       for(int i = 0; i < USE_TAPE_TMP; i++) {
+               state_fio->StateValue(config.wave_shaper[i]);
+               state_fio->StateValue(config.direct_load_mzt[i]);
+               state_fio->StateValue(config.baud_high[i]);
+       }
+       #endif
+       #if defined(USE_SHARED_DLL) || defined(USE_VARIABLE_MEMORY)
+       state_fio->StateValue(config.current_ram_size);
+       #endif
+       state_fio->StateValue(config.cpu_power);
+       
        return true;
 }
 
index 0f0f5aa..e1f61c6 100644 (file)
@@ -131,10 +131,10 @@ typedef struct {
                int keyboard_type;
        #endif
        #if defined(USE_FIXED_CONFIG) || defined(USE_MOUSE_TYPE)
-               int mouse_type;
+               int mouse_type; /*!< Emulated type of mouse by VM */ 
        #endif
        #if defined(USE_FIXED_CONFIG) || defined(USE_JOYSTICK_TYPE)
-               int joystick_type;
+               int joystick_type; /*!< Emulated type of joystick by VM */ 
        #endif
        #if defined(USE_FIXED_CONFIG) || defined(USE_SOUND_TYPE)
                int sound_type;
@@ -217,6 +217,8 @@ typedef struct {
                int filter_type;
        #endif
 
+       uint32_t mouse_sensitivity_x; /*!< SENSITIVITY of MOUSE , X Value * 2^12, limit is 2^16-1 */
+       uint32_t mouse_sensitivity_y; /*!< SENSITIVITY of MOUSE , Y Value * 2^12, limit is 2^16 - 1 */
        // NOTE: Belows contain STAGED CONFIGURATION.
 #if defined(_USE_QT)
        bool use_separate_thread_draw;
index f0aab14..c8aab6f 100644 (file)
@@ -1,5 +1,5 @@
 message("* qt/osd")
-SET(THIS_LIB_VERSION 3.3.2)
+SET(THIS_LIB_VERSION 3.3.3)
 
 set(s_qt_osd_headers
        osd_base.h
index b3eb7c7..56e7868 100644 (file)
@@ -858,7 +858,7 @@ void EmuThreadClassBase::set_romakana(bool flag)
        }
 }
 
-void EmuThreadClassBase::moved_mouse(int x, int y)
+void EmuThreadClassBase::moved_mouse(int x, int y, int globalx, int globaly)
 {
        if(using_flags->is_use_one_board_computer() || using_flags->is_use_mouse() || (using_flags->get_max_button() > 0)) {
                mouse_x = x;
@@ -867,7 +867,7 @@ void EmuThreadClassBase::moved_mouse(int x, int y)
                bool flag = p_osd->is_mouse_enabled();
                if(!flag) return;
                //printf("Mouse Moved: %d, %d\n", x, y);
-               p_osd->set_mouse_pointer(x, y);
+               p_osd->set_mouse_pointer(globalx, globaly);
        }
 }
 
index d5bf6e8..4f9a58d 100644 (file)
@@ -279,8 +279,8 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m)
        //connect(hRunEmu, SIGNAL(quit_draw_thread()), hDrawEmu, SLOT(doExit()));
        connect(this, SIGNAL(quit_draw_thread()), hDrawEmu, SLOT(doExit()));
 
-       connect(glv, SIGNAL(do_notify_move_mouse(int, int)),
-                       hRunEmu, SLOT(moved_mouse(int, int)));
+       connect(glv, SIGNAL(do_notify_move_mouse(int, int, int, int)),
+                       hRunEmu, SLOT(moved_mouse(int, int, int, int)));
        connect(glv, SIGNAL(do_notify_button_pressed(Qt::MouseButton)),
                hRunEmu, SLOT(button_pressed_mouse(Qt::MouseButton)));
        connect(glv, SIGNAL(do_notify_button_released(Qt::MouseButton)),
index 8ff5be7..10e14ad 100644 (file)
@@ -1,6 +1,6 @@
 message("* qt/gui")
 
-set(THIS_LIB_VERSION 3.2.4)
+set(THIS_LIB_VERSION 3.2.5)
 #include(cotire)
 #include(PrecompiledHeader)
 
index 5d00125..ff985de 100644 (file)
@@ -254,7 +254,7 @@ public slots:
 
        // From emu_thread_slots.cpp .
        void do_set_display_size(int w, int h, int ww, int wh);
-       void moved_mouse(int, int);
+       void moved_mouse(int x, int y, int globalx, int globaly);
 
        void do_write_protect_disk(int drv, bool flag);
        void do_close_disk(int);
index 6bd441f..d4897d2 100644 (file)
@@ -159,7 +159,7 @@ public slots:
 
 signals:
        void update_screenChanged(int tick);
-       void do_notify_move_mouse(int x, int y);
+       void do_notify_move_mouse(int x, int y, int globalx, int globaly);
 
        void sig_toggle_mouse(void);
        void do_notify_button_pressed(Qt::MouseButton button);
index a9f038c..87ad746 100644 (file)
@@ -43,13 +43,15 @@ void GLDrawClass::setEnableMouse(bool enable)
 
 void GLDrawClass::mouseMoveEvent(QMouseEvent *event)
 {
-       double xx;
-       double yy;
+       double xx, gxx;
+       double yy, gyy;
        int d_ww = using_flags->get_screen_width();
        int d_hh = using_flags->get_screen_height();
        QPointF pos = event->localPos();
        double xpos = (double)(pos.x()) / (double)width();
        double ypos = (double)(pos.y()) / (double)height();
+       double gxpos = (double)(event->globalPos().x()) / (double)width();
+       double gypos = (double)(event->globalPos().y()) / (double)height();
        //printf("@@ %d %d\n", pos.x(), pos.y());
        if(using_flags->is_use_one_board_computer() || using_flags->is_use_mouse() || (using_flags->get_max_button() > 0)) {
                if(!enable_mouse) return;
@@ -60,31 +62,43 @@ void GLDrawClass::mouseMoveEvent(QMouseEvent *event)
                        case 0:
                                xx = xpos * (double)d_ww;
                                yy = ypos * (double)d_hh;
+                               gxx = gxpos * (double)d_ww;
+                               gyy = gypos * (double)d_hh;
                                break;
                        case 2:
                                xx = (1.0 - xpos) * (double)d_ww;
                                yy = (1.0 - ypos) * (double)d_hh;
+                               gxx = (1.0 - gxpos) * (double)d_ww;
+                               gyy = (1.0 - gypos) * (double)d_hh;
                                break;
                        case 1:
                                xx = ypos * (double)d_ww;
                                yy = (1.0 - xpos) * (double)d_hh;
+                               gxx = gypos * (double)d_ww;
+                               gyy = (1.0 - gxpos) * (double)d_hh;
                                break;
                        case 3:
                                xx = (1.0 - ypos) * (double)d_ww;
                                yy = xpos * (double)d_hh;
+                               gxx = (1.0 - gypos) * (double)d_ww;
+                               gyy = gxpos * (double)d_hh;
                                break;
                        default:
                                xx = xpos * (double)d_ww;
                                yy = ypos * (double)d_hh;
+                               gxx = gxpos * (double)d_ww;
+                               gyy = gypos * (double)d_hh;
                                break;
                }
        } else {
                xx = xpos * (double)d_ww;
                yy = ypos * (double)d_hh;
+               gxx = gxpos * (double)d_ww;
+               gyy = gypos * (double)d_hh;
        }
 
        //csp_logger->debug_log(CSP_LOG_DEBUG, CSP_LOG_TYPE_GENERAL, "Mouse Move: (%f,%f) -> (%d, %d)\n", xpos, ypos, (int)xx, (int)yy);
-       emit do_notify_move_mouse((int)xx, (int)yy);
+       emit do_notify_move_mouse((int)xx, (int)yy, (int)gxx, (int)gyy);
 
 }
 // Will fix. zap of emu-> or ??
index ba03bfb..bcbe2f2 100644 (file)
@@ -214,8 +214,6 @@ protected:
        int mouse_button;
        int mouse_oldx;
        int mouse_oldy;
-       int delta_x;
-       int delta_y;
        //Qt::CursorShape mouse_shape;
        
        QImage background_image;
index d3cb1de..bc68462 100644 (file)
@@ -258,14 +258,14 @@ void OSD_BASE::update_input()
        //bool hid = false;
        if(mouse_enabled) {
                QMutexLocker n(mouse_mutex);
-               mouse_status[0] = mouse_ptrx - mouse_oldx;
-               mouse_status[1] = mouse_ptry - mouse_oldy; 
+               int xx = (p_config->mouse_sensitivity_x & ((1 << 16) - 1)) * mouse_ptrx;
+               int yy = (p_config->mouse_sensitivity_y & ((1 << 16) - 1)) * mouse_ptry;
+               mouse_status[0] = (xx - mouse_oldx) >> 12;
+               mouse_status[1] = (yy - mouse_oldy) >> 12; 
                mouse_status[2] = mouse_button;
-               mouse_oldx = mouse_ptrx;
-               mouse_oldy = mouse_ptry;
                //printf("Mouse delta(%d, %d)\n", delta_x, delta_y);
-               mouse_oldx = mouse_ptrx;
-               mouse_oldy = mouse_ptry;
+               mouse_oldx = xx;
+               mouse_oldy = yy;
        }
        //}
        // move mouse cursor to the center of window
@@ -795,8 +795,13 @@ void OSD_BASE::enable_mouse()
        // enable mouse emulation
        if(!mouse_enabled) {
                QMutexLocker n(mouse_mutex);
-               mouse_oldx = mouse_ptrx = get_screen_width() / 2;
-               mouse_oldy = mouse_ptry = get_screen_height() / 2;
+               int xx = (p_config->mouse_sensitivity_x & ((1 << 16) - 1)) * get_screen_width() / 2;
+               int yy = (p_config->mouse_sensitivity_y & ((1 << 16) - 1)) * get_screen_height() / 2;
+               
+               mouse_oldx = xx;
+               mouse_oldy = yy;
+               mouse_ptrx = get_screen_width() / 2;
+               mouse_ptry = get_screen_height() / 2;
                mouse_status[0] = 0;
                mouse_status[1] = 0;
                mouse_status[2] = mouse_button;
@@ -836,8 +841,7 @@ void OSD_BASE::set_mouse_pointer(int x, int y)
                
                mouse_ptrx = x;
                mouse_ptry = y;
-               delta_x += ((mouse_ptrx - mouse_oldx) / 3);
-               delta_y += ((mouse_ptry - mouse_oldy) / 3);
+               
 //             mouse_oldx = mouse_ptrx;
 //             mouse_oldy = mouse_ptry;
                //printf("Mouse Moved: (%d, %d) -> delta(%d, %d)\n", mouse_ptrx, mouse_ptry, delta_x, delta_y);