FullscreenUI: Re-enable most previously-missing settings

This commit is contained in:
Connor McLaughlin
2022-08-26 01:26:55 +10:00
parent cac2714555
commit cab51c6764
24 changed files with 1229 additions and 1244 deletions

View File

@@ -10,6 +10,9 @@
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="win32_nogui_platform.cpp" />
<ClCompile Include="x11_nogui_platform.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="nogui_host.h" />
@@ -25,6 +28,9 @@
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="win32_nogui_platform.h" />
<ClInclude Include="x11_nogui_platform.h">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Manifest Include="duckstation-nogui.manifest" />

View File

@@ -5,6 +5,7 @@
<ClCompile Include="win32_nogui_platform.cpp" />
<ClCompile Include="vty_nogui_platform.cpp" />
<ClCompile Include="wayland_nogui_platform.cpp" />
<ClCompile Include="x11_nogui_platform.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
@@ -14,6 +15,7 @@
<ClInclude Include="vty_key_names.h" />
<ClInclude Include="nogui_platform.h" />
<ClInclude Include="wayland_nogui_platform.h" />
<ClInclude Include="x11_nogui_platform.h" />
</ItemGroup>
<ItemGroup>
<Manifest Include="duckstation-nogui.manifest" />

View File

@@ -509,6 +509,14 @@ void NoGUIHost::ProcessPlatformKeyEvent(s32 key, bool pressed)
});
}
void NoGUIHost::ProcessPlatformTextEvent(const char* text)
{
if (!ImGuiManager::WantsTextInput())
return;
Host::RunOnCPUThread([text = std::string(text)]() { ImGuiManager::AddTextInput(std::move(text)); });
}
void NoGUIHost::PlatformWindowFocusGained()
{
Host::RunOnCPUThread([]() {
@@ -847,6 +855,16 @@ void Host::RequestResizeHostDisplay(s32 width, s32 height)
g_nogui_window->RequestRenderWindowSize(width, height);
}
void Host::OpenURL(const std::string_view& url)
{
g_nogui_window->OpenURL(url);
}
bool Host::CopyTextToClipboard(const std::string_view& text)
{
return g_nogui_window->CopyTextToClipboard(text);
}
void Host::OnPerformanceCountersUpdated()
{
// noop

View File

@@ -27,6 +27,7 @@ void ProcessPlatformMouseMoveEvent(float x, float y);
void ProcessPlatformMouseButtonEvent(s32 button, bool pressed);
void ProcessPlatformMouseWheelEvent(float x, float y);
void ProcessPlatformKeyEvent(s32 key, bool pressed);
void ProcessPlatformTextEvent(const char* text);
void PlatformWindowFocusGained();
void PlatformWindowFocusLost();
bool GetSavedPlatformWindowGeometry(s32* x, s32* y, s32* width, s32* height);

View File

@@ -37,6 +37,9 @@ public:
virtual bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height) = 0;
virtual bool OpenURL(const std::string_view& url) = 0;
virtual bool CopyTextToClipboard(const std::string_view& text) = 0;
#ifdef _WIN32
static std::unique_ptr<NoGUIPlatform> CreateWin32Platform();
#endif

View File

@@ -108,6 +108,19 @@ bool VTYNoGUIPlatform::RequestRenderWindowSize(s32 new_window_width, s32 new_win
return false;
}
bool VTYNoGUIPlatform::OpenURL(const std::string_view& url)
{
Log_ErrorPrintf("VTYNoGUIPlatform::OpenURL() not implemented: %.*s", static_cast<int>(url.size()), url.data());
return false;
}
bool VTYNoGUIPlatform::CopyTextToClipboard(const std::string_view& text)
{
Log_ErrorPrintf("VTYNoGUIPlatform::CopyTextToClipboard() not implemented: %.*s", static_cast<int>(text.size()),
text.data());
return false;
}
void VTYNoGUIPlatform::SetPlatformWindowTitle(std::string title)
{
Log_InfoPrintf("Window Title: %s", title.c_str());

View File

@@ -36,6 +36,9 @@ public:
bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height) override;
bool OpenURL(const std::string_view& url) override;
bool CopyTextToClipboard(const std::string_view& text) override;
private:
void OpenEVDevFDs();
void CloseEVDevFDs();

View File

@@ -455,6 +455,18 @@ bool WaylandNoGUIPlatform::RequestRenderWindowSize(s32 new_window_width, s32 new
return false;
}
bool WaylandNoGUIPlatform::OpenURL(const std::string_view& url)
{
Log_ErrorPrintf("WaylandNoGUIPlatform::OpenURL() not implemented: %.*s", static_cast<int>(url.size()), url.data());
return false;
}
bool WaylandNoGUIPlatform::CopyTextToClipboard(const std::string_view& text)
{
Log_ErrorPrintf("WaylandNoGUIPlatform::CopyTextToClipboard() not implemented: %.*s", static_cast<int>(text.size()), text.data());
return false;
}
std::unique_ptr<NoGUIPlatform> NoGUIPlatform::CreateWaylandPlatform()
{
std::unique_ptr<WaylandNoGUIPlatform> ret = std::unique_ptr<WaylandNoGUIPlatform>(new WaylandNoGUIPlatform());

View File

@@ -41,6 +41,9 @@ public:
bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height) override;
bool OpenURL(const std::string_view& url) override;
bool CopyTextToClipboard(const std::string_view& text) override;
private:
void InitializeKeyMap();

View File

@@ -1,12 +1,15 @@
#include "win32_nogui_platform.h"
#include "common/log.h"
#include "common/scoped_guard.h"
#include "common/string_util.h"
#include "common/threading.h"
#include "core/host.h"
#include "core/host_settings.h"
#include "frontend-common/imgui_manager.h"
#include "nogui_host.h"
#include "resource.h"
#include "win32_key_names.h"
#include <shellapi.h>
#include <tchar.h>
Log_SetChannel(Win32HostInterface);
@@ -255,6 +258,37 @@ bool Win32NoGUIPlatform::RequestRenderWindowSize(s32 new_window_width, s32 new_w
return SetWindowPos(m_hwnd, NULL, rc.left, rc.top, new_window_width, new_window_height, SWP_SHOWWINDOW);
}
bool Win32NoGUIPlatform::OpenURL(const std::string_view& url)
{
return (ShellExecuteW(nullptr, L"open", StringUtil::UTF8StringToWideString(url).c_str(), nullptr, nullptr,
SW_SHOWNORMAL) != NULL);
}
bool Win32NoGUIPlatform::CopyTextToClipboard(const std::string_view& text)
{
const int wlen = MultiByteToWideChar(CP_UTF8, 0, text.data(), static_cast<int>(text.length()), nullptr, 0);
if (wlen < 0)
return false;
if (!OpenClipboard(m_hwnd))
return false;
ScopedGuard clipboard_cleanup([]() { CloseClipboard(); });
EmptyClipboard();
const HANDLE hText = GlobalAlloc(GMEM_MOVEABLE, (wlen + 1) * sizeof(wchar_t));
if (hText == NULL)
return false;
LPWSTR mem = static_cast<LPWSTR>(GlobalLock(hText));
MultiByteToWideChar(CP_UTF8, 0, text.data(), static_cast<int>(text.length()), mem, wlen);
mem[wlen] = 0;
GlobalUnlock(hText);
SetClipboardData(CF_UNICODETEXT, hText);
return true;
}
LRESULT CALLBACK Win32NoGUIPlatform::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
Win32NoGUIPlatform* platform = static_cast<Win32NoGUIPlatform*>(g_nogui_window.get());
@@ -279,6 +313,23 @@ LRESULT CALLBACK Win32NoGUIPlatform::WndProc(HWND hwnd, UINT msg, WPARAM wParam,
}
break;
case WM_CHAR:
{
if (ImGuiManager::WantsTextInput())
{
const WCHAR utf16[2] = {static_cast<wchar_t>(wParam), 0};
char utf8[8] = {};
const int utf8_len =
WideCharToMultiByte(CP_UTF8, 0, utf16, sizeof(utf16), utf8, sizeof(utf8) - 1, nullptr, nullptr);
if (utf8_len > 0)
{
utf8[utf8_len] = 0;
NoGUIHost::ProcessPlatformTextEvent(utf8);
}
}
}
break;
case WM_MOUSEMOVE:
{
const float x = static_cast<float>(static_cast<s16>(LOWORD(lParam)));

View File

@@ -35,6 +35,9 @@ public:
bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height) override;
bool OpenURL(const std::string_view& url) override;
bool CopyTextToClipboard(const std::string_view& text) override;
private:
enum : u32
{

View File

@@ -317,6 +317,19 @@ bool X11NoGUIPlatform::RequestRenderWindowSize(s32 new_window_width, s32 new_win
return false;
}
bool X11NoGUIPlatform::OpenURL(const std::string_view& url)
{
Log_ErrorPrintf("X11NoGUIPlatform::OpenURL() not implemented: %.*s", static_cast<int>(url.size()), url.data());
return false;
}
bool X11NoGUIPlatform::CopyTextToClipboard(const std::string_view& text)
{
Log_ErrorPrintf("X11NoGUIPlatform::CopyTextToClipboard() not implemented: %.*s", static_cast<int>(text.size()),
text.data());
return false;
}
std::unique_ptr<NoGUIPlatform> NoGUIPlatform::CreateX11Platform()
{
std::unique_ptr<X11NoGUIPlatform> ret = std::unique_ptr<X11NoGUIPlatform>(new X11NoGUIPlatform());

View File

@@ -60,6 +60,9 @@ public:
bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height) override;
bool OpenURL(const std::string_view& url) override;
bool CopyTextToClipboard(const std::string_view& text) override;
private:
void InitializeKeyMap();
void SaveWindowGeometry();