mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 09:35:40 +00:00
CommonHostInterface: Add public method to activate autofire
This commit is contained in:
parent
a67f77d2a1
commit
8f23a79d36
|
@ -1453,6 +1453,31 @@ void CommonHostInterface::SetControllerAutoFireState(u32 controller_index, s32 b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommonHostInterface::SetControllerAutoFireSlotState(u32 controller_index, u32 slot_index, bool active)
|
||||||
|
{
|
||||||
|
for (ControllerAutoFireState& ts : m_controller_autofires)
|
||||||
|
{
|
||||||
|
if (ts.controller_index != controller_index || ts.slot_index != slot_index)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!active)
|
||||||
|
{
|
||||||
|
if (ts.state)
|
||||||
|
{
|
||||||
|
Controller* controller = System::GetController(ts.controller_index);
|
||||||
|
if (controller)
|
||||||
|
controller->SetButtonState(ts.button_code, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ts.state = false;
|
||||||
|
ts.countdown = ts.frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
ts.active = active;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CommonHostInterface::UpdateControllerAutoFire()
|
void CommonHostInterface::UpdateControllerAutoFire()
|
||||||
{
|
{
|
||||||
for (ControllerAutoFireState& ts : m_controller_autofires)
|
for (ControllerAutoFireState& ts : m_controller_autofires)
|
||||||
|
@ -1598,7 +1623,7 @@ void CommonHostInterface::UpdateControllerInputMap(SettingsInterface& si)
|
||||||
const std::string binding(
|
const std::string binding(
|
||||||
si.GetStringValue(category, TinyString::FromFormat("AutoFire%u", turbo_button_index + 1), ""));
|
si.GetStringValue(category, TinyString::FromFormat("AutoFire%u", turbo_button_index + 1), ""));
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
// Android doesn't require a binding, since we can trigger it from the touchscreen controller.
|
// Android doesn't require a binding, since we can trigger it from the touchscreen controller.
|
||||||
if (binding.empty())
|
if (binding.empty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -1613,6 +1638,7 @@ void CommonHostInterface::UpdateControllerInputMap(SettingsInterface& si)
|
||||||
|
|
||||||
ControllerAutoFireState ts;
|
ControllerAutoFireState ts;
|
||||||
ts.controller_index = controller_index;
|
ts.controller_index = controller_index;
|
||||||
|
ts.slot_index = turbo_button_index;
|
||||||
ts.button_code = button_code.value();
|
ts.button_code = button_code.value();
|
||||||
ts.frequency = static_cast<u8>(
|
ts.frequency = static_cast<u8>(
|
||||||
std::clamp<s32>(si.GetIntValue(category, TinyString::FromFormat("AutoFire%uFrequency", turbo_button_index + 1),
|
std::clamp<s32>(si.GetIntValue(category, TinyString::FromFormat("AutoFire%uFrequency", turbo_button_index + 1),
|
||||||
|
|
|
@ -311,6 +311,9 @@ public:
|
||||||
/// Controller navigation, used by fullscreen mode.
|
/// Controller navigation, used by fullscreen mode.
|
||||||
void SetControllerNavigationButtonState(FrontendCommon::ControllerNavigationButton button, bool pressed);
|
void SetControllerNavigationButtonState(FrontendCommon::ControllerNavigationButton button, bool pressed);
|
||||||
|
|
||||||
|
/// Alters autofire state for controllers (activates/deactivates).
|
||||||
|
void SetControllerAutoFireSlotState(u32 controller_index, u32 slot_index, bool active);
|
||||||
|
|
||||||
/// Toggles fast forward state.
|
/// Toggles fast forward state.
|
||||||
bool IsFastForwardEnabled() const { return m_fast_forward_enabled; }
|
bool IsFastForwardEnabled() const { return m_fast_forward_enabled; }
|
||||||
void SetFastForwardEnabled(bool enabled);
|
void SetFastForwardEnabled(bool enabled);
|
||||||
|
@ -535,6 +538,7 @@ private:
|
||||||
struct ControllerAutoFireState
|
struct ControllerAutoFireState
|
||||||
{
|
{
|
||||||
u32 controller_index;
|
u32 controller_index;
|
||||||
|
u32 slot_index;
|
||||||
s32 button_code;
|
s32 button_code;
|
||||||
u8 frequency;
|
u8 frequency;
|
||||||
u8 countdown;
|
u8 countdown;
|
||||||
|
|
Loading…
Reference in a new issue