mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-27 18:15:42 -04:00
AnalogController: Add option to use analog stick as dpad in digital mode
This commit is contained in:
parent
7210b0826a
commit
2fb67ee7db
@ -13,6 +13,7 @@ A "BIOS" ROM image is required to to start the emulator and to play games. You c
|
|||||||
|
|
||||||
## Latest News
|
## Latest News
|
||||||
|
|
||||||
|
- 2020/10/30: Option to use analog stick as d-pad for analog controller added.
|
||||||
- 2020/10/20: New cheat manager with memory scanning added. More features will be added over time.
|
- 2020/10/20: New cheat manager with memory scanning added. More features will be added over time.
|
||||||
- 2020/10/05: CD-ROM read speedup enhancement added.
|
- 2020/10/05: CD-ROM read speedup enhancement added.
|
||||||
- 2020/09/30: CPU overclocking is now supported. Use with caution as it will break games and increase system requirements. It can be set globally or per-game.
|
- 2020/09/30: CPU overclocking is now supported. Use with caution as it will break games and increase system requirements. It can be set globally or per-game.
|
||||||
|
@ -189,6 +189,25 @@ void AnalogController::SetMotorState(u8 motor, u8 value)
|
|||||||
m_motor_state[motor] = value;
|
m_motor_state[motor] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8 AnalogController::GetExtraButtonMaskLSB() const
|
||||||
|
{
|
||||||
|
if (!m_analog_dpad_in_digital_mode)
|
||||||
|
return 0xFF;
|
||||||
|
|
||||||
|
static constexpr u8 NEG_THRESHOLD = static_cast<u8>(128.0f - (127.0 * 0.5f));
|
||||||
|
static constexpr u8 POS_THRESHOLD = static_cast<u8>(128.0f + (127.0 * 0.5f));
|
||||||
|
|
||||||
|
const bool left = (m_axis_state[static_cast<u8>(Axis::LeftX)] <= NEG_THRESHOLD);
|
||||||
|
const bool right = (m_axis_state[static_cast<u8>(Axis::LeftX)] >= POS_THRESHOLD);
|
||||||
|
const bool up = (m_axis_state[static_cast<u8>(Axis::LeftY)] <= NEG_THRESHOLD);
|
||||||
|
const bool down = (m_axis_state[static_cast<u8>(Axis::LeftY)] >= POS_THRESHOLD);
|
||||||
|
|
||||||
|
return ~((static_cast<u8>(left) << static_cast<u8>(Button::Left)) |
|
||||||
|
(static_cast<u8>(right) << static_cast<u8>(Button::Right)) |
|
||||||
|
(static_cast<u8>(up) << static_cast<u8>(Button::Up)) |
|
||||||
|
(static_cast<u8>(down) << static_cast<u8>(Button::Down)));
|
||||||
|
}
|
||||||
|
|
||||||
bool AnalogController::Transfer(const u8 data_in, u8* data_out)
|
bool AnalogController::Transfer(const u8 data_in, u8* data_out)
|
||||||
{
|
{
|
||||||
bool ack;
|
bool ack;
|
||||||
@ -284,7 +303,7 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out)
|
|||||||
if (m_rumble_unlocked)
|
if (m_rumble_unlocked)
|
||||||
SetMotorState(1, ((data_in & 0x01) != 0) ? 255 : 0);
|
SetMotorState(1, ((data_in & 0x01) != 0) ? 255 : 0);
|
||||||
|
|
||||||
*data_out = Truncate8(m_button_state);
|
*data_out = Truncate8(m_button_state) & GetExtraButtonMaskLSB();
|
||||||
m_state = State::GetStateButtonsMSB;
|
m_state = State::GetStateButtonsMSB;
|
||||||
ack = true;
|
ack = true;
|
||||||
}
|
}
|
||||||
@ -511,10 +530,15 @@ u32 AnalogController::StaticGetVibrationMotorCount()
|
|||||||
|
|
||||||
Controller::SettingList AnalogController::StaticGetSettings()
|
Controller::SettingList AnalogController::StaticGetSettings()
|
||||||
{
|
{
|
||||||
static constexpr std::array<SettingInfo, 3> settings = {
|
static constexpr std::array<SettingInfo, 4> settings = {
|
||||||
{{SettingInfo::Type::Boolean, "AutoEnableAnalog", TRANSLATABLE("AnalogController", "Enable Analog Mode on Reset"),
|
{{SettingInfo::Type::Boolean, "AutoEnableAnalog", TRANSLATABLE("AnalogController", "Enable Analog Mode on Reset"),
|
||||||
TRANSLATABLE("AnalogController", "Automatically enables analog mode when the console is reset/powered on."),
|
TRANSLATABLE("AnalogController", "Automatically enables analog mode when the console is reset/powered on."),
|
||||||
"false"},
|
"false"},
|
||||||
|
{SettingInfo::Type::Boolean, "AnalogDPadInDigitalMode",
|
||||||
|
TRANSLATABLE("AnalogController", "Use Analog Sticks for D-Pad in Digital Mode"),
|
||||||
|
TRANSLATABLE("AnalogController",
|
||||||
|
"Allows you to use the analog sticks to control the d-pad in digital mode, as well as the buttons."),
|
||||||
|
"false"},
|
||||||
{SettingInfo::Type::Float, "AxisScale", TRANSLATABLE("AnalogController", "Analog Axis Scale"),
|
{SettingInfo::Type::Float, "AxisScale", TRANSLATABLE("AnalogController", "Analog Axis Scale"),
|
||||||
TRANSLATABLE(
|
TRANSLATABLE(
|
||||||
"AnalogController",
|
"AnalogController",
|
||||||
@ -533,6 +557,7 @@ void AnalogController::LoadSettings(const char* section)
|
|||||||
{
|
{
|
||||||
Controller::LoadSettings(section);
|
Controller::LoadSettings(section);
|
||||||
m_auto_enable_analog = g_host_interface->GetBoolSettingValue(section, "AutoEnableAnalog", false);
|
m_auto_enable_analog = g_host_interface->GetBoolSettingValue(section, "AutoEnableAnalog", false);
|
||||||
|
m_analog_dpad_in_digital_mode = g_host_interface->GetBoolSettingValue(section, "AnalogDPadInDigitalMode", false);
|
||||||
m_rumble_bias =
|
m_rumble_bias =
|
||||||
static_cast<u8>(std::min<u32>(g_host_interface->GetIntSettingValue(section, "VibrationBias", 8), 255));
|
static_cast<u8>(std::min<u32>(g_host_interface->GetIntSettingValue(section, "VibrationBias", 8), 255));
|
||||||
}
|
}
|
||||||
|
@ -131,10 +131,12 @@ private:
|
|||||||
u16 GetID() const;
|
u16 GetID() const;
|
||||||
void SetAnalogMode(bool enabled);
|
void SetAnalogMode(bool enabled);
|
||||||
void SetMotorState(u8 motor, u8 value);
|
void SetMotorState(u8 motor, u8 value);
|
||||||
|
u8 GetExtraButtonMaskLSB() const;
|
||||||
|
|
||||||
u32 m_index;
|
u32 m_index;
|
||||||
|
|
||||||
bool m_auto_enable_analog = false;
|
bool m_auto_enable_analog = false;
|
||||||
|
bool m_analog_dpad_in_digital_mode = false;
|
||||||
u8 m_rumble_bias = 8;
|
u8 m_rumble_bias = 8;
|
||||||
|
|
||||||
bool m_analog_mode = false;
|
bool m_analog_mode = false;
|
||||||
|
@ -457,7 +457,7 @@ void LibretroHostInterface::OnSystemDestroyed()
|
|||||||
m_using_hardware_renderer = false;
|
m_using_hardware_renderer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::array<retro_core_option_definition, 38> s_option_definitions = {{
|
static std::array<retro_core_option_definition, 40> s_option_definitions = {{
|
||||||
{"duckstation_Console.Region",
|
{"duckstation_Console.Region",
|
||||||
"Console Region",
|
"Console Region",
|
||||||
"Determines which region/hardware to emulate. Auto-Detect will use the region of the disc inserted.",
|
"Determines which region/hardware to emulate. Auto-Detect will use the region of the disc inserted.",
|
||||||
@ -681,6 +681,11 @@ static std::array<retro_core_option_definition, 38> s_option_definitions = {{
|
|||||||
"Automatically enables analog mode in supported controllers at start/reset.",
|
"Automatically enables analog mode in supported controllers at start/reset.",
|
||||||
{{"true", "Enabled"}, {"false", "Disabled"}},
|
{{"true", "Enabled"}, {"false", "Disabled"}},
|
||||||
"false"},
|
"false"},
|
||||||
|
{"duckstation_Controller1.AutoEnableAnalog",
|
||||||
|
"Controller 1 Use Analog Sticks for D-Pad in Digital Mode",
|
||||||
|
"Allows you to use the analog sticks to control the d-pad in digital mode, as well as the buttons.",
|
||||||
|
{{"true", "Enabled"}, {"false", "Disabled"}},
|
||||||
|
"false"},
|
||||||
{"duckstation_Controller2.Type",
|
{"duckstation_Controller2.Type",
|
||||||
"Controller 2 Type",
|
"Controller 2 Type",
|
||||||
"Sets the type of controller for Slot 2.",
|
"Sets the type of controller for Slot 2.",
|
||||||
@ -696,6 +701,11 @@ static std::array<retro_core_option_definition, 38> s_option_definitions = {{
|
|||||||
"Automatically enables analog mode in supported controllers at start/reset.",
|
"Automatically enables analog mode in supported controllers at start/reset.",
|
||||||
{{"true", "Enabled"}, {"false", "Disabled"}},
|
{{"true", "Enabled"}, {"false", "Disabled"}},
|
||||||
"false"},
|
"false"},
|
||||||
|
{"duckstation_Controller2.AutoEnableAnalog",
|
||||||
|
"Controller 2 Use Analog Sticks for D-Pad in Digital Mode",
|
||||||
|
"Allows you to use the analog sticks to control the d-pad in digital mode, as well as the buttons.",
|
||||||
|
{{"true", "Enabled"}, {"false", "Disabled"}},
|
||||||
|
"false"},
|
||||||
{"duckstation_Display.ShowOSDMessages",
|
{"duckstation_Display.ShowOSDMessages",
|
||||||
"Display OSD Messages",
|
"Display OSD Messages",
|
||||||
"Shows on-screen messages generated by the core.",
|
"Shows on-screen messages generated by the core.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user