Qt: Add option to pause when controller is disconnected
This commit is contained in:
@ -162,7 +162,9 @@ void DInputSource::Shutdown()
|
||||
{
|
||||
while (!m_controllers.empty())
|
||||
{
|
||||
InputManager::OnInputDeviceDisconnected(GetDeviceIdentifier(static_cast<u32>(m_controllers.size() - 1)));
|
||||
const u32 index = static_cast<u32>(m_controllers.size() - 1);
|
||||
InputManager::OnInputDeviceDisconnected({{.source_type = InputSourceType::DInput, .source_index = index}},
|
||||
GetDeviceIdentifier(static_cast<u32>(m_controllers.size() - 1)));
|
||||
m_controllers.pop_back();
|
||||
}
|
||||
}
|
||||
@ -265,7 +267,9 @@ void DInputSource::PollEvents()
|
||||
|
||||
if (hr != DI_OK)
|
||||
{
|
||||
InputManager::OnInputDeviceDisconnected(GetDeviceIdentifier(static_cast<u32>(i)));
|
||||
InputManager::OnInputDeviceDisconnected(
|
||||
{{.source_type = InputSourceType::DInput, .source_index = static_cast<u32>(i)}},
|
||||
GetDeviceIdentifier(static_cast<u32>(i)));
|
||||
m_controllers.erase(m_controllers.begin() + i);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1440,9 +1440,9 @@ void InputManager::OnInputDeviceConnected(std::string_view identifier, std::stri
|
||||
Host::OnInputDeviceConnected(identifier, device_name);
|
||||
}
|
||||
|
||||
void InputManager::OnInputDeviceDisconnected(std::string_view identifier)
|
||||
void InputManager::OnInputDeviceDisconnected(InputBindingKey key, std::string_view identifier)
|
||||
{
|
||||
Host::OnInputDeviceDisconnected(identifier);
|
||||
Host::OnInputDeviceDisconnected(key, identifier);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@ -351,7 +351,7 @@ std::vector<std::string> GetInputProfileNames();
|
||||
void OnInputDeviceConnected(std::string_view identifier, std::string_view device_name);
|
||||
|
||||
/// Called when an input device is disconnected.
|
||||
void OnInputDeviceDisconnected(std::string_view identifier);
|
||||
void OnInputDeviceDisconnected(InputBindingKey key, std::string_view identifier);
|
||||
} // namespace InputManager
|
||||
|
||||
namespace Host {
|
||||
@ -362,7 +362,7 @@ void AddFixedInputBindings(SettingsInterface& si);
|
||||
void OnInputDeviceConnected(std::string_view identifier, std::string_view device_name);
|
||||
|
||||
/// Called when an input device is disconnected.
|
||||
void OnInputDeviceDisconnected(std::string_view identifier);
|
||||
void OnInputDeviceDisconnected(InputBindingKey key, std::string_view identifier);
|
||||
|
||||
/// Enables "relative" mouse mode, locking the cursor position and returning relative coordinates.
|
||||
void SetMouseMode(bool relative, bool hide_cursor);
|
||||
|
||||
@ -822,7 +822,9 @@ bool SDLInputSource::CloseDevice(int joystick_index)
|
||||
if (it == m_controllers.end())
|
||||
return false;
|
||||
|
||||
InputManager::OnInputDeviceDisconnected(fmt::format("SDL-{}", it->player_id));
|
||||
InputManager::OnInputDeviceDisconnected(
|
||||
{{.source_type = InputSourceType::SDL, .source_index = static_cast<u32>(it->player_id)}},
|
||||
fmt::format("SDL-{}", it->player_id));
|
||||
|
||||
if (it->haptic)
|
||||
SDL_HapticClose(it->haptic);
|
||||
|
||||
@ -442,7 +442,12 @@ void XInputSource::HandleControllerConnection(u32 index)
|
||||
void XInputSource::HandleControllerDisconnection(u32 index)
|
||||
{
|
||||
Log_InfoPrintf("XInput controller %u disconnected.", index);
|
||||
InputManager::OnInputDeviceDisconnected(fmt::format("XInput-{}", index));
|
||||
|
||||
InputManager::OnInputDeviceDisconnected({{
|
||||
.source_type = InputSourceType::XInput,
|
||||
.source_index = index,
|
||||
}},
|
||||
fmt::format("XInput-{}", index));
|
||||
m_controllers[index] = {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user