InputManager: Ensure Android source is always enabled
This commit is contained in:
parent
b99bf90596
commit
6f868e8d2a
|
@ -115,6 +115,9 @@ static void LoadMacroButtonConfig(SettingsInterface& si, const std::string& sect
|
||||||
const Controller::ControllerInfo* cinfo);
|
const Controller::ControllerInfo* cinfo);
|
||||||
static void ApplyMacroButton(u32 pad, const MacroButton& mb);
|
static void ApplyMacroButton(u32 pad, const MacroButton& mb);
|
||||||
static void UpdateMacroButtons();
|
static void UpdateMacroButtons();
|
||||||
|
|
||||||
|
static void UpdateInputSourceState(SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock,
|
||||||
|
InputSourceType type, std::unique_ptr<InputSource> (*factory_function)());
|
||||||
} // namespace InputManager
|
} // namespace InputManager
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
@ -472,6 +475,44 @@ const char* InputManager::InputSourceToString(InputSourceType clazz)
|
||||||
return s_input_class_names[static_cast<u32>(clazz)];
|
return s_input_class_names[static_cast<u32>(clazz)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InputManager::GetInputSourceDefaultEnabled(InputSourceType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case InputSourceType::Keyboard:
|
||||||
|
case InputSourceType::Pointer:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
case InputSourceType::DInput:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case InputSourceType::XInput:
|
||||||
|
// Disable xinput by default if we have SDL.
|
||||||
|
#ifdef WITH_SDL2
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
case InputSourceType::RawInput:
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_SDL2
|
||||||
|
case InputSourceType::SDL:
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
case InputSourceType::Android:
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<InputSourceType> InputManager::ParseInputSourceString(const std::string_view& str)
|
std::optional<InputSourceType> InputManager::ParseInputSourceString(const std::string_view& str)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < static_cast<u32>(InputSourceType::Count); i++)
|
for (u32 i = 0; i < static_cast<u32>(InputSourceType::Count); i++)
|
||||||
|
@ -1687,11 +1728,21 @@ GenericInputBindingMapping InputManager::GetGenericBindingMapping(const std::str
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateInputSourceState(SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock,
|
bool InputManager::IsInputSourceEnabled(SettingsInterface& si, InputSourceType type)
|
||||||
InputSourceType type, std::unique_ptr<InputSource> (*factory_function)(),
|
|
||||||
bool default_state)
|
|
||||||
{
|
{
|
||||||
const bool enabled = si.GetBoolValue("InputSources", InputManager::InputSourceToString(type), default_state);
|
#ifdef __ANDROID__
|
||||||
|
// Force Android source to always be enabled so nobody accidentally breaks it via ini.
|
||||||
|
if (type == InputSourceType::Android)
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return si.GetBoolValue("InputSources", InputManager::InputSourceToString(type), GetInputSourceDefaultEnabled(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputManager::UpdateInputSourceState(SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock,
|
||||||
|
InputSourceType type, std::unique_ptr<InputSource> (*factory_function)())
|
||||||
|
{
|
||||||
|
const bool enabled = IsInputSourceEnabled(si, type);
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
if (s_input_sources[static_cast<u32>(type)])
|
if (s_input_sources[static_cast<u32>(type)])
|
||||||
|
@ -1723,17 +1774,17 @@ static void UpdateInputSourceState(SettingsInterface& si, std::unique_lock<std::
|
||||||
void InputManager::ReloadSources(SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock)
|
void InputManager::ReloadSources(SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
UpdateInputSourceState(si, settings_lock, InputSourceType::DInput, &InputSource::CreateDInputSource, false);
|
UpdateInputSourceState(si, settings_lock, InputSourceType::DInput, &InputSource::CreateDInputSource);
|
||||||
UpdateInputSourceState(si, settings_lock, InputSourceType::XInput, &InputSource::CreateXInputSource, false);
|
UpdateInputSourceState(si, settings_lock, InputSourceType::XInput, &InputSource::CreateXInputSource);
|
||||||
UpdateInputSourceState(si, settings_lock, InputSourceType::RawInput, &InputSource::CreateWin32RawInputSource, false);
|
UpdateInputSourceState(si, settings_lock, InputSourceType::RawInput, &InputSource::CreateWin32RawInputSource);
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_SDL2
|
#ifdef WITH_SDL2
|
||||||
UpdateInputSourceState(si, settings_lock, InputSourceType::SDL, &InputSource::CreateSDLSource, true);
|
UpdateInputSourceState(si, settings_lock, InputSourceType::SDL, &InputSource::CreateSDLSource);
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_EVDEV
|
#ifdef WITH_EVDEV
|
||||||
UpdateInputSourceState(si, settings_lock, InputSourceType::Evdev, &InputSource::CreateEvdevSource, true);
|
UpdateInputSourceState(si, settings_lock, InputSourceType::Evdev, &InputSource::CreateEvdevSource);
|
||||||
#endif
|
#endif
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
UpdateInputSourceState(si, settings_lock, InputSourceType::Android, &InputSource::CreateAndroidSource, true);
|
UpdateInputSourceState(si, settings_lock, InputSourceType::Android, &InputSource::CreateAndroidSource);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,6 +172,9 @@ InputSource* GetInputSourceInterface(InputSourceType type);
|
||||||
/// Converts an input class to a string.
|
/// Converts an input class to a string.
|
||||||
const char* InputSourceToString(InputSourceType clazz);
|
const char* InputSourceToString(InputSourceType clazz);
|
||||||
|
|
||||||
|
/// Returns the default state for an input source.
|
||||||
|
bool GetInputSourceDefaultEnabled(InputSourceType type);
|
||||||
|
|
||||||
/// Parses an input class string.
|
/// Parses an input class string.
|
||||||
std::optional<InputSourceType> ParseInputSourceString(const std::string_view& str);
|
std::optional<InputSourceType> ParseInputSourceString(const std::string_view& str);
|
||||||
|
|
||||||
|
@ -215,6 +218,9 @@ std::vector<InputBindingKey> EnumerateMotors();
|
||||||
/// Retrieves bindings that match the generic bindings for the specified device.
|
/// Retrieves bindings that match the generic bindings for the specified device.
|
||||||
GenericInputBindingMapping GetGenericBindingMapping(const std::string_view& device);
|
GenericInputBindingMapping GetGenericBindingMapping(const std::string_view& device);
|
||||||
|
|
||||||
|
/// Returns true if the specified input source is enabled.
|
||||||
|
bool IsInputSourceEnabled(SettingsInterface& si, InputSourceType type);
|
||||||
|
|
||||||
/// Re-parses the config and registers all hotkey and pad bindings.
|
/// Re-parses the config and registers all hotkey and pad bindings.
|
||||||
void ReloadBindings(SettingsInterface& si, SettingsInterface& binding_si);
|
void ReloadBindings(SettingsInterface& si, SettingsInterface& binding_si);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue