From 2db16c2c04bcfc056dcd26012abfb91e9f051bb3 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 17 Nov 2018 04:17:32 +0100 Subject: [PATCH] Input: add config entries for mouse deadzones and acceleration --- rpcs3/Emu/Io/PadHandler.h | 5 +++++ rpcs3/keyboard_pad_handler.cpp | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Io/PadHandler.h b/rpcs3/Emu/Io/PadHandler.h index 115e1dcf37..f54e2bb677 100644 --- a/rpcs3/Emu/Io/PadHandler.h +++ b/rpcs3/Emu/Io/PadHandler.h @@ -335,6 +335,11 @@ struct pad_config final : cfg::node cfg::_bool enable_vibration_motor_small{ this, "Enable Small Vibration Motor", true }; cfg::_bool switch_vibration_motors{ this, "Switch Vibration Motors", false }; + cfg::_int<0, 255> mouse_deadzone_x{ this, "Mouse Deadzone X Axis", 60 }; + cfg::_int<0, 255> mouse_deadzone_y{ this, "Mouse Deadzone Y Axis", 60 }; + cfg::_int<0, 500> mouse_acceleration_x{ this, "Mouse Acceleration X Axis", 200 }; + cfg::_int<0, 500> mouse_acceleration_y{ this, "Mouse Acceleration Y Axis", 250 }; + bool load() { if (fs::file cfg_file{ cfg_name, fs::read }) diff --git a/rpcs3/keyboard_pad_handler.cpp b/rpcs3/keyboard_pad_handler.cpp index 96a6164f0e..31948e6c6c 100644 --- a/rpcs3/keyboard_pad_handler.cpp +++ b/rpcs3/keyboard_pad_handler.cpp @@ -257,22 +257,22 @@ void keyboard_pad_handler::keyPressEvent(QKeyEvent* event) return; case Qt::Key_K: m_multi_y = std::min(m_multi_y + 0.1, 5.0); - LOG_SUCCESS(GENERAL, "mouse move adjustment: multiplier y = %.2f", m_multi_y); + LOG_SUCCESS(GENERAL, "mouse move adjustment: multiplier y = %d", (int)(m_multi_y * 100)); event->ignore(); return; case Qt::Key_J: m_multi_y = std::max(0.0, m_multi_y - 0.1); - LOG_SUCCESS(GENERAL, "mouse move adjustment: multiplier y = %.2f", m_multi_y); + LOG_SUCCESS(GENERAL, "mouse move adjustment: multiplier y = %d", (int)(m_multi_y * 100)); event->ignore(); return; case Qt::Key_H: m_multi_x = std::min(m_multi_x + 0.1, 5.0); - LOG_SUCCESS(GENERAL, "mouse move adjustment: multiplier x = %.2f", m_multi_x); + LOG_SUCCESS(GENERAL, "mouse move adjustment: multiplier x = %d", (int)(m_multi_x * 100)); event->ignore(); return; case Qt::Key_G: m_multi_x = std::max(0.0, m_multi_x - 0.1); - LOG_SUCCESS(GENERAL, "mouse move adjustment: multiplier x = %.2f", m_multi_x); + LOG_SUCCESS(GENERAL, "mouse move adjustment: multiplier x = %d", (int)(m_multi_x * 100)); event->ignore(); return; default: @@ -513,6 +513,11 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr pad, const std:: if (p_profile == nullptr) return false; + m_deadzone_x = p_profile->mouse_deadzone_x; + m_deadzone_y = p_profile->mouse_deadzone_y; + m_multi_x = p_profile->mouse_acceleration_x / 100; + m_multi_y = p_profile->mouse_acceleration_y / 100; + auto find_key = [&](const cfg::string& name) { int key = FindKeyCode(mouse_list, name, false);