input: Add option to make show screen button a toggle (#1383)

This commit is contained in:
goeiecool9999 2024-10-19 01:56:56 +02:00 committed by GitHub
parent d6575455ee
commit f9a4b2dbb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 64 additions and 31 deletions

View file

@ -686,3 +686,14 @@ bool VPADController::set_default_mapping(const std::shared_ptr<ControllerBase>&
return mapping_updated;
}
void VPADController::load(const pugi::xml_node& node)
{
if (const auto value = node.child("toggle_display"))
m_screen_active_toggle = ConvertString<bool>(value.child_value());
}
void VPADController::save(pugi::xml_node& node)
{
node.append_child("toggle_display").append_child(pugi::node_pcdata).set_value(fmt::format("{}", (int)m_screen_active_toggle).c_str());
}

View file

@ -66,6 +66,8 @@ public:
bool is_mic_active() { return m_mic_active; }
bool is_screen_active() { return m_screen_active; }
bool is_screen_active_toggle() { return m_screen_active_toggle; }
void set_screen_toggle(bool toggle) {m_screen_active_toggle = toggle;}
static std::string_view get_button_name(ButtonId id);
@ -86,9 +88,13 @@ public:
bool set_default_mapping(const std::shared_ptr<ControllerBase>& controller) override;
void load(const pugi::xml_node& node) override;
void save(pugi::xml_node& node) override;
private:
bool m_mic_active = false;
bool m_screen_active = false;
bool m_screen_active_toggle = false;
uint32be m_last_holdvalue = 0;
std::chrono::high_resolution_clock::time_point m_last_hold_change{}, m_last_pulse{};