Skip to content

Commit

Permalink
InputManager: Fix relative mode engaging for gun controllers
Browse files Browse the repository at this point in the history
It still needs to activate when using raw input.
  • Loading branch information
stenzek committed Nov 13, 2024
1 parent 3504294 commit c2316df
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/core/fullscreen_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/core/imgui_overlays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/input_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion src/core/playstation_mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>(PlayStationMouse::Binding::PointerX), InputBindingInfo::Type::Pointer, GenericInputBinding::Unknown },
{ "Pointer", TRANSLATE_NOOP("PlaystationMouse", "Pointer"), ICON_PF_MOUSE_ANY, static_cast<u32>(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
Expand Down
5 changes: 3 additions & 2 deletions src/duckstation-qt/controllerbindingwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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<InputBindingWidget*>(QString::fromUtf8(bi.name));
if (!widget)
Expand Down
12 changes: 8 additions & 4 deletions src/util/input_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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<u32>(bi.type));
break;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c2316df

Please sign in to comment.