From d65006b91ba5e432f84be9c0c224e80240a9b2af Mon Sep 17 00:00:00 2001 From: spycrab Date: Tue, 23 May 2017 22:12:01 +0200 Subject: [PATCH] Qt: Fix games crashing on start --- .../Config/Mapping/GCKeyboardEmu.cpp | 2 -- .../DolphinQt2/Config/Mapping/GCPadEmu.cpp | 2 -- .../Config/Mapping/MappingWindow.cpp | 5 ++--- .../Config/Mapping/WiimoteEmuExtension.cpp | 2 -- .../Config/Mapping/WiimoteEmuGeneral.cpp | 2 -- .../Mapping/WiimoteEmuMotionControl.cpp | 1 - Source/Core/DolphinQt2/MainWindow.cpp | 21 +++++++++++++++++++ Source/Core/DolphinQt2/MainWindow.h | 2 ++ 8 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Source/Core/DolphinQt2/Config/Mapping/GCKeyboardEmu.cpp b/Source/Core/DolphinQt2/Config/Mapping/GCKeyboardEmu.cpp index 67fe910949..60eb9a4847 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/GCKeyboardEmu.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/GCKeyboardEmu.cpp @@ -15,8 +15,6 @@ GCKeyboardEmu::GCKeyboardEmu(MappingWindow* window) : MappingWidget(window) { - Keyboard::Initialize(); - CreateMainLayout(); } diff --git a/Source/Core/DolphinQt2/Config/Mapping/GCPadEmu.cpp b/Source/Core/DolphinQt2/Config/Mapping/GCPadEmu.cpp index d7c689f539..4bc0e181cb 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/GCPadEmu.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/GCPadEmu.cpp @@ -15,8 +15,6 @@ GCPadEmu::GCPadEmu(MappingWindow* window) : MappingWidget(window) { - Pad::Initialize(); - CreateMainLayout(); } diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp index af0fde8475..7b24f1c678 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp @@ -25,10 +25,11 @@ #include "DolphinQt2/Config/Mapping/WiimoteEmuMotionControl.h" #include "DolphinQt2/Settings.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" -#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/Device.h" #include "InputCommon/InputConfig.h" +#include "InputCommon/ControllerInterface/ControllerInterface.h" + MappingWindow::MappingWindow(QWidget* parent, int port_num) : QDialog(parent), m_port(port_num) { setWindowTitle(tr("Port %1").arg(port_num + 1)); @@ -38,8 +39,6 @@ MappingWindow::MappingWindow(QWidget* parent, int port_num) : QDialog(parent), m CreateResetLayout(); CreateMainLayout(); ConnectWidgets(); - - g_controller_interface.Initialize(reinterpret_cast(winId())); } void MappingWindow::CreateDevicesLayout() diff --git a/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuExtension.cpp b/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuExtension.cpp index d443e3319a..5cf9290bf5 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuExtension.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuExtension.cpp @@ -14,8 +14,6 @@ WiimoteEmuExtension::WiimoteEmuExtension(MappingWindow* window) : MappingWidget(window) { - Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES); - CreateClassicLayout(); CreateDrumsLayout(); CreateGuitarLayout(); diff --git a/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuGeneral.cpp b/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuGeneral.cpp index e306fdc907..9d0655e0a3 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuGeneral.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuGeneral.cpp @@ -19,8 +19,6 @@ WiimoteEmuGeneral::WiimoteEmuGeneral(MappingWindow* window, WiimoteEmuExtension* extension) : MappingWidget(window), m_extension_widget(extension) { - Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES); - CreateMainLayout(); Connect(); } diff --git a/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuMotionControl.cpp b/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuMotionControl.cpp index cf9f787429..506f1e4dd7 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuMotionControl.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/WiimoteEmuMotionControl.cpp @@ -15,7 +15,6 @@ WiimoteEmuMotionControl::WiimoteEmuMotionControl(MappingWindow* window) : MappingWidget(window) { - Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES); CreateMainLayout(); } diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index cdb78bdb0a..90eef84439 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -10,7 +10,12 @@ #include "Core/BootManager.h" #include "Core/ConfigManager.h" #include "Core/Core.h" +#include "Core/HW/GCKeyboard.h" +#include "Core/HW/GCPad.h" #include "Core/HW/ProcessorInterface.h" +#include "Core/HW/Wiimote.h" +#include "Core/HW/WiimoteEmu/WiimoteEmu.h" +#include "Core/HotkeyManager.h" #include "Core/Movie.h" #include "Core/NetPlayProto.h" #include "Core/State.h" @@ -24,6 +29,8 @@ #include "DolphinQt2/Resources.h" #include "DolphinQt2/Settings.h" +#include "InputCommon/ControllerInterface/ControllerInterface.h" + MainWindow::MainWindow() : QMainWindow(nullptr) { setWindowTitle(tr("Dolphin")); @@ -38,6 +45,8 @@ MainWindow::MainWindow() : QMainWindow(nullptr) ConnectRenderWidget(); ConnectStack(); ConnectMenuBar(); + + InitControllers(); } MainWindow::~MainWindow() @@ -45,6 +54,18 @@ MainWindow::~MainWindow() m_render_widget->deleteLater(); } +void MainWindow::InitControllers() +{ + if (g_controller_interface.IsInit()) + return; + + g_controller_interface.Initialize(reinterpret_cast(winId())); + Pad::Initialize(); + Keyboard::Initialize(); + Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES); + HotkeyManagerEmu::Initialize(); +} + void MainWindow::CreateComponents() { m_menu_bar = new MenuBar(this); diff --git a/Source/Core/DolphinQt2/MainWindow.h b/Source/Core/DolphinQt2/MainWindow.h index 2b5f6cf1bf..c2917c1ac0 100644 --- a/Source/Core/DolphinQt2/MainWindow.h +++ b/Source/Core/DolphinQt2/MainWindow.h @@ -65,6 +65,8 @@ private: void ConnectToolBar(); void ConnectPathsDialog(); + void InitControllers(); + void StartGame(const QString& path); void ShowRenderWidget(); void HideRenderWidget();