mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-10 08:24:32 +00:00
InputManager: Don't display controller connected for initial 3 seconds
Avoids spamming the OSD when starting up.
This commit is contained in:
@@ -358,15 +358,10 @@ void Host::AddFixedInputBindings(const SettingsInterface& si)
|
||||
|
||||
void Host::OnInputDeviceConnected(InputBindingKey key, std::string_view identifier, std::string_view device_name)
|
||||
{
|
||||
Host::AddIconOSDMessage(OSDMessageType::Info, fmt::format("InputDeviceConnected-{}", identifier),
|
||||
ICON_EMOJI_INFORMATION,
|
||||
fmt::format("Input device {0} ({1}) connected.", device_name, identifier));
|
||||
}
|
||||
|
||||
void Host::OnInputDeviceDisconnected(InputBindingKey key, std::string_view identifier)
|
||||
{
|
||||
Host::AddIconOSDMessage(OSDMessageType::Info, fmt::format("InputDeviceConnected-{}", identifier),
|
||||
ICON_EMOJI_INFORMATION, fmt::format("Input device {} disconnected.", identifier));
|
||||
}
|
||||
|
||||
s32 Host::Internal::GetTranslatedStringImpl(std::string_view context, std::string_view msg,
|
||||
|
||||
@@ -2699,12 +2699,6 @@ void Host::OnInputDeviceConnected(InputBindingKey key, std::string_view identifi
|
||||
Qt::QueuedConnection, key, QtUtils::StringViewToQString(identifier),
|
||||
QtUtils::StringViewToQString(device_name), qeffect_list);
|
||||
g_core_thread->updateBackgroundControllerPollInterval();
|
||||
|
||||
if (System::IsValid() || GPUThread::IsFullscreenUIRequested())
|
||||
{
|
||||
Host::AddIconOSDMessage(OSDMessageType::Info, fmt::format("ControllerConnected{}", identifier), ICON_FA_GAMEPAD,
|
||||
fmt::format(TRANSLATE_FS("QtHost", "Controller {} connected."), identifier));
|
||||
}
|
||||
}
|
||||
|
||||
void Host::OnInputDeviceDisconnected(InputBindingKey key, std::string_view identifier)
|
||||
@@ -2712,26 +2706,6 @@ void Host::OnInputDeviceDisconnected(InputBindingKey key, std::string_view ident
|
||||
QMetaObject::invokeMethod(g_core_thread->getInputDeviceListModel(), &InputDeviceListModel::onDeviceDisconnected,
|
||||
Qt::QueuedConnection, key, QtUtils::StringViewToQString(identifier));
|
||||
g_core_thread->updateBackgroundControllerPollInterval();
|
||||
|
||||
if (g_settings.pause_on_controller_disconnection && System::GetState() == System::State::Running &&
|
||||
InputManager::HasAnyBindingsForSource(key))
|
||||
{
|
||||
std::string message =
|
||||
fmt::format(TRANSLATE_FS("QtHost", "System paused because controller {} was disconnected."), identifier);
|
||||
Host::RunOnCoreThread([message = QString::fromStdString(message)]() {
|
||||
System::PauseSystem(true);
|
||||
|
||||
// has to be done after pause, otherwise pause message takes precedence
|
||||
emit g_core_thread->statusMessage(message);
|
||||
});
|
||||
Host::AddIconOSDMessage(OSDMessageType::Warning, fmt::format("ControllerConnected{}", identifier), ICON_FA_GAMEPAD,
|
||||
std::move(message));
|
||||
}
|
||||
else if (System::IsValid() || GPUThread::IsFullscreenUIRequested())
|
||||
{
|
||||
Host::AddIconOSDMessage(OSDMessageType::Info, fmt::format("ControllerConnected{}", identifier), ICON_FA_GAMEPAD,
|
||||
fmt::format(TRANSLATE_FS("QtHost", "Controller {} disconnected."), identifier));
|
||||
}
|
||||
}
|
||||
|
||||
void Host::AddFixedInputBindings(const SettingsInterface& si)
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
|
||||
#include "core/controller.h"
|
||||
#include "core/core.h"
|
||||
#include "core/gpu_thread.h"
|
||||
#include "core/host.h"
|
||||
#include "core/system.h"
|
||||
#include "core/system_private.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/bitutils.h"
|
||||
@@ -21,6 +23,7 @@
|
||||
#include "common/thirdparty/SmallVector.h"
|
||||
#include "common/timer.h"
|
||||
|
||||
#include "IconsFontAwesome.h"
|
||||
#include "IconsPromptFont.h"
|
||||
|
||||
#include "fmt/core.h"
|
||||
@@ -55,6 +58,9 @@ enum : u32
|
||||
LAST_EXTERNAL_INPUT_SOURCE = static_cast<u32>(InputSourceType::Count),
|
||||
};
|
||||
|
||||
/// Delay before showing any controller connected notifications after startup.
|
||||
static constexpr float DEVICE_CONNECTED_NOTIFICATION_DELAY = 3.0f;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Binding Type
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -1836,12 +1842,37 @@ void InputManager::OnInputDeviceConnected(InputBindingKey key, std::string_view
|
||||
INFO_LOG("Device '{}' connected: '{}'", identifier, device_name);
|
||||
SynchronizePadEffectBindings(key);
|
||||
Host::OnInputDeviceConnected(key, identifier, device_name);
|
||||
|
||||
if ((System::IsValid() || GPUThread::IsFullscreenUIRequested()) &&
|
||||
System::GetProcessUptime() >= DEVICE_CONNECTED_NOTIFICATION_DELAY)
|
||||
{
|
||||
Host::AddIconOSDMessage(OSDMessageType::Info, fmt::format("ControllerConnected{}", identifier), ICON_FA_GAMEPAD,
|
||||
fmt::format(TRANSLATE_FS("InputManager", "Controller {} connected."), identifier));
|
||||
}
|
||||
}
|
||||
|
||||
void InputManager::OnInputDeviceDisconnected(InputBindingKey key, std::string_view identifier)
|
||||
{
|
||||
INFO_LOG("Device '{}' disconnected", identifier);
|
||||
Host::OnInputDeviceDisconnected(key, identifier);
|
||||
|
||||
if (System::IsValid() || GPUThread::IsFullscreenUIRequested())
|
||||
{
|
||||
Host::AddIconOSDMessage(OSDMessageType::Info, fmt::format("ControllerConnected{}", identifier), ICON_FA_GAMEPAD,
|
||||
fmt::format(TRANSLATE_FS("QtHost", "Controller {} disconnected."), identifier));
|
||||
}
|
||||
|
||||
if (g_settings.pause_on_controller_disconnection && System::GetState() == System::State::Running &&
|
||||
HasAnyBindingsForSource(key))
|
||||
{
|
||||
Host::RunOnCoreThread([identifier = std::string(identifier)]() {
|
||||
System::PauseSystem(true);
|
||||
|
||||
// has to be done after pause, otherwise pause message takes precedence
|
||||
Host::ReportStatusMessage(
|
||||
fmt::format(TRANSLATE_FS("InputManager", "System paused because controller {} was disconnected."), identifier));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<ForceFeedbackDevice> InputManager::CreateForceFeedbackDevice(const std::string_view device,
|
||||
|
||||
Reference in New Issue
Block a user