mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-07-09 17:14:47 -06:00
input: add methods to override button and axis values
This commit is contained in:
parent
8f0feefd04
commit
1d9bdd99c9
@ -264,6 +264,12 @@ void EmulatedController::clear_controllers()
|
||||
float EmulatedController::get_axis_value(uint64 mapping) const
|
||||
{
|
||||
std::shared_lock lock(m_mutex);
|
||||
const auto overriddenAxisMappingIt = m_overriddenAxisMappings.find(mapping);
|
||||
if (overriddenAxisMappingIt != m_overriddenAxisMappings.cend() && overriddenAxisMappingIt->second != 0.0f)
|
||||
{
|
||||
return overriddenAxisMappingIt->second;
|
||||
}
|
||||
|
||||
const auto it = m_mappings.find(mapping);
|
||||
if (it != m_mappings.cend())
|
||||
{
|
||||
@ -275,9 +281,25 @@ float EmulatedController::get_axis_value(uint64 mapping) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EmulatedController::set_button_value(uint64 mapping, bool value)
|
||||
{
|
||||
m_overriddenButtonMappings[mapping] = value;
|
||||
|
||||
}
|
||||
void EmulatedController::set_axis_value(uint64 mapping, float value)
|
||||
{
|
||||
m_overriddenAxisMappings[mapping] = value;
|
||||
}
|
||||
|
||||
bool EmulatedController::is_mapping_down(uint64 mapping) const
|
||||
{
|
||||
std::shared_lock lock(m_mutex);
|
||||
const auto overriddenButtonMappingIt = m_overriddenButtonMappings.find(mapping);
|
||||
if (overriddenButtonMappingIt != m_overriddenButtonMappings.cend() && overriddenButtonMappingIt->second)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto it = m_mappings.find(mapping);
|
||||
if (it != m_mappings.cend())
|
||||
{
|
||||
|
||||
@ -101,6 +101,8 @@ public:
|
||||
bool was_home_button_down() { return std::exchange(m_homebutton_down, false); }
|
||||
|
||||
virtual bool set_default_mapping(const std::shared_ptr<ControllerBase>& controller) { return false; }
|
||||
void set_button_value(uint64 mapping, bool value);
|
||||
void set_axis_value(uint64 mapping, float value);
|
||||
|
||||
protected:
|
||||
size_t m_player_index;
|
||||
@ -118,6 +120,8 @@ protected:
|
||||
uint64 button;
|
||||
};
|
||||
std::unordered_map<uint64, Mapping> m_mappings;
|
||||
std::unordered_map<uint64, bool> m_overriddenButtonMappings;
|
||||
std::unordered_map<uint64, float> m_overriddenAxisMappings;
|
||||
|
||||
bool m_homebutton_down = false;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user