mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 22:05:38 +00:00
Merge pull request #1188 from ggrtk/popn-controller
DigitalController: Add option to force as Pop'n Controller
This commit is contained in:
commit
591f69f771
|
@ -234,6 +234,9 @@ Controller::SettingList Controller::GetSettings(ControllerType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
case ControllerType::DigitalController:
|
||||||
|
return DigitalController::StaticGetSettings();
|
||||||
|
|
||||||
case ControllerType::AnalogController:
|
case ControllerType::AnalogController:
|
||||||
return AnalogController::StaticGetSettings();
|
return AnalogController::StaticGetSettings();
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ bool DigitalController::Transfer(const u8 data_in, u8* data_out)
|
||||||
|
|
||||||
case TransferState::ButtonsLSB:
|
case TransferState::ButtonsLSB:
|
||||||
{
|
{
|
||||||
*data_out = Truncate8(m_button_state);
|
*data_out = Truncate8(m_button_state) & GetButtonsLSBMask();
|
||||||
m_transfer_state = TransferState::ButtonsMSB;
|
m_transfer_state = TransferState::ButtonsMSB;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -181,3 +181,26 @@ u32 DigitalController::StaticGetVibrationMotorCount()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controller::SettingList DigitalController::StaticGetSettings()
|
||||||
|
{
|
||||||
|
static constexpr std::array<SettingInfo, 1> settings = {
|
||||||
|
{{SettingInfo::Type::Boolean, "ForcePopnControllerMode",
|
||||||
|
TRANSLATABLE("DigitalController", "Force Pop'n Controller Mode"),
|
||||||
|
TRANSLATABLE("DigitalController", "Forces the Digital Controller to act as a Pop'n Controller."), "false"}}};
|
||||||
|
return SettingList(settings.begin(), settings.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DigitalController::LoadSettings(const char* section)
|
||||||
|
{
|
||||||
|
Controller::LoadSettings(section);
|
||||||
|
m_popn_controller_mode = g_host_interface->GetBoolSettingValue(section, "ForcePopnControllerMode", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 DigitalController::GetButtonsLSBMask() const
|
||||||
|
{
|
||||||
|
constexpr u8 popn_controller_mask =
|
||||||
|
~(u8(1) << static_cast<u8>(Button::Right) | u8(1) << static_cast<u8>(Button::Down) |
|
||||||
|
u8(1) << static_cast<u8>(Button::Left));
|
||||||
|
return m_popn_controller_mode ? popn_controller_mask : 0xFF;
|
||||||
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
static AxisList StaticGetAxisNames();
|
static AxisList StaticGetAxisNames();
|
||||||
static ButtonList StaticGetButtonNames();
|
static ButtonList StaticGetButtonNames();
|
||||||
static u32 StaticGetVibrationMotorCount();
|
static u32 StaticGetVibrationMotorCount();
|
||||||
|
static SettingList StaticGetSettings();
|
||||||
|
|
||||||
ControllerType GetType() const override;
|
ControllerType GetType() const override;
|
||||||
std::optional<s32> GetAxisCodeByName(std::string_view axis_name) const override;
|
std::optional<s32> GetAxisCodeByName(std::string_view axis_name) const override;
|
||||||
|
@ -54,6 +55,8 @@ public:
|
||||||
|
|
||||||
void SetButtonState(Button button, bool pressed);
|
void SetButtonState(Button button, bool pressed);
|
||||||
|
|
||||||
|
void LoadSettings(const char* section) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class TransferState : u8
|
enum class TransferState : u8
|
||||||
{
|
{
|
||||||
|
@ -67,4 +70,8 @@ private:
|
||||||
u16 m_button_state = UINT16_C(0xFFFF);
|
u16 m_button_state = UINT16_C(0xFFFF);
|
||||||
|
|
||||||
TransferState m_transfer_state = TransferState::Idle;
|
TransferState m_transfer_state = TransferState::Idle;
|
||||||
|
|
||||||
|
bool m_popn_controller_mode = false;
|
||||||
|
|
||||||
|
u8 GetButtonsLSBMask() const;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue