mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-28 21:08:04 +03:00
Merge a39cccdb30
into 8ee64a84c7
This commit is contained in:
commit
4f6159ce21
4 changed files with 20 additions and 26 deletions
|
@ -4,10 +4,8 @@
|
||||||
#include "DolphinNoGUI/Platform.h"
|
#include "DolphinNoGUI/Platform.h"
|
||||||
|
|
||||||
#include <OptionParser.h>
|
#include <OptionParser.h>
|
||||||
#include <cstddef>
|
#include <csignal>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -32,15 +30,13 @@
|
||||||
#endif
|
#endif
|
||||||
#include "UICommon/UICommon.h"
|
#include "UICommon/UICommon.h"
|
||||||
|
|
||||||
#include "InputCommon/GCAdapter.h"
|
|
||||||
|
|
||||||
#include "VideoCommon/VideoBackendBase.h"
|
#include "VideoCommon/VideoBackendBase.h"
|
||||||
|
|
||||||
static std::unique_ptr<Platform> s_platform;
|
static std::unique_ptr<Platform> s_platform;
|
||||||
|
|
||||||
static void signal_handler(int)
|
static void signal_handler(int)
|
||||||
{
|
{
|
||||||
const char message[] = "A signal was received. A second signal will force Dolphin to stop.\n";
|
constexpr char message[] = "A signal was received. A second signal will force Dolphin to stop.\n";
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
puts(message);
|
puts(message);
|
||||||
#else
|
#else
|
||||||
|
@ -75,7 +71,7 @@ bool Host_UIBlocksControllerState()
|
||||||
}
|
}
|
||||||
|
|
||||||
static Common::Event s_update_main_frame_event;
|
static Common::Event s_update_main_frame_event;
|
||||||
void Host_Message(HostMessageID id)
|
void Host_Message(const HostMessageID id)
|
||||||
{
|
{
|
||||||
if (id == HostMessageID::WMUserStop)
|
if (id == HostMessageID::WMUserStop)
|
||||||
s_platform->Stop();
|
s_platform->Stop();
|
||||||
|
@ -201,11 +197,12 @@ static std::unique_ptr<Platform> GetPlatform(const optparse::Values& options)
|
||||||
#define main app_main
|
#define main app_main
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(const int argc, char* argv[])
|
||||||
{
|
{
|
||||||
Core::DeclareAsHostThread();
|
Core::DeclareAsHostThread();
|
||||||
|
|
||||||
auto parser = CommandLineParse::CreateParser(CommandLineParse::ParserOptions::OmitGUIOptions);
|
const auto parser =
|
||||||
|
CommandLineParse::CreateParser(CommandLineParse::ParserOptions::OmitGUIOptions);
|
||||||
parser->add_option("-p", "--platform")
|
parser->add_option("-p", "--platform")
|
||||||
.action("store")
|
.action("store")
|
||||||
.help("Window platform to use [%choices]")
|
.help("Window platform to use [%choices]")
|
||||||
|
@ -302,14 +299,14 @@ int main(int argc, char* argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::AddOnStateChangedCallback([](Core::State state) {
|
Core::AddOnStateChangedCallback([](const Core::State state) {
|
||||||
if (state == Core::State::Uninitialized)
|
if (state == Core::State::Uninitialized)
|
||||||
s_platform->Stop();
|
s_platform->Stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
signal(SIGINT, signal_handler);
|
std::signal(SIGINT, signal_handler);
|
||||||
signal(SIGTERM, signal_handler);
|
std::signal(SIGTERM, signal_handler);
|
||||||
#else
|
#else
|
||||||
// Shut down cleanly on SIGINT and SIGTERM
|
// Shut down cleanly on SIGINT and SIGTERM
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include "Core/HW/ProcessorInterface.h"
|
#include "Core/HW/ProcessorInterface.h"
|
||||||
#include "Core/IOS/IOS.h"
|
#include "Core/IOS/IOS.h"
|
||||||
#include "Core/IOS/STM/STM.h"
|
#include "Core/IOS/STM/STM.h"
|
||||||
#include "Core/State.h"
|
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
|
|
||||||
Platform::~Platform() = default;
|
Platform::~Platform() = default;
|
||||||
|
@ -24,7 +23,7 @@ void Platform::UpdateRunningFlag()
|
||||||
{
|
{
|
||||||
if (m_shutdown_requested.TestAndClear())
|
if (m_shutdown_requested.TestAndClear())
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
const auto& system = Core::System::GetInstance();
|
||||||
const auto ios = system.GetIOS();
|
const auto ios = system.GetIOS();
|
||||||
const auto stm = ios ? ios->GetDeviceByName("/dev/stm/eventhook") : nullptr;
|
const auto stm = ios ? ios->GetDeviceByName("/dev/stm/eventhook") : nullptr;
|
||||||
if (!m_tried_graceful_shutdown.IsSet() && stm &&
|
if (!m_tried_graceful_shutdown.IsSet() && stm &&
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
class PlatformHeadless : public Platform
|
class PlatformHeadless final : public Platform
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void SetTitle(const std::string& title) override;
|
void SetTitle(const std::string& title) override;
|
||||||
|
|
|
@ -3,16 +3,13 @@
|
||||||
|
|
||||||
#include "DolphinNoGUI/Platform.h"
|
#include "DolphinNoGUI/Platform.h"
|
||||||
|
|
||||||
#include "Common/MsgHandler.h"
|
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/State.h"
|
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstdio>
|
|
||||||
#include <dwmapi.h>
|
#include <dwmapi.h>
|
||||||
|
|
||||||
#include "VideoCommon/Present.h"
|
#include "VideoCommon/Present.h"
|
||||||
|
@ -20,7 +17,7 @@
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
class PlatformWin32 : public Platform
|
class PlatformWin32 final : public Platform
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~PlatformWin32() override;
|
~PlatformWin32() override;
|
||||||
|
@ -29,17 +26,17 @@ public:
|
||||||
void SetTitle(const std::string& string) override;
|
void SetTitle(const std::string& string) override;
|
||||||
void MainLoop() override;
|
void MainLoop() override;
|
||||||
|
|
||||||
WindowSystemInfo GetWindowSystemInfo() const;
|
WindowSystemInfo GetWindowSystemInfo() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr TCHAR WINDOW_CLASS_NAME[] = _T("DolphinNoGUI");
|
static constexpr TCHAR WINDOW_CLASS_NAME[] = _T("DolphinNoGUI");
|
||||||
|
|
||||||
static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
bool RegisterRenderWindowClass();
|
static bool RegisterRenderWindowClass();
|
||||||
bool CreateRenderWindow();
|
bool CreateRenderWindow();
|
||||||
void UpdateWindowPosition();
|
void UpdateWindowPosition();
|
||||||
void ProcessEvents();
|
void ProcessEvents() const;
|
||||||
|
|
||||||
HWND m_hwnd{};
|
HWND m_hwnd{};
|
||||||
|
|
||||||
|
@ -66,7 +63,7 @@ bool PlatformWin32::RegisterRenderWindowClass()
|
||||||
wc.hInstance = GetModuleHandle(nullptr);
|
wc.hInstance = GetModuleHandle(nullptr);
|
||||||
wc.hIcon = LoadIcon(nullptr, IDI_ICON1);
|
wc.hIcon = LoadIcon(nullptr, IDI_ICON1);
|
||||||
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
|
||||||
wc.lpszMenuName = nullptr;
|
wc.lpszMenuName = nullptr;
|
||||||
wc.lpszClassName = WINDOW_CLASS_NAME;
|
wc.lpszClassName = WINDOW_CLASS_NAME;
|
||||||
wc.hIconSm = LoadIcon(nullptr, IDI_ICON1);
|
wc.hIconSm = LoadIcon(nullptr, IDI_ICON1);
|
||||||
|
@ -158,7 +155,7 @@ void PlatformWin32::UpdateWindowPosition()
|
||||||
m_window_height = rc.bottom - rc.top;
|
m_window_height = rc.bottom - rc.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformWin32::ProcessEvents()
|
void PlatformWin32::ProcessEvents() const
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
while (PeekMessage(&msg, m_hwnd, 0, 0, PM_REMOVE))
|
while (PeekMessage(&msg, m_hwnd, 0, 0, PM_REMOVE))
|
||||||
|
@ -168,7 +165,8 @@ void PlatformWin32::ProcessEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT PlatformWin32::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT PlatformWin32::WndProc(const HWND hwnd, const UINT msg, const WPARAM wParam,
|
||||||
|
const LPARAM lParam)
|
||||||
{
|
{
|
||||||
PlatformWin32* platform = reinterpret_cast<PlatformWin32*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
|
PlatformWin32* platform = reinterpret_cast<PlatformWin32*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
|
||||||
switch (msg)
|
switch (msg)
|
||||||
|
@ -185,7 +183,7 @@ LRESULT PlatformWin32::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
|
||||||
if (hwnd)
|
if (hwnd)
|
||||||
{
|
{
|
||||||
// Remove rounded corners from the render window on Windows 11
|
// Remove rounded corners from the render window on Windows 11
|
||||||
const DWM_WINDOW_CORNER_PREFERENCE corner_preference = DWMWCP_DONOTROUND;
|
constexpr DWM_WINDOW_CORNER_PREFERENCE corner_preference = DWMWCP_DONOTROUND;
|
||||||
DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &corner_preference,
|
DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &corner_preference,
|
||||||
sizeof(corner_preference));
|
sizeof(corner_preference));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue