Input: add config entries for mouse deadzones and acceleration

This commit is contained in:
Megamouse 2018-11-17 04:17:32 +01:00
parent 7ebd3bbcbf
commit 2db16c2c04
2 changed files with 14 additions and 4 deletions

View File

@ -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 })

View File

@ -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> 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);