JogCon: Add ForceFeedbackDevice binding

This commit is contained in:
Stenzek 2024-04-29 00:50:02 +10:00
parent 053139ff19
commit 1384468615
No known key found for this signature in database
2 changed files with 23 additions and 0 deletions

View File

@ -869,8 +869,13 @@ static const Controller::ControllerBindingInfo s_binding_info[] = {
AXIS("RRight", TRANSLATE_NOOP("JogCon", "Right Stick Right"), ICON_PF_RIGHT_ANALOG_RIGHT, JogCon::HalfAxis::RRight, GenericInputBinding::RightStickRight), AXIS("RRight", TRANSLATE_NOOP("JogCon", "Right Stick Right"), ICON_PF_RIGHT_ANALOG_RIGHT, JogCon::HalfAxis::RRight, GenericInputBinding::RightStickRight),
AXIS("RDown", TRANSLATE_NOOP("JogCon", "Right Stick Down"), ICON_PF_RIGHT_ANALOG_DOWN, JogCon::HalfAxis::RDown, GenericInputBinding::RightStickDown), AXIS("RDown", TRANSLATE_NOOP("JogCon", "Right Stick Down"), ICON_PF_RIGHT_ANALOG_DOWN, JogCon::HalfAxis::RDown, GenericInputBinding::RightStickDown),
AXIS("RUp", TRANSLATE_NOOP("JogCon", "Right Stick Up"), ICON_PF_RIGHT_ANALOG_UP, JogCon::HalfAxis::RUp, GenericInputBinding::RightStickUp), AXIS("RUp", TRANSLATE_NOOP("JogCon", "Right Stick Up"), ICON_PF_RIGHT_ANALOG_UP, JogCon::HalfAxis::RUp, GenericInputBinding::RightStickUp),
// clang-format on // clang-format on
{"ForceFeedbackDevice", TRANSLATE_NOOP("JogCon", "Force Feedback Device"), nullptr,
static_cast<u32>(JogCon::Button::Count) + static_cast<u32>(JogCon::HalfAxis::Count), InputBindingInfo::Type::Device,
GenericInputBinding::Unknown},
#undef AXIS #undef AXIS
#undef BUTTON #undef BUTTON
}; };
@ -935,4 +940,17 @@ void JogCon::LoadSettings(SettingsInterface& si, const char* section)
m_rumble_bias = static_cast<u8>(std::min<u32>(si.GetIntValue(section, "VibrationBias", 8), 255)); m_rumble_bias = static_cast<u8>(std::min<u32>(si.GetIntValue(section, "VibrationBias", 8), 255));
m_invert_left_stick = static_cast<u8>(si.GetIntValue(section, "InvertLeftStick", 0)); m_invert_left_stick = static_cast<u8>(si.GetIntValue(section, "InvertLeftStick", 0));
m_invert_right_stick = static_cast<u8>(si.GetIntValue(section, "InvertRightStick", 0)); m_invert_right_stick = static_cast<u8>(si.GetIntValue(section, "InvertRightStick", 0));
std::string force_feedback_device_name = si.GetStringValue(section, "ForceFeedbackDevice");
if (m_force_feedback_device_name != force_feedback_device_name)
{
m_force_feedback_device_name = std::move(force_feedback_device_name);
m_force_feedback_device.reset();
if (!m_force_feedback_device_name.empty())
{
m_force_feedback_device = InputManager::CreateForceFeedbackDevice(m_force_feedback_device_name);
if (!m_force_feedback_device)
Log_ErrorFmt("Failed to create force feedback device {}", m_force_feedback_device_name);
}
}
} }

View File

@ -8,6 +8,8 @@
#include <optional> #include <optional>
#include <string_view> #include <string_view>
class ForceFeedbackDevice;
class JogCon final : public Controller class JogCon final : public Controller
{ {
public: public:
@ -189,4 +191,7 @@ private:
JogconDirection jog_direction = JogconDirection::JOGCON_DIR_NONE; JogconDirection jog_direction = JogconDirection::JOGCON_DIR_NONE;
u8 jog_rotations = 0x0; u8 jog_rotations = 0x0;
JogconCommand jog_last_command = JogconCommand::JOGCON_CMD_NONE; JogconCommand jog_last_command = JogconCommand::JOGCON_CMD_NONE;
std::string m_force_feedback_device_name;
std::unique_ptr<ForceFeedbackDevice> m_force_feedback_device;
}; };