Split out controller initialization to UICommon
This commit is contained in:
parent
be551b1529
commit
2f3c0cdbc5
|
@ -48,8 +48,6 @@ constexpr const char* DUBOIS_ALGORITHM_SHADER = "dubois";
|
|||
|
||||
HotkeyScheduler::HotkeyScheduler() : m_stop_requested(false)
|
||||
{
|
||||
HotkeyManagerEmu::Initialize();
|
||||
HotkeyManagerEmu::LoadConfig();
|
||||
HotkeyManagerEmu::Enable(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -321,24 +321,12 @@ void MainWindow::InitControllers()
|
|||
if (g_controller_interface.IsInit())
|
||||
return;
|
||||
|
||||
g_controller_interface.Initialize(GetWindowSystemInfo(windowHandle()));
|
||||
if (!g_controller_interface.HasDefaultDevice())
|
||||
{
|
||||
// Note that the CI default device could be still temporarily removed at any time
|
||||
WARN_LOG_FMT(CONTROLLERINTERFACE,
|
||||
"No default device has been added in time. EmulatedController(s) defaulting adds"
|
||||
" input mappings made for a specific default device depending on the platform");
|
||||
}
|
||||
GCAdapter::Init();
|
||||
Pad::Initialize();
|
||||
Pad::InitializeGBA();
|
||||
Keyboard::Initialize();
|
||||
Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES);
|
||||
FreeLook::Initialize();
|
||||
UICommon::InitControllers(GetWindowSystemInfo(windowHandle()));
|
||||
|
||||
m_hotkey_scheduler = new HotkeyScheduler();
|
||||
m_hotkey_scheduler->Start();
|
||||
|
||||
// Defaults won't work reliabily without loading and saving the config first
|
||||
// Defaults won't work reliably without loading and saving the config first
|
||||
|
||||
Wiimote::LoadConfig();
|
||||
Wiimote::GetConfig()->SaveConfig();
|
||||
|
@ -362,13 +350,7 @@ void MainWindow::ShutdownControllers()
|
|||
|
||||
Settings::Instance().UnregisterDevicesChangedCallback();
|
||||
|
||||
Pad::Shutdown();
|
||||
Pad::ShutdownGBA();
|
||||
Keyboard::Shutdown();
|
||||
Wiimote::Shutdown();
|
||||
HotkeyManagerEmu::Shutdown();
|
||||
FreeLook::Shutdown();
|
||||
g_controller_interface.Shutdown();
|
||||
UICommon::ShutdownControllers();
|
||||
|
||||
m_hotkey_scheduler->deleteLater();
|
||||
}
|
||||
|
|
|
@ -28,12 +28,18 @@
|
|||
#include "Core/ConfigLoaders/BaseConfigLoader.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/FreeLookManager.h"
|
||||
#include "Core/HW/GBAPad.h"
|
||||
#include "Core/HW/GCKeyboard.h"
|
||||
#include "Core/HW/GCPad.h"
|
||||
#include "Core/HW/ProcessorInterface.h"
|
||||
#include "Core/HW/Wiimote.h"
|
||||
#include "Core/HotkeyManager.h"
|
||||
#include "Core/IOS/IOS.h"
|
||||
#include "Core/IOS/STM/STM.h"
|
||||
#include "Core/WiiRoot.h"
|
||||
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/GCAdapter.h"
|
||||
|
||||
#include "UICommon/DiscordPresence.h"
|
||||
|
@ -128,6 +134,41 @@ void Shutdown()
|
|||
Config::Shutdown();
|
||||
}
|
||||
|
||||
void InitControllers(const WindowSystemInfo& wsi)
|
||||
{
|
||||
if (g_controller_interface.IsInit())
|
||||
return;
|
||||
|
||||
g_controller_interface.Initialize(wsi);
|
||||
|
||||
if (!g_controller_interface.HasDefaultDevice())
|
||||
{
|
||||
// Note that the CI default device could be still temporarily removed at any time
|
||||
WARN_LOG_FMT(CONTROLLERINTERFACE, "No default device has been added in time. Premade control "
|
||||
"mappings intended for the default device may not work.");
|
||||
}
|
||||
|
||||
GCAdapter::Init();
|
||||
Pad::Initialize();
|
||||
Pad::InitializeGBA();
|
||||
Keyboard::Initialize();
|
||||
Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES);
|
||||
HotkeyManagerEmu::Initialize();
|
||||
FreeLook::Initialize();
|
||||
}
|
||||
|
||||
void ShutdownControllers()
|
||||
{
|
||||
Pad::Shutdown();
|
||||
Pad::ShutdownGBA();
|
||||
Keyboard::Shutdown();
|
||||
Wiimote::Shutdown();
|
||||
HotkeyManagerEmu::Shutdown();
|
||||
FreeLook::Shutdown();
|
||||
|
||||
g_controller_interface.Shutdown();
|
||||
}
|
||||
|
||||
void SetLocale(std::string locale_name)
|
||||
{
|
||||
auto set_locale = [](const std::string& locale) {
|
||||
|
|
|
@ -7,11 +7,16 @@
|
|||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
struct WindowSystemInfo;
|
||||
|
||||
namespace UICommon
|
||||
{
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
void InitControllers(const WindowSystemInfo& wsi);
|
||||
void ShutdownControllers();
|
||||
|
||||
#ifdef HAVE_X11
|
||||
void InhibitScreenSaver(unsigned long win, bool enable);
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue