mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Merge pull request #7519 from stenzek/controller-window
Core: Switch controller interface to render surface on booting
This commit is contained in:
commit
97e3200f57
@ -456,10 +456,14 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The frontend will likely have initialized the controller interface, as it needs
|
||||||
|
// it to provide the configuration dialogs. In this case, instead of re-initializing
|
||||||
|
// entirely, we switch the window used for inputs to the render window. This way, the
|
||||||
|
// cursor position is relative to the render window, instead of the main window.
|
||||||
bool init_controllers = false;
|
bool init_controllers = false;
|
||||||
if (!g_controller_interface.IsInit())
|
if (!g_controller_interface.IsInit())
|
||||||
{
|
{
|
||||||
g_controller_interface.Initialize(wsi.render_surface);
|
g_controller_interface.Initialize(wsi);
|
||||||
Pad::Initialize();
|
Pad::Initialize();
|
||||||
Keyboard::Initialize();
|
Keyboard::Initialize();
|
||||||
init_controllers = true;
|
init_controllers = true;
|
||||||
@ -467,6 +471,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Update references in case controllers were refreshed
|
// Update references in case controllers were refreshed
|
||||||
|
g_controller_interface.ChangeWindow(wsi.render_surface);
|
||||||
Pad::LoadConfig();
|
Pad::LoadConfig();
|
||||||
Keyboard::LoadConfig();
|
Keyboard::LoadConfig();
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
||||||
#include "DolphinQt/Settings.h"
|
#include "DolphinQt/Settings.h"
|
||||||
|
|
||||||
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||||
|
|
||||||
#include "VideoCommon/RenderBase.h"
|
#include "VideoCommon/RenderBase.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
@ -32,8 +34,16 @@ Host* Host::GetInstance()
|
|||||||
|
|
||||||
void Host::SetRenderHandle(void* handle)
|
void Host::SetRenderHandle(void* handle)
|
||||||
{
|
{
|
||||||
|
if (m_render_handle == handle)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_render_handle = handle;
|
||||||
if (g_renderer)
|
if (g_renderer)
|
||||||
|
{
|
||||||
g_renderer->ChangeSurface(handle);
|
g_renderer->ChangeSurface(handle);
|
||||||
|
if (g_controller_interface.IsInit())
|
||||||
|
g_controller_interface.ChangeWindow(handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Host::GetRenderFocus()
|
bool Host::GetRenderFocus()
|
||||||
|
@ -169,6 +169,7 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters) : QMainW
|
|||||||
setWindowIcon(Resources::GetAppIcon());
|
setWindowIcon(Resources::GetAppIcon());
|
||||||
setUnifiedTitleAndToolBarOnMac(true);
|
setUnifiedTitleAndToolBarOnMac(true);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
setAttribute(Qt::WA_NativeWindow);
|
||||||
|
|
||||||
InitControllers();
|
InitControllers();
|
||||||
|
|
||||||
@ -237,7 +238,7 @@ void MainWindow::InitControllers()
|
|||||||
if (g_controller_interface.IsInit())
|
if (g_controller_interface.IsInit())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_controller_interface.Initialize(reinterpret_cast<void*>(winId()));
|
g_controller_interface.Initialize(GetWindowSystemInfo(windowHandle()));
|
||||||
Pad::Initialize();
|
Pad::Initialize();
|
||||||
Keyboard::Initialize();
|
Keyboard::Initialize();
|
||||||
Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES);
|
Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES);
|
||||||
@ -874,7 +875,8 @@ void MainWindow::SetFullScreenResolution(bool fullscreen)
|
|||||||
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
|
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
|
||||||
ChangeDisplaySettings(&screen_settings, CDS_FULLSCREEN);
|
ChangeDisplaySettings(&screen_settings, CDS_FULLSCREEN);
|
||||||
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
|
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
m_xrr_config->ToggleDisplayMode(fullscreen);
|
if (m_xrr_config)
|
||||||
|
m_xrr_config->ToggleDisplayMode(fullscreen);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,6 +940,11 @@ void MainWindow::HideRenderWidget(bool reinit)
|
|||||||
if (m_render_widget->isFullScreen())
|
if (m_render_widget->isFullScreen())
|
||||||
SetFullScreenResolution(focus);
|
SetFullScreenResolution(focus);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// The controller interface will still be registered to the old render widget, if the core
|
||||||
|
// has booted. Therefore, we should re-bind it to the main window for now. When the core
|
||||||
|
// is next started, it will be swapped back to the new render widget.
|
||||||
|
g_controller_interface.ChangeWindow(GetWindowSystemInfo(windowHandle()).render_surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1003,14 +1010,18 @@ void MainWindow::ShowGraphicsWindow()
|
|||||||
if (!m_graphics_window)
|
if (!m_graphics_window)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
m_xrr_config = std::make_unique<X11Utils::XRRConfiguration>(
|
if (GetWindowSystemType() == WindowSystemType::X11)
|
||||||
static_cast<Display*>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow(
|
{
|
||||||
"display", windowHandle())),
|
m_xrr_config = std::make_unique<X11Utils::XRRConfiguration>(
|
||||||
winId());
|
static_cast<Display*>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow(
|
||||||
|
"display", windowHandle())),
|
||||||
|
winId());
|
||||||
|
}
|
||||||
m_graphics_window = new GraphicsWindow(m_xrr_config.get(), this);
|
m_graphics_window = new GraphicsWindow(m_xrr_config.get(), this);
|
||||||
#else
|
#else
|
||||||
m_graphics_window = new GraphicsWindow(nullptr, this);
|
m_graphics_window = new GraphicsWindow(nullptr, this);
|
||||||
#endif
|
#endif
|
||||||
|
InstallHotkeyFilter(m_graphics_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_graphics_window->show();
|
m_graphics_window->show();
|
||||||
@ -1273,7 +1284,8 @@ void MainWindow::NetPlayQuit()
|
|||||||
void MainWindow::EnableScreenSaver(bool enable)
|
void MainWindow::EnableScreenSaver(bool enable)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
UICommon::EnableScreenSaver(winId(), enable);
|
if (GetWindowSystemType() == WindowSystemType::X11)
|
||||||
|
UICommon::EnableScreenSaver(winId(), enable);
|
||||||
#else
|
#else
|
||||||
UICommon::EnableScreenSaver(enable);
|
UICommon::EnableScreenSaver(enable);
|
||||||
#endif
|
#endif
|
||||||
|
@ -173,7 +173,7 @@ private:
|
|||||||
MenuBar* m_menu_bar;
|
MenuBar* m_menu_bar;
|
||||||
SearchBar* m_search_bar;
|
SearchBar* m_search_bar;
|
||||||
GameList* m_game_list;
|
GameList* m_game_list;
|
||||||
RenderWidget* m_render_widget;
|
RenderWidget* m_render_widget = nullptr;
|
||||||
bool m_rendering_to_main;
|
bool m_rendering_to_main;
|
||||||
bool m_stop_requested = false;
|
bool m_stop_requested = false;
|
||||||
bool m_exit_requested = false;
|
bool m_exit_requested = false;
|
||||||
|
@ -41,12 +41,12 @@ ControllerInterface g_controller_interface;
|
|||||||
//
|
//
|
||||||
// Detect devices and inputs outputs / will make refresh function later
|
// Detect devices and inputs outputs / will make refresh function later
|
||||||
//
|
//
|
||||||
void ControllerInterface::Initialize(void* const hwnd)
|
void ControllerInterface::Initialize(const WindowSystemInfo& wsi)
|
||||||
{
|
{
|
||||||
if (m_is_init)
|
if (m_is_init)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_hwnd = hwnd;
|
m_wsi = wsi;
|
||||||
m_is_populating_devices = true;
|
m_is_populating_devices = true;
|
||||||
|
|
||||||
#ifdef CIFACE_USE_DINPUT
|
#ifdef CIFACE_USE_DINPUT
|
||||||
@ -59,7 +59,8 @@ void ControllerInterface::Initialize(void* const hwnd)
|
|||||||
// nothing needed
|
// nothing needed
|
||||||
#endif
|
#endif
|
||||||
#ifdef CIFACE_USE_OSX
|
#ifdef CIFACE_USE_OSX
|
||||||
ciface::OSX::Init(hwnd);
|
if (m_wsi.type == WindowSystemType::MacOS)
|
||||||
|
ciface::OSX::Init(wsi.render_surface);
|
||||||
// nothing needed for Quartz
|
// nothing needed for Quartz
|
||||||
#endif
|
#endif
|
||||||
#ifdef CIFACE_USE_SDL
|
#ifdef CIFACE_USE_SDL
|
||||||
@ -79,6 +80,15 @@ void ControllerInterface::Initialize(void* const hwnd)
|
|||||||
RefreshDevices();
|
RefreshDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControllerInterface::ChangeWindow(void* hwnd)
|
||||||
|
{
|
||||||
|
if (!m_is_init)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_wsi.render_surface = hwnd;
|
||||||
|
RefreshDevices();
|
||||||
|
}
|
||||||
|
|
||||||
void ControllerInterface::RefreshDevices()
|
void ControllerInterface::RefreshDevices()
|
||||||
{
|
{
|
||||||
if (!m_is_init)
|
if (!m_is_init)
|
||||||
@ -92,17 +102,22 @@ void ControllerInterface::RefreshDevices()
|
|||||||
m_is_populating_devices = true;
|
m_is_populating_devices = true;
|
||||||
|
|
||||||
#ifdef CIFACE_USE_DINPUT
|
#ifdef CIFACE_USE_DINPUT
|
||||||
ciface::DInput::PopulateDevices(reinterpret_cast<HWND>(m_hwnd));
|
if (m_wsi.type == WindowSystemType::Windows)
|
||||||
|
ciface::DInput::PopulateDevices(reinterpret_cast<HWND>(m_wsi.render_surface));
|
||||||
#endif
|
#endif
|
||||||
#ifdef CIFACE_USE_XINPUT
|
#ifdef CIFACE_USE_XINPUT
|
||||||
ciface::XInput::PopulateDevices();
|
ciface::XInput::PopulateDevices();
|
||||||
#endif
|
#endif
|
||||||
#ifdef CIFACE_USE_XLIB
|
#ifdef CIFACE_USE_XLIB
|
||||||
ciface::XInput2::PopulateDevices(m_hwnd);
|
if (m_wsi.type == WindowSystemType::X11)
|
||||||
|
ciface::XInput2::PopulateDevices(m_wsi.render_surface);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CIFACE_USE_OSX
|
#ifdef CIFACE_USE_OSX
|
||||||
ciface::OSX::PopulateDevices(m_hwnd);
|
if (m_wsi.type == WindowSystemType::MacOS)
|
||||||
ciface::Quartz::PopulateDevices(m_hwnd);
|
{
|
||||||
|
ciface::OSX::PopulateDevices(m_wsi.render_surface);
|
||||||
|
ciface::Quartz::PopulateDevices(m_wsi.render_surface);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CIFACE_USE_SDL
|
#ifdef CIFACE_USE_SDL
|
||||||
ciface::SDL::PopulateDevices();
|
ciface::SDL::PopulateDevices();
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Common/WindowSystemInfo.h"
|
||||||
#include "InputCommon/ControllerInterface/Device.h"
|
#include "InputCommon/ControllerInterface/Device.h"
|
||||||
|
|
||||||
// enable disable sources
|
// enable disable sources
|
||||||
@ -39,8 +40,9 @@
|
|||||||
class ControllerInterface : public ciface::Core::DeviceContainer
|
class ControllerInterface : public ciface::Core::DeviceContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ControllerInterface() : m_is_init(false), m_hwnd(nullptr) {}
|
ControllerInterface() : m_is_init(false) {}
|
||||||
void Initialize(void* const hwnd);
|
void Initialize(const WindowSystemInfo& wsi);
|
||||||
|
void ChangeWindow(void* hwnd);
|
||||||
void RefreshDevices();
|
void RefreshDevices();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
void AddDevice(std::shared_ptr<ciface::Core::Device> device);
|
void AddDevice(std::shared_ptr<ciface::Core::Device> device);
|
||||||
@ -56,7 +58,7 @@ private:
|
|||||||
mutable std::mutex m_callbacks_mutex;
|
mutable std::mutex m_callbacks_mutex;
|
||||||
bool m_is_init;
|
bool m_is_init;
|
||||||
std::atomic<bool> m_is_populating_devices{false};
|
std::atomic<bool> m_is_populating_devices{false};
|
||||||
void* m_hwnd;
|
WindowSystemInfo m_wsi;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ControllerInterface g_controller_interface;
|
extern ControllerInterface g_controller_interface;
|
||||||
|
Loading…
Reference in New Issue
Block a user