qt: Add mouse sensitivity setting

This commit is contained in:
Cacodemon345
2022-06-01 15:31:58 +06:00
parent adb44ca660
commit 3b74aad9d6
8 changed files with 122 additions and 51 deletions

View File

@@ -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

View File

@@ -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 */

View File

@@ -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.;
}

View File

@@ -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

View File

@@ -6,35 +6,38 @@
<rect>
<x>0</x>
<y>0</y>
<width>370</width>
<height>228</height>
<width>458</width>
<height>303</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>370</width>
<height>228</height>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>370</width>
<height>228</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Preferences</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="1">
<spacer name="verticalSpacer">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
@@ -48,6 +51,13 @@
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Mouse sensitivity:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton">
<property name="text">
@@ -55,26 +65,7 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Language:</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QComboBox" name="comboBox">
<property name="editable">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>(Default)</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="11" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -84,6 +75,47 @@
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="pushButtonLanguage">
<property name="text">
<string>Default</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Icon set:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Default</string>
</property>
</widget>
</item>
<item row="8" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Language:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
@@ -97,32 +129,39 @@
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Icon set:</string>
<item row="7" column="0" colspan="2">
<widget class="QSlider" name="horizontalSlider">
<property name="minimum">
<number>50</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="pushButtonLanguage">
<property name="text">
<string>Default</string>
<property name="maximum">
<number>200</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="pageStep">
<number>20</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QComboBox" name="comboBox">
<property name="editable">
<bool>false</bool>
</property>
</spacer>
<item>
<property name="text">
<string>(Default)</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>

View File

@@ -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;

View File

@@ -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();

View File

@@ -28,6 +28,7 @@
#include <86box/win.h>
int mouse_capture;
double mouse_sensitivity = 1.0; /* Unused. */
typedef struct {
int buttons;