mirror of
https://git.eden-emu.dev/archive/citron
synced 2026-03-27 20:09:34 -04:00
feat: Add mouse wheel support for game input passthrough
- Implement mouse wheel event handling in SDL2 backend (emu_window_sdl2) - Add wheel event routing from GRenderWindow to input subsystem - Add debugging logs to trace mouse wheel events through input chain - Support mouse wheel input for mods like Ultracam when games are running (WIP) Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
@@ -374,6 +375,7 @@ void EmulatedDevices::SetMouseWheel(const Common::Input::CallbackStatus& callbac
|
||||
const auto analog_value = TransformToAnalog(callback);
|
||||
|
||||
device_status.mouse_wheel_values[index] = analog_value;
|
||||
LOG_DEBUG(Input, "EmulatedDevices::SetMouseWheel: index={}, value={}", index, analog_value.value);
|
||||
|
||||
if (is_configuring) {
|
||||
device_status.mouse_wheel_state = {};
|
||||
@@ -455,6 +457,11 @@ AnalogStickState EmulatedDevices::GetMouseWheel() const {
|
||||
return device_status.mouse_wheel_state;
|
||||
}
|
||||
|
||||
void EmulatedDevices::ResetMouseWheel() {
|
||||
std::scoped_lock lock{mutex};
|
||||
device_status.mouse_wheel_state = {};
|
||||
}
|
||||
|
||||
void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) {
|
||||
std::scoped_lock lock{callback_mutex};
|
||||
for (const auto& poller_pair : callback_list) {
|
||||
|
||||
@@ -135,6 +135,9 @@ public:
|
||||
/// Returns the latest mouse wheel change
|
||||
AnalogStickState GetMouseWheel() const;
|
||||
|
||||
/// Resets the mouse wheel state (should be called each frame)
|
||||
void ResetMouseWheel();
|
||||
|
||||
/**
|
||||
* Adds a callback to the list of events
|
||||
* @param update_callback InterfaceUpdateCallback that will be triggered
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/core_timing.h"
|
||||
@@ -55,6 +56,9 @@ void DebugMouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
next_state.delta_wheel_y = mouse_wheel_state.y - last_mouse_wheel_state.y;
|
||||
|
||||
last_mouse_wheel_state = mouse_wheel_state;
|
||||
|
||||
// Reset mouse wheel state after reading to ensure delta values work correctly
|
||||
emulated_devices->ResetMouseWheel();
|
||||
next_state.button = mouse_button_state;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ void Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
next_state.delta_wheel_y = mouse_wheel_state.y - last_mouse_wheel_state.y;
|
||||
|
||||
last_mouse_wheel_state = mouse_wheel_state;
|
||||
|
||||
// Reset mouse wheel state after reading to ensure delta values work correctly
|
||||
emulated_devices->ResetMouseWheel();
|
||||
next_state.button = mouse_button_state;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user