Skip to content

Commit

Permalink
Merge pull request #18634 from hrydgard/misc-fixes
Browse files Browse the repository at this point in the history
Misc fixes and cleanups (touch control opacity, etc)
  • Loading branch information
hrydgard committed Dec 29, 2023
2 parents 5b0e821 + 6318137 commit 01d7361
Show file tree
Hide file tree
Showing 41 changed files with 207 additions and 191 deletions.
2 changes: 1 addition & 1 deletion Common/ArmEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ void ARMXEmitter::MOVI2R(ARMReg reg, u32 val, bool optimize)
}
}

static const char *armRegStrings[] = {
static const char *const armRegStrings[] = {
"r0","r1","r2","r3",
"r4","r5","r6","r7",
"r8","r9","r10","r11",
Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/OpenGL/GLFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ void ResetGLExtensions() {
g_all_egl_extensions.clear();
}

static const char *glsl_fragment_prelude =
static const char * const glsl_fragment_prelude =
"#ifdef GL_ES\n"
"precision mediump float;\n"
"#endif\n";
Expand Down
8 changes: 4 additions & 4 deletions Common/GPU/ShaderTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct Builtin {
const char *replacement;
};

static const char *cbufferDecl = R"(
static const char * const cbufferDecl = R"(
cbuffer data : register(b0) {
float2 u_texelDelta;
float2 u_pixelDelta;
Expand All @@ -85,13 +85,13 @@ cbuffer data : register(b0) {
};
)";

static const char *vulkanPrologue =
static const char * const vulkanPrologue =
R"(#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
)";

static const char *vulkanUboDecl = R"(
static const char * const vulkanUboDecl = R"(
layout (std140, set = 0, binding = 0) uniform Data {
vec2 u_texelDelta;
vec2 u_pixelDelta;
Expand All @@ -102,7 +102,7 @@ layout (std140, set = 0, binding = 0) uniform Data {
};
)";

static const char *d3d9RegisterDecl = R"(
static const char * const d3d9RegisterDecl = R"(
float4 gl_HalfPixel : register(c0);
float2 u_texelDelta : register(c1);
float2 u_pixelDelta : register(c2);
Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using namespace PPSSPP_VK;

VulkanLogOptions g_LogOptions;

static const char *validationLayers[] = {
static const char * const validationLayers[] = {
"VK_LAYER_KHRONOS_validation",
/*
// For layers included in the Android NDK.
Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanFramebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "Common/GPU/Vulkan/VulkanFramebuffer.h"
#include "Common/GPU/Vulkan/VulkanQueueRunner.h"

static const char *rpTypeDebugNames[] = {
static const char * const rpTypeDebugNames[] = {
"RENDER",
"RENDER_DEPTH",
"MV_RENDER",
Expand Down
4 changes: 2 additions & 2 deletions Common/GPU/Vulkan/VulkanLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ bool g_vulkanMayBeAvailable = false;

#define LOAD_GLOBAL_FUNC_LOCAL(lib, x) (PFN_ ## x)dlsym(lib, #x);

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

#ifndef _WIN32
static const char *so_names[] = {
static const char * const so_names[] = {
#if PPSSPP_PLATFORM(IOS)
"@executable_path/Frameworks/libMoltenVK.dylib",
#elif PPSSPP_PLATFORM(MAC)
Expand Down
2 changes: 1 addition & 1 deletion Common/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ bool GenericLogEnabled(LogLevel level, LogType type) {
LogManager *LogManager::logManager_ = NULL;

// NOTE: Needs to be kept in sync with the LogType enum.
static const char *g_logTypeNames[] = {
static const char * const g_logTypeNames[] = {
"SYSTEM",
"BOOT",
"COMMON",
Expand Down
2 changes: 1 addition & 1 deletion Common/LoongArchCPUDetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ LoongArchCPUInfoParser::LoongArchCPUInfoParser() {
}

int LoongArchCPUInfoParser::ProcessorCount() {
static const char *marker = "core";
static const char * const marker = "core";
std::set<std::string> coreIndex;
for (auto core : cores_) {
for (auto line : core) {
Expand Down
2 changes: 1 addition & 1 deletion Common/Net/HTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ ServerRequest::~ServerRequest() {
}
delete in_;
if (!out_->Empty()) {
WARN_LOG(IO, "Output not empty - connection abort? (%s) (%d bytes)", this->header_.resource, out_->BytesRemaining());
WARN_LOG(IO, "Output not empty - connection abort? (%s) (%d bytes)", this->header_.resource, (int)out_->BytesRemaining());
}
delete out_;
}
Expand Down
30 changes: 27 additions & 3 deletions Common/Net/URL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,35 @@
#include "Common/StringUtils.h"
#include "Common/Net/URL.h"

const char *UrlEncoder::unreservedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~";
const char *UrlEncoder::hexChars = "0123456789ABCDEF";

int MultipartFormDataEncoder::seq = 0;

void UrlEncoder::AppendEscaped(const std::string &value)
{
static const char * const unreservedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~";
static const char * const hexChars = "0123456789ABCDEF";

for (size_t lastEnd = 0; lastEnd < value.length(); )
{
size_t pos = value.find_first_not_of(unreservedChars, lastEnd);
if (pos == value.npos)
{
data += value.substr(lastEnd);
break;
}

if (pos != lastEnd)
data += value.substr(lastEnd, pos - lastEnd);
lastEnd = pos;

// Encode the reserved character.
char c = value[pos];
data += '%';
data += hexChars[(c >> 4) & 15];
data += hexChars[(c >> 0) & 15];
++lastEnd;
}
}

void Url::Split() {
size_t colonSlashSlash = url_.find("://");
if (colonSlashSlash == std::string::npos) {
Expand Down
26 changes: 1 addition & 25 deletions Common/Net/URL.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,34 +86,10 @@ struct UrlEncoder
}

// Percent encoding, aka application/x-www-form-urlencoded.
void AppendEscaped(const std::string &value)
{
for (size_t lastEnd = 0; lastEnd < value.length(); )
{
size_t pos = value.find_first_not_of(unreservedChars, lastEnd);
if (pos == value.npos)
{
data += value.substr(lastEnd);
break;
}

if (pos != lastEnd)
data += value.substr(lastEnd, pos - lastEnd);
lastEnd = pos;

// Encode the reserved character.
char c = value[pos];
data += '%';
data += hexChars[(c >> 4) & 15];
data += hexChars[(c >> 0) & 15];
++lastEnd;
}
}
void AppendEscaped(const std::string &value);

std::string data;
int paramCount;
static const char *unreservedChars;
static const char *hexChars;
};


Expand Down
6 changes: 3 additions & 3 deletions Common/RiscVCPUDetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ RiscVCPUInfoParser::RiscVCPUInfoParser() {

int RiscVCPUInfoParser::ProcessorCount() {
// Not using present as that counts the logical CPUs (aka harts.)
static const char *marker = "processor\t: ";
static const char * const marker = "processor\t: ";
std::set<std::string> processors;
for (auto core : cores_) {
for (auto line : core) {
Expand All @@ -107,7 +107,7 @@ int RiscVCPUInfoParser::TotalLogicalCount() {
return high - low + 1;
}

static const char *marker = "hart\t\t: ";
static const char * const marker = "hart\t\t: ";
std::set<std::string> harts;
for (auto core : cores_) {
for (auto line : core) {
Expand All @@ -120,7 +120,7 @@ int RiscVCPUInfoParser::TotalLogicalCount() {
}

std::string RiscVCPUInfoParser::ISAString() {
static const char *marker = "isa\t\t: ";
static const char * const marker = "isa\t\t: ";
for (auto core : cores_) {
for (auto line : core) {
if (line.find(marker) != line.npos)
Expand Down
21 changes: 0 additions & 21 deletions Common/UI/PopupScreens.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,6 @@ class PopupContextMenuScreen : public PopupScreen {
std::vector<bool> enabled_;
};

class AbstractChoiceWithValueDisplay : public UI::Choice {
public:
AbstractChoiceWithValueDisplay(const std::string &text, LayoutParams *layoutParams = nullptr)
: Choice(text, layoutParams) {
}

void Draw(UIContext &dc) override;
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;

void SetPasswordDisplay() {
passwordDisplay_ = true;
}

protected:
virtual std::string ValueText() const = 0;

float CalculateValueScale(const UIContext &dc, const std::string &valueText, float availWidth) const;

bool passwordDisplay_ = false;
};

// Reads and writes value to determine the current selection.
class PopupMultiChoice : public AbstractChoiceWithValueDisplay {
public:
Expand Down
32 changes: 32 additions & 0 deletions Common/UI/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,38 @@ class InfoItem : public Item {
bool choiceStyle_ = false;
};

class AbstractChoiceWithValueDisplay : public Choice {
public:
AbstractChoiceWithValueDisplay(const std::string &text, LayoutParams *layoutParams = nullptr)
: Choice(text, layoutParams) {
}

void Draw(UIContext &dc) override;
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;

void SetPasswordDisplay() {
passwordDisplay_ = true;
}

protected:
virtual std::string ValueText() const = 0;

float CalculateValueScale(const UIContext &dc, const std::string &valueText, float availWidth) const;

bool passwordDisplay_ = false;
};

class ChoiceWithCallbackValueDisplay : public AbstractChoiceWithValueDisplay {
public:
ChoiceWithCallbackValueDisplay(const std::string &text, std::function<std::string()> valueFunc, LayoutParams *layoutParams = nullptr)
: AbstractChoiceWithValueDisplay(text, layoutParams), valueFunc_(valueFunc) {}
protected:
std::string ValueText() const override {
return valueFunc_();
}
std::function<std::string()> valueFunc_;
};

class ItemHeader : public Item {
public:
ItemHeader(const std::string &text, LayoutParams *layoutParams = 0);
Expand Down
4 changes: 2 additions & 2 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ struct ConfigPrivate {
};

#ifdef _DEBUG
static const char *logSectionName = "LogDebug";
static const char * const logSectionName = "LogDebug";
#else
static const char *logSectionName = "Log";
static const char * const logSectionName = "Log";
#endif

std::string GPUBackendToString(GPUBackend backend) {
Expand Down
2 changes: 1 addition & 1 deletion Core/Dialog/SavedataParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ int SavedataParam::BuildHash(unsigned char *output,
std::string SavedataParam::GetSpaceText(u64 size, bool roundUp)
{
char text[50];
static const char *suffixes[] = {"B", "KB", "MB", "GB"};
static const char * const suffixes[] = {"B", "KB", "MB", "GB"};
for (size_t i = 0; i < ARRAY_SIZE(suffixes); ++i)
{
if (size < 1024)
Expand Down
2 changes: 1 addition & 1 deletion Core/FileLoaders/DiskCachingFileLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define fseeko fseek
#endif

static const char *CACHEFILE_MAGIC = "ppssppDC";
static const char * const CACHEFILE_MAGIC = "ppssppDC";
static const s64 SAFETY_FREE_DISK_SPACE = 768 * 1024 * 1024; // 768 MB
// Aim to allow this many files cached at once.
static const u32 CACHE_SPACE_FLEX = 4;
Expand Down
6 changes: 3 additions & 3 deletions Core/FileSystems/DirectoryFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,9 @@ static void tmFromFiletime(tm &dest, const FILETIME &src) {
// Hopefully no PSP games read directories after they create files in them...
static std::string SimulateVFATBug(std::string filename) {
// These are the characters allowed in DOS filenames.
static const char *FAT_UPPER_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&'(){}-_`~";
static const char *FAT_LOWER_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&'(){}-_`~";
static const char *LOWER_CHARS = "abcdefghijklmnopqrstuvwxyz";
static const char * const FAT_UPPER_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&'(){}-_`~";
static const char * const FAT_LOWER_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&'(){}-_`~";
static const char * const LOWER_CHARS = "abcdefghijklmnopqrstuvwxyz";

// To avoid logging/comparing, skip all this if it has no lowercase chars to begin with.
size_t lowerchar = filename.find_first_of(LOWER_CHARS);
Expand Down
6 changes: 3 additions & 3 deletions Core/MIPS/IR/IRInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static std::string GetGPRName(int r) {
}

void DisassembleParam(char *buf, int bufSize, u8 param, char type, u32 constant) {
static const char *vfpuCtrlNames[VFPU_CTRL_MAX] = {
static const char * const vfpuCtrlNames[VFPU_CTRL_MAX] = {
"SPFX",
"TPFX",
"DPFX",
Expand All @@ -252,7 +252,7 @@ void DisassembleParam(char *buf, int bufSize, u8 param, char type, u32 constant)
"RCX6",
"RCX7",
};
static const char *initVec4Names[8] = {
static const char * const initVec4Names[8] = {
"[0 0 0 0]",
"[1 1 1 1]",
"[-1 -1 -1 -1]",
Expand All @@ -261,7 +261,7 @@ void DisassembleParam(char *buf, int bufSize, u8 param, char type, u32 constant)
"[0 0 1 0]",
"[0 0 0 1]",
};
static const char *xyzw = "xyzw";
static const char * const xyzw = "xyzw";

switch (type) {
case 'G':
Expand Down
4 changes: 2 additions & 2 deletions Core/MIPS/MIPSDebugInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ const char *MIPSDebugInterface::GetName()
}

std::string MIPSDebugInterface::GetRegName(int cat, int index) {
static const char *regName[32] = {
static const char * const regName[32] = {
"zero", "at", "v0", "v1",
"a0", "a1", "a2", "a3",
"t0", "t1", "t2", "t3",
Expand All @@ -273,7 +273,7 @@ std::string MIPSDebugInterface::GetRegName(int cat, int index) {
"t8", "t9", "k0", "k1",
"gp", "sp", "fp", "ra"
};
static const char *fpRegName[32] = {
static const char * const fpRegName[32] = {
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
"f16", "f16", "f18", "f19", "f20", "f21", "f22", "f23",
Expand Down
Loading

0 comments on commit 01d7361

Please sign in to comment.