Skip to content

Commit

Permalink
Merge branch 'master' into Font-alloc/free
Browse files Browse the repository at this point in the history
  • Loading branch information
shenweip committed Mar 16, 2020
2 parents ac56a8e + 9aefc01 commit c7db6b6
Show file tree
Hide file tree
Showing 67 changed files with 1,596 additions and 975 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -272,6 +272,7 @@ if(NOT MSVC)
# Disable some warnings
add_definitions(-Wno-multichar)
add_definitions(-Wno-deprecated-register)
add_definitions(-Wno-tautological-pointer-compare)

# Don't compile with strict aliasing, we're not 100% aliasing-safe
add_compile_options(-fno-strict-aliasing)
Expand Down
21 changes: 21 additions & 0 deletions Common/GL/GLInterface/EGLSwitch.cpp
@@ -0,0 +1,21 @@
// Copyright 2014 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "ppsspp_config.h"
#if PPSSPP_PLATFORM(SWITCH)
#include <switch.h>
#include "Common/Log.h"
#include "Common/GL/GLInterface/EGLSwitch.h"

EGLDisplay cInterfaceEGLSwitch::OpenDisplay() {
return eglGetDisplay(EGL_DEFAULT_DISPLAY);
}

EGLNativeWindowType cInterfaceEGLSwitch::InitializePlatform(EGLNativeWindowType host_window, EGLConfig config) {
return nwindowGetDefault();
}

void cInterfaceEGLSwitch::ShutdownPlatform() {
}
#endif
24 changes: 24 additions & 0 deletions Common/GL/GLInterface/EGLSwitch.h
@@ -0,0 +1,24 @@
// Copyright 2014 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include "Common/GL/GLInterface/EGL.h"

class cInterfaceEGLSwitch : public cInterfaceEGL {
public:
cInterfaceEGLSwitch() {}
protected:
EGLDisplay OpenDisplay() override;
EGLNativeWindowType InitializePlatform(EGLNativeWindowType host_window, EGLConfig config) override;
void ShutdownPlatform() override;
void OverrideBackbufferDimensions(int internalWidth, int internalHeight) override {
internalWidth_ = internalWidth;
internalHeight_ = internalHeight;
}

private:
int internalWidth_ = 0;
int internalHeight_ = 0;
};
5 changes: 5 additions & 0 deletions Common/GL/GLInterface/GLInterface.cpp
Expand Up @@ -2,10 +2,13 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "ppsspp_config.h"
#include "Common/GL/GLInterfaceBase.h"

#ifdef __ANDROID__
#include "Common/GL/GLInterface/EGLAndroid.h"
#elif PPSSPP_PLATFORM(SWITCH)
#include "Common/GL/GLInterface/EGLSwitch.h"
#elif defined(__APPLE__)
#include "Common/GL/GLInterface/AGL.h"
#elif defined(_WIN32)
Expand All @@ -23,6 +26,8 @@
cInterfaceBase* HostGL_CreateGLInterface(){
#ifdef __ANDROID__
return new cInterfaceEGLAndroid;
#elif if PPSSPP_PLATFORM(SWITCH)
return new cInterfaceEGLSwitch;
#elif defined(__APPLE__)
return new cInterfaceAGL;
#elif defined(_WIN32)
Expand Down
1 change: 1 addition & 0 deletions Common/Vulkan/VulkanLoader.cpp
Expand Up @@ -236,6 +236,7 @@ bool g_vulkanMayBeAvailable = false;

static const char *device_name_blacklist[] = {
"NVIDIA:SHIELD Tablet K1",
"SDL:Horizon",
};

static const char *so_names[] = {
Expand Down
3 changes: 2 additions & 1 deletion Core/Config.cpp
Expand Up @@ -776,6 +776,7 @@ static ConfigSetting graphicsSettings[] = {
ConfigSetting("LogFrameDrops", &g_Config.bLogFrameDrops, false, true, false),

ConfigSetting("InflightFrames", &g_Config.iInflightFrames, 3, true, false),
ConfigSetting("RenderDuplicateFrames", &g_Config.bRenderDuplicateFrames, false, true, true),

ConfigSetting(false),
};
Expand Down Expand Up @@ -968,7 +969,7 @@ static ConfigSetting systemParamSettings[] = {
ReportedConfigSetting("ButtonPreference", &g_Config.iButtonPreference, PSP_SYSTEMPARAM_BUTTON_CROSS, true, true),
ConfigSetting("LockParentalLevel", &g_Config.iLockParentalLevel, 0, true, true),
ConfigSetting("WlanAdhocChannel", &g_Config.iWlanAdhocChannel, PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC, true, true),
#if defined(USING_WIN_UI)
#if defined(USING_WIN_UI) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID)
ConfigSetting("BypassOSKWithKeyboard", &g_Config.bBypassOSKWithKeyboard, false, true, true),
#endif
ConfigSetting("WlanPowerSave", &g_Config.bWlanPowerSave, (bool) PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF, true, true),
Expand Down
2 changes: 1 addition & 1 deletion Core/Config.h
Expand Up @@ -207,6 +207,7 @@ struct Config {
bool bGfxDebugOutput;
bool bGfxDebugSplitSubmit;
int iInflightFrames;
bool bRenderDuplicateFrames;

// Sound
bool bEnableSound;
Expand Down Expand Up @@ -410,7 +411,6 @@ struct Config {

int iPSPModel;
int iFirmwareVersion;
// TODO: Make this work with your platform, too!
bool bBypassOSKWithKeyboard;

// Debugger
Expand Down
38 changes: 24 additions & 14 deletions Core/Dialog/PSPNetconfDialog.cpp
Expand Up @@ -28,9 +28,14 @@
#define NETCONF_CONNECT_APNET 0
#define NETCONF_STATUS_APNET 1
#define NETCONF_CONNECT_ADHOC 2
#define NETCONF_CONNECT_APNET_LAST 3
#define NETCONF_CREATE_ADHOC 4
#define NETCONF_JOIN_ADHOC 5

// Needs testing.
const static int NET_INIT_DELAY_US = 300000;
const static int NET_SHUTDOWN_DELAY_US = 26000;

PSPNetconfDialog::PSPNetconfDialog() {
}

Expand All @@ -39,15 +44,15 @@ PSPNetconfDialog::~PSPNetconfDialog() {

int PSPNetconfDialog::Init(u32 paramAddr) {
// Already running
if (status != SCE_UTILITY_STATUS_NONE && status != SCE_UTILITY_STATUS_SHUTDOWN)
if (status != SCE_UTILITY_STATUS_NONE)
return SCE_ERROR_UTILITY_INVALID_STATUS;

int size = Memory::Read_U32(paramAddr);
memset(&request, 0, sizeof(request));
// Only copy the right size to support different request format
Memory::Memcpy(&request, paramAddr, size);

status = SCE_UTILITY_STATUS_INITIALIZE;
ChangeStatusInit(NET_INIT_DELAY_US);

// Eat any keys pressed before the dialog inited.
UpdateButtons();
Expand All @@ -67,16 +72,18 @@ void PSPNetconfDialog::DrawBanner() {
}

int PSPNetconfDialog::Update(int animSpeed) {
if (GetStatus() != SCE_UTILITY_STATUS_RUNNING) {
return SCE_ERROR_UTILITY_INVALID_STATUS;
}

UpdateButtons();
auto di = GetI18NCategory("Dialog");
auto err = GetI18NCategory("Error");
const float WRAP_WIDTH = 254.0f;
const ImageID confirmBtnImage = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? ImageID("I_CROSS") : ImageID("I_CIRCLE");
const int confirmBtn = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE;

if (status == SCE_UTILITY_STATUS_INITIALIZE) {
status = SCE_UTILITY_STATUS_RUNNING;
} else if (status == SCE_UTILITY_STATUS_RUNNING && (request.netAction == NETCONF_CONNECT_APNET || request.netAction == NETCONF_STATUS_APNET)) {
if (request.netAction == NETCONF_CONNECT_APNET || request.netAction == NETCONF_STATUS_APNET || request.netAction == NETCONF_CONNECT_APNET_LAST) {
UpdateFade(animSpeed);
StartDraw();
DrawBanner();
Expand All @@ -87,34 +94,37 @@ int PSPNetconfDialog::Update(int animSpeed) {

if (IsButtonPressed(confirmBtn)) {
StartFade(false);
status = SCE_UTILITY_STATUS_FINISHED;
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
// TODO: When the dialog is aborted, does it really set the result to this?
// It seems to make Phantasy Star Portable 2 happy, so it should be okay for now.
request.common.result = SCE_UTILITY_DIALOG_RESULT_ABORT;
}

} else if (status == SCE_UTILITY_STATUS_RUNNING && (request.netAction == NETCONF_CONNECT_ADHOC || request.netAction == NETCONF_CREATE_ADHOC || request.netAction == NETCONF_JOIN_ADHOC)) {
if (request.NetconfData != NULL) {

EndDraw();
} else if (request.netAction == NETCONF_CONNECT_ADHOC || request.netAction == NETCONF_CREATE_ADHOC || request.netAction == NETCONF_JOIN_ADHOC) {
if (request.NetconfData.IsValid()) {
Shutdown(true);
if (sceNetAdhocctlCreate(request.NetconfData->groupName) == 0) {
status = SCE_UTILITY_STATUS_FINISHED;
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
return 0;
}
return -1;
}
} else if (status == SCE_UTILITY_STATUS_FINISHED) {
status = SCE_UTILITY_STATUS_SHUTDOWN;
}

EndDraw();
return 0;
}

int PSPNetconfDialog::Shutdown(bool force) {
if (status != SCE_UTILITY_STATUS_FINISHED && !force)
return SCE_ERROR_UTILITY_INVALID_STATUS;

return PSPDialog::Shutdown(force);
PSPDialog::Shutdown(force);
if (!force) {
ChangeStatusShutdown(NET_SHUTDOWN_DELAY_US);
}

return 0;
}

void PSPNetconfDialog::DoState(PointerWrap &p) {
Expand Down
5 changes: 5 additions & 0 deletions Core/Dialog/PSPNetconfDialog.h
Expand Up @@ -44,6 +44,11 @@ class PSPNetconfDialog: public PSPDialog {
virtual int Shutdown(bool force = false) override;
virtual void DoState(PointerWrap &p) override;

protected:
bool UseAutoStatus() override {
return false;
}

private:
void DrawBanner();
SceUtilityNetconfParam request;
Expand Down
73 changes: 47 additions & 26 deletions Core/Dialog/PSPOskDialog.cpp
Expand Up @@ -16,6 +16,7 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.

#include <algorithm>
#include "base/NativeApp.h"
#include "i18n/i18n.h"
#include "math/math_util.h"
#include "util/text/utf8.h"
Expand All @@ -30,10 +31,6 @@
#include "Common/ChunkFile.h"
#include "GPU/GPUState.h"

#if defined(USING_WIN_UI)
#include "base/NativeApp.h"
#endif

#ifndef _WIN32
#include <ctype.h>
#include <math.h>
Expand Down Expand Up @@ -332,6 +329,9 @@ int PSPOskDialog::Init(u32 oskPtr) {
// Eat any keys pressed before the dialog inited.
UpdateButtons();

std::lock_guard<std::mutex> guard(nativeMutex_);
nativeStatus_ = PSPOskNativeStatus::IDLE;

StartFade(true);
return 0;
}
Expand Down Expand Up @@ -837,36 +837,58 @@ void PSPOskDialog::RenderKeyboard()
}
}

#if defined(USING_WIN_UI)
// TODO: Why does this have a 2 button press lag/delay when
// re-opening the dialog box? I don't get it.
int PSPOskDialog::NativeKeyboard() {
if (GetStatus() != SCE_UTILITY_STATUS_RUNNING) {
return SCE_ERROR_UTILITY_INVALID_STATUS;
}

std::wstring titleText;
GetWideStringFromPSPPointer(titleText, oskParams->fields[0].desc);
#if defined(USING_WIN_UI) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID)
bool beginInputBox = false;
if (nativeStatus_ == PSPOskNativeStatus::IDLE) {
std::lock_guard<std::mutex> guard(nativeMutex_);
if (nativeStatus_ == PSPOskNativeStatus::IDLE) {
nativeStatus_ = PSPOskNativeStatus::WAITING;
beginInputBox = true;
}
}

if (beginInputBox) {
std::wstring titleText;
GetWideStringFromPSPPointer(titleText, oskParams->fields[0].desc);

std::wstring defaultText;
GetWideStringFromPSPPointer(defaultText, oskParams->fields[0].intext);
std::wstring defaultText;
GetWideStringFromPSPPointer(defaultText, oskParams->fields[0].intext);

if (defaultText.empty())
defaultText.assign(L"VALUE");
if (defaultText.empty())
defaultText.assign(L"VALUE");

// TODO: This is USING_WIN_UI only, so we rely on it being synchronous...
// But we should really have this set some state that is checked each time NativeKeyboard is called.
System_InputBoxGetString(ConvertWStringToUTF8(titleText), ConvertWStringToUTF8(defaultText), [&](bool result, const std::string &value) {
if (result) {
inputChars = ConvertUTF8ToWString(value);
u32 maxLength = FieldMaxLength();
if (inputChars.length() > maxLength) {
ERROR_LOG(SCEUTILITY, "NativeKeyboard: input text too long(%d characters/glyphs max), truncating to game-requested length.", maxLength);
inputChars.erase(maxLength, std::string::npos);
System_InputBoxGetString(ConvertWStringToUTF8(titleText), ConvertWStringToUTF8(defaultText), [&](bool result, const std::string &value) {
std::lock_guard<std::mutex> guard(nativeMutex_);
if (nativeStatus_ != PSPOskNativeStatus::WAITING) {
return;
}

nativeValue_ = value;
nativeStatus_ = result ? PSPOskNativeStatus::SUCCESS : PSPOskNativeStatus::FAILURE;
});
} else if (nativeStatus_ == PSPOskNativeStatus::SUCCESS) {
inputChars = ConvertUTF8ToWString(nativeValue_);
nativeValue_.clear();

u32 maxLength = FieldMaxLength();
if (inputChars.length() > maxLength) {
ERROR_LOG(SCEUTILITY, "NativeKeyboard: input text too long(%d characters/glyphs max), truncating to game-requested length.", maxLength);
inputChars.erase(maxLength, std::string::npos);
}
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
});
nativeStatus_ = PSPOskNativeStatus::DONE;
} else if (nativeStatus_ == PSPOskNativeStatus::FAILURE) {
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
nativeStatus_ = PSPOskNativeStatus::DONE;
}
#endif

u16_le *outText = oskParams->fields[0].outtext;

Expand All @@ -886,7 +908,6 @@ int PSPOskDialog::NativeKeyboard() {

return 0;
}
#endif

int PSPOskDialog::Update(int animSpeed) {
if (GetStatus() != SCE_UTILITY_STATUS_RUNNING) {
Expand All @@ -908,12 +929,10 @@ int PSPOskDialog::Update(int animSpeed) {
int selectedRow = selectedChar / numKeyCols[currentKeyboard];
int selectedExtra = selectedChar % numKeyCols[currentKeyboard];

// TODO: Add your platforms here when you have a NativeKeyboard func.

#if defined(USING_WIN_UI)
#if defined(USING_WIN_UI) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID)
// Windows: Fall back to the OSK/continue normally if we're in fullscreen.
// The dialog box doesn't work right if in fullscreen.
if(g_Config.bBypassOSKWithKeyboard && !g_Config.bFullScreen)
if (g_Config.bBypassOSKWithKeyboard && !g_Config.bFullScreen)
return NativeKeyboard();
#endif

Expand Down Expand Up @@ -1095,6 +1114,7 @@ int PSPOskDialog::Shutdown(bool force)
if (!force) {
ChangeStatusShutdown(OSK_SHUTDOWN_DELAY_US);
}
nativeStatus_ = PSPOskNativeStatus::IDLE;

return 0;
}
Expand All @@ -1113,6 +1133,7 @@ void PSPOskDialog::DoState(PointerWrap &p)
p.Do(oskOuttext);
p.Do(selectedChar);
p.Do(inputChars);
// Don't need to save state native status or value.
}

pspUtilityDialogCommon *PSPOskDialog::GetCommonParam()
Expand Down

0 comments on commit c7db6b6

Please sign in to comment.