aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2026-07-26 05:11:03 +0200
committercrueter <crueter@eden-emu.dev>2026-07-26 05:11:03 +0200
commit39763e7321fa17486f1b466a1777f8aa4a91949f (patch)
tree19b0481fb690bea4852705d3c0e760c12fa313ac /src
parente69415c07bd06a2a26faac8bf343b883541a1006 (diff)
[core/hle/services/am] nuke ButtonPoller and Mouse thread (#4229)
Signed-off-by: lizzie <lizzie@eden-emu.dev> - [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- doesn't even do anything now, please check if controller i/o is affected by this change this should also fix latency issues with the mouse the ButtonPoller thread isn't longer required since we update the state immediately with the .on_change callback registered Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4229 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/am/button_poller.cpp19
-rw-r--r--src/core/hle/service/am/button_poller.h3
-rw-r--r--src/input_common/drivers/mouse.cpp16
-rw-r--r--src/input_common/drivers/mouse.h6
-rw-r--r--src/yuzu/bootmanager.cpp7
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp2
-rw-r--r--src/yuzu/configuration/configure_ringcon.cpp1
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl3.cpp2
8 files changed, 21 insertions, 35 deletions
diff --git a/src/core/hle/service/am/button_poller.cpp b/src/core/hle/service/am/button_poller.cpp
index 6999acfa12..825d28f5f0 100644
--- a/src/core/hle/service/am/button_poller.cpp
+++ b/src/core/hle/service/am/button_poller.cpp
@@ -41,7 +41,6 @@ ButtonPoller::ButtonPoller(Core::System& system, WindowSystem& window_system) {
Core::HID::ControllerUpdateCallback engine_callback{
.on_change = [this, &window_system](Core::HID::ControllerTriggerType type) {
if (type == Core::HID::ControllerTriggerType::Button) {
- std::unique_lock lk{m_mutex};
OnButtonStateChanged(window_system);
}
},
@@ -52,29 +51,11 @@ ButtonPoller::ButtonPoller(Core::System& system, WindowSystem& window_system) {
m_handheld_key = m_handheld->SetCallback(engine_callback);
m_player1 = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
m_player1_key = m_player1->SetCallback(engine_callback);
-
- m_thread = std::jthread([this, &window_system](std::stop_token stop_token) {
- Common::SetCurrentThreadName("ButtonPoller");
- while (!stop_token.stop_requested()) {
- using namespace std::chrono_literals;
- std::unique_lock lk{m_mutex};
- m_cv.wait_for(lk, 50ms);
- if (stop_token.stop_requested())
- break;
- OnButtonStateChanged(window_system);
- std::this_thread::sleep_for(5ms);
- }
- });
}
ButtonPoller::~ButtonPoller() {
m_handheld->DeleteCallback(m_handheld_key);
m_player1->DeleteCallback(m_player1_key);
- m_cv.notify_all();
- if (m_thread.joinable()) {
- m_thread.request_stop();
- m_thread.join();
- }
}
void ButtonPoller::OnButtonStateChanged(WindowSystem& window_system) {
diff --git a/src/core/hle/service/am/button_poller.h b/src/core/hle/service/am/button_poller.h
index 11d147d328..f5f12a13b2 100644
--- a/src/core/hle/service/am/button_poller.h
+++ b/src/core/hle/service/am/button_poller.h
@@ -33,9 +33,6 @@ public:
void OnButtonStateChanged(WindowSystem& window_system);
private:
- std::mutex m_mutex;
- std::condition_variable m_cv;
- std::jthread m_thread;
std::optional<std::chrono::steady_clock::time_point> m_home_button_press_start{};
std::optional<std::chrono::steady_clock::time_point> m_capture_button_press_start{};
std::optional<std::chrono::steady_clock::time_point> m_power_button_press_start{};
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp
index 7e029d2cdf..00b7220c1e 100644
--- a/src/input_common/drivers/mouse.cpp
+++ b/src/input_common/drivers/mouse.cpp
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
@@ -72,15 +72,6 @@ Mouse::Mouse(std::string input_engine_) : InputEngine(std::move(input_engine_))
wheel_position = {};
last_mouse_change = {};
last_motion_change = {};
-
- update_thread = std::jthread([this](std::stop_token stop_token) {
- Common::SetCurrentThreadName("Mouse");
- while (!stop_token.stop_requested()) {
- UpdateStickInput();
- UpdateMotionInput();
- std::this_thread::sleep_for(std::chrono::milliseconds(update_time));
- }
- });
}
void Mouse::UpdateStickInput() {
@@ -185,6 +176,11 @@ void Mouse::Move(int x, int y, int center_x, int center_y) {
}
}
+void Mouse::NotifyChanged() {
+ UpdateStickInput();
+ UpdateMotionInput();
+}
+
void Mouse::MouseMove(f32 touch_x, f32 touch_y) {
SetAxis(real_mouse_identifier, mouse_axis_x, touch_x);
SetAxis(real_mouse_identifier, mouse_axis_y, touch_y);
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h
index 2e5e989067..166168c824 100644
--- a/src/input_common/drivers/mouse.h
+++ b/src/input_common/drivers/mouse.h
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
@@ -93,6 +93,9 @@ public:
void ReleaseAllButtons();
+ /// @brief Notifies we changed something about the mouse state and we must update
+ void NotifyChanged();
+
std::vector<Common::ParamPackage> GetInputDevices() const override;
AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override;
Common::Input::ButtonNames GetUIName(const Common::ParamPackage& params) const override;
@@ -110,7 +113,6 @@ private:
Common::Vec3<float> last_motion_change;
Common::Vec2<int> wheel_position;
bool button_pressed = false;
- std::jthread update_thread;
};
} // namespace InputCommon
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 248e302aa5..f9c0233901 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -487,6 +487,7 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) {
input_subsystem->GetMouse()->PressMouseButton(button);
input_subsystem->GetMouse()->PressButton(pos.x(), pos.y(), button);
input_subsystem->GetMouse()->PressTouchButton(touch_x, touch_y, button);
+ input_subsystem->GetMouse()->NotifyChanged();
emit MouseActivity();
}
@@ -507,6 +508,7 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) {
input_subsystem->GetMouse()->MouseMove(touch_x, touch_y);
input_subsystem->GetMouse()->TouchMove(touch_x, touch_y);
input_subsystem->GetMouse()->Move(pos.x(), pos.y(), center_x, center_y);
+ input_subsystem->GetMouse()->NotifyChanged();
// Center mouse for mouse panning
if (Settings::values.mouse_panning && !Settings::values.mouse_enabled) {
@@ -532,6 +534,7 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) {
const auto button = QtButtonToMouseButton(event->button());
input_subsystem->GetMouse()->ReleaseButton(button);
+ input_subsystem->GetMouse()->NotifyChanged();
}
void GRenderWindow::ConstrainMouse() {
@@ -564,6 +567,7 @@ void GRenderWindow::wheelEvent(QWheelEvent* event) {
const int x = event->angleDelta().x();
const int y = event->angleDelta().y();
input_subsystem->GetMouse()->MouseWheelChange(x, y);
+ input_subsystem->GetMouse()->NotifyChanged();
}
void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) {
@@ -710,8 +714,9 @@ bool GRenderWindow::event(QEvent* event) {
void GRenderWindow::focusOutEvent(QFocusEvent* event) {
QWidget::focusOutEvent(event);
input_subsystem->GetKeyboard()->ReleaseAllKeys();
- input_subsystem->GetMouse()->ReleaseAllButtons();
input_subsystem->GetTouchScreen()->ReleaseAllTouch();
+ input_subsystem->GetMouse()->ReleaseAllButtons();
+ input_subsystem->GetMouse()->NotifyChanged();
}
void GRenderWindow::resizeEvent(QResizeEvent* event) {
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 821825f6e1..2750cd4a13 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -1546,12 +1546,14 @@ void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) {
const auto button = GRenderWindow::QtButtonToMouseButton(event->button());
input_subsystem->GetMouse()->PressButton(0, 0, button);
+ input_subsystem->GetMouse()->NotifyChanged();
}
void ConfigureInputPlayer::wheelEvent(QWheelEvent* event) {
const int x = event->angleDelta().x();
const int y = event->angleDelta().y();
input_subsystem->GetMouse()->MouseWheelChange(x, y);
+ input_subsystem->GetMouse()->NotifyChanged();
}
void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) {
diff --git a/src/yuzu/configuration/configure_ringcon.cpp b/src/yuzu/configuration/configure_ringcon.cpp
index 4c842bd069..d722eba07b 100644
--- a/src/yuzu/configuration/configure_ringcon.cpp
+++ b/src/yuzu/configuration/configure_ringcon.cpp
@@ -378,6 +378,7 @@ void ConfigureRingController::mousePressEvent(QMouseEvent* event) {
const auto button = GRenderWindow::QtButtonToMouseButton(event->button());
input_subsystem->GetMouse()->PressButton(0, 0, button);
+ input_subsystem->GetMouse()->NotifyChanged();
}
void ConfigureRingController::keyPressEvent(QKeyEvent* event) {
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp
index cd390d29f9..16a54412e5 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp
@@ -74,6 +74,7 @@ void EmuWindow_SDL3::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
} else {
input_subsystem->GetMouse()->ReleaseButton(mouse_button);
}
+ input_subsystem->GetMouse()->NotifyChanged();
}
void EmuWindow_SDL3::OnMouseMotion(s32 x, s32 y) {
@@ -81,6 +82,7 @@ void EmuWindow_SDL3::OnMouseMotion(s32 x, s32 y) {
input_subsystem->GetMouse()->Move(x, y, 0, 0);
input_subsystem->GetMouse()->MouseMove(touch_x, touch_y);
input_subsystem->GetMouse()->TouchMove(touch_x, touch_y);
+ input_subsystem->GetMouse()->NotifyChanged();
}
void EmuWindow_SDL3::OnFingerDown(float x, float y, std::size_t id) {