Qt: Log input state when binding

pull/3576/head
Stenzek 1 month ago
parent 9baa09aace
commit 055caf5cbe
No known key found for this signature in database

@ -8,6 +8,7 @@
#include "qtutils.h" #include "qtutils.h"
#include "common/bitutils.h" #include "common/bitutils.h"
#include "common/log.h"
#include "fmt/format.h" #include "fmt/format.h"
@ -18,6 +19,8 @@
#include "moc_inputbindingdialog.cpp" #include "moc_inputbindingdialog.cpp"
LOG_CHANNEL(Host);
InputBindingDialog::InputBindingDialog(SettingsInterface* sif, InputBindingInfo::Type bind_type, InputBindingDialog::InputBindingDialog(SettingsInterface* sif, InputBindingInfo::Type bind_type,
std::string section_name, std::string key_name, std::string section_name, std::string key_name,
std::vector<std::string> bindings, QWidget* parent) std::vector<std::string> bindings, QWidget* parent)
@ -72,6 +75,14 @@ InputBindingDialog::~InputBindingDialog()
Q_ASSERT(!isListeningForInput()); Q_ASSERT(!isListeningForInput());
} }
void InputBindingDialog::logInputEvent(InputBindingInfo::Type bind_type, InputBindingKey key, float value,
float initial_value, float min_value)
{
const TinyString key_str = InputManager::ConvertInputBindingKeyToString(bind_type, key);
DEV_LOG("Binding input event: key={} value={:.2f} initial_value={:.2f} min_value={:.2f}", key_str, value,
initial_value, min_value);
}
bool InputBindingDialog::eventFilter(QObject* watched, QEvent* event) bool InputBindingDialog::eventFilter(QObject* watched, QEvent* event)
{ {
const QEvent::Type event_type = event->type(); const QEvent::Type event_type = event->type();
@ -310,6 +321,8 @@ void InputBindingDialog::inputManagerHookCallback(InputBindingKey key, float val
m_value_ranges.emplace_back(key, std::make_pair(initial_value, min_value)); m_value_ranges.emplace_back(key, std::make_pair(initial_value, min_value));
} }
logInputEvent(m_bind_type, key, value, initial_value, min_value);
const float abs_value = std::abs(value); const float abs_value = std::abs(value);
const bool reverse_threshold = const bool reverse_threshold =
(key.source_subtype == InputSubclass::ControllerAxis && std::abs(initial_value) > 0.5f); (key.source_subtype == InputSubclass::ControllerAxis && std::abs(initial_value) > 0.5f);

@ -1,10 +1,14 @@
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: CC-BY-NC-ND-4.0 // SPDX-License-Identifier: CC-BY-NC-ND-4.0
#pragma once #pragma once
#include "common/types.h"
#include "ui_inputbindingdialog.h" #include "ui_inputbindingdialog.h"
#include "util/input_manager.h" #include "util/input_manager.h"
#include "common/types.h"
#include <QtWidgets/QDialog> #include <QtWidgets/QDialog>
#include <optional> #include <optional>
#include <string> #include <string>
@ -21,6 +25,9 @@ public:
std::string key_name, std::vector<std::string> bindings, QWidget* parent); std::string key_name, std::vector<std::string> bindings, QWidget* parent);
~InputBindingDialog(); ~InputBindingDialog();
static void logInputEvent(InputBindingInfo::Type bind_type, InputBindingKey key, float value, float initial_value,
float min_value);
protected: protected:
enum : u32 enum : u32
{ {

@ -350,6 +350,8 @@ void InputBindingWidget::inputManagerHookCallback(InputBindingKey key, float val
m_value_ranges.emplace_back(key, std::make_pair(initial_value, min_value)); m_value_ranges.emplace_back(key, std::make_pair(initial_value, min_value));
} }
InputBindingDialog::logInputEvent(m_bind_type, key, value, initial_value, min_value);
const float abs_value = std::abs(value); const float abs_value = std::abs(value);
const bool reverse_threshold = const bool reverse_threshold =
(key.source_subtype == InputSubclass::ControllerAxis && std::abs(initial_value) > 0.5f); (key.source_subtype == InputSubclass::ControllerAxis && std::abs(initial_value) > 0.5f);

Loading…
Cancel
Save