mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
Add relative input for the Wiimote IR
This adds an option to enable relative input for the Wiimote IR as described in issue 9014. Enabling it will result in the pointer not going back to the centre and the inputs will control the direction, not the absolute position. Also adds a Dead Zone setting which is really needed when relative input is enabled to prevent the cursor from slowly drifting on most controllers. (Note: the Deadzone setting has no effect when relative input is disabled)
This commit is contained in:
parent
58d0e22354
commit
5cf07fdfbf
@ -843,6 +843,13 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(groupSetting->m_name))));
|
||||
szr->Add(setting->wxcontrol, 0, wxLEFT, 0);
|
||||
}
|
||||
for (auto& groupSetting : group->boolean_settings)
|
||||
{
|
||||
auto* checkbox = new PadSettingCheckBox(parent, groupSetting.get());
|
||||
checkbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustSetting, eventsink);
|
||||
options.push_back(checkbox);
|
||||
Add(checkbox->wxcontrol, 0, wxALL | wxLEFT, 5);
|
||||
}
|
||||
|
||||
wxBoxSizer* const h_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
h_szr->Add(szr, 1, 0, 5);
|
||||
|
@ -299,6 +299,8 @@ ControllerEmu::Cursor::Cursor(const std::string& _name)
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Center"), 0.5));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Width"), 0.5));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Height"), 0.5));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 20));
|
||||
boolean_settings.emplace_back(std::make_unique<BooleanSetting>(_trans("Relative Input"), false));
|
||||
}
|
||||
|
||||
void ControllerEmu::LoadDefaults(const ControllerInterface& ciface)
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
@ -424,12 +425,36 @@ public:
|
||||
yy += (numeric_settings[0]->GetValue() - 0.5);
|
||||
}
|
||||
|
||||
*x = xx;
|
||||
*y = yy;
|
||||
// relative input
|
||||
if (boolean_settings[0]->GetValue())
|
||||
{
|
||||
const ControlState deadzone = numeric_settings[3]->GetValue();
|
||||
// deadzone to avoid the cursor slowly drifting
|
||||
if (std::abs(xx) > deadzone)
|
||||
m_x = MathUtil::Clamp(m_x + xx * SPEED_MULTIPLIER, -1.0, 1.0);
|
||||
if (std::abs(yy) > deadzone)
|
||||
m_y = MathUtil::Clamp(m_y + yy * SPEED_MULTIPLIER, -1.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_x = xx;
|
||||
m_y = yy;
|
||||
}
|
||||
|
||||
*x = m_x;
|
||||
*y = m_y;
|
||||
}
|
||||
}
|
||||
|
||||
ControlState m_z;
|
||||
|
||||
private:
|
||||
// This is used to reduce the cursor speed for relative input
|
||||
// to something that makes sense with the default range.
|
||||
static constexpr double SPEED_MULTIPLIER = 0.04;
|
||||
|
||||
ControlState m_x = 0.0;
|
||||
ControlState m_y = 0.0;
|
||||
};
|
||||
|
||||
class Extension : public ControlGroup
|
||||
|
Loading…
x
Reference in New Issue
Block a user