InputManager: Don't display controller connected for initial 3 seconds

Avoids spamming the OSD when starting up.
This commit is contained in:
Stenzek
2026-01-12 17:34:49 +10:00
parent 5154ea9b18
commit 56cbbb1323
3 changed files with 31 additions and 31 deletions

View File

@@ -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,

View File

@@ -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)

View File

@@ -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,