diff --git a/src/config.c b/src/config.c
index 6f923b28a..763453a36 100644
--- a/src/config.c
+++ b/src/config.c
@@ -599,6 +599,12 @@ load_general(void)
lang_id = plat_language_code(p);
}
+ mouse_sensitivity = config_get_double(cat, "mouse_sensitivity", 1.0);
+ if (mouse_sensitivity < 0.5)
+ mouse_sensitivity = 0.5;
+ else if (mouse_sensitivity > 2.0)
+ mouse_sensitivity = 2.0;
+
p = config_get_string(cat, "iconset", NULL);
if (p != NULL)
strcpy(icon_set, p);
@@ -2307,6 +2313,11 @@ save_general(void)
else
config_delete_var(cat, "confirm_save");
+ if (mouse_sensitivity != 1.0)
+ config_set_double(cat, "mouse_sensitivity", mouse_sensitivity);
+ else
+ config_delete_var(cat, "mouse_sensitivity");
+
if (lang_id == DEFAULT_LANGUAGE)
config_delete_var(cat, "language");
else
diff --git a/src/include/86box/86box.h b/src/include/86box/86box.h
index 220d120fa..61269fddb 100644
--- a/src/include/86box/86box.h
+++ b/src/include/86box/86box.h
@@ -131,6 +131,7 @@ extern int enable_discord; /* (C) enable Discord integration */
extern int is_pentium; /* TODO: Move back to cpu/cpu.h when it's figured out,
how to remove that hack from the ET4000/W32p. */
extern int fixed_size_x, fixed_size_y;
+extern double mouse_sensitivity; /* (C) Mouse sensitivity scale */
extern char exe_path[2048]; /* path (dir) of executable */
diff --git a/src/qt/qt_progsettings.cpp b/src/qt/qt_progsettings.cpp
index d5bfdaa2f..3d895cf41 100644
--- a/src/qt/qt_progsettings.cpp
+++ b/src/qt/qt_progsettings.cpp
@@ -110,6 +110,9 @@ ProgSettings::ProgSettings(QWidget *parent) :
ui->comboBoxLanguage->setCurrentIndex(ui->comboBoxLanguage->findData(i.key()));
}
}
+
+ mouseSensitivity = mouse_sensitivity;
+ ui->horizontalSlider->setValue(mouseSensitivity * 100.);
}
void ProgSettings::accept()
@@ -132,6 +135,7 @@ void ProgSettings::accept()
connect(main_window, &MainWindow::updateStatusBarActivity, main_window->status.get(), &MachineStatus::setActivity);
connect(main_window, &MainWindow::updateStatusBarEmpty, main_window->status.get(), &MachineStatus::setEmpty);
connect(main_window, &MainWindow::statusBarMessage, main_window->status.get(), &MachineStatus::message, Qt::QueuedConnection);
+ mouse_sensitivity = mouseSensitivity;
QDialog::accept();
}
@@ -193,3 +197,9 @@ void ProgSettings::on_pushButtonLanguage_released()
{
ui->comboBoxLanguage->setCurrentIndex(0);
}
+
+void ProgSettings::on_horizontalSlider_valueChanged(int value)
+{
+ mouseSensitivity = (double)value / 100.;
+}
+
diff --git a/src/qt/qt_progsettings.hpp b/src/qt/qt_progsettings.hpp
index 75fba149a..6e0b49c8c 100644
--- a/src/qt/qt_progsettings.hpp
+++ b/src/qt/qt_progsettings.hpp
@@ -57,10 +57,13 @@ private slots:
void on_pushButton_released();
void on_pushButtonLanguage_released();
+ void on_horizontalSlider_valueChanged(int value);
+
private:
Ui::ProgSettings *ui;
friend class MainWindow;
+ double mouseSensitivity;
};
#endif // QT_PROGSETTINGS_HPP
diff --git a/src/qt/qt_progsettings.ui b/src/qt/qt_progsettings.ui
index b64272f8b..11bb39b74 100644
--- a/src/qt/qt_progsettings.ui
+++ b/src/qt/qt_progsettings.ui
@@ -6,35 +6,38 @@
0
0
- 370
- 228
+ 458
+ 303
- 370
- 228
+ 0
+ 0
- 370
- 228
+ 16777215
+ 16777215
Preferences
- -
-
+
+ QLayout::SetFixedSize
+
+
-
+
- Qt::Vertical
+ Qt::Horizontal
- 20
- 40
+ 40
+ 20
@@ -48,6 +51,13 @@
+ -
+
+
+ Mouse sensitivity:
+
+
+
-
@@ -55,26 +65,7 @@
- -
-
-
- Language:
-
-
-
- -
-
-
- false
-
-
-
-
- (Default)
-
-
-
-
- -
+
-
Qt::Horizontal
@@ -84,6 +75,47 @@
+ -
+
+
+ Default
+
+
+
+ -
+
+
+ Icon set:
+
+
+
+ -
+
+
+ Default
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Language:
+
+
+
-
@@ -97,32 +129,39 @@
- -
-
-
- Icon set:
+
-
+
+
+ 50
-
-
- -
-
-
- Default
+
+ 200
+
+
+ 10
+
+
+ 20
+
+
+ 100
-
-
- -
-
Qt::Horizontal
-
-
- 40
- 20
-
+
+
+ -
+
+
+ false
-
+
-
+
+ (Default)
+
+
+
diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp
index 1b43fe70c..cafba579b 100644
--- a/src/qt/qt_rendererstack.cpp
+++ b/src/qt/qt_rendererstack.cpp
@@ -44,6 +44,8 @@ extern "C" {
#include <86box/mouse.h>
#include <86box/plat.h>
#include <86box/video.h>
+
+double mouse_sensitivity = 1.0;
}
extern "C" void macos_poll_mouse();
@@ -123,6 +125,9 @@ RendererStack::mousePoll()
if (this->mouse_poll_func)
#endif
this->mouse_poll_func();
+
+ mouse_x *= mouse_sensitivity;
+ mouse_y *= mouse_sensitivity;
}
int ignoreNextMouseEvent = 1;
diff --git a/src/unix/unix_sdl.c b/src/unix/unix_sdl.c
index d86b5f72c..aeeb9d60c 100644
--- a/src/unix/unix_sdl.c
+++ b/src/unix/unix_sdl.c
@@ -43,6 +43,7 @@ int title_set = 0;
int resize_pending = 0;
int resize_w = 0;
int resize_h = 0;
+double mouse_sensitivity = 1.0; /* Unused. */
static uint8_t interpixels[17842176];
extern void RenderImGui();
diff --git a/src/win/win_mouse.c b/src/win/win_mouse.c
index e5d1c229a..b69646a6e 100644
--- a/src/win/win_mouse.c
+++ b/src/win/win_mouse.c
@@ -28,6 +28,7 @@
#include <86box/win.h>
int mouse_capture;
+double mouse_sensitivity = 1.0; /* Unused. */
typedef struct {
int buttons;