8000 [UWP] Improvements 2 (Configs, Render, Input) by basharast · Pull Request #17952 · hrydgard/ppsspp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[UWP] Improvements 2 (Configs, Render, Input) #17952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions Common/GPU/ShaderTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,10 @@ static EShLanguage GetShLanguageFromStage(const ShaderStage stage) {
}

void ShaderTranslationInit() {
// TODO: We have TLS issues on UWP
#if !PPSSPP_PLATFORM(UWP)
glslang::InitializeProcess();
#endif
}
void ShaderTranslationShutdown() {
#if !PPSSPP_PLATFORM(UWP)
glslang::FinalizeProcess();
#endif
}

struct Builtin {
Expand Down Expand Up @@ -229,11 +224,6 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, const ShaderLan
return result;
}

#if PPSSPP_PLATFORM(UWP)
*errorMessage = "No shader translation available (UWP)";
return false;
#endif

errorMessage->clear();

glslang::TProgram program;
Expand Down
5 changes: 5 additions & 0 deletions Common/UI/UIScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Common/Data/Text/I18n.h"
#include "Common/Render/DrawBuffer.h"
#include "Common/Log.h"
#include <Common/System/Request.h>

static const bool ClickDebug = false;

Expand Down Expand Up @@ -389,6 +390,10 @@ void PopupScreen::TriggerFinish(DialogResult result) {

OnCompleted(result);
}
#if PPSSPP_PLATFORM(UWP)
// Inform UI that popup close to hide OSK (if visible)
System_NotifyUIState("popup_closed");
#endif
}

void PopupScreen::CreateViews() {
Expand Down
11 changes: 11 additions & 0 deletions Common/UI/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,17 @@ TextEdit::TextEdit(const std::string &text, const std::string &title, const std:
caret_ = (int)text_.size();
}

void TextEdit::FocusChanged(int focusFlags) {
#if PPSSPP_PLATFORM(UWP)
if (focusFlags == FF_GOTFOCUS) {
System_NotifyUIState("text_gotfocus");
}
else {
System_NotifyUIState("text_lostfocus");
}
#endif
}

void TextEdit::Draw(UIContext &dc) {
dc.PushScissor(bounds_);
dc.SetFontStyle(dc.theme->uiFont);
Expand Down
1 change: 1 addition & 0 deletions Common/UI/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ class TextEdit : public View {
void SetMaxLen(size_t maxLen) { maxLen_ = maxLen; }
void SetTextAlign(int align) { align_ = align; } // Only really useful for setting FLAG_DYNAMIC_ASCII

void FocusChanged(int focusFlags) override;
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
void Draw(UIContext &dc) override;
std::string DescribeText() const override;
Expand Down
11 changes: 10 additions & 1 deletion UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
#endif
#if PPSSPP_PLATFORM(UWP)
#include <dwrite_3.h>
#include "UWP/UWPHelpers/InputHelpers.h"
#endif
#if PPSSPP_PLATFORM(ANDROID)
#include "android/jni/app-android.h"
Expand Down Expand Up @@ -305,7 +306,7 @@ void PostLoadConfig() {
else
g_i18nrepo.LoadIni(g_Config.sLanguageIni, langOverridePath);

#if !PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP)
#if !PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(UWP)
CreateSysDirectories();
#endif
}
Expand Down Expand Up @@ -1268,6 +1269,14 @@ bool NativeKey(const KeyInput &key) {
return false;
}

#if PPSSPP_PLATFORM(UWP)
// Ignore if key sent from OnKeyDown/OnKeyUp/XInput while text edit active
// it's already handled by `OnCharacterReceived`
if (IgnoreInput(key.keyCode) && !(key.flags & KEY_CHAR)) {
return false;
}
#endif

// INFO_LOG(SYSTEM, "Key code: %i flags: %i", key.keyCode, key.flags);
#if !defined(MOBILE_DEVICE)
if (g_Config.bPauseExitsEmulator) {
Expand Down
77 changes: 68 additions & 9 deletions UWP/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
#include "pch.h"
#include "App.h"

#include <ppltasks.h>
#include <mutex>

#include "Common/Net/HTTPClient.h"
#include "Common/Net/Resolve.h"

#include "Common/File/VFS/VFS.h"
#include "Common/File/VFS/DirectoryReader.h"
#include "Common/Data/Encoding/Utf8.h"
#include "Common/Input/InputState.h"
#include "Common/System/NativeApp.h"
#include "Common/System/System.h"
#include "Common/LogManager.h"
#include "Core/System.h"
#include "Core/Config.h"
#include "Core/Core.h"

#include <ppltasks.h>

#include "UWPHelpers/LaunchItem.h"
#include <UWPUtil.h>

using namespace UWP;

Expand All @@ -27,7 +33,6 @@ using namespace Windows::UI::Input;
using namespace Windows::System;
using namespace Windows::Foundation;
using namespace Windows::Graphics::Display;
using namespace Windows::Storage;

// The main function is only used to initialize our IFrameworkView class.
[Platform::MTAThread]
Expand All @@ -47,6 +52,59 @@ App::App() :
{
}

void App::InitialPPSSPP() {
// Initial net
net::Init();

// Get install location
auto packageDirectory = Package::Current->InstalledPath;
const Path& exePath = Path(FromPlatformString(packageDirectory));
g_VFS.Register("", new DirectoryReader(exePath / "Content"));
g_VFS.Register("", new DirectoryReader(exePath));

// Mount a filesystem
g_Config.flash0Directory = exePath / "assets/flash0";

// Prepare for initialization
std::wstring internalDataFolderW = ApplicationData::Current->LocalFolder->Path->Data();
g_Config.internalDataDirectory = Path(internalDataFolderW);
g_Config.memStickDirectory = g_Config.internalDataDirectory;

// On Win32 it makes more sense to initialize the system directories here
// because the next place it was called was in the EmuThread, and it's too late by then.
CreateSysDirectories();

LogManager::Init(&g_Config.bEnableLogging);

// Set the config path to local state by default
// it will be overrided by `NativeInit` if there is custom memStick
g_Config.SetSearchPath(GetSysDirectory(DIRECTORY_SYSTEM));
g_Config.Load();

if (g_Config.bFirstRun) {
// Clear `memStickDirectory` to show memory stick screen on first start
g_Config.memStickDirectory.clear();
}

// Since we don't have any async operation in `NativeInit`
// it's better to call it here
const char* argv[2] = { "fake", nullptr };
std::string cacheFolder = ConvertWStringToUTF8(ApplicationData::Current->TemporaryFolder->Path->Data());
// We will not be able to use `argv`
// since launch parameters usually handled by `OnActivated`
// and `OnActivated` will be invoked later, even after `PPSSPP_UWPMain(..)`
// so we are handling launch cases using `LaunchItem`
NativeInit(1, argv, "", "", cacheFolder.c_str());

// Override backend, `DIRECT3D11` is the only way for UWP apps
g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D11;

// Calling `NativeInit` before will help us to deal with custom configs
// such as custom adapter, so it's better to initial render device here
m_deviceResources = std::make_shared<DX::DeviceResources>();
m_deviceResources->CreateWindowSizeDependentResources();
}

// The first method called when the IFrameworkView is being created.
void App::Initialize(CoreApplicationView^ applicationView) {
// Register event handlers for app lifecycle. This example includes Activated, so that we
Expand All @@ -59,10 +117,6 @@ void App::Initialize(CoreApplicationView^ applicationView) {

CoreApplication::Resuming +=
ref new EventHandler<Platform::Object^>(this, &App::OnResuming);

// At this point we have access to the device.
// We can create the device-dependent resources.
m_deviceResources = std::make_shared<DX::DeviceResources>();
}

// Called when the CoreWindow object is created (or re-created).
Expand All @@ -89,6 +143,7 @@ void App::SetWindow(CoreWindow^ window) {

window->KeyDown += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &App::OnKeyDown);
window->KeyUp += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &App::OnKeyUp);
window->CharacterReceived += ref new TypedEventHandler<CoreWindow^, CharacterReceivedEventArgs^>(this, &App::OnCharacterReceived);

window->PointerMoved += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::OnPointerMoved);
window->PointerEntered += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::OnPointerEntered);
Expand All @@ -111,7 +166,7 @@ void App::SetWindow(CoreWindow^ window) {
Windows::UI::Core::BackRequestedEventArgs^>(
this, &App::App_BackRequested);

m_deviceResources->SetWindow(window);
InitialPPSSPP();
}

bool App::HasBackButton() {
Expand All @@ -137,6 +192,10 @@ void App::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyE
m_main->OnKeyUp(args->KeyStatus.ScanCode, args->VirtualKey);
}

void App::OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args) {
m_main->OnCharacterReceived(args->KeyStatus.ScanCode, args->KeyCode);
}

void App::OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) {
int pointerId = touchMap_.TouchId(args->CurrentPoint->PointerId);
if (pointerId < 0)
Expand Down
2 changes: 2 additions & 0 deletions UWP/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ namespace UWP {
// Input
void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args);

void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
void OnPointerEntered(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
Expand All @@ -94,6 +95,7 @@ namespace UWP {
void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);

void App_BackRequested(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ e);
void InitialPPSSPP();

private:
std::shared_ptr<DX::DeviceResources> m_deviceResources;
Expand Down
Loading
0