From c2316dfdc81570f2e50a6d21772bf9487949ec04 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 13 Nov 2024 23:56:25 +1000 Subject: [PATCH] InputManager: Fix relative mode engaging for gun controllers It still needs to activate when using raw input. --- src/core/fullscreen_ui.cpp | 2 +- src/core/imgui_overlays.cpp | 1 + src/core/input_types.h | 3 ++- src/core/playstation_mouse.cpp | 2 +- src/duckstation-qt/controllerbindingwidgets.cpp | 5 +++-- src/util/input_manager.cpp | 12 ++++++++---- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 244682c2b..b742fa008 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -1625,7 +1625,7 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, InputBindingIn const char* name, const char* display_name, const char* icon_name, bool show_type) { - if (type == InputBindingInfo::Type::Pointer) + if (type == InputBindingInfo::Type::Pointer || type == InputBindingInfo::Type::RelativePointer) return; TinyString title; diff --git a/src/core/imgui_overlays.cpp b/src/core/imgui_overlays.cpp index 47556c01d..7b5e6e951 100644 --- a/src/core/imgui_overlays.cpp +++ b/src/core/imgui_overlays.cpp @@ -791,6 +791,7 @@ void ImGuiManager::DrawInputsOverlay() case InputBindingInfo::Type::Macro: case InputBindingInfo::Type::Unknown: case InputBindingInfo::Type::Pointer: + case InputBindingInfo::Type::RelativePointer: default: break; } diff --git a/src/core/input_types.h b/src/core/input_types.h index 06fb6fc01..a4ec75d6c 100644 --- a/src/core/input_types.h +++ b/src/core/input_types.h @@ -15,7 +15,8 @@ struct InputBindingInfo Axis, HalfAxis, Motor, - Pointer, // Receive relative mouse movement events, bind_index is offset by the axis. + Pointer, // Absolute pointer, does not receive any events, but is queryable. + RelativePointer, // Receive relative mouse movement events, bind_index is offset by the axis. Macro, }; diff --git a/src/core/playstation_mouse.cpp b/src/core/playstation_mouse.cpp index d748fe3ee..73b33e76d 100644 --- a/src/core/playstation_mouse.cpp +++ b/src/core/playstation_mouse.cpp @@ -202,7 +202,7 @@ static const Controller::ControllerBindingInfo s_binding_info[] = { } // clang-format off - { "Pointer", TRANSLATE_NOOP("PlaystationMouse", "Pointer"), ICON_PF_MOUSE_ANY, static_cast(PlayStationMouse::Binding::PointerX), InputBindingInfo::Type::Pointer, GenericInputBinding::Unknown }, + { "Pointer", TRANSLATE_NOOP("PlaystationMouse", "Pointer"), ICON_PF_MOUSE_ANY, static_cast(PlayStationMouse::Binding::PointerX), InputBindingInfo::Type::RelativePointer, GenericInputBinding::Unknown }, BUTTON("Left", TRANSLATE_NOOP("PlayStationMouse", "Left Button"), ICON_PF_MOUSE_BUTTON_1, PlayStationMouse::Binding::Left, GenericInputBinding::Cross), BUTTON("Right", TRANSLATE_NOOP("PlayStationMouse", "Right Button"), ICON_PF_MOUSE_BUTTON_2, PlayStationMouse::Binding::Right, GenericInputBinding::Circle), // clang-format on diff --git a/src/duckstation-qt/controllerbindingwidgets.cpp b/src/duckstation-qt/controllerbindingwidgets.cpp index fc75b7ca6..c1d4ac883 100644 --- a/src/duckstation-qt/controllerbindingwidgets.cpp +++ b/src/duckstation-qt/controllerbindingwidgets.cpp @@ -405,7 +405,7 @@ void ControllerBindingWidget::createBindingWidgets(QWidget* parent) for (const Controller::ControllerBindingInfo& bi : m_controller_info->bindings) { if (bi.type == InputBindingInfo::Type::Axis || bi.type == InputBindingInfo::Type::HalfAxis || - bi.type == InputBindingInfo::Type::Pointer) + bi.type == InputBindingInfo::Type::Pointer || bi.type == InputBindingInfo::Type::RelativePointer) { if (!axis_gbox) { @@ -484,7 +484,8 @@ void ControllerBindingWidget::bindBindingWidgets(QWidget* parent) for (const Controller::ControllerBindingInfo& bi : m_controller_info->bindings) { if (bi.type == InputBindingInfo::Type::Axis || bi.type == InputBindingInfo::Type::HalfAxis || - bi.type == InputBindingInfo::Type::Button || bi.type == InputBindingInfo::Type::Pointer) + bi.type == InputBindingInfo::Type::Button || bi.type == InputBindingInfo::Type::Pointer || + bi.type == InputBindingInfo::Type::RelativePointer) { InputBindingWidget* widget = parent->findChild(QString::fromUtf8(bi.name)); if (!widget) diff --git a/src/util/input_manager.cpp b/src/util/input_manager.cpp index ce8140ddd..4231cdade 100644 --- a/src/util/input_manager.cpp +++ b/src/util/input_manager.cpp @@ -303,7 +303,7 @@ bool InputManager::ParseBindingAndGetSource(std::string_view binding, InputBindi std::string InputManager::ConvertInputBindingKeyToString(InputBindingInfo::Type binding_type, InputBindingKey key) { - if (binding_type == InputBindingInfo::Type::Pointer) + if (binding_type == InputBindingInfo::Type::Pointer || binding_type == InputBindingInfo::Type::RelativePointer) { // pointer and device bindings don't have a data part if (key.source_type == InputSourceType::Pointer) @@ -356,7 +356,7 @@ std::string InputManager::ConvertInputBindingKeysToString(InputBindingInfo::Type const InputBindingKey* keys, size_t num_keys) { // can't have a chord of devices/pointers - if (binding_type == InputBindingInfo::Type::Pointer) + if (binding_type == InputBindingInfo::Type::Pointer || binding_type == InputBindingInfo::Type::Pointer) { // so only take the first if (num_keys > 0) @@ -857,7 +857,7 @@ void InputManager::AddPadBindings(const SettingsInterface& si, const std::string } break; - case InputBindingInfo::Type::Pointer: + case InputBindingInfo::Type::RelativePointer: { auto cb = [pad_index, base = bi.bind_index](InputBindingKey key, float value) { if (!System::IsValid()) @@ -887,6 +887,9 @@ void InputManager::AddPadBindings(const SettingsInterface& si, const std::string } break; + case InputBindingInfo::Type::Pointer: + break; + default: ERROR_LOG("Unhandled binding info type {}", static_cast(bi.type)); break; @@ -1309,7 +1312,8 @@ void InputManager::UpdatePointerRelativeDelta(u32 index, InputPointerAxis axis, void InputManager::UpdateRelativeMouseMode() { // Check for relative mode bindings, and enable if there's anything using it. - bool has_relative_mode_bindings = !s_pointer_move_callbacks.empty(); + // Raw input needs to force relative mode/clipping, because it's now disconnected from the system pointer. + bool has_relative_mode_bindings = !s_pointer_move_callbacks.empty() || IsUsingRawInput(); if (!has_relative_mode_bindings) { for (const auto& it : s_binding_map)