Qt: Fix games crashing on start

This commit is contained in:
spycrab 2017-05-23 22:12:01 +02:00
parent f994538875
commit d65006b91b
8 changed files with 25 additions and 12 deletions

View File

@ -15,8 +15,6 @@
GCKeyboardEmu::GCKeyboardEmu(MappingWindow* window) : MappingWidget(window)
{
Keyboard::Initialize();
CreateMainLayout();
}

View File

@ -15,8 +15,6 @@
GCPadEmu::GCPadEmu(MappingWindow* window) : MappingWidget(window)
{
Pad::Initialize();
CreateMainLayout();
}

View File

@ -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<void*>(winId()));
}
void MappingWindow::CreateDevicesLayout()

View File

@ -14,8 +14,6 @@
WiimoteEmuExtension::WiimoteEmuExtension(MappingWindow* window) : MappingWidget(window)
{
Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES);
CreateClassicLayout();
CreateDrumsLayout();
CreateGuitarLayout();

View File

@ -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();
}

View File

@ -15,7 +15,6 @@
WiimoteEmuMotionControl::WiimoteEmuMotionControl(MappingWindow* window) : MappingWidget(window)
{
Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES);
CreateMainLayout();
}

View File

@ -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<void*>(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);

View File

@ -65,6 +65,8 @@ private:
void ConnectToolBar();
void ConnectPathsDialog();
void InitControllers();
void StartGame(const QString& path);
void ShowRenderWidget();
void HideRenderWidget();