1.5.1
This commit is contained in:
@@ -36,12 +36,13 @@ Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW.
|
|||||||
- Auto CPU Boost
|
- Auto CPU Boost
|
||||||
- For faster game loading
|
- For faster game loading
|
||||||
- Enable CPU Boost (1785 MHz) when CPU Core#3 (System Core) is stressed (mainly I/O operations).
|
- Enable CPU Boost (1785 MHz) when CPU Core#3 (System Core) is stressed (mainly I/O operations).
|
||||||
- Effective only when charger is connected.
|
- Effective only when charger is connected or governor is enabled.
|
||||||
|
- This feature is considered unsafe on Erista, especially when combined with high GPU frequency or with governor enabled.
|
||||||
|
|
||||||
- CPU & GPU frequency governor (Experimental)
|
- CPU & GPU frequency governor (Experimental)
|
||||||
- Adjust frequency based on load. Might decrease power draw but can introduce stutters. Can be turned off for specific titles.
|
- Adjust frequency based on load. Might decrease power draw but can introduce stutters. Can be turned off for specific titles.
|
||||||
|
|
||||||
- Set charging current (100 mA - 2000 mA) and charging limit (20% - 100%)
|
- Set charging current (100 mA - 3000 mA) and charging limit (20% - 100%)
|
||||||
- Long-term use of charge limit may render the battery gauge inaccurate. Performing full cycles could help recalibration, or try [battery_desync_fix_nx](https://github.com/CTCaer/battery_desync_fix_nx).
|
- Long-term use of charge limit may render the battery gauge inaccurate. Performing full cycles could help recalibration, or try [battery_desync_fix_nx](https://github.com/CTCaer/battery_desync_fix_nx).
|
||||||
|
|
||||||
- Global Profile
|
- Global Profile
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ TARGET_EXEC := test
|
|||||||
BUILD_DIR := ./build
|
BUILD_DIR := ./build
|
||||||
SRC_DIRS := ./
|
SRC_DIRS := ./
|
||||||
|
|
||||||
|
# CXX := clang++ g++-12
|
||||||
|
|
||||||
# Find all the C and C++ files we want to compile
|
# Find all the C and C++ files we want to compile
|
||||||
# Note the single quotes around the * expressions. Make will incorrectly expand these otherwise.
|
# Note the single quotes around the * expressions. Make will incorrectly expand these otherwise.
|
||||||
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp' -or -name '*.c' -or -name '*.s')
|
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp' -or -name '*.c' -or -name '*.s')
|
||||||
|
|||||||
@@ -18,39 +18,56 @@
|
|||||||
|
|
||||||
namespace ams::ldr::oc {
|
namespace ams::ldr::oc {
|
||||||
|
|
||||||
|
volatile EristaMtcTable EristaMtcTablePlaceholder = { .rev = ERISTA_MTC_MAGIC, };
|
||||||
|
volatile MarikoMtcTable MarikoMtcTablePlaceholder = { .rev = MARIKO_MTC_MAGIC, };
|
||||||
|
|
||||||
volatile CustomizeTable C = {
|
volatile CustomizeTable C = {
|
||||||
/* DRAM Timing:
|
/* DRAM Timing:
|
||||||
* AUTO_ADJ_MARIKO_SAFE_NO_ADJ_ERISTA: Auto adjust timings for Mariko LPDDR4X ≤3733 Mbps specs, 8Gb density; No timing adjustment for Erista. (Default)
|
* AUTO_ADJ_SAFE_MARIKO_ONLY: Auto adjust timings for Mariko LPDDR4X ≤3733 Mbps specs, 8Gb density. (Default)
|
||||||
* AUTO_ADJ_MARIKO_4266_NO_ADJ_ERISTA: Auto adjust timings for Mariko LPDDR4X 4266 Mbps specs, 8Gb density; No timing adjustments for Erista.
|
* AUTO_ADJ_4266_MARIKO_ONLY: Auto adjust timings for Mariko LPDDR4X 4266 Mbps specs, 8Gb density.
|
||||||
* NO_ADJ_ALL: No timing adjustment for both Erista and Mariko. Might achieve better performance on Mariko but lower maximum frequency is expected.
|
* NO_ADJ_ALL: No timing adjustment for both Erista and Mariko.
|
||||||
|
* CUSTOMIZED_ALL: Replace with values in customized table for both Erista and Mariko.
|
||||||
*/
|
*/
|
||||||
.mtcConf = AUTO_ADJ_MARIKO_SAFE_NO_ADJ_ERISTA,
|
.mtcConf = AUTO_ADJ_SAFE_MARIKO_ONLY,
|
||||||
|
|
||||||
/* Mariko CPU:
|
/* Common:
|
||||||
* - Max Clock in kHz:
|
* - Boost Clock in kHz:
|
||||||
* Default: 1785000
|
|
||||||
* 2397000 might be unreachable for some SoCs.
|
|
||||||
*/
|
|
||||||
.marikoCpuMaxClock = 2397000,
|
|
||||||
/* - Boost Clock in kHz:
|
|
||||||
* Default: 1785000
|
* Default: 1785000
|
||||||
* Boost clock will be applied when applications request higher CPU frequency for quicker loading.
|
* Boost clock will be applied when applications request higher CPU frequency for quicker loading.
|
||||||
* This will be set regardless of whether sys-clk is enabled.
|
* This will be set regardless of whether sys-clk is enabled.
|
||||||
*/
|
*/
|
||||||
.marikoCpuBoostClock = 1785000,
|
.commonCpuBoostClock = 1785000,
|
||||||
/* - Max Voltage in mV:
|
/* - EMC Vddq (Erista Only) and RAM Vdd2 Voltage in uV
|
||||||
|
* Range: 1100'000 to 1250'000 uV
|
||||||
|
* Erista Default(HOS): 1125'000 (bootloader: 1100'000)
|
||||||
|
* Mariko Default: 1100'000 (It will not work without sys-clk-OC.)
|
||||||
|
* Value should be divided evenly by 12'500.
|
||||||
|
* Not enabled by default.
|
||||||
|
*/
|
||||||
|
.commonEmcMemVolt = 0,
|
||||||
|
|
||||||
|
/* Erista CPU:
|
||||||
|
* - Max Voltage in mV
|
||||||
|
* - CpuVoltL4T: 1235
|
||||||
|
*/
|
||||||
|
.eristaCpuMaxVolt = 1235,
|
||||||
|
|
||||||
|
/* Erista EMC(RAM):
|
||||||
|
* - RAM Clock in kHz
|
||||||
|
* [WARNING]
|
||||||
|
* RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM:
|
||||||
|
* - Graphical glitches
|
||||||
|
* - System instabilities
|
||||||
|
* - NAND corruption
|
||||||
|
*/
|
||||||
|
.eristaEmcMaxClock = 1862400,
|
||||||
|
|
||||||
|
/* Mariko CPU:
|
||||||
|
* - Max Voltage in mV:
|
||||||
* Default voltage: 1120
|
* Default voltage: 1120
|
||||||
*/
|
*/
|
||||||
.marikoCpuMaxVolt = 1235,
|
.marikoCpuMaxVolt = 1235,
|
||||||
|
|
||||||
/* Mariko GPU:
|
|
||||||
* - Max Clock in kHz:
|
|
||||||
* Default: 921600
|
|
||||||
* NVIDIA Maximum: 1267200
|
|
||||||
* 1305600 might be unreachable for some SoCs.
|
|
||||||
*/
|
|
||||||
.marikoGpuMaxClock = 1305600,
|
|
||||||
|
|
||||||
/* Mariko EMC(RAM):
|
/* Mariko EMC(RAM):
|
||||||
* - RAM Clock in kHz:
|
* - RAM Clock in kHz:
|
||||||
* Values should be ≥ 1600000, and divided evenly by 9600.
|
* Values should be ≥ 1600000, and divided evenly by 9600.
|
||||||
@@ -70,28 +87,107 @@ volatile CustomizeTable C = {
|
|||||||
*/
|
*/
|
||||||
.marikoEmcVddqVolt = 0,
|
.marikoEmcVddqVolt = 0,
|
||||||
|
|
||||||
/* Erista CPU:
|
/* Advanced Settings:
|
||||||
* - Max Voltage in mV
|
* - Erista CPU DVFS Table:
|
||||||
*/
|
*/
|
||||||
.eristaCpuMaxVolt = 1235,
|
.eristaCpuDvfsTable = {
|
||||||
|
{ 204000, { 721094 }, {} },
|
||||||
|
{ 306000, { 754040 }, {} },
|
||||||
|
{ 408000, { 786986 }, {} },
|
||||||
|
{ 510000, { 819932 }, {} },
|
||||||
|
{ 612000, { 852878 }, {} },
|
||||||
|
{ 714000, { 885824 }, {} },
|
||||||
|
{ 816000, { 918770 }, {} },
|
||||||
|
{ 918000, { 951716 }, {} },
|
||||||
|
{ 1020000, { 984662 }, { -2875621, 358099, -8585 } },
|
||||||
|
{ 1122000, { 1017608 }, { -52225, 104159, -2816 } },
|
||||||
|
{ 1224000, { 1050554 }, { 1076868, 8356, -727 } },
|
||||||
|
{ 1326000, { 1083500 }, { 2208191, -84659, 1240 } },
|
||||||
|
{ 1428000, { 1116446 }, { 2519460, -105063, 1611 } },
|
||||||
|
{ 1581000, { 1130000 }, { 2889664, -122173, 1834 } },
|
||||||
|
{ 1683000, { 1168000 }, { 5100873, -279186, 4747 } },
|
||||||
|
{ 1785000, { 1227500 }, { 5100873, -279186, 4747 } },
|
||||||
|
// Appending table
|
||||||
|
{ 1887000, { 1235000 }, { 5100873, -279186, 4747 } },
|
||||||
|
{ 1963500, { 1235000 }, { 5100873, -279186, 4747 } },
|
||||||
|
{ 2091000, { 1235000 }, { 5100873, -279186, 4747 } },
|
||||||
|
},
|
||||||
|
|
||||||
/* Erista EMC(RAM):
|
/* - Mariko CPU DVFS Table:
|
||||||
* - RAM Clock in kHz
|
* 2397000 might not work for some SoCs.
|
||||||
* [WARNING]
|
|
||||||
* RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM:
|
|
||||||
* - Graphical glitches
|
|
||||||
* - System instabilities
|
|
||||||
* - NAND corruption
|
|
||||||
*/
|
*/
|
||||||
.eristaEmcMaxClock = 1862400,
|
.marikoCpuDvfsTable = {
|
||||||
/* - EMC Vddq (Erista Only) and RAM Vdd2 Voltage in uV
|
{ 204000, { 721589, -12695, 27 }, {} },
|
||||||
* Range: 1100'000 to 1250'000 uV
|
{ 306000, { 747134, -14195, 27 }, {} },
|
||||||
* Erista Default(HOS): 1125'000 (bootloader: 1100'000)
|
{ 408000, { 776324, -15705, 27 }, {} },
|
||||||
* Mariko Default: 1100'000 (It will not work without sys-clk-OC.)
|
{ 510000, { 809160, -17205, 27 }, {} },
|
||||||
* Value should be divided evenly by 12'500.
|
{ 612000, { 845641, -18715, 27 }, {} },
|
||||||
* Not enabled by default.
|
{ 714000, { 885768, -20215, 27 }, {} },
|
||||||
|
{ 816000, { 929540, -21725, 27 }, {} },
|
||||||
|
{ 918000, { 976958, -23225, 27 }, {} },
|
||||||
|
{ 1020000, { 1028021, -24725, 27 }, { 1120000 } },
|
||||||
|
{ 1122000, { 1082730, -26235, 27 }, { 1120000 } },
|
||||||
|
{ 1224000, { 1141084, -27735, 27 }, { 1120000 } },
|
||||||
|
{ 1326000, { 1203084, -29245, 27 }, { 1120000 } },
|
||||||
|
{ 1428000, { 1268729, -30745, 27 }, { 1120000 } },
|
||||||
|
{ 1581000, { 1374032, -33005, 27 }, { 1120000 } },
|
||||||
|
{ 1683000, { 1448791, -34505, 27 }, { 1120000 } },
|
||||||
|
{ 1785000, { 1527196, -36015, 27 }, { 1120000 } },
|
||||||
|
{ 1887000, { 1609246, -37515, 27 }, { 1120000 } },
|
||||||
|
{ 1963500, { 1675751, -38635, 27 }, { 1120000 } },
|
||||||
|
// Appending table
|
||||||
|
{ 2091000, { 1716501, -39395, 27 }, { 1120000 } },
|
||||||
|
{ 2193000, { 1775132, -40505, 27 }, { 1120000 } },
|
||||||
|
{ 2295000, { 1866287, -42005, 27 }, { 1120000 } },
|
||||||
|
{ 2397000, { 1961107, -43506, 27 }, { 1120000 } },
|
||||||
|
},
|
||||||
|
|
||||||
|
/* - Erista GPU DVFS Table:
|
||||||
*/
|
*/
|
||||||
.commonEmcMemVolt = 0,
|
.eristaGpuDvfsTable = {
|
||||||
|
{ 76800, { }, { 814294, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 153600, { }, { 856185, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 230400, { }, { 898077, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 307200, { }, { 939968, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 384000, { }, { 981860, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 460800, { }, { 1023751, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 537600, { }, { 1065642, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 614400, { }, { 1107534, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 691200, { }, { 1149425, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 768000, { }, { 1191317, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 844800, { }, { 1233208, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 921600, { }, { 1275100, 8144, -940, 808, -21583, 226 } },
|
||||||
|
// { 998400, { }, { 1316991, 8144, -940, 808, -21583, 226 } },
|
||||||
|
},
|
||||||
|
|
||||||
|
/* - Mariko GPU DVFS Table:
|
||||||
|
* 1305600 might not work for some SoCs.
|
||||||
|
*/
|
||||||
|
.marikoGpuDvfsTable = {
|
||||||
|
{ 76800, {}, { 610000, } },
|
||||||
|
{ 153600, {}, { 610000, } },
|
||||||
|
{ 230400, {}, { 610000, } },
|
||||||
|
{ 307200, {}, { 610000, } },
|
||||||
|
{ 384000, {}, { 610000, } },
|
||||||
|
{ 460800, {}, { 610000, } },
|
||||||
|
{ 537600, {}, { 801688, -10900, -163, 298, -10599, 162 } },
|
||||||
|
{ 614400, {}, { 824214, -5743, -452, 238, -6325, 81 } },
|
||||||
|
{ 691200, {}, { 848830, -3903, -552, 119, -4030, -2 } },
|
||||||
|
{ 768000, {}, { 891575, -4409, -584, 0, -2849, 39 } },
|
||||||
|
{ 844800, {}, { 940071, -5367, -602, -60, -63, -93 } },
|
||||||
|
{ 921600, {}, { 986765, -6637, -614, -179, 1905, -13 } },
|
||||||
|
{ 998400, {}, { 1098475, -13529, -497, -179, 3626, 9 } },
|
||||||
|
{ 1075200, {}, { 1163644, -12688, -648, 0, 1077, 40 } },
|
||||||
|
{ 1152000, {}, { 1204812, -9908, -830, 0, 1469, 110 } },
|
||||||
|
{ 1228800, {}, { 1277303, -11675, -859, 0, 3722, 313 } },
|
||||||
|
{ 1267200, {}, { 1335531, -12567, -867, 0, 3681, 559 } },
|
||||||
|
// Appending table
|
||||||
|
{ 1305600, {}, { 1374130, -13725, -859, 0, 4442, 576 } },
|
||||||
|
},
|
||||||
|
|
||||||
|
.eristaMtcTable = const_cast<EristaMtcTable *>(&EristaMtcTablePlaceholder),
|
||||||
|
.marikoMtcTable = const_cast<MarikoMtcTable *>(&MarikoMtcTablePlaceholder),
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,35 +16,54 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define CUST_REV 3
|
#define CUST_REV 4
|
||||||
|
|
||||||
#include "oc_common.hpp"
|
#include "oc_common.hpp"
|
||||||
|
#include "pcv/pcv_common.hpp"
|
||||||
|
|
||||||
namespace ams::ldr::oc {
|
namespace ams::ldr::oc {
|
||||||
|
|
||||||
#include "mtc_timing_table.hpp"
|
#include "mtc_timing_table.hpp"
|
||||||
|
|
||||||
enum MtcConfig {
|
enum MtcConfig: u32 {
|
||||||
AUTO_ADJ_MARIKO_SAFE_NO_ADJ_ERISTA = 0,
|
AUTO_ADJ_SAFE_MARIKO_ONLY = 0,
|
||||||
AUTO_ADJ_MARIKO_4266_NO_ADJ_ERISTA = 1,
|
AUTO_ADJ_4266_MARIKO_ONLY = 1,
|
||||||
NO_ADJ_ALL = 2,
|
NO_ADJ_ALL = 2,
|
||||||
|
CUSTOMIZED_ALL = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) CustomizeTable {
|
using CustomizeCpuDvfsTable = pcv::cvb_entry_t[pcv::DvfsTableEntryLimit];
|
||||||
|
using CustomizeGpuDvfsTable = pcv::cvb_entry_t[pcv::DvfsTableEntryLimit];
|
||||||
|
static_assert(sizeof(CustomizeCpuDvfsTable) == sizeof(CustomizeGpuDvfsTable));
|
||||||
|
static_assert(sizeof(CustomizeCpuDvfsTable) == sizeof(pcv::cvb_entry_t) * pcv::DvfsTableEntryLimit);
|
||||||
|
|
||||||
|
constexpr uint32_t ERISTA_MTC_MAGIC = 0x43544D45; // EMTC
|
||||||
|
constexpr uint32_t MARIKO_MTC_MAGIC = 0x43544D4D; // MMTC
|
||||||
|
|
||||||
|
typedef struct CustomizeTable {
|
||||||
u8 cust[4] = {'C', 'U', 'S', 'T'};
|
u8 cust[4] = {'C', 'U', 'S', 'T'};
|
||||||
u16 custRev = CUST_REV;
|
u32 custRev = CUST_REV;
|
||||||
u16 mtcConf = AUTO_ADJ_MARIKO_SAFE_NO_ADJ_ERISTA;
|
u32 mtcConf;
|
||||||
u32 marikoCpuMaxClock;
|
u32 commonCpuBoostClock;
|
||||||
u32 marikoCpuBoostClock;
|
u32 commonEmcMemVolt;
|
||||||
u32 marikoCpuMaxVolt;
|
|
||||||
u32 marikoGpuMaxClock;
|
|
||||||
u32 marikoEmcMaxClock;
|
|
||||||
u32 marikoEmcVddqVolt;
|
|
||||||
u32 eristaCpuMaxVolt;
|
u32 eristaCpuMaxVolt;
|
||||||
u32 eristaEmcMaxClock;
|
u32 eristaEmcMaxClock;
|
||||||
u32 commonEmcMemVolt;
|
u32 marikoCpuMaxVolt;
|
||||||
|
u32 marikoEmcMaxClock;
|
||||||
|
u32 marikoEmcVddqVolt;
|
||||||
|
CustomizeCpuDvfsTable eristaCpuDvfsTable;
|
||||||
|
CustomizeCpuDvfsTable marikoCpuDvfsTable;
|
||||||
|
CustomizeGpuDvfsTable eristaGpuDvfsTable;
|
||||||
|
CustomizeGpuDvfsTable marikoGpuDvfsTable;
|
||||||
|
EristaMtcTable* eristaMtcTable;
|
||||||
|
MarikoMtcTable* marikoMtcTable;
|
||||||
} CustomizeTable;
|
} CustomizeTable;
|
||||||
|
static_assert(sizeof(CustomizeTable) == sizeof(u8) * 4 + sizeof(u32) * 9 + sizeof(CustomizeCpuDvfsTable) * 4 + sizeof(void*) * 2);
|
||||||
|
static_assert(sizeof(CustomizeTable) == 7000);
|
||||||
|
|
||||||
extern volatile CustomizeTable C;
|
extern volatile CustomizeTable C;
|
||||||
|
|
||||||
|
extern volatile EristaMtcTable EristaMtcTablePlaceholder;
|
||||||
|
extern volatile MarikoMtcTable MarikoMtcTablePlaceholder;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
* from GCC preprocessor output
|
* from GCC preprocessor output
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
struct MarikoTiming {
|
struct MarikoTiming {
|
||||||
uint32_t emc_rc;
|
uint32_t emc_rc;
|
||||||
uint32_t emc_rfc;
|
uint32_t emc_rfc;
|
||||||
|
|||||||
@@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
#include "customize.hpp"
|
#include "customize.hpp"
|
||||||
|
|
||||||
|
#define PATCH_OFFSET(offset, value) \
|
||||||
|
static_assert(sizeof(__typeof__(offset)) <= sizeof(u64)); \
|
||||||
|
*(offset) = value;
|
||||||
|
|
||||||
namespace ams::ldr {
|
namespace ams::ldr {
|
||||||
R_DEFINE_ERROR_RESULT(OutOfRange, 1000);
|
R_DEFINE_ERROR_RESULT(OutOfRange, 1000);
|
||||||
R_DEFINE_ERROR_RESULT(InvalidMemPllmEntry, 1001);
|
R_DEFINE_ERROR_RESULT(InvalidMemPllmEntry, 1001);
|
||||||
@@ -92,7 +96,4 @@ namespace ams::ldr::oc {
|
|||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline void PatchOffset(T* offset, T value) { static_assert(sizeof(T) < sizeof(u64)); *(offset) = value; }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,53 @@ void saveExec(const char* file_loc, const void* buf, size_t size) {
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result Test_PcvDvfsTable() {
|
||||||
|
using namespace ams::ldr::oc::pcv;
|
||||||
|
|
||||||
|
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&mariko::CpuCvbTableDefault)) == 18);
|
||||||
|
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&erista::CpuCvbTableDefault)) == 16);
|
||||||
|
|
||||||
|
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&mariko::GpuCvbTableDefault)) == 17);
|
||||||
|
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&erista::GpuCvbTableDefault)) == 12);
|
||||||
|
|
||||||
|
cvb_entry_t last_mariko_cpu_cvb_entry_default = { 1963500, { 1675751, -38635, 27 }, { 1120000 } };
|
||||||
|
assert(memcmp(GetDvfsTableLastEntry((cvb_entry_t *)(&mariko::CpuCvbTableDefault)), (void *)&last_mariko_cpu_cvb_entry_default, sizeof(last_mariko_cpu_cvb_entry_default)) == 0);
|
||||||
|
assert(GetDvfsTableLastEntry((cvb_entry_t *)(&erista::GpuCvbTableDefault))->freq == 921600);
|
||||||
|
|
||||||
|
// Customized table default
|
||||||
|
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.eristaCpuDvfsTable)) == 19);
|
||||||
|
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.marikoCpuDvfsTable)) == 22);
|
||||||
|
|
||||||
|
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.eristaGpuDvfsTable)) == 12);
|
||||||
|
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.marikoGpuDvfsTable)) == 18);
|
||||||
|
|
||||||
|
constexpr size_t limit = ams::ldr::oc::pcv::DvfsTableEntryLimit;
|
||||||
|
cvb_entry_t customized_table[limit] = {};
|
||||||
|
for (int i = 0; i < limit; i++) {
|
||||||
|
assert(GetDvfsTableEntryCount(customized_table) == i);
|
||||||
|
auto p = GetDvfsTableLastEntry(customized_table);
|
||||||
|
if (p)
|
||||||
|
assert(p->freq == i);
|
||||||
|
|
||||||
|
customized_table[i].freq = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
void unitTest() {
|
||||||
|
UnitTest test[] = {
|
||||||
|
{ "PCV DVFS Table", &Test_PcvDvfsTable }
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto &t : test) {
|
||||||
|
t.Test();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
unitTest();
|
||||||
|
|
||||||
const char* pcv_opt = "pcv";
|
const char* pcv_opt = "pcv";
|
||||||
const char* ptm_opt = "ptm";
|
const char* ptm_opt = "ptm";
|
||||||
const char* save_opt = "-s";
|
const char* save_opt = "-s";
|
||||||
|
|||||||
@@ -19,10 +19,12 @@
|
|||||||
#ifndef ATMOSPHERE_IS_STRATOSPHERE
|
#ifndef ATMOSPHERE_IS_STRATOSPHERE
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
typedef uint8_t u8;
|
typedef uint8_t u8;
|
||||||
typedef uint16_t u16;
|
typedef uint16_t u16;
|
||||||
@@ -43,4 +45,34 @@ typedef int Result;
|
|||||||
#define R_DEFINE_ERROR_RESULT(name, rc) \
|
#define R_DEFINE_ERROR_RESULT(name, rc) \
|
||||||
inline Result Result##name() { return rc; }
|
inline Result Result##name() { return rc; }
|
||||||
|
|
||||||
|
#define HEXDUMP(ptr, len) \
|
||||||
|
{ \
|
||||||
|
const uint8_t* p = reinterpret_cast<const uint8_t *>(ptr); \
|
||||||
|
size_t i, j; \
|
||||||
|
for (i = 0; i < len; i += 16) { \
|
||||||
|
printf("%06zx: ", i); \
|
||||||
|
for (j = 0; j < 16 && i + j < len; j++) \
|
||||||
|
printf("%02x ", p[i + j]); \
|
||||||
|
for (; j < 16; j++) \
|
||||||
|
printf(" "); \
|
||||||
|
for (j = 0; j < 16 && i + j < len; j++) \
|
||||||
|
printf("%c", isprint(p[i + j]) ? p[i + j] : '.'); \
|
||||||
|
printf("\n"); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
typedef struct UnitTest {
|
||||||
|
using Func = Result(*)();
|
||||||
|
|
||||||
|
const char* description;
|
||||||
|
Func fun = nullptr;
|
||||||
|
|
||||||
|
void Test() {
|
||||||
|
Result res = fun();
|
||||||
|
if (R_FAILED(res)) {
|
||||||
|
CRASH(description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} UnitTest;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -63,7 +63,7 @@ Result MemVoltHandler(u32* ptr) {
|
|||||||
if (emc_uv % uv_step)
|
if (emc_uv % uv_step)
|
||||||
emc_uv = emc_uv / uv_step * uv_step; // rounding
|
emc_uv = emc_uv / uv_step * uv_step; // rounding
|
||||||
|
|
||||||
PatchOffset(ptr, emc_uv);
|
PATCH_OFFSET(ptr, emc_uv);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
@@ -91,16 +91,23 @@ void SafetyCheck() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
u32 eristaCpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.eristaCpuDvfsTable)->freq);
|
||||||
|
u32 marikoCpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.marikoCpuDvfsTable)->freq);
|
||||||
|
u32 eristaGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.eristaGpuDvfsTable)->freq);
|
||||||
|
u32 marikoGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.marikoGpuDvfsTable)->freq);
|
||||||
|
|
||||||
sValidator validators[] = {
|
sValidator validators[] = {
|
||||||
{ C.marikoCpuMaxClock, 1785'000, 3000'000 },
|
{ C.commonCpuBoostClock, 1020'000, 3000'000, true },
|
||||||
{ C.marikoCpuBoostClock, 1020'000, 3000'000, true },
|
{ C.commonEmcMemVolt, 1100'000, 1250'000 },
|
||||||
{ C.marikoCpuMaxVolt, 1100, 1300 },
|
|
||||||
{ C.marikoGpuMaxClock, 768'000, 1536'000 },
|
|
||||||
{ C.marikoEmcMaxClock, 1600'000, 2400'000 },
|
|
||||||
{ C.marikoEmcVddqVolt, 550'000, 650'000 },
|
|
||||||
{ C.eristaCpuMaxVolt, 1100, 1300 },
|
{ C.eristaCpuMaxVolt, 1100, 1300 },
|
||||||
{ C.eristaEmcMaxClock, 1600'000, 2400'000 },
|
{ C.eristaEmcMaxClock, 1600'000, 2400'000 },
|
||||||
{ C.commonEmcMemVolt, 1100'000, 1250'000 },
|
{ C.marikoCpuMaxVolt, 1100, 1300 },
|
||||||
|
{ C.marikoEmcMaxClock, 1600'000, 2400'000 },
|
||||||
|
{ C.marikoEmcVddqVolt, 550'000, 650'000 },
|
||||||
|
{ eristaCpuDvfsMaxFreq, 1785'000, 3000'000 },
|
||||||
|
{ marikoCpuDvfsMaxFreq, 1785'000, 3000'000 },
|
||||||
|
{ eristaGpuDvfsMaxFreq, 768'000, 1536'000 },
|
||||||
|
{ marikoGpuDvfsMaxFreq, 768'000, 1536'000 },
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto& i : validators) {
|
for (auto& i : validators) {
|
||||||
|
|||||||
@@ -17,141 +17,240 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../oc_common.hpp"
|
#include "../oc_common.hpp"
|
||||||
|
#include "pcv_common.hpp"
|
||||||
|
|
||||||
namespace ams::ldr::oc::pcv {
|
namespace ams::ldr::oc::pcv {
|
||||||
|
|
||||||
typedef struct cvb_coefficients {
|
namespace mariko {
|
||||||
s32 c0 = 0;
|
constexpr cvb_entry_t CpuCvbTableDefault[] = {
|
||||||
s32 c1 = 0;
|
// CPUB01_CVB_TABLE
|
||||||
s32 c2 = 0;
|
{ 204000, { 721589, -12695, 27 }, {} },
|
||||||
s32 c3 = 0;
|
{ 306000, { 747134, -14195, 27 }, {} },
|
||||||
s32 c4 = 0;
|
{ 408000, { 776324, -15705, 27 }, {} },
|
||||||
s32 c5 = 0;
|
{ 510000, { 809160, -17205, 27 }, {} },
|
||||||
} cvb_coefficients;
|
{ 612000, { 845641, -18715, 27 }, {} },
|
||||||
|
{ 714000, { 885768, -20215, 27 }, {} },
|
||||||
typedef struct cpu_freq_cvb_table_t {
|
{ 816000, { 929540, -21725, 27 }, {} },
|
||||||
u64 freq;
|
{ 918000, { 976958, -23225, 27 }, {} },
|
||||||
cvb_coefficients cvb_dfll_param;
|
{ 1020000, { 1028021, -24725, 27 }, { 1120000 } },
|
||||||
cvb_coefficients cvb_pll_param;
|
{ 1122000, { 1082730, -26235, 27 }, { 1120000 } },
|
||||||
} cpu_freq_cvb_table_t;
|
{ 1224000, { 1141084, -27735, 27 }, { 1120000 } },
|
||||||
static_assert(sizeof(cpu_freq_cvb_table_t) == 0x38);
|
{ 1326000, { 1203084, -29245, 27 }, { 1120000 } },
|
||||||
|
{ 1428000, { 1268729, -30745, 27 }, { 1120000 } },
|
||||||
typedef struct gpu_cvb_pll_table_t {
|
{ 1581000, { 1374032, -33005, 27 }, { 1120000 } },
|
||||||
u64 freq;
|
{ 1683000, { 1448791, -34505, 27 }, { 1120000 } },
|
||||||
cvb_coefficients cvb_dfll_param;
|
{ 1785000, { 1527196, -36015, 27 }, { 1120000 } },
|
||||||
cvb_coefficients cvb_pll_param;
|
{ 1887000, { 1609246, -37515, 27 }, { 1120000 } },
|
||||||
} gpu_cvb_pll_table_t;
|
{ 1963500, { 1675751, -38635, 27 }, { 1120000 } },
|
||||||
static_assert(sizeof(gpu_cvb_pll_table_t) == 0x38);
|
{ },
|
||||||
|
|
||||||
typedef struct emc_dvb_dvfs_table_t {
|
|
||||||
u64 freq;
|
|
||||||
s32 volt[4] = {0};
|
|
||||||
} emc_dvb_dvfs_table_t;
|
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) div_nmp {
|
|
||||||
u8 divn_shift;
|
|
||||||
u8 divn_width;
|
|
||||||
u8 divm_shift;
|
|
||||||
u8 divm_width;
|
|
||||||
u8 divp_shift;
|
|
||||||
u8 divp_width;
|
|
||||||
u8 override_divn_shift;
|
|
||||||
u8 override_divm_shift;
|
|
||||||
u8 override_divp_shift;
|
|
||||||
} div_nmp;
|
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) clk_pll_param {
|
|
||||||
u32 freq;
|
|
||||||
u32 input_min;
|
|
||||||
u32 input_max;
|
|
||||||
u32 cf_min;
|
|
||||||
u32 cf_max;
|
|
||||||
u32 vco_min;
|
|
||||||
u32 vco_max;
|
|
||||||
s32 lock_delay;
|
|
||||||
u32 fixed_rate;
|
|
||||||
u32 unk_0;
|
|
||||||
struct div_nmp *div_nmp;
|
|
||||||
u32 unk_1[4];
|
|
||||||
void (*unk_fn)(u64* unk_struct); // set_defaults?
|
|
||||||
} clk_pll_param;
|
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) dvfs_rail {
|
|
||||||
u32 id;
|
|
||||||
u32 unk_0[5];
|
|
||||||
u32 freq;
|
|
||||||
u32 unk_1[8];
|
|
||||||
u32 unk_flag;
|
|
||||||
u32 min_mv;
|
|
||||||
u32 step_mv;
|
|
||||||
u32 max_mv;
|
|
||||||
u32 unk_2[11];
|
|
||||||
} dvfs_rail;
|
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) regulator {
|
|
||||||
u64 id;
|
|
||||||
const char* name;
|
|
||||||
u32 type;
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
u32 volt_reg;
|
|
||||||
u32 step_uv;
|
|
||||||
u32 min_uv;
|
|
||||||
u32 default_uv;
|
|
||||||
u32 max_uv;
|
|
||||||
u32 unk_0[2];
|
|
||||||
} type_1;
|
|
||||||
struct {
|
|
||||||
u32 unk_0;
|
|
||||||
u32 step_uv;
|
|
||||||
u32 unk_1;
|
|
||||||
u32 min_uv;
|
|
||||||
u32 max_uv;
|
|
||||||
u32 unk_2;
|
|
||||||
u32 default_uv;
|
|
||||||
} type_2_3;
|
|
||||||
};
|
};
|
||||||
u32 unk_x[60];
|
|
||||||
} regulator;
|
|
||||||
static_assert(sizeof(regulator) == 0x120);
|
|
||||||
|
|
||||||
constexpr u32 CpuClkOSLimit = 1785'000;
|
constexpr u16 CpuMinVolts[] = { 800, 637, 620, 610 };
|
||||||
|
|
||||||
constexpr u32 EmcClkOSLimit = 1600'000;
|
constexpr u32 CpuClkOfficial = 1963'500;
|
||||||
|
constexpr u32 CpuVoltOfficial = 1120;
|
||||||
|
|
||||||
#define R_SKIP() R_SUCCEED()
|
constexpr cvb_entry_t GpuCvbTableDefault[] = {
|
||||||
|
// GPUB01_NA_CVB_TABLE
|
||||||
|
{ 76800, {}, { 610000, } },
|
||||||
|
{ 153600, {}, { 610000, } },
|
||||||
|
{ 230400, {}, { 610000, } },
|
||||||
|
{ 307200, {}, { 610000, } },
|
||||||
|
{ 384000, {}, { 610000, } },
|
||||||
|
{ 460800, {}, { 610000, } },
|
||||||
|
{ 537600, {}, { 801688, -10900, -163, 298, -10599, 162 } },
|
||||||
|
{ 614400, {}, { 824214, -5743, -452, 238, -6325, 81 } },
|
||||||
|
{ 691200, {}, { 848830, -3903, -552, 119, -4030, -2 } },
|
||||||
|
{ 768000, {}, { 891575, -4409, -584, 0, -2849, 39 } },
|
||||||
|
{ 844800, {}, { 940071, -5367, -602, -60, -63, -93 } },
|
||||||
|
{ 921600, {}, { 986765, -6637, -614, -179, 1905, -13 } },
|
||||||
|
{ 998400, {}, { 1098475, -13529, -497, -179, 3626, 9 } },
|
||||||
|
{ 1075200, {}, { 1163644, -12688, -648, 0, 1077, 40 } },
|
||||||
|
{ 1152000, {}, { 1204812, -9908, -830, 0, 1469, 110 } },
|
||||||
|
{ 1228800, {}, { 1277303, -11675, -859, 0, 3722, 313 } },
|
||||||
|
{ 1267200, {}, { 1335531, -12567, -867, 0, 3681, 559 } },
|
||||||
|
{ },
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr u32 GpuClkPllLimit = 1300'000'000;
|
||||||
|
|
||||||
|
/* GPU Max Clock asm Pattern:
|
||||||
|
*
|
||||||
|
* MOV W11, #0x1000 MOV (wide immediate) 0x1000 0xB (11)
|
||||||
|
* sf | opc | | hw | imm16 | Rd
|
||||||
|
* #31 |30 29|28 27 26 25 24 23|22 21|20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 |4 3 2 1 0
|
||||||
|
* 0 | 1 0 | 1 0 0 1 0 1| 0 0| 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 |0 1 0 1 1
|
||||||
|
*
|
||||||
|
* MOVK W11, #0xE, LSL#16 <shift>16 0xE 0xB (11)
|
||||||
|
* sf | opc | | hw | imm16 | Rd
|
||||||
|
* #31 |30 29|28 27 26 25 24 23|22 21|20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 |4 3 2 1 0
|
||||||
|
* 0 | 1 1 | 1 0 0 1 0 1| 0 1| 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 |0 1 0 1 1
|
||||||
|
*/
|
||||||
|
inline constexpr u32 asm_pattern[] = { 0x52820000, 0x72A001C0 };
|
||||||
|
inline auto asm_compare_no_rd = [](u32 ins1, u32 ins2) { return ((ins1 ^ ins2) >> 5) == 0; };
|
||||||
|
inline auto asm_get_rd = [](u32 ins) { return ins & ((1 << 5) - 1); };
|
||||||
|
inline auto asm_set_rd = [](u32 ins, u8 rd) { return (ins & 0xFFFFFFE0) | (rd & 0x1F); };
|
||||||
|
inline auto asm_set_imm16 = [](u32 ins, u16 imm) { return (ins & 0xFFE0001F) | ((imm & 0xFFFF) << 5); };
|
||||||
|
|
||||||
|
inline bool GpuMaxClockPatternFn(u32* ptr32) {
|
||||||
|
return asm_compare_no_rd(*ptr32, asm_pattern[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr emc_dvb_dvfs_table_t EmcDvbTableDefault[] = {
|
||||||
|
{ 204000, { 637, 637, 637, } },
|
||||||
|
{ 408000, { 637, 637, 637, } },
|
||||||
|
{ 800000, { 637, 637, 637, } },
|
||||||
|
{ 1065600, { 637, 637, 637, } },
|
||||||
|
{ 1331200, { 650, 637, 637, } },
|
||||||
|
{ 1600000, { 675, 650, 637, } },
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr u32 EmcClkOSAlt = 1331'200;
|
||||||
|
constexpr u32 EmcClkPllmLimit = 2133'000'000;
|
||||||
|
constexpr u32 EmcVddqDefault = 600'000;
|
||||||
|
constexpr u32 MemVdd2Default = 1100'000;
|
||||||
|
|
||||||
|
constexpr u32 MTC_TABLE_REV = 3;
|
||||||
|
|
||||||
|
void Patch(uintptr_t mapped_nso, size_t nso_size);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace erista {
|
||||||
|
constexpr cvb_entry_t CpuCvbTableDefault[] = {
|
||||||
|
// CPU_PLL_CVB_TABLE_ODN
|
||||||
|
{ 204000, { 721094 }, {} },
|
||||||
|
{ 306000, { 754040 }, {} },
|
||||||
|
{ 408000, { 786986 }, {} },
|
||||||
|
{ 510000, { 819932 }, {} },
|
||||||
|
{ 612000, { 852878 }, {} },
|
||||||
|
{ 714000, { 885824 }, {} },
|
||||||
|
{ 816000, { 918770 }, {} },
|
||||||
|
{ 918000, { 951716 }, {} },
|
||||||
|
{ 1020000, { 984662 }, { -2875621, 358099, -8585 } },
|
||||||
|
{ 1122000, { 1017608 }, { -52225, 104159, -2816 } },
|
||||||
|
{ 1224000, { 1050554 }, { 1076868, 8356, -727 } },
|
||||||
|
{ 1326000, { 1083500 }, { 2208191, -84659, 1240 } },
|
||||||
|
{ 1428000, { 1116446 }, { 2519460, -105063, 1611 } },
|
||||||
|
{ 1581000, { 1130000 }, { 2889664, -122173, 1834 } },
|
||||||
|
{ 1683000, { 1168000 }, { 5100873, -279186, 4747 } },
|
||||||
|
{ 1785000, { 1227500 }, { 5100873, -279186, 4747 } },
|
||||||
|
{ },
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr u32 CpuVoltL4T = 1235'000;
|
||||||
|
|
||||||
|
constexpr u16 CpuMinVolts[] = { 950, 850, 825, 810 };
|
||||||
|
|
||||||
|
inline bool CpuMaxVoltPatternFn(u32* ptr32) {
|
||||||
|
u32 val = *ptr32;
|
||||||
|
return (val == 1132 || val == 1170 || val == 1227);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr cvb_entry_t GpuCvbTableDefault[] = {
|
||||||
|
// NA_FREQ_CVB_TABLE
|
||||||
|
{ 76800, { }, { 814294, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 153600, { }, { 856185, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 230400, { }, { 898077, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 307200, { }, { 939968, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 384000, { }, { 981860, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 460800, { }, { 1023751, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 537600, { }, { 1065642, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 614400, { }, { 1107534, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 691200, { }, { 1149425, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 768000, { }, { 1191317, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 844800, { }, { 1233208, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ 921600, { }, { 1275100, 8144, -940, 808, -21583, 226 } },
|
||||||
|
{ },
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr u32 MemVoltHOS = 1125'000;
|
||||||
|
constexpr u32 EmcClkPllmLimit = 1866'000'000;
|
||||||
|
|
||||||
|
constexpr u32 MTC_TABLE_REV = 7;
|
||||||
|
|
||||||
|
void Patch(uintptr_t mapped_nso, size_t nso_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool isMariko>
|
||||||
|
Result CpuFreqCvbTable(u32* ptr) {
|
||||||
|
cvb_entry_t* default_table = isMariko ? (cvb_entry_t *)(&mariko::CpuCvbTableDefault) : (cvb_entry_t *)(&erista::CpuCvbTableDefault);
|
||||||
|
cvb_entry_t* customize_table = const_cast<cvb_entry_t *>(isMariko ? C.marikoCpuDvfsTable : C.eristaCpuDvfsTable);
|
||||||
|
|
||||||
|
u32 cpu_max_volt = isMariko ? C.marikoCpuMaxVolt : C.eristaCpuMaxVolt;
|
||||||
|
u32 cpu_freq_threshold = isMariko ? 1020'000 : 1785'000;
|
||||||
|
|
||||||
|
size_t default_entry_count = GetDvfsTableEntryCount(default_table);
|
||||||
|
size_t default_table_size = default_entry_count * sizeof(cvb_entry_t);
|
||||||
|
size_t customize_entry_count = GetDvfsTableEntryCount(customize_table);
|
||||||
|
size_t customize_table_size = customize_entry_count * sizeof(cvb_entry_t);
|
||||||
|
|
||||||
|
// Validate existing table
|
||||||
|
cvb_entry_t* table_free = reinterpret_cast<cvb_entry_t *>(ptr) + 1;
|
||||||
|
void* cpu_cvb_table_head = reinterpret_cast<u8 *>(table_free) - default_table_size;
|
||||||
|
bool validated = std::memcmp(cpu_cvb_table_head, default_table, default_table_size) == 0;
|
||||||
|
R_UNLESS(validated, ldr::ResultInvalidCpuDvfs());
|
||||||
|
|
||||||
|
std::memcpy(cpu_cvb_table_head, static_cast<void *>(customize_table), customize_table_size);
|
||||||
|
|
||||||
|
// Patch CPU max volt
|
||||||
|
if (cpu_max_volt) {
|
||||||
|
cvb_entry_t* entry = static_cast<cvb_entry_t *>(cpu_cvb_table_head);
|
||||||
|
for (size_t i = 0; i < customize_entry_count; i++) {
|
||||||
|
if (entry->freq >= cpu_freq_threshold) {
|
||||||
|
PATCH_OFFSET(&(entry->cvb_pll_param.c0), cpu_max_volt * 1000);
|
||||||
|
}
|
||||||
|
entry++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool isMariko>
|
||||||
|
Result GpuFreqCvbTable(u32* ptr) {
|
||||||
|
cvb_entry_t* default_table = isMariko ? (cvb_entry_t *)(&mariko::GpuCvbTableDefault) : (cvb_entry_t *)(&erista::GpuCvbTableDefault);
|
||||||
|
cvb_entry_t* customize_table = const_cast<cvb_entry_t *>(isMariko ? C.marikoGpuDvfsTable : C.eristaGpuDvfsTable);
|
||||||
|
|
||||||
|
size_t default_entry_count = GetDvfsTableEntryCount(default_table);
|
||||||
|
size_t default_table_size = default_entry_count * sizeof(cvb_entry_t);
|
||||||
|
size_t customize_entry_count = GetDvfsTableEntryCount(customize_table);
|
||||||
|
size_t customize_table_size = customize_entry_count * sizeof(cvb_entry_t);
|
||||||
|
|
||||||
|
// Validate existing table
|
||||||
|
cvb_entry_t* table_free = reinterpret_cast<cvb_entry_t *>(ptr) + 1;
|
||||||
|
void* gpu_cvb_table_head = reinterpret_cast<u8 *>(table_free) - default_table_size;
|
||||||
|
bool validated = std::memcmp(gpu_cvb_table_head, default_table, default_table_size) == 0;
|
||||||
|
R_UNLESS(validated, ldr::ResultInvalidGpuDvfs());
|
||||||
|
|
||||||
|
std::memcpy(gpu_cvb_table_head, (void*)customize_table, customize_table_size);
|
||||||
|
|
||||||
|
R_SUCCEED();
|
||||||
|
};
|
||||||
|
|
||||||
Result MemFreqPllmLimit(u32* ptr);
|
Result MemFreqPllmLimit(u32* ptr);
|
||||||
Result MemVoltHandler(u32* ptr); // Used for Erista MEM Vdd2 + EMC Vddq or Mariko MEM Vdd2
|
Result MemVoltHandler(u32* ptr); // Used for Erista MEM Vdd2 + EMC Vddq or Mariko MEM Vdd2
|
||||||
|
|
||||||
template<typename Table>
|
template<typename T>
|
||||||
Result MemMtcTableClone(Table* des, Table* src) {
|
Result MemMtcCustomizeTable(T* dst, T* src) {
|
||||||
constexpr u32 mtc_magic = 0x5F43544D;
|
constexpr u32 mtc_magic = std::is_same_v<T, MarikoMtcTable> ? MARIKO_MTC_MAGIC : ERISTA_MTC_MAGIC;
|
||||||
R_UNLESS(src->rev == mtc_magic, ldr::ResultInvalidMtcMagic());
|
R_UNLESS(src->rev == mtc_magic, ldr::ResultInvalidMtcMagic());
|
||||||
|
|
||||||
|
constexpr u32 ZERO_VAL = UINT32_MAX;
|
||||||
// Skip params from dvfs_ver to clock_src;
|
// Skip params from dvfs_ver to clock_src;
|
||||||
for (size_t offset = offsetof(Table, clk_src_emc); offset < sizeof(Table); offset += sizeof(u32)) {
|
for (size_t offset = offsetof(T, clk_src_emc); offset < sizeof(T); offset += sizeof(u32)) {
|
||||||
u32* src_ent = reinterpret_cast<u32 *>(reinterpret_cast<size_t>(src) + offset);
|
u32* src_ent = reinterpret_cast<u32 *>(reinterpret_cast<size_t>(src) + offset);
|
||||||
u32* des_ent = reinterpret_cast<u32 *>(reinterpret_cast<size_t>(des) + offset);
|
u32* dst_ent = reinterpret_cast<u32 *>(reinterpret_cast<size_t>(dst) + offset);
|
||||||
u32 src_val = *src_ent;
|
u32 src_val = *src_ent;
|
||||||
|
|
||||||
constexpr u32 placeholder_val = UINT32_MAX;
|
if (src_val) {
|
||||||
if (src_val != placeholder_val) {
|
PATCH_OFFSET(dst_ent, src_val == ZERO_VAL ? 0 : src_val);
|
||||||
PatchOffset(des_ent, src_val);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace erista {
|
|
||||||
void Patch(uintptr_t mapped_nso, size_t nso_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace mariko {
|
|
||||||
void Patch(uintptr_t mapped_nso, size_t nso_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SafetyCheck();
|
void SafetyCheck();
|
||||||
void Patch(uintptr_t mapped_nso, size_t nso_size);
|
void Patch(uintptr_t mapped_nso, size_t nso_size);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,156 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Switch-OC-Suite
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
* version 2, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace ams::ldr::oc::pcv {
|
||||||
|
|
||||||
|
typedef struct cvb_coefficients {
|
||||||
|
s32 c0 = 0;
|
||||||
|
s32 c1 = 0;
|
||||||
|
s32 c2 = 0;
|
||||||
|
s32 c3 = 0;
|
||||||
|
s32 c4 = 0;
|
||||||
|
s32 c5 = 0;
|
||||||
|
} cvb_coefficients;
|
||||||
|
|
||||||
|
typedef struct cvb_entry_t {
|
||||||
|
u64 freq;
|
||||||
|
cvb_coefficients cvb_dfll_param;
|
||||||
|
cvb_coefficients cvb_pll_param;
|
||||||
|
} cvb_entry_t;
|
||||||
|
static_assert(sizeof(cvb_entry_t) == 0x38);
|
||||||
|
|
||||||
|
typedef struct emc_dvb_dvfs_table_t {
|
||||||
|
u64 freq;
|
||||||
|
s32 volt[4] = {0};
|
||||||
|
} emc_dvb_dvfs_table_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) div_nmp {
|
||||||
|
u8 divn_shift;
|
||||||
|
u8 divn_width;
|
||||||
|
u8 divm_shift;
|
||||||
|
u8 divm_width;
|
||||||
|
u8 divp_shift;
|
||||||
|
u8 divp_width;
|
||||||
|
u8 override_divn_shift;
|
||||||
|
u8 override_divm_shift;
|
||||||
|
u8 override_divp_shift;
|
||||||
|
} div_nmp;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) clk_pll_param {
|
||||||
|
u32 freq;
|
||||||
|
u32 input_min;
|
||||||
|
u32 input_max;
|
||||||
|
u32 cf_min;
|
||||||
|
u32 cf_max;
|
||||||
|
u32 vco_min;
|
||||||
|
u32 vco_max;
|
||||||
|
s32 lock_delay;
|
||||||
|
u32 fixed_rate;
|
||||||
|
u32 unk_0;
|
||||||
|
struct div_nmp *div_nmp;
|
||||||
|
u32 unk_1[4];
|
||||||
|
void (*unk_fn)(u64* unk_struct); // set_defaults?
|
||||||
|
} clk_pll_param;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) dvfs_rail {
|
||||||
|
u32 id;
|
||||||
|
u32 unk_0[5];
|
||||||
|
u32 freq;
|
||||||
|
u32 unk_1[8];
|
||||||
|
u32 unk_flag;
|
||||||
|
u32 min_mv;
|
||||||
|
u32 step_mv;
|
||||||
|
u32 max_mv;
|
||||||
|
u32 unk_2[11];
|
||||||
|
} dvfs_rail;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) regulator {
|
||||||
|
u64 id;
|
||||||
|
const char* name;
|
||||||
|
u32 type;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
u32 volt_reg;
|
||||||
|
u32 step_uv;
|
||||||
|
u32 min_uv;
|
||||||
|
u32 default_uv;
|
||||||
|
u32 max_uv;
|
||||||
|
u32 unk_0[2];
|
||||||
|
} type_1;
|
||||||
|
struct {
|
||||||
|
u32 unk_0;
|
||||||
|
u32 step_uv;
|
||||||
|
u32 unk_1;
|
||||||
|
u32 min_uv;
|
||||||
|
u32 max_uv;
|
||||||
|
u32 unk_2;
|
||||||
|
u32 default_uv;
|
||||||
|
} type_2_3;
|
||||||
|
};
|
||||||
|
u32 unk_x[60];
|
||||||
|
} regulator;
|
||||||
|
static_assert(sizeof(regulator) == 0x120);
|
||||||
|
|
||||||
|
constexpr u32 CpuClkOSLimit = 1785'000;
|
||||||
|
|
||||||
|
constexpr u32 EmcClkOSLimit = 1600'000;
|
||||||
|
|
||||||
|
#define R_SKIP() R_SUCCEED()
|
||||||
|
|
||||||
|
// Count 32 / Index 31 is reserved to be empty
|
||||||
|
constexpr size_t DvfsTableEntryCount = 32;
|
||||||
|
constexpr size_t DvfsTableEntryLimit = DvfsTableEntryCount - 1;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
size_t GetDvfsTableEntryCount(T* table_head) {
|
||||||
|
using NT = std::remove_const_t<std::remove_volatile_t<T>>;
|
||||||
|
|
||||||
|
auto is_empty = [](NT* entry) {
|
||||||
|
uint8_t* m = reinterpret_cast<uint8_t *>(entry);
|
||||||
|
for (size_t i = 0; i < sizeof(NT); i++) {
|
||||||
|
if (*(m + i))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
NT* table = const_cast<NT *>(table_head);
|
||||||
|
size_t count = 0;
|
||||||
|
while (count < DvfsTableEntryLimit) {
|
||||||
|
if (is_empty(table++)) {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return DvfsTableEntryLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T* GetDvfsTableLastEntry(T* table_head) {
|
||||||
|
using NT = std::remove_const_t<std::remove_volatile_t<T>>;
|
||||||
|
|
||||||
|
NT* table = const_cast<NT *>(table_head);
|
||||||
|
size_t count = GetDvfsTableEntryCount(table_head);
|
||||||
|
if (!count) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
size_t index = count - 1;
|
||||||
|
return table + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,36 +14,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pcv_erista.hpp"
|
#include "pcv.hpp"
|
||||||
|
|
||||||
namespace ams::ldr::oc::pcv::erista {
|
namespace ams::ldr::oc::pcv::erista {
|
||||||
|
|
||||||
Result CpuFreqCvbTable(u32* ptr) {
|
|
||||||
cpu_freq_cvb_table_t* default_end = reinterpret_cast<cpu_freq_cvb_table_t *>(ptr);
|
|
||||||
cpu_freq_cvb_table_t* new_start = default_end + 1;
|
|
||||||
|
|
||||||
// Validate existing table
|
|
||||||
void* cpu_cvb_table_head = reinterpret_cast<u8 *>(new_start) - sizeof(CpuCvbTableDefault);
|
|
||||||
bool validated = std::memcmp(cpu_cvb_table_head, CpuCvbTableDefault, sizeof(CpuCvbTableDefault)) == 0;
|
|
||||||
R_UNLESS(validated, ldr::ResultInvalidCpuDvfs());
|
|
||||||
|
|
||||||
std::memcpy(reinterpret_cast<void *>(new_start), CpuCvbTableAppend, sizeof(CpuCvbTableAppend));
|
|
||||||
|
|
||||||
// Patch CPU max volt in existing and appended CPU dvfs table
|
|
||||||
if (C.eristaCpuMaxVolt) {
|
|
||||||
size_t table_size = sizeof(CpuCvbTableAppend) / sizeof(cpu_freq_cvb_table_t);
|
|
||||||
cpu_freq_cvb_table_t* entry = new_start;
|
|
||||||
for (size_t i = 0; i < table_size; i++) {
|
|
||||||
if (entry->cvb_dfll_param.c0 == CpuVoltL4T) {
|
|
||||||
PatchOffset(reinterpret_cast<u32 *>(&(entry->cvb_dfll_param.c0)), C.eristaCpuMaxVolt * 1000);
|
|
||||||
}
|
|
||||||
entry++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
R_SUCCEED();
|
|
||||||
}
|
|
||||||
|
|
||||||
Result CpuVoltRange(u32* ptr) {
|
Result CpuVoltRange(u32* ptr) {
|
||||||
u32 min_volt_got = *(ptr - 1);
|
u32 min_volt_got = *(ptr - 1);
|
||||||
for (const auto& mv : CpuMinVolts) {
|
for (const auto& mv : CpuMinVolts) {
|
||||||
@@ -53,7 +27,7 @@ Result CpuVoltRange(u32* ptr) {
|
|||||||
if (!C.eristaCpuMaxVolt)
|
if (!C.eristaCpuMaxVolt)
|
||||||
R_SKIP();
|
R_SKIP();
|
||||||
|
|
||||||
PatchOffset(ptr, C.eristaCpuMaxVolt);
|
PATCH_OFFSET(ptr, C.eristaCpuMaxVolt);
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
R_THROW(ldr::ResultInvalidCpuMinVolt());
|
R_THROW(ldr::ResultInvalidCpuMinVolt());
|
||||||
@@ -80,7 +54,12 @@ Result MemFreqMtcTable(u32* ptr) {
|
|||||||
for (u32 i = khz_list_size - 1; i > 0; i--)
|
for (u32 i = khz_list_size - 1; i > 0; i--)
|
||||||
std::memcpy(static_cast<void *>(table_list[i]), static_cast<void *>(table_list[i - 1]), sizeof(EristaMtcTable));
|
std::memcpy(static_cast<void *>(table_list[i]), static_cast<void *>(table_list[i - 1]), sizeof(EristaMtcTable));
|
||||||
|
|
||||||
PatchOffset(ptr, C.eristaEmcMaxClock);
|
PATCH_OFFSET(ptr, C.eristaEmcMaxClock);
|
||||||
|
|
||||||
|
// Handle customize table replacement
|
||||||
|
if (C.mtcConf == CUSTOMIZED_ALL) {
|
||||||
|
MemMtcCustomizeTable(table_list[0], const_cast<EristaMtcTable *>(C.eristaMtcTable));
|
||||||
|
}
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
@@ -89,19 +68,23 @@ Result MemFreqMax(u32* ptr) {
|
|||||||
if (C.eristaEmcMaxClock <= EmcClkOSLimit)
|
if (C.eristaEmcMaxClock <= EmcClkOSLimit)
|
||||||
R_SKIP();
|
R_SKIP();
|
||||||
|
|
||||||
PatchOffset(ptr, C.eristaEmcMaxClock);
|
PATCH_OFFSET(ptr, C.eristaEmcMaxClock);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
||||||
|
u32 CpuCvbDefaultMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(CpuCvbTableDefault)->freq);
|
||||||
|
u32 GpuCvbDefaultMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(GpuCvbTableDefault)->freq);
|
||||||
|
|
||||||
PatcherEntry<u32> patches[] = {
|
PatcherEntry<u32> patches[] = {
|
||||||
{ "CPU Freq Table", &CpuFreqCvbTable, 1, nullptr, CpuClkOSLimit },
|
{ "CPU Freq Table", CpuFreqCvbTable<false>, 1, nullptr, CpuCvbDefaultMaxFreq },
|
||||||
{ "CPU Volt Limit", &CpuVoltRange, 0, &CpuMaxVoltPatternFn },
|
{ "CPU Volt Limit", &CpuVoltRange, 0, &CpuMaxVoltPatternFn },
|
||||||
{ "MEM Freq Mtc", &MemFreqMtcTable, 0, nullptr, EmcClkOSLimit },
|
{ "GPU Freq Table", GpuFreqCvbTable<false>, 1, nullptr, GpuCvbDefaultMaxFreq },
|
||||||
{ "MEM Freq Max", &MemFreqMax, 0, nullptr, EmcClkOSLimit },
|
{ "MEM Freq Mtc", &MemFreqMtcTable, 0, nullptr, EmcClkOSLimit },
|
||||||
{ "MEM Freq PLLM", &MemFreqPllmLimit, 2, nullptr, EmcClkPllmLimit },
|
{ "MEM Freq Max", &MemFreqMax, 0, nullptr, EmcClkOSLimit },
|
||||||
{ "MEM Volt", &MemVoltHandler, 2, nullptr, MemVoltHOS },
|
{ "MEM Freq PLLM", &MemFreqPllmLimit, 2, nullptr, EmcClkPllmLimit },
|
||||||
|
{ "MEM Volt", &MemVoltHandler, 2, nullptr, MemVoltHOS },
|
||||||
};
|
};
|
||||||
|
|
||||||
for (uintptr_t ptr = mapped_nso;
|
for (uintptr_t ptr = mapped_nso;
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) Switch-OC-Suite
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms and conditions of the GNU General Public License,
|
|
||||||
* version 2, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "pcv.hpp"
|
|
||||||
|
|
||||||
namespace ams::ldr::oc::pcv::erista {
|
|
||||||
|
|
||||||
constexpr cpu_freq_cvb_table_t CpuCvbTableDefault[] = {
|
|
||||||
// CPU_PLL_CVB_TABLE_ODN
|
|
||||||
{ 204000, { 721094 }, {} },
|
|
||||||
{ 306000, { 754040 }, {} },
|
|
||||||
{ 408000, { 786986 }, {} },
|
|
||||||
{ 510000, { 819932 }, {} },
|
|
||||||
{ 612000, { 852878 }, {} },
|
|
||||||
{ 714000, { 885824 }, {} },
|
|
||||||
{ 816000, { 918770 }, {} },
|
|
||||||
{ 918000, { 951716 }, {} },
|
|
||||||
{ 1020000, { 984662 }, { -2875621, 358099, -8585 } },
|
|
||||||
{ 1122000, { 1017608 }, { -52225, 104159, -2816 } },
|
|
||||||
{ 1224000, { 1050554 }, { 1076868, 8356, -727 } },
|
|
||||||
{ 1326000, { 1083500 }, { 2208191, -84659, 1240 } },
|
|
||||||
{ 1428000, { 1116446 }, { 2519460, -105063, 1611 } },
|
|
||||||
{ 1581000, { 1130000 }, { 2889664, -122173, 1834 } },
|
|
||||||
{ 1683000, { 1168000 }, { 5100873, -279186, 4747 } },
|
|
||||||
{ 1785000, { 1227500 }, { 5100873, -279186, 4747 } },
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr u32 CpuVoltL4T = 1235'000;
|
|
||||||
|
|
||||||
constexpr cpu_freq_cvb_table_t CpuCvbTableAppend[] = {
|
|
||||||
{ 1887000, { CpuVoltL4T }, { 5100873, -279186, 4747 } },
|
|
||||||
{ 1963500, { CpuVoltL4T }, { 5100873, -279186, 4747 } },
|
|
||||||
{ 2091000, { CpuVoltL4T }, { 5100873, -279186, 4747 } },
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr u32 CpuMinVolts[] = { 950, 850, 825, 810 };
|
|
||||||
|
|
||||||
inline bool CpuMaxVoltPatternFn(u32* ptr32) {
|
|
||||||
u32 val = *ptr32;
|
|
||||||
return (val == 1132 || val == 1170 || val == 1227);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr u32 MemVoltHOS = 1125'000;
|
|
||||||
constexpr u32 EmcClkPllmLimit = 1866'000'000;
|
|
||||||
|
|
||||||
constexpr u32 MTC_TABLE_REV = 7;
|
|
||||||
|
|
||||||
void Patch(uintptr_t mapped_nso, size_t nso_size);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pcv_mariko.hpp"
|
#include "pcv.hpp"
|
||||||
|
|
||||||
namespace ams::ldr::oc::pcv::mariko {
|
namespace ams::ldr::oc::pcv::mariko {
|
||||||
|
|
||||||
@@ -26,37 +26,7 @@ Result CpuFreqVdd(u32* ptr) {
|
|||||||
R_UNLESS(entry->step_mv == 5000, ldr::ResultInvalidCpuFreqVddEntry());
|
R_UNLESS(entry->step_mv == 5000, ldr::ResultInvalidCpuFreqVddEntry());
|
||||||
R_UNLESS(entry->max_mv == 1525'000, ldr::ResultInvalidCpuFreqVddEntry());
|
R_UNLESS(entry->max_mv == 1525'000, ldr::ResultInvalidCpuFreqVddEntry());
|
||||||
|
|
||||||
if (!C.marikoCpuMaxClock)
|
PATCH_OFFSET(ptr, GetDvfsTableLastEntry(C.marikoCpuDvfsTable)->freq);
|
||||||
R_SKIP();
|
|
||||||
|
|
||||||
PatchOffset(ptr, C.marikoCpuMaxClock);
|
|
||||||
|
|
||||||
R_SUCCEED();
|
|
||||||
}
|
|
||||||
|
|
||||||
Result CpuFreqCvbTable(u32* ptr) {
|
|
||||||
cpu_freq_cvb_table_t* default_end = reinterpret_cast<cpu_freq_cvb_table_t *>(ptr);
|
|
||||||
cpu_freq_cvb_table_t* new_start = default_end + 1;
|
|
||||||
|
|
||||||
// Validate existing table
|
|
||||||
void* cpu_cvb_table_head = reinterpret_cast<u8 *>(new_start) - sizeof(CpuCvbTableDefault);
|
|
||||||
bool validated = std::memcmp(cpu_cvb_table_head, CpuCvbTableDefault, sizeof(CpuCvbTableDefault)) == 0;
|
|
||||||
R_UNLESS(validated, ldr::ResultInvalidCpuDvfs());
|
|
||||||
|
|
||||||
if (C.marikoCpuMaxClock > CpuClkOfficial)
|
|
||||||
std::memcpy(reinterpret_cast<void *>(new_start), CpuCvbTableAppend, sizeof(CpuCvbTableAppend));
|
|
||||||
|
|
||||||
// Patch CPU max volt in existing and appended CPU dvfs table
|
|
||||||
if (C.marikoCpuMaxVolt) {
|
|
||||||
size_t table_size = (sizeof(CpuCvbTableDefault) + sizeof(CpuCvbTableAppend)) / sizeof(cpu_freq_cvb_table_t);
|
|
||||||
cpu_freq_cvb_table_t* entry = static_cast<cpu_freq_cvb_table_t *>(cpu_cvb_table_head);
|
|
||||||
for (size_t i = 0; i < table_size; i++) {
|
|
||||||
if (entry->cvb_pll_param.c0 == CpuVoltOfficial * 1000) {
|
|
||||||
PatchOffset(reinterpret_cast<u32 *>(&(entry->cvb_pll_param.c0)), C.marikoCpuMaxVolt * 1000);
|
|
||||||
}
|
|
||||||
entry++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
@@ -70,29 +40,12 @@ Result CpuVoltRange(u32* ptr) {
|
|||||||
if (!C.marikoCpuMaxVolt)
|
if (!C.marikoCpuMaxVolt)
|
||||||
R_SKIP();
|
R_SKIP();
|
||||||
|
|
||||||
PatchOffset(ptr, C.marikoCpuMaxVolt);
|
PATCH_OFFSET(ptr, C.marikoCpuMaxVolt);
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
R_THROW(ldr::ResultInvalidCpuMinVolt());
|
R_THROW(ldr::ResultInvalidCpuMinVolt());
|
||||||
}
|
}
|
||||||
|
|
||||||
Result GpuFreqCvbTable(u32* ptr) {
|
|
||||||
gpu_cvb_pll_table_t* default_end = reinterpret_cast<gpu_cvb_pll_table_t *>(ptr);
|
|
||||||
gpu_cvb_pll_table_t* new_start = default_end + 1;
|
|
||||||
|
|
||||||
// Validate existing table
|
|
||||||
void* gpu_cvb_table_head = reinterpret_cast<u8 *>(new_start) - sizeof(GpuCvbTableDefault);
|
|
||||||
bool validated = std::memcmp(gpu_cvb_table_head, GpuCvbTableDefault, sizeof(GpuCvbTableDefault)) == 0;
|
|
||||||
R_UNLESS(validated, ldr::ResultInvalidGpuDvfs());
|
|
||||||
|
|
||||||
if (C.marikoGpuMaxClock <= GpuClkOfficial)
|
|
||||||
R_SKIP();
|
|
||||||
|
|
||||||
std::memcpy(reinterpret_cast<void *>(new_start), GpuCvbTableAppend, sizeof(GpuCvbTableAppend));
|
|
||||||
|
|
||||||
R_SUCCEED();
|
|
||||||
}
|
|
||||||
|
|
||||||
Result GpuFreqMaxAsm(u32* ptr32) {
|
Result GpuFreqMaxAsm(u32* ptr32) {
|
||||||
// Check if both two instructions match the pattern
|
// Check if both two instructions match the pattern
|
||||||
u32 ins1 = *ptr32, ins2 = *(ptr32 + 1);
|
u32 ins1 = *ptr32, ins2 = *(ptr32 + 1);
|
||||||
@@ -104,15 +57,13 @@ Result GpuFreqMaxAsm(u32* ptr32) {
|
|||||||
if (rd != asm_get_rd(ins2))
|
if (rd != asm_get_rd(ins2))
|
||||||
R_THROW(ldr::ResultInvalidGpuFreqMaxPattern());
|
R_THROW(ldr::ResultInvalidGpuFreqMaxPattern());
|
||||||
|
|
||||||
if (!C.marikoGpuMaxClock)
|
u32 max_clock = GetDvfsTableLastEntry(C.marikoGpuDvfsTable)->freq;
|
||||||
R_SKIP();
|
|
||||||
|
|
||||||
u32 asm_patch[2] = {
|
u32 asm_patch[2] = {
|
||||||
asm_set_rd(asm_set_imm16(asm_pattern[0], C.marikoGpuMaxClock), rd),
|
asm_set_rd(asm_set_imm16(asm_pattern[0], max_clock), rd),
|
||||||
asm_set_rd(asm_set_imm16(asm_pattern[1], C.marikoGpuMaxClock >> 16), rd)
|
asm_set_rd(asm_set_imm16(asm_pattern[1], max_clock >> 16), rd)
|
||||||
};
|
};
|
||||||
PatchOffset(ptr32, asm_patch[0]);
|
PATCH_OFFSET(ptr32, asm_patch[0]);
|
||||||
PatchOffset(ptr32 + 1, asm_patch[1]);
|
PATCH_OFFSET(ptr32 + 1, asm_patch[1]);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
@@ -149,7 +100,7 @@ void MemMtcTableAutoAdjust(MarikoMtcTable* table, const MarikoMtcTable* ref) {
|
|||||||
* you'd better calculate timings yourself rather than relying on following algorithm.
|
* you'd better calculate timings yourself rather than relying on following algorithm.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (C.mtcConf == NO_ADJ_ALL)
|
if (C.mtcConf != AUTO_ADJ_SAFE_MARIKO_ONLY && C.mtcConf != AUTO_ADJ_SAFE_MARIKO_ONLY)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#define ADJUST_PROP(TARGET, REF) \
|
#define ADJUST_PROP(TARGET, REF) \
|
||||||
@@ -189,7 +140,7 @@ void MemMtcTableAutoAdjust(MarikoMtcTable* table, const MarikoMtcTable* ref) {
|
|||||||
ADJUST_PARAM_TABLE(table, la_scale_regs.mc_ptsa_grant_decrement, ref);
|
ADJUST_PARAM_TABLE(table, la_scale_regs.mc_ptsa_grant_decrement, ref);
|
||||||
|
|
||||||
/* Timings that are available in or can be derived from LPDDR4X datasheet or TRM */
|
/* Timings that are available in or can be derived from LPDDR4X datasheet or TRM */
|
||||||
const bool use_4266_spec = C.mtcConf == AUTO_ADJ_MARIKO_4266_NO_ADJ_ERISTA;
|
const bool use_4266_spec = C.mtcConf == AUTO_ADJ_4266_MARIKO_ONLY;
|
||||||
// tCK_avg (average clock period) in ns
|
// tCK_avg (average clock period) in ns
|
||||||
const double tCK_avg = 1000'000. / C.marikoEmcMaxClock;
|
const double tCK_avg = 1000'000. / C.marikoEmcMaxClock;
|
||||||
// tRPpb (row precharge time per bank) in ns
|
// tRPpb (row precharge time per bank) in ns
|
||||||
@@ -335,7 +286,12 @@ Result MemFreqMtcTable(u32* ptr) {
|
|||||||
|
|
||||||
delete tmp;
|
delete tmp;
|
||||||
|
|
||||||
PatchOffset(ptr, C.marikoEmcMaxClock);
|
PATCH_OFFSET(ptr, C.marikoEmcMaxClock);
|
||||||
|
|
||||||
|
// Handle customize table replacement
|
||||||
|
if (C.mtcConf == CUSTOMIZED_ALL) {
|
||||||
|
MemMtcCustomizeTable(table_list[0], reinterpret_cast<MarikoMtcTable *>(reinterpret_cast<u8 *>(C.marikoMtcTable)));
|
||||||
|
}
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
@@ -367,7 +323,7 @@ Result MemFreqMax(u32* ptr) {
|
|||||||
if (C.marikoEmcMaxClock <= EmcClkOSLimit)
|
if (C.marikoEmcMaxClock <= EmcClkOSLimit)
|
||||||
R_SKIP();
|
R_SKIP();
|
||||||
|
|
||||||
PatchOffset(ptr, C.marikoEmcMaxClock);
|
PATCH_OFFSET(ptr, C.marikoEmcMaxClock);
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,7 +340,7 @@ Result EmcVddqVolt(u32* ptr) {
|
|||||||
R_UNLESS(entry->type_2_3.min_uv == uv_min, ldr::ResultInvalidRegulatorEntry());
|
R_UNLESS(entry->type_2_3.min_uv == uv_min, ldr::ResultInvalidRegulatorEntry());
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
};
|
};
|
||||||
|
|
||||||
R_TRY(validator());
|
R_TRY(validator());
|
||||||
|
|
||||||
u32 emc_uv = C.marikoEmcVddqVolt;
|
u32 emc_uv = C.marikoEmcVddqVolt;
|
||||||
@@ -394,25 +350,28 @@ Result EmcVddqVolt(u32* ptr) {
|
|||||||
if (emc_uv % uv_step)
|
if (emc_uv % uv_step)
|
||||||
emc_uv = emc_uv / uv_step * uv_step; // rounding
|
emc_uv = emc_uv / uv_step * uv_step; // rounding
|
||||||
|
|
||||||
PatchOffset(ptr, emc_uv);
|
PATCH_OFFSET(ptr, emc_uv);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
||||||
|
u32 CpuCvbDefaultMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(CpuCvbTableDefault)->freq);
|
||||||
|
u32 GpuCvbDefaultMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(GpuCvbTableDefault)->freq);
|
||||||
|
|
||||||
PatcherEntry<u32> patches[] = {
|
PatcherEntry<u32> patches[] = {
|
||||||
{ "CPU Freq Vdd", &CpuFreqVdd, 1, nullptr, CpuClkOSLimit },
|
{ "CPU Freq Vdd", &CpuFreqVdd, 1, nullptr, CpuClkOSLimit },
|
||||||
{ "CPU Freq Table", &CpuFreqCvbTable, 1, nullptr, CpuClkOfficial },
|
{ "CPU Freq Table", CpuFreqCvbTable<true>, 1, nullptr, CpuCvbDefaultMaxFreq },
|
||||||
{ "CPU Volt Limit", &CpuVoltRange, 13, nullptr, CpuVoltOfficial },
|
{ "CPU Volt Limit", &CpuVoltRange, 13, nullptr, CpuVoltOfficial },
|
||||||
{ "GPU Freq Table", &GpuFreqCvbTable, 1, nullptr, GpuClkOfficial },
|
{ "GPU Freq Table", GpuFreqCvbTable<true>, 1, nullptr, GpuCvbDefaultMaxFreq },
|
||||||
{ "GPU Freq Asm", &GpuFreqMaxAsm, 2, &GpuMaxClockPatternFn },
|
{ "GPU Freq Asm", &GpuFreqMaxAsm, 2, &GpuMaxClockPatternFn },
|
||||||
{ "GPU Freq PLL", &GpuFreqPllLimit, 1, nullptr, GpuClkPllLimit },
|
{ "GPU Freq PLL", &GpuFreqPllLimit, 1, nullptr, GpuClkPllLimit },
|
||||||
{ "MEM Freq Mtc", &MemFreqMtcTable, 0, nullptr, EmcClkOSLimit },
|
{ "MEM Freq Mtc", &MemFreqMtcTable, 0, nullptr, EmcClkOSLimit },
|
||||||
{ "MEM Freq Dvb", &MemFreqDvbTable, 1, nullptr, EmcClkOSLimit },
|
{ "MEM Freq Dvb", &MemFreqDvbTable, 1, nullptr, EmcClkOSLimit },
|
||||||
{ "MEM Freq Max", &MemFreqMax, 0, nullptr, EmcClkOSLimit },
|
{ "MEM Freq Max", &MemFreqMax, 0, nullptr, EmcClkOSLimit },
|
||||||
{ "MEM Freq PLLM", &MemFreqPllmLimit, 2, nullptr, EmcClkPllmLimit },
|
{ "MEM Freq PLLM", &MemFreqPllmLimit, 2, nullptr, EmcClkPllmLimit },
|
||||||
{ "MEM Vddq", &EmcVddqVolt, 2, nullptr, EmcVddqDefault },
|
{ "MEM Vddq", &EmcVddqVolt, 2, nullptr, EmcVddqDefault },
|
||||||
{ "MEM Vdd2", &MemVoltHandler, 2, nullptr, MemVdd2Default }
|
{ "MEM Vdd2", &MemVoltHandler, 2, nullptr, MemVdd2Default }
|
||||||
};
|
};
|
||||||
|
|
||||||
for (uintptr_t ptr = mapped_nso;
|
for (uintptr_t ptr = mapped_nso;
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) Switch-OC-Suite
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms and conditions of the GNU General Public License,
|
|
||||||
* version 2, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "pcv.hpp"
|
|
||||||
|
|
||||||
namespace ams::ldr::oc::pcv::mariko {
|
|
||||||
|
|
||||||
constexpr cpu_freq_cvb_table_t CpuCvbTableDefault[] = {
|
|
||||||
// CPUB01_CVB_TABLE
|
|
||||||
{ 204000, { 721589, -12695, 27 }, {} },
|
|
||||||
{ 306000, { 747134, -14195, 27 }, {} },
|
|
||||||
{ 408000, { 776324, -15705, 27 }, {} },
|
|
||||||
{ 510000, { 809160, -17205, 27 }, {} },
|
|
||||||
{ 612000, { 845641, -18715, 27 }, {} },
|
|
||||||
{ 714000, { 885768, -20215, 27 }, {} },
|
|
||||||
{ 816000, { 929540, -21725, 27 }, {} },
|
|
||||||
{ 918000, { 976958, -23225, 27 }, {} },
|
|
||||||
{ 1020000, { 1028021, -24725, 27 }, { 1120000 } },
|
|
||||||
{ 1122000, { 1082730, -26235, 27 }, { 1120000 } },
|
|
||||||
{ 1224000, { 1141084, -27735, 27 }, { 1120000 } },
|
|
||||||
{ 1326000, { 1203084, -29245, 27 }, { 1120000 } },
|
|
||||||
{ 1428000, { 1268729, -30745, 27 }, { 1120000 } },
|
|
||||||
{ 1581000, { 1374032, -33005, 27 }, { 1120000 } },
|
|
||||||
{ 1683000, { 1448791, -34505, 27 }, { 1120000 } },
|
|
||||||
{ 1785000, { 1527196, -36015, 27 }, { 1120000 } },
|
|
||||||
{ 1887000, { 1609246, -37515, 27 }, { 1120000 } },
|
|
||||||
{ 1963500, { 1675751, -38635, 27 }, { 1120000 } },
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr cpu_freq_cvb_table_t CpuCvbTableAppend[] = {
|
|
||||||
{ 2091000, { 1716501, -39395, 27 }, { 1120000 } },
|
|
||||||
{ 2193000, { 1775132, -40505, 27 }, { 1120000 } },
|
|
||||||
{ 2295000, { 1866287, -42005, 27 }, { 1120000 } },
|
|
||||||
// 2397000 kHz is not listed in l4t
|
|
||||||
{ 2397000, { 1961107, -43506, 27 }, { 1120000 } },
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr u32 CpuMinVolts[] = { 800, 637, 620, 610 };
|
|
||||||
|
|
||||||
constexpr u32 CpuClkOfficial = 1963'500;
|
|
||||||
constexpr u32 CpuVoltOfficial = 1120;
|
|
||||||
|
|
||||||
constexpr gpu_cvb_pll_table_t GpuCvbTableDefault[] = {
|
|
||||||
// GPUB01_NA_CVB_TABLE
|
|
||||||
{ 76800, {}, { 610000, } },
|
|
||||||
{ 153600, {}, { 610000, } },
|
|
||||||
{ 230400, {}, { 610000, } },
|
|
||||||
{ 307200, {}, { 610000, } },
|
|
||||||
{ 384000, {}, { 610000, } },
|
|
||||||
{ 460800, {}, { 610000, } },
|
|
||||||
{ 537600, {}, { 801688, -10900, -163, 298, -10599, 162 } },
|
|
||||||
{ 614400, {}, { 824214, -5743, -452, 238, -6325, 81 } },
|
|
||||||
{ 691200, {}, { 848830, -3903, -552, 119, -4030, -2 } },
|
|
||||||
{ 768000, {}, { 891575, -4409, -584, 0, -2849, 39 } },
|
|
||||||
{ 844800, {}, { 940071, -5367, -602, -60, -63, -93 } },
|
|
||||||
{ 921600, {}, { 986765, -6637, -614, -179, 1905, -13 } },
|
|
||||||
{ 998400, {}, { 1098475, -13529, -497, -179, 3626, 9 } },
|
|
||||||
{ 1075200, {}, { 1163644, -12688, -648, 0, 1077, 40 } },
|
|
||||||
{ 1152000, {}, { 1204812, -9908, -830, 0, 1469, 110 } },
|
|
||||||
{ 1228800, {}, { 1277303, -11675, -859, 0, 3722, 313 } },
|
|
||||||
{ 1267200, {}, { 1335531, -12567, -867, 0, 3681, 559 } },
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr gpu_cvb_pll_table_t GpuCvbTableAppend[] = {
|
|
||||||
// 1305600 kHz is not listed in l4t
|
|
||||||
{ 1305600, {}, { 1374130, -13725, -859, 0, 4442, 576 } },
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr u32 GpuClkOfficial = 1267'200;
|
|
||||||
constexpr u32 GpuClkPllLimit = 1300'000'000;
|
|
||||||
|
|
||||||
/* GPU Max Clock asm Pattern:
|
|
||||||
*
|
|
||||||
* MOV W11, #0x1000 MOV (wide immediate) 0x1000 0xB (11)
|
|
||||||
* sf | opc | | hw | imm16 | Rd
|
|
||||||
* #31 |30 29|28 27 26 25 24 23|22 21|20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 |4 3 2 1 0
|
|
||||||
* 0 | 1 0 | 1 0 0 1 0 1| 0 0| 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 |0 1 0 1 1
|
|
||||||
*
|
|
||||||
* MOVK W11, #0xE, LSL#16 <shift>16 0xE 0xB (11)
|
|
||||||
* sf | opc | | hw | imm16 | Rd
|
|
||||||
* #31 |30 29|28 27 26 25 24 23|22 21|20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 |4 3 2 1 0
|
|
||||||
* 0 | 1 1 | 1 0 0 1 0 1| 0 1| 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 |0 1 0 1 1
|
|
||||||
*/
|
|
||||||
inline constexpr u32 asm_pattern[] = { 0x52820000, 0x72A001C0 };
|
|
||||||
inline auto asm_compare_no_rd = [](u32 ins1, u32 ins2) { return ((ins1 ^ ins2) >> 5) == 0; };
|
|
||||||
inline auto asm_get_rd = [](u32 ins) { return ins & ((1 << 5) - 1); };
|
|
||||||
inline auto asm_set_rd = [](u32 ins, u8 rd) { return (ins & 0xFFFFFFE0) | (rd & 0x1F); };
|
|
||||||
inline auto asm_set_imm16 = [](u32 ins, u16 imm) { return (ins & 0xFFE0001F) | ((imm & 0xFFFF) << 5); };
|
|
||||||
|
|
||||||
inline bool GpuMaxClockPatternFn(u32* ptr32) {
|
|
||||||
return asm_compare_no_rd(*ptr32, asm_pattern[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr emc_dvb_dvfs_table_t EmcDvbTableDefault[] = {
|
|
||||||
{ 204000, { 637, 637, 637, } },
|
|
||||||
{ 408000, { 637, 637, 637, } },
|
|
||||||
{ 800000, { 637, 637, 637, } },
|
|
||||||
{ 1065600, { 637, 637, 637, } },
|
|
||||||
{ 1331200, { 650, 637, 637, } },
|
|
||||||
{ 1600000, { 675, 650, 637, } },
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr u32 EmcClkOSAlt = 1331'200;
|
|
||||||
constexpr u32 EmcClkPllmLimit = 2133'000'000;
|
|
||||||
constexpr u32 EmcVddqDefault = 600'000;
|
|
||||||
constexpr u32 MemVdd2Default = 1100'000;
|
|
||||||
|
|
||||||
constexpr u32 MTC_TABLE_REV = 3;
|
|
||||||
|
|
||||||
void Patch(uintptr_t mapped_nso, size_t nso_size);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -19,20 +19,20 @@
|
|||||||
namespace ams::ldr::oc::ptm {
|
namespace ams::ldr::oc::ptm {
|
||||||
|
|
||||||
Result CpuPtmBoost(perf_conf_entry* entry) {
|
Result CpuPtmBoost(perf_conf_entry* entry) {
|
||||||
if (!C.marikoCpuBoostClock)
|
if (!C.commonCpuBoostClock)
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
|
|
||||||
u32 cpuPtmBoostNew = C.marikoCpuBoostClock * 1000;
|
u32 cpuPtmBoostNew = C.commonCpuBoostClock * 1000;
|
||||||
|
|
||||||
PatchOffset(&(entry->cpu_freq_1), cpuPtmBoostNew);
|
PATCH_OFFSET(&(entry->cpu_freq_1), cpuPtmBoostNew);
|
||||||
PatchOffset(&(entry->cpu_freq_2), cpuPtmBoostNew);
|
PATCH_OFFSET(&(entry->cpu_freq_2), cpuPtmBoostNew);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result MemPtm(perf_conf_entry* entry) {
|
Result MemPtm(perf_conf_entry* entry) {
|
||||||
PatchOffset(&(entry->emc_freq_1), memPtmLimit);
|
PATCH_OFFSET(&(entry->emc_freq_1), memPtmLimit);
|
||||||
PatchOffset(&(entry->emc_freq_2), memPtmLimit);
|
PATCH_OFFSET(&(entry->emc_freq_2), memPtmLimit);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
@@ -52,13 +52,6 @@ bool PtmTablePatternFn(u32* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
||||||
#ifdef ATMOSPHERE_IS_STRATOSPHERE
|
|
||||||
// Ptm patcher is disabled for Erista
|
|
||||||
bool isMariko = (spl::GetSocType() == spl::SocType_Mariko);
|
|
||||||
if (!isMariko)
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
perf_conf_entry* confTable = nullptr;
|
perf_conf_entry* confTable = nullptr;
|
||||||
for (uintptr_t ptr = mapped_nso;
|
for (uintptr_t ptr = mapped_nso;
|
||||||
ptr <= mapped_nso + nso_size - sizeof(perf_conf_entry) * entryCnt;
|
ptr <= mapped_nso + nso_size - sizeof(perf_conf_entry) * entryCnt;
|
||||||
@@ -75,10 +68,15 @@ void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
|||||||
CRASH("confTable not found!");
|
CRASH("confTable not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
PatcherEntry<perf_conf_entry> patches[] = {
|
PatcherEntry<perf_conf_entry> cpuPtmBoostPatch = { "CPU Ptm Boost", &CpuPtmBoost, 2, };
|
||||||
{ "CPU Ptm Boost", &CpuPtmBoost, 2, },
|
PatcherEntry<perf_conf_entry> memPtmPatch = { "MEM Ptm", &MemPtm, 16, };
|
||||||
{ "MEM Ptm", &MemPtm, 16, },
|
|
||||||
};
|
#ifdef ATMOSPHERE_IS_STRATOSPHERE
|
||||||
|
bool isMariko = (spl::GetSocType() == spl::SocType_Mariko);
|
||||||
|
#else
|
||||||
|
bool isMariko = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
for (u32 i = 0; i < entryCnt; i++) {
|
for (u32 i = 0; i < entryCnt; i++) {
|
||||||
perf_conf_entry* entry = confTable + i;
|
perf_conf_entry* entry = confTable + i;
|
||||||
@@ -90,7 +88,7 @@ void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
|||||||
|
|
||||||
switch (entry->cpu_freq_1) {
|
switch (entry->cpu_freq_1) {
|
||||||
case cpuPtmBoost:
|
case cpuPtmBoost:
|
||||||
patches[0].Apply(entry);
|
cpuPtmBoostPatch.Apply(entry);
|
||||||
break;
|
break;
|
||||||
case cpuPtmDefault:
|
case cpuPtmDefault:
|
||||||
case cpuPtmDevOC:
|
case cpuPtmDevOC:
|
||||||
@@ -104,7 +102,9 @@ void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
|||||||
case memPtmLimit:
|
case memPtmLimit:
|
||||||
case memPtmAlt:
|
case memPtmAlt:
|
||||||
case memPtmClamp:
|
case memPtmClamp:
|
||||||
patches[1].Apply(entry);
|
if (isMariko) {
|
||||||
|
memPtmPatch.Apply(entry);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOGGING("%u (0x%08x) @%p", entry->emc_freq_1, entry->conf_id, &(entry->emc_freq_2));
|
LOGGING("%u (0x%08x) @%p", entry->emc_freq_1, entry->conf_id, &(entry->emc_freq_2));
|
||||||
@@ -112,10 +112,14 @@ void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& patch : patches) {
|
LOGGING("%s Count: %zu", cpuPtmBoostPatch.description, cpuPtmBoostPatch.patched_count);
|
||||||
LOGGING("%s Count: %zu", patch.description, patch.patched_count);
|
if (R_FAILED(cpuPtmBoostPatch.CheckResult()))
|
||||||
if (R_FAILED(patch.CheckResult()))
|
CRASH(cpuPtmBoostPatch.description);
|
||||||
CRASH(patch.description);
|
|
||||||
|
if (isMariko) {
|
||||||
|
LOGGING("%s Count: %zu", memPtmPatch.description, memPtmPatch.patched_count);
|
||||||
|
if (R_FAILED(memPtmPatch.CheckResult()))
|
||||||
|
CRASH(memPtmPatch.description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,176 +1,242 @@
|
|||||||
diff --git a/.gitignore b/.gitignore
|
|
||||||
index 3e35c18..6b42bc5 100644
|
|
||||||
--- a/.gitignore
|
|
||||||
+++ b/.gitignore
|
|
||||||
@@ -8,3 +8,4 @@ build/
|
|
||||||
*.nacp
|
|
||||||
|
|
||||||
*.nro
|
|
||||||
+*.DS_Store
|
|
||||||
diff --git a/Overlay/Makefile b/Overlay/Makefile
|
diff --git a/Overlay/Makefile b/Overlay/Makefile
|
||||||
index f881ed9..7184bb0 100644
|
index 5a2c2af..140130b 100644
|
||||||
--- a/Overlay/Makefile
|
--- a/Overlay/Makefile
|
||||||
+++ b/Overlay/Makefile
|
+++ b/Overlay/Makefile
|
||||||
@@ -38,7 +38,7 @@ include $(DEVKITPRO)/libnx/switch_rules
|
@@ -38,7 +38,7 @@ include $(DEVKITPRO)/libnx/switch_rules
|
||||||
# NACP building is skipped as well.
|
# NACP building is skipped as well.
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
APP_TITLE := ReverseNX-RT
|
APP_TITLE := ReverseNX-RT
|
||||||
-APP_VERSION := 1.0.1
|
-APP_VERSION := 1.0.2
|
||||||
+APP_VERSION := 1.0.2-OC
|
+APP_VERSION := 1.1.0-OC
|
||||||
|
|
||||||
TARGET := ReverseNX-RT-ovl
|
TARGET := ReverseNX-RT-ovl
|
||||||
BUILD := build
|
BUILD := build
|
||||||
@@ -53,7 +53,7 @@ NO_ICON := 1
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
|
|
||||||
|
|
||||||
-CFLAGS := -g -Wall -Os -ffunction-sections \
|
|
||||||
+CFLAGS := -g -Wall -O2 -ffunction-sections \
|
|
||||||
$(ARCH) $(DEFINES)
|
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -D__SWITCH__ -DAPP_VERSION="\"$(APP_VERSION)\""
|
|
||||||
diff --git a/Overlay/libs/Atmosphere-libs b/Overlay/libs/Atmosphere-libs
|
diff --git a/Overlay/libs/Atmosphere-libs b/Overlay/libs/Atmosphere-libs
|
||||||
index 2d522dc..c4d0335 160000
|
index 2d522dc..af0d008 160000
|
||||||
--- a/Overlay/libs/Atmosphere-libs
|
--- a/Overlay/libs/Atmosphere-libs
|
||||||
+++ b/Overlay/libs/Atmosphere-libs
|
+++ b/Overlay/libs/Atmosphere-libs
|
||||||
@@ -1 +1 @@
|
@@ -1 +1 @@
|
||||||
-Subproject commit 2d522dc6a12b2eb5eb3f103a8c5b5126ca301b1a
|
-Subproject commit 2d522dc6a12b2eb5eb3f103a8c5b5126ca301b1a
|
||||||
+Subproject commit c4d0335b79da7207b49abf1988f45b0168b692f0
|
+Subproject commit af0d008900128d8679b80569f69fe562ed7d6681
|
||||||
diff --git a/Overlay/libs/libtesla b/Overlay/libs/libtesla
|
|
||||||
index 6628524..640629f 160000
|
|
||||||
--- a/Overlay/libs/libtesla
|
|
||||||
+++ b/Overlay/libs/libtesla
|
|
||||||
@@ -1 +1 @@
|
|
||||||
-Subproject commit 66285245361a02e5480c7bb7dac9ef6449ae6181
|
|
||||||
+Subproject commit 640629f49f9e8997ef0769b21b26f4fc177c736f
|
|
||||||
diff --git a/Overlay/source/main.cpp b/Overlay/source/main.cpp
|
diff --git a/Overlay/source/main.cpp b/Overlay/source/main.cpp
|
||||||
index cec060c..13818bb 100644
|
index 810295c..87b6685 100644
|
||||||
--- a/Overlay/source/main.cpp
|
--- a/Overlay/source/main.cpp
|
||||||
+++ b/Overlay/source/main.cpp
|
+++ b/Overlay/source/main.cpp
|
||||||
@@ -1,9 +1,12 @@
|
@@ -1,7 +1,196 @@
|
||||||
#define TESLA_INIT_IMPL // If you have more than one file using the tesla header, only define this in the main one
|
#define TESLA_INIT_IMPL // If you have more than one file using the tesla header, only define this in the main one
|
||||||
#include <tesla.hpp> // The Tesla Header
|
#include <tesla.hpp> // The Tesla Header
|
||||||
+#include <atomic>
|
+#include <atomic>
|
||||||
#include "dmntcht.h"
|
#include "SaltyNX.h"
|
||||||
|
|
||||||
bool def = true;
|
+class ModeSync {
|
||||||
+bool defChanged = false;
|
+public:
|
||||||
bool isDocked = false;
|
+ enum ReverseNXMode {
|
||||||
+bool isDockedChanged = false;
|
+ ReverseNX_NotValid = 0,
|
||||||
bool PluginRunning = false;
|
+ ReverseNX_SystemDefault = 0,
|
||||||
bool closed = false;
|
+ ReverseNX_Handheld,
|
||||||
Handle debug;
|
+ ReverseNX_Docked,
|
||||||
@@ -20,6 +23,11 @@ bool plugin = false;
|
+ ReverseNX_Undefined,
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ void SetMode(bool isDefault, bool setDock, char* descBuf, size_t bufSize) {
|
||||||
|
+ auto changeHandler = [this](ReverseNXMode newMode) {
|
||||||
|
+ if (this->currentMode == ReverseNX_Undefined || this->currentMode != newMode) {
|
||||||
|
+ if (R_FAILED(this->ipc->SetMode(newMode))) {
|
||||||
|
+ this->ipc->ipcStatus = Ipc::IpcStatus_ConnectFailed;
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ this->currentMode = newMode;
|
||||||
|
+ }
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ tsl::hlp::ScopeGuard updateBufGuard([&] { this->ipc->UpdateStatusDesc(descBuf, bufSize); });
|
||||||
|
+
|
||||||
|
+ if (isDefault) {
|
||||||
|
+ changeHandler(ReverseNX_SystemDefault);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ changeHandler(setDock ? ReverseNX_Docked : ReverseNX_Handheld);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ModeSync() {
|
||||||
|
+ this->ipc = new Ipc;
|
||||||
|
+ this->ipc->Init();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ~ModeSync() {
|
||||||
|
+ this->ipc->Exit();
|
||||||
|
+ delete this->ipc;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+protected:
|
||||||
|
+ struct Ipc {
|
||||||
|
+ #define API_VER 2
|
||||||
|
+ #define SERVICE_NAME "sysclkOC"
|
||||||
|
+
|
||||||
|
+ enum SysClkIpcCmd {
|
||||||
|
+ SysClkIpcCmd_GetApiVersion = 0,
|
||||||
|
+ SysClkIpcCmd_GetConfigValues = 9,
|
||||||
|
+ SysClkIpcCmd_SetReverseNXRTMode = 11,
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ enum SysClkConfigValue {
|
||||||
|
+ SysClkConfigValue_SyncReverseNXMode = 4,
|
||||||
|
+ SysClkConfigValue_EnumMax = 8,
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ struct SysClkConfigValueList {
|
||||||
|
+ uint64_t values[SysClkConfigValue_EnumMax];
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ enum IpcStatus {
|
||||||
|
+ IpcStatus_OK,
|
||||||
|
+
|
||||||
|
+ IpcStatus_Unknown,
|
||||||
|
+ IpcStatus_NotRunning,
|
||||||
|
+ IpcStatus_InitFailed,
|
||||||
|
+ IpcStatus_ConnectFailed,
|
||||||
|
+ IpcStatus_UnsupportedVer,
|
||||||
|
+
|
||||||
|
+ IpcStatus_Count,
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ static constexpr const char* IpcStatusStr[IpcStatus_Count] = {
|
||||||
|
+ "",
|
||||||
|
+
|
||||||
|
+ "Unknown",
|
||||||
|
+ "Err: Not running",
|
||||||
|
+ "Err: Failed to init",
|
||||||
|
+ "Err: Failed to connect",
|
||||||
|
+ "Err: Unsupported version",
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ Result Init() {
|
||||||
|
+ Result rc = 0;
|
||||||
|
+ refCnt++;
|
||||||
|
+
|
||||||
|
+ if (serviceIsActive(&service))
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ rc = smGetService(&service, SERVICE_NAME);
|
||||||
|
+
|
||||||
|
+ if (R_FAILED(rc)) {
|
||||||
|
+ this->Exit();
|
||||||
|
+ return rc;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ rc = GetStatus();
|
||||||
|
+ return rc;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ void Exit() {
|
||||||
|
+ if (--refCnt == 0)
|
||||||
|
+ serviceClose(&service);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ bool IsServiceRunning() {
|
||||||
|
+ Handle handle;
|
||||||
|
+ SmServiceName name = smEncodeName(SERVICE_NAME);
|
||||||
|
+ if (R_FAILED(smRegisterService(&handle, name, false, 1))) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ svcCloseHandle(handle);
|
||||||
|
+ smUnregisterService(name);
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ Result GetApiVersion(u32* outVer) {
|
||||||
|
+ return serviceDispatchOut(&service, SysClkIpcCmd_GetApiVersion, *outVer);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ Result GetConfigValues(SysClkConfigValueList* outConfigValues) {
|
||||||
|
+ return serviceDispatchOut(&service, SysClkIpcCmd_GetConfigValues, *outConfigValues);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ Result SetMode(ReverseNXMode mode) {
|
||||||
|
+ return serviceDispatchIn(&service, SysClkIpcCmd_SetReverseNXRTMode, mode);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ Result GetStatus() {
|
||||||
|
+ if (!IsServiceRunning()) {
|
||||||
|
+ this->ipcStatus = IpcStatus_NotRunning;
|
||||||
|
+ return this->ipcStatus;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (R_FAILED(this->Init())) {
|
||||||
|
+ this->ipcStatus = IpcStatus_InitFailed;
|
||||||
|
+ return this->ipcStatus;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ tsl::hlp::ScopeGuard exitSrvGuard([&] { this->Exit(); });
|
||||||
|
+
|
||||||
|
+ uint32_t api_ver;
|
||||||
|
+ if (R_FAILED(GetApiVersion(&api_ver))) {
|
||||||
|
+ this->ipcStatus = IpcStatus_ConnectFailed;
|
||||||
|
+ return this->ipcStatus;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (api_ver != API_VER) {
|
||||||
|
+ this->ipcStatus = IpcStatus_UnsupportedVer;
|
||||||
|
+ return this->ipcStatus;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ SysClkConfigValueList* list = new SysClkConfigValueList;
|
||||||
|
+ tsl::hlp::ScopeGuard listGuard([&] { delete list; });
|
||||||
|
+
|
||||||
|
+ if (R_FAILED(GetConfigValues(list))) {
|
||||||
|
+ this->ipcStatus = IpcStatus_ConnectFailed;
|
||||||
|
+ return this->ipcStatus;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ exitSrvGuard.dismiss();
|
||||||
|
+
|
||||||
|
+ shouldSync = bool(list->values[SysClkConfigValue_SyncReverseNXMode]);
|
||||||
|
+ this->ipcStatus = IpcStatus_OK;
|
||||||
|
+ return this->ipcStatus;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ void UpdateStatusDesc(char* buffer, size_t size) {
|
||||||
|
+ snprintf(buffer, size,
|
||||||
|
+ "Mode Sync: %s%s",
|
||||||
|
+ IpcStatusStr[ipcStatus],
|
||||||
|
+ (ipcStatus == IpcStatus_OK) ? (
|
||||||
|
+ shouldSync ? "ON" : "OFF"
|
||||||
|
+ ) : ""
|
||||||
|
+ );
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ Service service;
|
||||||
|
+ std::atomic<std::size_t> refCnt;
|
||||||
|
+ IpcStatus ipcStatus = IpcStatus_Unknown;
|
||||||
|
+ bool shouldSync;
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ Ipc* ipc = nullptr;
|
||||||
|
+ ReverseNXMode currentMode = ReverseNX_Undefined;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
bool* def = 0;
|
||||||
|
bool* isDocked = 0;
|
||||||
|
bool* pluginActive = 0;
|
||||||
|
@@ -17,6 +206,7 @@ bool plugin = false;
|
||||||
char DockedChar[32];
|
char DockedChar[32];
|
||||||
char SystemChar[32];
|
char SystemChar[32];
|
||||||
char PluginChar[36];
|
char PluginChar[36];
|
||||||
+char SysclkChar[36];
|
+char SysclkChar[0x40];
|
||||||
+static Service g_sysclkSrv;
|
uint64_t PID = 0;
|
||||||
+static std::atomic<std::size_t> g_refCnt;
|
Handle remoteSharedMemory = 1;
|
||||||
+bool sysclkComm = false;
|
SharedMemory _sharedmemory = {};
|
||||||
+bool sysclkSync = false;
|
@@ -73,7 +263,7 @@ bool CheckPort () {
|
||||||
|
|
||||||
bool CheckPort () {
|
|
||||||
Handle saltysd;
|
|
||||||
@@ -43,17 +51,84 @@ bool CheckPort () {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
-bool isServiceRunning(const char *serviceName) {
|
|
||||||
- Handle handle;
|
|
||||||
- SmServiceName service_name = smEncodeName(serviceName);
|
|
||||||
+bool isServiceRunning(const char *serviceName) {
|
|
||||||
+ Handle handle;
|
|
||||||
+ SmServiceName service_name = smEncodeName(serviceName);
|
|
||||||
if (R_FAILED(smRegisterService(&handle, service_name, false, 1))) return true;
|
|
||||||
else {
|
|
||||||
- svcCloseHandle(handle);
|
|
||||||
+ svcCloseHandle(handle);
|
|
||||||
smUnregisterService(service_name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+#define SYSCLK_IPC_API_VERSION 1
|
|
||||||
+#define SYSCLK_IPC_SERVICE_NAME "sysclkOC"
|
|
||||||
+
|
|
||||||
+enum SysClkIpcCmd
|
|
||||||
+{
|
|
||||||
+ SysClkIpcCmd_GetApiVersion = 0,
|
|
||||||
+ SysClkIpcCmd_GetConfigValues = 9,
|
|
||||||
+ SysClkIpcCmd_SetReverseNXRTMode = 11,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+enum SysClkConfigValue
|
|
||||||
+{
|
|
||||||
+ SysClkConfigValue_SyncReverseNXMode = 4,
|
|
||||||
+ SysClkConfigValue_EnumMax = 8,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+enum ReverseNXMode
|
|
||||||
+{
|
|
||||||
+ ReverseNX_NotValid = 0,
|
|
||||||
+ ReverseNX_SystemDefault = 0,
|
|
||||||
+ ReverseNX_Handheld,
|
|
||||||
+ ReverseNX_Docked,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+struct SysClkConfigValueList
|
|
||||||
+{
|
|
||||||
+ uint64_t values[SysClkConfigValue_EnumMax];
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+void sysclkIpcExit(void)
|
|
||||||
+{
|
|
||||||
+ if (--g_refCnt == 0)
|
|
||||||
+ serviceClose(&g_sysclkSrv);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+Result sysclkIpcInitialize(void)
|
|
||||||
+{
|
|
||||||
+ Result rc = 0;
|
|
||||||
+
|
|
||||||
+ g_refCnt++;
|
|
||||||
+
|
|
||||||
+ if (serviceIsActive(&g_sysclkSrv))
|
|
||||||
+ return 0;
|
|
||||||
+
|
|
||||||
+ rc = smGetService(&g_sysclkSrv, SYSCLK_IPC_SERVICE_NAME);
|
|
||||||
+
|
|
||||||
+ if (R_FAILED(rc))
|
|
||||||
+ sysclkIpcExit();
|
|
||||||
+
|
|
||||||
+ return rc;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+Result sysclkIpcGetAPIVersion(u32* out_ver)
|
|
||||||
+{
|
|
||||||
+ return serviceDispatchOut(&g_sysclkSrv, SysClkIpcCmd_GetApiVersion, *out_ver);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+Result sysclkIpcGetConfigValues(SysClkConfigValueList* out_configValues)
|
|
||||||
+{
|
|
||||||
+ return serviceDispatchOut(&g_sysclkSrv, SysClkIpcCmd_GetConfigValues, *out_configValues);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+Result sysclkIpcSetReverseNXRTMode(ReverseNXMode mode)
|
|
||||||
+{
|
|
||||||
+ return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetReverseNXRTMode, mode);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
class GuiTest : public tsl::Gui {
|
class GuiTest : public tsl::Gui {
|
||||||
public:
|
public:
|
||||||
GuiTest(u8 arg1, u8 arg2, bool arg3) { }
|
- GuiTest(u8 arg1, u8 arg2, bool arg3) { }
|
||||||
@@ -67,7 +142,7 @@ public:
|
+ GuiTest(ModeSync* p) : modeSync(p) { }
|
||||||
|
|
||||||
// A list that can contain sub elements and handles scrolling
|
// Called when this Gui gets loaded to create the UI
|
||||||
auto list = new tsl::elm::List();
|
// Allocate all elements on the heap. libtesla will make sure to clean them up when not needed anymore
|
||||||
-
|
@@ -112,6 +302,7 @@ public:
|
||||||
+
|
|
||||||
list->addItem(new tsl::elm::CustomDrawer([](tsl::gfx::Renderer *renderer, s32 x, s32 y, s32 w, s32 h) {
|
|
||||||
if (SaltySD == false) renderer->drawString("SaltyNX is not working!", false, x, y+50, 20, renderer->a(0xF33F));
|
|
||||||
else if (plugin == false) renderer->drawString("Can't detect ReverseNX-RT plugin!", false, x, y+50, 20, renderer->a(0xF33F));
|
|
||||||
@@ -88,16 +163,18 @@ public:
|
|
||||||
else {
|
else {
|
||||||
renderer->drawString(SystemChar, false, x, y+40, 20, renderer->a(0xFFFF));
|
renderer->drawString(SystemChar, false, x, y+40, 20, renderer->a(0xFFFF));
|
||||||
renderer->drawString(DockedChar, false, x, y+60, 20, renderer->a(0xFFFF));
|
renderer->drawString(DockedChar, false, x, y+60, 20, renderer->a(0xFFFF));
|
||||||
@@ -178,186 +244,47 @@ index cec060c..13818bb 100644
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}), 100);
|
}), 100);
|
||||||
|
@@ -190,6 +381,8 @@ public:
|
||||||
if (MAGIC == 0x06BA7E39) {
|
|
||||||
auto *clickableListItem = new tsl::elm::ListItem("Change system control");
|
if (_def) sprintf(SystemChar, "Controlled by system: Yes");
|
||||||
- clickableListItem->setClickListener([](u64 keys) {
|
else sprintf(SystemChar, "Controlled by system: No");
|
||||||
- if (keys & KEY_A) {
|
|
||||||
+ clickableListItem->setClickListener([](u64 keys) {
|
|
||||||
+ if (keys & HidNpadButton_A) {
|
|
||||||
if (PluginRunning == true) {
|
|
||||||
def = !def;
|
|
||||||
+ defChanged = true;
|
|
||||||
if (dmntcht == true) {
|
|
||||||
dmntchtWriteCheatProcessMemory(def_address, &def, 0x1);
|
|
||||||
dmntchtReadCheatProcessMemory(def_address, &def, 0x1);
|
|
||||||
@@ -117,12 +194,13 @@ public:
|
|
||||||
});
|
|
||||||
|
|
||||||
list->addItem(clickableListItem);
|
|
||||||
-
|
|
||||||
+
|
+
|
||||||
auto *clickableListItem2 = new tsl::elm::ListItem("Change mode");
|
+ modeSync->SetMode(_def, _isDocked, SysclkChar, sizeof(SysclkChar));
|
||||||
- clickableListItem2->setClickListener([](u64 keys) {
|
|
||||||
- if (keys & KEY_A) {
|
|
||||||
+ clickableListItem2->setClickListener([](u64 keys) {
|
|
||||||
+ if (keys & HidNpadButton_A) {
|
|
||||||
if (PluginRunning == true && def == false) {
|
|
||||||
isDocked =! isDocked;
|
|
||||||
+ isDockedChanged = true;
|
|
||||||
if (dmntcht == true) {
|
|
||||||
dmntchtWriteCheatProcessMemory(docked_address, &isDocked, 0x1);
|
|
||||||
dmntchtReadCheatProcessMemory(docked_address, &isDocked, 0x1);
|
|
||||||
@@ -137,15 +215,15 @@ public:
|
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
-
|
|
||||||
+
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
list->addItem(clickableListItem2);
|
|
||||||
}
|
|
||||||
else if (SaltySD == true && plugin == true && check == false) {
|
|
||||||
auto *clickableListItem = new tsl::elm::ListItem("(De)activate plugin");
|
|
||||||
- clickableListItem->setClickListener([](u64 keys) {
|
|
||||||
- if (keys & KEY_A) {
|
|
||||||
+ clickableListItem->setClickListener([](u64 keys) {
|
|
||||||
+ if (keys & HidNpadButton_A) {
|
|
||||||
if (bak == false) {
|
|
||||||
rename("sdmc:/SaltySD/plugins/ReverseNX-RT.elf", "sdmc:/SaltySD/plugins/ReverseNX-RT.elf.bak");
|
|
||||||
bak = true;
|
|
||||||
@@ -156,7 +234,7 @@ public:
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
-
|
|
||||||
+
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
list->addItem(clickableListItem);
|
|
||||||
@@ -164,7 +242,7 @@ public:
|
|
||||||
|
|
||||||
// Add the list to the frame for it to be drawn
|
|
||||||
frame->setContent(list);
|
|
||||||
-
|
|
||||||
+
|
|
||||||
// Return the frame to have it become the top level element of this Gui
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
@@ -179,30 +257,39 @@ public:
|
|
||||||
closed = true;
|
|
||||||
}
|
|
||||||
if (PluginRunning == true) {
|
|
||||||
- if (i > 59) {
|
|
||||||
+ if (i > 29) {
|
|
||||||
if (dmntcht == true) dmntchtReadCheatProcessMemory(docked_address, &isDocked, 0x1);
|
|
||||||
else if (R_SUCCEEDED(svcDebugActiveProcess(&debug, PID))) {
|
|
||||||
svcReadDebugProcessMemory(&isDocked, debug, docked_address, 0x1);
|
|
||||||
svcCloseHandle(debug);
|
|
||||||
}
|
|
||||||
+ if (sysclkComm && !bak) {
|
|
||||||
+ if (!def && isDockedChanged) {
|
|
||||||
+ isDockedChanged = false;
|
|
||||||
+ sysclkIpcSetReverseNXRTMode(isDocked ? ReverseNX_Docked : ReverseNX_Handheld);
|
|
||||||
+ }
|
|
||||||
+ if (def && defChanged) {
|
|
||||||
+ defChanged = false;
|
|
||||||
+ sysclkIpcSetReverseNXRTMode(ReverseNX_SystemDefault);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
i = 0;
|
|
||||||
}
|
}
|
||||||
else i++;
|
else i++;
|
||||||
}
|
}
|
||||||
-
|
@@ -200,6 +393,8 @@ public:
|
||||||
+
|
virtual bool handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft, HidAnalogStickState joyStickPosRight) override {
|
||||||
if (isDocked == true) sprintf(DockedChar, "Mode: Docked");
|
|
||||||
else sprintf(DockedChar, "Mode: Handheld");
|
|
||||||
-
|
|
||||||
+
|
|
||||||
if (def == true) sprintf(SystemChar, "Controlled by system: Yes");
|
|
||||||
else sprintf(SystemChar, "Controlled by system: No");
|
|
||||||
-
|
|
||||||
+
|
|
||||||
if (bak == false) sprintf(PluginChar, "ReverseNX-RT plugin is activated.");
|
|
||||||
else sprintf(PluginChar, "ReverseNX-RT plugin is deactivated.");
|
|
||||||
-
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called once every frame to handle inputs not handled by other UI elements
|
|
||||||
- virtual bool handleInput(u64 keysDown, u64 keysHeld, touchPosition touchInput, JoystickPosition leftJoyStick, JoystickPosition rightJoyStick) override {
|
|
||||||
+ virtual bool handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft, HidAnalogStickState joyStickPosRight) override {
|
|
||||||
return false; // Return true here to singal the inputs have been consumed
|
return false; // Return true here to singal the inputs have been consumed
|
||||||
}
|
}
|
||||||
|
+
|
||||||
|
+ ModeSync* modeSync;
|
||||||
};
|
};
|
||||||
@@ -213,10 +300,10 @@ public:
|
|
||||||
virtual void initServices() override {
|
class OverlayTest : public tsl::Overlay {
|
||||||
smInitialize();
|
@@ -247,10 +442,12 @@ public:
|
||||||
fsdevMountSdmc();
|
|
||||||
-
|
|
||||||
+
|
|
||||||
SaltySD = CheckPort();
|
|
||||||
if (SaltySD == false) return;
|
|
||||||
-
|
|
||||||
+
|
|
||||||
FILE* temp = fopen("sdmc:/SaltySD/plugins/ReverseNX-RT.elf", "r");
|
|
||||||
if (temp != NULL) {
|
|
||||||
fclose(temp);
|
|
||||||
@@ -234,6 +321,20 @@ public:
|
|
||||||
else return;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ sysclkComm = false;
|
|
||||||
+ sysclkSync = false;
|
|
||||||
+ if (isServiceRunning(SYSCLK_IPC_SERVICE_NAME)) {
|
|
||||||
+ uint32_t apiVer;
|
|
||||||
+ if (R_SUCCEEDED(sysclkIpcInitialize()) && R_SUCCEEDED(sysclkIpcGetAPIVersion(&apiVer)) && apiVer == SYSCLK_IPC_API_VERSION) {
|
|
||||||
+ sysclkComm = true;
|
|
||||||
+
|
|
||||||
+ SysClkConfigValueList* list = new SysClkConfigValueList;
|
|
||||||
+ if (R_SUCCEEDED(sysclkIpcGetConfigValues(list)))
|
|
||||||
+ sysclkSync = bool(list->values[SysClkConfigValue_SyncReverseNXMode]);
|
|
||||||
+ delete list;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (R_FAILED(pmdmntGetApplicationProcessId(&PID))) remove("sdmc:/SaltySD/ReverseNX-RT.hex");
|
|
||||||
else {
|
|
||||||
check = true;
|
|
||||||
@@ -244,9 +345,9 @@ public:
|
|
||||||
fread(&def_address, 0x5, 1, offset);
|
|
||||||
fread(&MAGIC_address, 0x5, 1, offset);
|
|
||||||
fclose(offset);
|
|
||||||
-
|
|
||||||
+
|
|
||||||
dmntcht = isServiceRunning("dmnt:cht");
|
|
||||||
-
|
|
||||||
+
|
|
||||||
if (dmntcht == true) {
|
|
||||||
if (R_SUCCEEDED(dmntchtInitialize())) {
|
|
||||||
bool out = false;
|
|
||||||
@@ -272,16 +373,19 @@ public:
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
-
|
});
|
||||||
+
|
-
|
||||||
if (isDocked == true) sprintf(DockedChar, "Mode: Docked");
|
|
||||||
else sprintf(DockedChar, "Mode: Handheld");
|
|
||||||
-
|
|
||||||
+
|
|
||||||
if (def == true) sprintf(SystemChar, "Controlled by system: Yes");
|
|
||||||
else sprintf(SystemChar, "Controlled by system: No");
|
|
||||||
-
|
|
||||||
+
|
|
||||||
+ sprintf(SysclkChar, "Sys-clk-OC Sync: %s", sysclkComm ? (sysclkSync ? "ON" : "OFF") : "UNAVAILABLE");
|
|
||||||
+
|
+
|
||||||
|
+ modeSync = new ModeSync;
|
||||||
} // Called at the start to initialize all services necessary for this Overlay
|
} // Called at the start to initialize all services necessary for this Overlay
|
||||||
-
|
|
||||||
+
|
|
||||||
virtual void exitServices() override {
|
virtual void exitServices() override {
|
||||||
+ sysclkIpcExit();
|
+ delete modeSync;
|
||||||
dmntchtExit();
|
shmemClose(&_sharedmemory);
|
||||||
if (dmntcht == false) svcCloseHandle(debug);
|
|
||||||
fsdevUnmountDevice("sdmc");
|
fsdevUnmountDevice("sdmc");
|
||||||
|
} // Callet at the end to clean up all services previously initialized
|
||||||
|
@@ -260,8 +457,10 @@ public:
|
||||||
|
virtual void onHide() override {} // Called before overlay wants to change from visible to invisible state
|
||||||
|
|
||||||
|
virtual std::unique_ptr<tsl::Gui> loadInitialGui() override {
|
||||||
|
- return initially<GuiTest>(1, 2, true); // Initial Gui to load. It's possible to pass arguments to it's constructor like this
|
||||||
|
+ return initially<GuiTest>(modeSync); // Initial Gui to load. It's possible to pass arguments to it's constructor like this
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ ModeSync* modeSync = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
|||||||
@@ -128,10 +128,6 @@ Copy the `atmosphere`, and `switch` folders at the root of your sdcard, overwrit
|
|||||||
|
|
||||||
`/config/sys-clk/context.csv`
|
`/config/sys-clk/context.csv`
|
||||||
|
|
||||||
* sys-clk manager app (accessible from the hbmenu)
|
|
||||||
|
|
||||||
`/switch/sys-clk-manager.nro`
|
|
||||||
|
|
||||||
* sys-clk overlay (accessible from anywhere by invoking the [Tesla menu](https://gbatemp.net/threads/tesla-the-nintendo-switch-overlay-menu.557362/))
|
* sys-clk overlay (accessible from anywhere by invoking the [Tesla menu](https://gbatemp.net/threads/tesla-the-nintendo-switch-overlay-menu.557362/))
|
||||||
|
|
||||||
`/switch/.overlays/sys-clk-overlay.ovl`
|
`/switch/.overlays/sys-clk-overlay.ovl`
|
||||||
|
|||||||
@@ -23,14 +23,6 @@ mkdir -p "$DIST_DIR/atmosphere/contents/$TITLE_ID/flags"
|
|||||||
cp -vf "$ROOT_DIR/sysmodule/out/sys-clk-OC.nsp" "$DIST_DIR/atmosphere/contents/$TITLE_ID/exefs.nsp"
|
cp -vf "$ROOT_DIR/sysmodule/out/sys-clk-OC.nsp" "$DIST_DIR/atmosphere/contents/$TITLE_ID/exefs.nsp"
|
||||||
>"$DIST_DIR/atmosphere/contents/$TITLE_ID/flags/boot2.flag"
|
>"$DIST_DIR/atmosphere/contents/$TITLE_ID/flags/boot2.flag"
|
||||||
|
|
||||||
echo "*** manager ***"
|
|
||||||
pushd "$ROOT_DIR/manager"
|
|
||||||
make -j$CORES
|
|
||||||
popd > /dev/null
|
|
||||||
|
|
||||||
mkdir -p "$DIST_DIR/switch"
|
|
||||||
cp -vf "$ROOT_DIR/manager/sys-clk-manager.nro" "$DIST_DIR/switch/sys-clk-manager.nro"
|
|
||||||
|
|
||||||
echo "*** overlay ***"
|
echo "*** overlay ***"
|
||||||
pushd "$ROOT_DIR/overlay"
|
pushd "$ROOT_DIR/overlay"
|
||||||
make -j$CORES
|
make -j$CORES
|
||||||
|
|||||||
@@ -66,14 +66,13 @@ typedef struct
|
|||||||
SysClkProfile realProfile;
|
SysClkProfile realProfile;
|
||||||
} SysClkOcExtra;
|
} SysClkOcExtra;
|
||||||
|
|
||||||
|
#define FREQ_TABLE_MAX_ENTRY_COUNT 31
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t values[20];
|
uint32_t freq[FREQ_TABLE_MAX_ENTRY_COUNT];
|
||||||
} SysClkFrequencyTable;
|
} SysClkFrequencyTable;
|
||||||
|
|
||||||
uint32_t* GetModuleFreqTable(SysClkModule module);
|
|
||||||
uint32_t GetModuleMaximumFreq(SysClkModule module);
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SysClkOcGovernorConfig_AllDisabled = 0,
|
SysClkOcGovernorConfig_AllDisabled = 0,
|
||||||
SysClkOcGovernorConfig_CPU_Shift = 0,
|
SysClkOcGovernorConfig_CPU_Shift = 0,
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
const uint32_t CHARGING_CURRENT_MA_LIMIT = 3000;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SysClkConfigValue_PollingIntervalMs = 0,
|
SysClkConfigValue_PollingIntervalMs = 0,
|
||||||
SysClkConfigValue_TempLogIntervalMs,
|
SysClkConfigValue_TempLogIntervalMs,
|
||||||
@@ -95,7 +97,7 @@ static inline uint64_t sysclkValidConfigValue(SysClkConfigValue val, uint64_t in
|
|||||||
case SysClkConfigValue_GovernorExperimental:
|
case SysClkConfigValue_GovernorExperimental:
|
||||||
return (input & 0x1) == input;
|
return (input & 0x1) == input;
|
||||||
case SysClkConfigValue_ChargingCurrentLimit:
|
case SysClkConfigValue_ChargingCurrentLimit:
|
||||||
return (input >= 100 && input <= 2000 && input % 100 == 0);
|
return (input >= 100 && input <= CHARGING_CURRENT_MA_LIMIT && input % 100 == 0);
|
||||||
case SysClkConfigValue_ChargingLimitPercentage:
|
case SysClkConfigValue_ChargingLimitPercentage:
|
||||||
return (input <= 100 && input >= 20);
|
return (input <= 100 && input >= 20);
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -18,4 +18,5 @@ typedef enum
|
|||||||
SysClkError_Generic = 0,
|
SysClkError_Generic = 0,
|
||||||
SysClkError_ConfigNotLoaded = 1,
|
SysClkError_ConfigNotLoaded = 1,
|
||||||
SysClkError_ConfigSaveFailed = 2,
|
SysClkError_ConfigSaveFailed = 2,
|
||||||
|
SysClkError_InternalFrequencyTableError = 3,
|
||||||
} SysClkError;
|
} SysClkError;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "clocks.h"
|
#include "clocks.h"
|
||||||
|
|
||||||
#define SYSCLK_IPC_API_VERSION 1
|
#define SYSCLK_IPC_API_VERSION 2
|
||||||
#define SYSCLK_IPC_SERVICE_NAME "sysclkOC"
|
#define SYSCLK_IPC_SERVICE_NAME "sysclkOC"
|
||||||
|
|
||||||
enum SysClkIpcCmd
|
enum SysClkIpcCmd
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
* --------------------------------------------------------------------------
|
|
||||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
||||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
|
||||||
* wrote this file. As long as you retain this notice you can do whatever you
|
|
||||||
* want with this stuff. If you meet any of us some day, and you think this
|
|
||||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
|
||||||
* --------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <sysclk/clocks.h>
|
|
||||||
|
|
||||||
uint32_t g_freq_table_mem_hz[] = {
|
|
||||||
// From Hekate Minerva module
|
|
||||||
665600000,
|
|
||||||
800000000,
|
|
||||||
1065600000,
|
|
||||||
1331200000,
|
|
||||||
1600000000,
|
|
||||||
// 1728000000,
|
|
||||||
// 1795200000,
|
|
||||||
1862400000, // Max Hz
|
|
||||||
// 1894400000,
|
|
||||||
// 1932800000,
|
|
||||||
// 1996800000,
|
|
||||||
// 2064000000,
|
|
||||||
// 2099200000,
|
|
||||||
// 2131200000,
|
|
||||||
0,
|
|
||||||
};
|
|
||||||
|
|
||||||
uint32_t g_freq_table_cpu_hz[] = {
|
|
||||||
408000000,
|
|
||||||
510000000,
|
|
||||||
612000000,
|
|
||||||
714000000,
|
|
||||||
816000000,
|
|
||||||
918000000,
|
|
||||||
1020000000,
|
|
||||||
1122000000,
|
|
||||||
1224000000,
|
|
||||||
1326000000,
|
|
||||||
1428000000,
|
|
||||||
1581000000,
|
|
||||||
1683000000,
|
|
||||||
1785000000,
|
|
||||||
1887000000,
|
|
||||||
1963500000,
|
|
||||||
2091000000,
|
|
||||||
2193000000,
|
|
||||||
2295000000,
|
|
||||||
2397000000,
|
|
||||||
0,
|
|
||||||
};
|
|
||||||
|
|
||||||
uint32_t g_freq_table_gpu_hz[] = {
|
|
||||||
76800000,
|
|
||||||
153600000,
|
|
||||||
230400000,
|
|
||||||
307200000,
|
|
||||||
384000000,
|
|
||||||
460800000,
|
|
||||||
537600000,
|
|
||||||
614400000,
|
|
||||||
691200000,
|
|
||||||
768000000,
|
|
||||||
844800000,
|
|
||||||
921600000,
|
|
||||||
998400000,
|
|
||||||
1075200000,
|
|
||||||
1152000000,
|
|
||||||
1228800000,
|
|
||||||
1267200000,
|
|
||||||
1305600000,
|
|
||||||
0,
|
|
||||||
};
|
|
||||||
|
|
||||||
uint32_t* GetModuleFreqTable(SysClkModule module) {
|
|
||||||
switch (module) {
|
|
||||||
case SysClkModule_CPU:
|
|
||||||
return &g_freq_table_cpu_hz[0];
|
|
||||||
case SysClkModule_GPU:
|
|
||||||
return &g_freq_table_gpu_hz[0];
|
|
||||||
case SysClkModule_MEM:
|
|
||||||
return &g_freq_table_mem_hz[0];
|
|
||||||
default:
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t GetModuleMaximumFreq(SysClkModule module) {
|
|
||||||
uint32_t* p = GetModuleFreqTable(module);
|
|
||||||
if (p == NULL || *p == 0)
|
|
||||||
return UINT32_MAX;
|
|
||||||
|
|
||||||
while (*(++p));
|
|
||||||
return *(--p);
|
|
||||||
}
|
|
||||||
9
Source/sys-clk-OC/manager/.gitignore
vendored
9
Source/sys-clk-OC/manager/.gitignore
vendored
@@ -1,9 +0,0 @@
|
|||||||
.*/
|
|
||||||
build/
|
|
||||||
build.nx/
|
|
||||||
*~
|
|
||||||
*.bak
|
|
||||||
*.nro
|
|
||||||
*.nacp
|
|
||||||
*.elf
|
|
||||||
.vscode
|
|
||||||
@@ -1,674 +0,0 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
||||||
@@ -1,245 +0,0 @@
|
|||||||
#---------------------------------------------------------------------------------
|
|
||||||
.SUFFIXES:
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITPRO)),)
|
|
||||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
|
||||||
endif
|
|
||||||
|
|
||||||
TOPDIR ?= $(CURDIR)
|
|
||||||
include $(DEVKITPRO)/libnx/switch_rules
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# DATA is a list of directories containing data files
|
|
||||||
# INCLUDES is a list of directories containing header files
|
|
||||||
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
|
|
||||||
#
|
|
||||||
# NO_ICON: if set to anything, do not use icon.
|
|
||||||
# NO_NACP: if set to anything, no .nacp file is generated.
|
|
||||||
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
|
|
||||||
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
|
|
||||||
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
|
|
||||||
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
|
|
||||||
# ICON is the filename of the icon (.jpg), relative to the project folder.
|
|
||||||
# If not set, it attempts to use one of the following (in this order):
|
|
||||||
# - <Project name>.jpg
|
|
||||||
# - icon.jpg
|
|
||||||
# - <libnx folder>/default_icon.jpg
|
|
||||||
#
|
|
||||||
# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder.
|
|
||||||
# If not set, it attempts to use one of the following (in this order):
|
|
||||||
# - <Project name>.json
|
|
||||||
# - config.json
|
|
||||||
# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead
|
|
||||||
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
|
|
||||||
# NACP building is skipped as well.
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := sys-clk-manager
|
|
||||||
BUILD := build.nx
|
|
||||||
SOURCES := src ../common/src ../common/src/client
|
|
||||||
RESOURCES := resources
|
|
||||||
DATA := data
|
|
||||||
INCLUDES := ../common/include
|
|
||||||
APP_TITLE := sys-clk-OC manager
|
|
||||||
APP_AUTHOR := RetroNX Team
|
|
||||||
|
|
||||||
ROMFS := $(BUILD)/romfs
|
|
||||||
BOREALIS_PATH := lib/borealis
|
|
||||||
BOREALIS_RESOURCES := romfs:/borealis/
|
|
||||||
APP_RESOURCES := romfs:/
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# version control constants
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET_VERSION := $$(date +%Y/%m/%d)
|
|
||||||
APP_VERSION := $(TARGET_VERSION)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O2 -ffunction-sections \
|
|
||||||
$(ARCH) $(DEFINES)
|
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -D__SWITCH__ \
|
|
||||||
-DAPP_TITLE="\"$(APP_TITLE)\"" \
|
|
||||||
-DBOREALIS_RESOURCES="\"$(BOREALIS_RESOURCES)\"" \
|
|
||||||
-DAPP_RESOURCES="\"$(APP_RESOURCES)\""
|
|
||||||
|
|
||||||
CXXFLAGS := $(CFLAGS) -std=c++1z
|
|
||||||
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
LIBS := -lnx -lm
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(PORTLIBS) $(LIBNX)
|
|
||||||
|
|
||||||
include $(TOPDIR)/$(BOREALIS_PATH)/library/borealis.mk
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
export TOPDIR := $(CURDIR)
|
|
||||||
|
|
||||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
|
||||||
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(CONFIG_JSON)),)
|
|
||||||
jsons := $(wildcard *.json)
|
|
||||||
ifneq (,$(findstring $(TARGET).json,$(jsons)))
|
|
||||||
export APP_JSON := $(TOPDIR)/$(TARGET).json
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring config.json,$(jsons)))
|
|
||||||
export APP_JSON := $(TOPDIR)/config.json
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.jpg)
|
|
||||||
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
|
|
||||||
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.jpg,$(icons)))
|
|
||||||
export APP_ICON := $(TOPDIR)/icon.jpg
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(strip $(NO_ICON)),)
|
|
||||||
export NROFLAGS += --icon=$(APP_ICON)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(strip $(NO_NACP)),)
|
|
||||||
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(APP_TITLEID),)
|
|
||||||
export NACPFLAGS += --titleid=$(APP_TITLEID)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(ROMFS),)
|
|
||||||
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) $(ROMFS) clean all
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
all: $(BUILD)
|
|
||||||
|
|
||||||
$(ROMFS):
|
|
||||||
@[ -d $@ ] || mkdir -p $@
|
|
||||||
@echo Merging ROMFS...
|
|
||||||
@cp -rf $(CURDIR)/$(BOREALIS_PATH)/resources/. $(CURDIR)/$(ROMFS)/borealis/
|
|
||||||
@cp -rf $(CURDIR)/$(RESOURCES)/. $(CURDIR)/$(ROMFS)/
|
|
||||||
|
|
||||||
$(BUILD): $(ROMFS)
|
|
||||||
@[ -d $@ ] || mkdir -p $@
|
|
||||||
@MSYS2_ARG_CONV_EXCL="-D;$(MSYS2_ARG_CONV_EXCL)" $(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
ifeq ($(strip $(APP_JSON)),)
|
|
||||||
@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
|
|
||||||
else
|
|
||||||
@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
.PHONY: all
|
|
||||||
|
|
||||||
DEPENDS := $(OFILES:.o=.d)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(APP_JSON)),)
|
|
||||||
|
|
||||||
all : $(OUTPUT).nro
|
|
||||||
|
|
||||||
ifeq ($(strip $(NO_NACP)),)
|
|
||||||
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
|
|
||||||
else
|
|
||||||
$(OUTPUT).nro : $(OUTPUT).elf
|
|
||||||
endif
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
all : $(OUTPUT).nsp
|
|
||||||
|
|
||||||
$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm
|
|
||||||
|
|
||||||
$(OUTPUT).nso : $(OUTPUT).elf
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(OUTPUT).elf : $(OFILES)
|
|
||||||
|
|
||||||
$(OFILES_SRC) : $(HFILES_BIN)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# you need a rule like this for each extension you use as binary data
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
-include $(DEPENDS)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# sys-clk-manager
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 109 KiB |
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
AccessModifierOffset: -2
|
|
||||||
AlignConsecutiveAssignments: 'true'
|
|
||||||
BasedOnStyle: WebKit
|
|
||||||
BreakBeforeBraces: Allman
|
|
||||||
IncludeBlocks: Regroup
|
|
||||||
IncludeCategories:
|
|
||||||
- Regex: '^<borealis/.*\.hpp>'
|
|
||||||
Priority: 2
|
|
||||||
- Regex: '^<.*\.h>'
|
|
||||||
Priority: 1
|
|
||||||
- Regex: '^<.*'
|
|
||||||
Priority: 2
|
|
||||||
- Regex: '.*'
|
|
||||||
Priority: 3
|
|
||||||
IndentCaseLabels: 'true'
|
|
||||||
PointerAlignment: Left
|
|
||||||
SortIncludes: 'true'
|
|
||||||
Standard: Cpp11
|
|
||||||
|
|
||||||
...
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
*.glsl text eol=lf
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
.*/
|
|
||||||
build/
|
|
||||||
build.nx/
|
|
||||||
*~
|
|
||||||
*.bak
|
|
||||||
*.nro
|
|
||||||
*.nacp
|
|
||||||
*.elf
|
|
||||||
.vscode
|
|
||||||
builddir
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
; DO NOT EDIT (unless you know what you are doing)
|
|
||||||
;
|
|
||||||
; This subdirectory is a git "subrepo", and this file is maintained by the
|
|
||||||
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
|
|
||||||
;
|
|
||||||
[subrepo]
|
|
||||||
remote = https://github.com/natinusala/borealis
|
|
||||||
branch = master
|
|
||||||
commit = 2ec4957301f702635feac64111dcd212d2a37ec6
|
|
||||||
parent = ec9981362c84ff6d44bb574f311f1d994dc80d9c
|
|
||||||
method = rebase
|
|
||||||
cmdver = 0.4.0
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
Copyright (c) 2019 fincs
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
@@ -1,674 +0,0 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
||||||
@@ -1,231 +0,0 @@
|
|||||||
#---------------------------------------------------------------------------------
|
|
||||||
.SUFFIXES:
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITPRO)),)
|
|
||||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
|
||||||
endif
|
|
||||||
|
|
||||||
TOPDIR ?= $(CURDIR)
|
|
||||||
include $(DEVKITPRO)/libnx/switch_rules
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# DATA is a list of directories containing data files
|
|
||||||
# INCLUDES is a list of directories containing header files
|
|
||||||
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
|
|
||||||
#
|
|
||||||
# NO_ICON: if set to anything, do not use icon.
|
|
||||||
# NO_NACP: if set to anything, no .nacp file is generated.
|
|
||||||
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
|
|
||||||
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
|
|
||||||
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
|
|
||||||
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
|
|
||||||
# ICON is the filename of the icon (.jpg), relative to the project folder.
|
|
||||||
# If not set, it attempts to use one of the following (in this order):
|
|
||||||
# - <Project name>.jpg
|
|
||||||
# - icon.jpg
|
|
||||||
# - <libnx folder>/default_icon.jpg
|
|
||||||
#
|
|
||||||
# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder.
|
|
||||||
# If not set, it attempts to use one of the following (in this order):
|
|
||||||
# - <Project name>.json
|
|
||||||
# - config.json
|
|
||||||
# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead
|
|
||||||
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
|
|
||||||
# NACP building is skipped as well.
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := borealis_example
|
|
||||||
BUILD := build.nx
|
|
||||||
SOURCES := example
|
|
||||||
DATA := data
|
|
||||||
ICON := resources/icon/borealis.jpg
|
|
||||||
INCLUDES := example
|
|
||||||
APP_TITLE := borealis example
|
|
||||||
APP_AUTHOR := natinusala
|
|
||||||
APP_VERSION := 1.0
|
|
||||||
|
|
||||||
ROMFS := resources
|
|
||||||
BOREALIS_PATH := .
|
|
||||||
BOREALIS_RESOURCES := romfs:/
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O2 -ffunction-sections \
|
|
||||||
$(ARCH) $(DEFINES)
|
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -D__SWITCH__ \
|
|
||||||
-DBOREALIS_RESOURCES="\"$(BOREALIS_RESOURCES)\""
|
|
||||||
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-exceptions -std=c++1z -O2
|
|
||||||
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
LIBS := -lnx -lm
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(PORTLIBS) $(LIBNX)
|
|
||||||
|
|
||||||
include $(TOPDIR)/library/borealis.mk
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
export TOPDIR := $(CURDIR)
|
|
||||||
|
|
||||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
|
||||||
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(CONFIG_JSON)),)
|
|
||||||
jsons := $(wildcard *.json)
|
|
||||||
ifneq (,$(findstring $(TARGET).json,$(jsons)))
|
|
||||||
export APP_JSON := $(TOPDIR)/$(TARGET).json
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring config.json,$(jsons)))
|
|
||||||
export APP_JSON := $(TOPDIR)/config.json
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.jpg)
|
|
||||||
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
|
|
||||||
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.jpg,$(icons)))
|
|
||||||
export APP_ICON := $(TOPDIR)/icon.jpg
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(strip $(NO_ICON)),)
|
|
||||||
export NROFLAGS += --icon=$(APP_ICON)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(strip $(NO_NACP)),)
|
|
||||||
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(APP_TITLEID),)
|
|
||||||
export NACPFLAGS += --titleid=$(APP_TITLEID)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(ROMFS),)
|
|
||||||
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean all
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
all: $(BUILD)
|
|
||||||
|
|
||||||
$(BUILD):
|
|
||||||
@[ -d $@ ] || mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
ifeq ($(strip $(APP_JSON)),)
|
|
||||||
@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
|
|
||||||
else
|
|
||||||
@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
.PHONY: all
|
|
||||||
|
|
||||||
DEPENDS := $(OFILES:.o=.d)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(APP_JSON)),)
|
|
||||||
|
|
||||||
all : $(OUTPUT).nro
|
|
||||||
|
|
||||||
ifeq ($(strip $(NO_NACP)),)
|
|
||||||
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
|
|
||||||
else
|
|
||||||
$(OUTPUT).nro : $(OUTPUT).elf
|
|
||||||
endif
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
all : $(OUTPUT).nsp
|
|
||||||
|
|
||||||
$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm
|
|
||||||
|
|
||||||
$(OUTPUT).nso : $(OUTPUT).elf
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(OUTPUT).elf : $(OFILES)
|
|
||||||
|
|
||||||
$(OFILES_SRC) : $(HFILES_BIN)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# you need a rule like this for each extension you use as binary data
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
-include $(DEPENDS)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
# borealis
|
|
||||||
|
|
||||||
Hardware accelerated, Nintendo Switch inspired UI library for PC and Nintendo Switch. Powered by nanovg. Skeleton based on the [hybrid glfw app](https://github.com/fincs/hybrid_app) by fincs.
|
|
||||||
|
|
||||||
The library is still in early development and WILL lack features and contain bugs. Feel free to report them in the issues, or make a pull request if you happen to fix some.
|
|
||||||
|
|
||||||
You can see the planned features in the Projects tab.
|
|
||||||
|
|
||||||
Documentation is available [right here](https://github.com/natinusala/borealis/wiki). Warning: may not be up to date.
|
|
||||||
|
|
||||||
## Building the example for Switch
|
|
||||||
|
|
||||||
To build for Switch, a standard development environment must first be set up. In order to do so, [refer to the Getting Started guide](https://devkitpro.org/wiki/Getting_Started).
|
|
||||||
|
|
||||||
```bash
|
|
||||||
(sudo) (dkp-)pacman -S switch-glfw switch-mesa switch-glm
|
|
||||||
make -j
|
|
||||||
nxlink -s borealis_example.nro
|
|
||||||
```
|
|
||||||
|
|
||||||
## Building the example for PC
|
|
||||||
|
|
||||||
To build for PC, the following components are required:
|
|
||||||
|
|
||||||
- meson/ninja build system
|
|
||||||
- A C++ compiler supporting the C++17 standard
|
|
||||||
- GLFW version 3.3 or higher (as a static library)
|
|
||||||
- GLM version 0.9.8 or higher
|
|
||||||
|
|
||||||
Please refer to the usual sources of information for your particular operating system. Usually the commands needed to build this project will look like this:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
meson build
|
|
||||||
ninja -C build
|
|
||||||
./build/borealis_example
|
|
||||||
```
|
|
||||||
|
|
||||||
Also, please note that the `resources` folder must be available in the working directory, otherwise the program will fail to find the shaders.
|
|
||||||
|
|
||||||
### Building the example for Windows using msys2
|
|
||||||
|
|
||||||
msys2 provides all packages needed to build this project:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-meson mingw-w64-x86_64-ninja mingw-w64-x86_64-pkg-config mingw-w64-x86_64-glfw mingw-w64-x86_64-glm
|
|
||||||
meson build
|
|
||||||
ninja -C build
|
|
||||||
./build/borealis_example
|
|
||||||
```
|
|
||||||
|
|
||||||
### Including in your project (TL;DR: see the example makefile in this repo)
|
|
||||||
0. Your project must be built as C++17 (`-std=c++1z`). You also need to remove `-fno-rtti` and `-fno-exceptions` if you have them
|
|
||||||
1. Use a submodule (or even better, a [subrepo](https://github.com/ingydotnet/git-subrepo)) to clone this repository in your project
|
|
||||||
2. Copy the `resources` folder to the root of your project
|
|
||||||
3. For PC (meson):
|
|
||||||
1. take a standard meson file
|
|
||||||
2. use `subdir` to import the library folder
|
|
||||||
3. use the `borealis_files`, `borealis_dependencies` and `borealis_include` variables for respectively objects to build, dependencies (glfw...) and includes directory
|
|
||||||
4. add a `BOREALIS_RESOURCES` define pointing to the resources folder at runtime (so `resources`)
|
|
||||||
4. For Switch:
|
|
||||||
1. take a standard homebrew makefile
|
|
||||||
2. add a `BOREALIS_PATH` variable containing the subfolder you put the library in
|
|
||||||
3. use `include` to load `borealis.mk` (after `LIBDIRS` and `BOREALIS_PATH`)
|
|
||||||
4. set `ROMFS` to the resources folder
|
|
||||||
5. add a `BOREALIS_RESOURCES` define pointing to the resources folder at runtime (so `romfs:/`)
|
|
||||||
@@ -1,171 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019-2020 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <borealis.hpp>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "sample_installer_page.hpp"
|
|
||||||
#include "sample_loading_page.hpp"
|
|
||||||
|
|
||||||
std::vector<std::string> NOTIFICATIONS = {
|
|
||||||
"You have cool hair",
|
|
||||||
"I like your shoes",
|
|
||||||
"borealis is powered by nanovg",
|
|
||||||
"The Triforce is an inside job",
|
|
||||||
"Pozznx will trigger in one day and twelve hours",
|
|
||||||
"Aurora Borealis? At this time of day, at this time of year, in this part of the gaming market, located entirely within your Switch?!",
|
|
||||||
"May I see it?",
|
|
||||||
"Hmm, Steamed Hams!"
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
// Init the app
|
|
||||||
brls::Logger::setLogLevel(brls::LogLevel::DEBUG);
|
|
||||||
|
|
||||||
if (!brls::Application::init("Borealis example"))
|
|
||||||
{
|
|
||||||
brls::Logger::error("Unable to init Borealis application");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a sample view
|
|
||||||
brls::TabFrame* rootFrame = new brls::TabFrame();
|
|
||||||
rootFrame->setTitle("Borealis Example App");
|
|
||||||
rootFrame->setIcon(BOREALIS_ASSET("icon/borealis.jpg"));
|
|
||||||
|
|
||||||
brls::List* testList = new brls::List();
|
|
||||||
|
|
||||||
brls::ListItem* dialogItem = new brls::ListItem("Open a dialog");
|
|
||||||
dialogItem->getClickEvent()->subscribe([](brls::View* view) {
|
|
||||||
brls::Dialog* dialog = new brls::Dialog("Warning: PozzNX will wipe all data on your Switch and render it inoperable, do you want to proceed?");
|
|
||||||
|
|
||||||
brls::GenericEvent::Callback closeCallback = [dialog](brls::View* view) {
|
|
||||||
dialog->close();
|
|
||||||
brls::Application::notify("Running PozzNX...");
|
|
||||||
};
|
|
||||||
|
|
||||||
dialog->addButton("Continue", closeCallback);
|
|
||||||
dialog->addButton("Continue", closeCallback);
|
|
||||||
dialog->addButton("Continue", closeCallback);
|
|
||||||
|
|
||||||
dialog->setCancelable(false);
|
|
||||||
|
|
||||||
dialog->open();
|
|
||||||
});
|
|
||||||
|
|
||||||
brls::ListItem* notificationItem = new brls::ListItem("Post a random notification");
|
|
||||||
notificationItem->getClickEvent()->subscribe([](brls::View* view) {
|
|
||||||
std::string notification = NOTIFICATIONS[std::rand() % NOTIFICATIONS.size()];
|
|
||||||
brls::Application::notify(notification);
|
|
||||||
});
|
|
||||||
|
|
||||||
brls::ListItem* themeItem = new brls::ListItem("TV Resolution");
|
|
||||||
themeItem->setValue("Automatic");
|
|
||||||
|
|
||||||
brls::SelectListItem* jankItem = new brls::SelectListItem(
|
|
||||||
"User Interface Jank",
|
|
||||||
{ "Native", "Minimal", "Regular", "Maximum", "SX OS", "Windows Vista", "iOS 14" });
|
|
||||||
|
|
||||||
brls::ListItem* crashItem = new brls::ListItem("Divide by 0", "Can the Switch do it?");
|
|
||||||
crashItem->getClickEvent()->subscribe([](brls::View* view) { brls::Application::crash("The software was closed because an error occured:\nSIGABRT (signal 6)"); });
|
|
||||||
|
|
||||||
brls::ListItem* popupItem = new brls::ListItem("Open popup");
|
|
||||||
popupItem->getClickEvent()->subscribe([](brls::View* view) {
|
|
||||||
brls::TabFrame* popupTabFrame = new brls::TabFrame();
|
|
||||||
popupTabFrame->addTab("Red", new brls::Rectangle(nvgRGB(255, 0, 0)));
|
|
||||||
popupTabFrame->addTab("Green", new brls::Rectangle(nvgRGB(0, 255, 0)));
|
|
||||||
popupTabFrame->addTab("Blue", new brls::Rectangle(nvgRGB(0, 0, 255)));
|
|
||||||
brls::PopupFrame::open("Popup title", BOREALIS_ASSET("icon/borealis.jpg"), popupTabFrame, "Subtitle left", "Subtitle right");
|
|
||||||
});
|
|
||||||
|
|
||||||
brls::ListItem* installerItem = new brls::ListItem("Open example installer");
|
|
||||||
installerItem->getClickEvent()->subscribe([](brls::View* view) {
|
|
||||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
|
||||||
stagedFrame->setTitle("My great installer");
|
|
||||||
|
|
||||||
stagedFrame->addStage(new SampleInstallerPage(stagedFrame, "Go to step 2"));
|
|
||||||
stagedFrame->addStage(new SampleLoadingPage(stagedFrame));
|
|
||||||
stagedFrame->addStage(new SampleInstallerPage(stagedFrame, "Finish"));
|
|
||||||
|
|
||||||
brls::Application::pushView(stagedFrame);
|
|
||||||
});
|
|
||||||
|
|
||||||
brls::SelectListItem* layerSelectItem = new brls::SelectListItem("Select Layer", { "Layer 1", "Layer 2" });
|
|
||||||
|
|
||||||
testList->addView(dialogItem);
|
|
||||||
testList->addView(notificationItem);
|
|
||||||
testList->addView(themeItem);
|
|
||||||
testList->addView(jankItem);
|
|
||||||
testList->addView(crashItem);
|
|
||||||
testList->addView(installerItem);
|
|
||||||
testList->addView(popupItem);
|
|
||||||
|
|
||||||
brls::Label* testLabel = new brls::Label(brls::LabelStyle::REGULAR, "For more information about how to use Nintendo Switch and its features, please refer to the Nintendo Support Website on your smart device or PC.", true);
|
|
||||||
testList->addView(testLabel);
|
|
||||||
|
|
||||||
brls::ListItem* actionTestItem = new brls::ListItem("Custom Actions");
|
|
||||||
actionTestItem->registerAction("Show notification", brls::Key::L, [] {
|
|
||||||
brls::Application::notify("Custom Action triggered");
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
testList->addView(actionTestItem);
|
|
||||||
|
|
||||||
brls::LayerView* testLayers = new brls::LayerView();
|
|
||||||
brls::List* layerList1 = new brls::List();
|
|
||||||
brls::List* layerList2 = new brls::List();
|
|
||||||
|
|
||||||
layerList1->addView(new brls::Header("Layer 1", false));
|
|
||||||
layerList1->addView(new brls::ListItem("Item 1"));
|
|
||||||
layerList1->addView(new brls::ListItem("Item 2"));
|
|
||||||
layerList1->addView(new brls::ListItem("Item 3"));
|
|
||||||
|
|
||||||
layerList2->addView(new brls::Header("Layer 2", false));
|
|
||||||
layerList2->addView(new brls::ListItem("Item 1"));
|
|
||||||
layerList2->addView(new brls::ListItem("Item 2"));
|
|
||||||
layerList2->addView(new brls::ListItem("Item 3"));
|
|
||||||
|
|
||||||
testLayers->addLayer(layerList1);
|
|
||||||
testLayers->addLayer(layerList2);
|
|
||||||
|
|
||||||
layerSelectItem->getValueSelectedEvent()->subscribe([=](size_t selection) {
|
|
||||||
testLayers->changeLayer(selection);
|
|
||||||
});
|
|
||||||
|
|
||||||
testList->addView(layerSelectItem);
|
|
||||||
|
|
||||||
rootFrame->addTab("First tab", testList);
|
|
||||||
rootFrame->addTab("Second tab", testLayers);
|
|
||||||
rootFrame->addSeparator();
|
|
||||||
rootFrame->addTab("Third tab", new brls::Rectangle(nvgRGB(255, 0, 0)));
|
|
||||||
rootFrame->addTab("Fourth tab", new brls::Rectangle(nvgRGB(0, 255, 0)));
|
|
||||||
|
|
||||||
// Add the root view to the stack
|
|
||||||
brls::Application::pushView(rootFrame);
|
|
||||||
|
|
||||||
// Run the app
|
|
||||||
while (brls::Application::mainLoop())
|
|
||||||
;
|
|
||||||
|
|
||||||
// Exit
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 Billy Laws
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sample_installer_page.hpp"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
SampleInstallerPage::SampleInstallerPage(brls::StagedAppletFrame* frame, std::string label)
|
|
||||||
{
|
|
||||||
// Label
|
|
||||||
this->button = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel(label)->setImage(BOREALIS_ASSET("icon/borealis.jpg"));
|
|
||||||
this->button->setParent(this);
|
|
||||||
this->button->getClickEvent()->subscribe([frame](View* view) {
|
|
||||||
if (frame->isLastStage())
|
|
||||||
brls::Application::popView();
|
|
||||||
else
|
|
||||||
frame->nextStage();
|
|
||||||
});
|
|
||||||
this->label = new brls::Label(brls::LabelStyle::DIALOG, "Here, you would normally do useful things", true);
|
|
||||||
this->label->setHorizontalAlign(NVG_ALIGN_CENTER);
|
|
||||||
this->label->setParent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SampleInstallerPage::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx)
|
|
||||||
{
|
|
||||||
this->label->frame(ctx);
|
|
||||||
this->button->frame(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
brls::View* SampleInstallerPage::getDefaultFocus()
|
|
||||||
{
|
|
||||||
return this->button;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SampleInstallerPage::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash)
|
|
||||||
{
|
|
||||||
this->label->setWidth(roundf((float)this->width * style->CrashFrame.labelWidth));
|
|
||||||
this->label->invalidate(true);
|
|
||||||
|
|
||||||
this->label->setBoundaries(
|
|
||||||
this->x + this->width / 2 - this->label->getWidth() / 2,
|
|
||||||
this->y + (this->height - style->AppletFrame.footerHeight) / 2,
|
|
||||||
this->label->getWidth(),
|
|
||||||
this->label->getHeight());
|
|
||||||
|
|
||||||
this->button->setBoundaries(
|
|
||||||
this->x + this->width / 2 - style->CrashFrame.buttonWidth / 2,
|
|
||||||
this->y + this->height / 2 + style->CrashFrame.buttonHeight,
|
|
||||||
style->CrashFrame.buttonWidth,
|
|
||||||
style->CrashFrame.buttonHeight);
|
|
||||||
this->button->invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
SampleInstallerPage::~SampleInstallerPage()
|
|
||||||
{
|
|
||||||
delete this->label;
|
|
||||||
delete this->button;
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 Billy Laws
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis.hpp>
|
|
||||||
|
|
||||||
class SampleInstallerPage : public brls::View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
brls::Button* button;
|
|
||||||
brls::Label* label;
|
|
||||||
|
|
||||||
public:
|
|
||||||
SampleInstallerPage(brls::StagedAppletFrame* frame, std::string label);
|
|
||||||
~SampleInstallerPage();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
|
|
||||||
brls::View* getDefaultFocus() override;
|
|
||||||
};
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 Billy Laws
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sample_loading_page.hpp"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
SampleLoadingPage::SampleLoadingPage(brls::StagedAppletFrame* frame)
|
|
||||||
: frame(frame)
|
|
||||||
{
|
|
||||||
// Label
|
|
||||||
this->progressDisp = new brls::ProgressDisplay();
|
|
||||||
this->progressDisp->setProgress(this->progressValue, 1000);
|
|
||||||
this->progressDisp->setParent(this);
|
|
||||||
this->label = new brls::Label(brls::LabelStyle::DIALOG, "Example loading display", true);
|
|
||||||
this->label->setHorizontalAlign(NVG_ALIGN_CENTER);
|
|
||||||
this->label->setParent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SampleLoadingPage::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx)
|
|
||||||
{
|
|
||||||
if (progressValue == 500)
|
|
||||||
this->frame->nextStage();
|
|
||||||
|
|
||||||
this->progressValue++;
|
|
||||||
this->progressDisp->setProgress(this->progressValue, 500);
|
|
||||||
this->progressDisp->frame(ctx);
|
|
||||||
this->label->frame(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SampleLoadingPage::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash)
|
|
||||||
{
|
|
||||||
this->label->setWidth(roundf((float)this->width * style->CrashFrame.labelWidth));
|
|
||||||
this->label->invalidate(true);
|
|
||||||
|
|
||||||
this->label->setBoundaries(
|
|
||||||
this->x + this->width / 2 - this->label->getWidth() / 2,
|
|
||||||
this->y + (this->height - style->AppletFrame.footerHeight) / 2,
|
|
||||||
this->label->getWidth(),
|
|
||||||
this->label->getHeight());
|
|
||||||
|
|
||||||
this->progressDisp->setBoundaries(
|
|
||||||
this->x + this->width / 2 - style->CrashFrame.buttonWidth,
|
|
||||||
this->y + this->height / 2,
|
|
||||||
style->CrashFrame.buttonWidth * 2,
|
|
||||||
style->CrashFrame.buttonHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SampleLoadingPage::willAppear(bool resetState)
|
|
||||||
{
|
|
||||||
this->progressDisp->willAppear(resetState);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SampleLoadingPage::willDisappear(bool resetState)
|
|
||||||
{
|
|
||||||
this->progressDisp->willDisappear(resetState);
|
|
||||||
}
|
|
||||||
|
|
||||||
SampleLoadingPage::~SampleLoadingPage()
|
|
||||||
{
|
|
||||||
delete this->progressDisp;
|
|
||||||
delete this->label;
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 Billy Laws
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis.hpp>
|
|
||||||
|
|
||||||
class SampleLoadingPage : public brls::View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
brls::StagedAppletFrame* frame;
|
|
||||||
brls::ProgressDisplay* progressDisp;
|
|
||||||
brls::Label* label;
|
|
||||||
int progressValue = 0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
SampleLoadingPage(brls::StagedAppletFrame* frame);
|
|
||||||
~SampleLoadingPage();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
|
|
||||||
|
|
||||||
void willAppear(bool resetState = false) override;
|
|
||||||
void willDisappear(bool resetState = false) override;
|
|
||||||
};
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
||||||
current_dir := $(BOREALIS_PATH)/$(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
|
|
||||||
|
|
||||||
LIBS := -lglfw3 -lEGL -lglapi -ldrm_nouveau -lm $(LIBS)
|
|
||||||
|
|
||||||
SOURCES := $(SOURCES) \
|
|
||||||
$(current_dir)/lib \
|
|
||||||
$(current_dir)/lib/extern/glad \
|
|
||||||
$(current_dir)/lib/extern/nanovg \
|
|
||||||
$(current_dir)/lib/extern/libretro-common/compat \
|
|
||||||
$(current_dir)/lib/extern/libretro-common/encodings \
|
|
||||||
$(current_dir)/lib/extern/libretro-common/features
|
|
||||||
|
|
||||||
INCLUDES := $(INCLUDES) \
|
|
||||||
$(current_dir)/include \
|
|
||||||
$(current_dir)/include/borealis/extern/glad \
|
|
||||||
$(current_dir)/include/borealis/extern/nanovg \
|
|
||||||
$(current_dir)/include/borealis/extern/libretro-common
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifndef BOREALIS_RESOURCES
|
|
||||||
#error BOREALIS_RESOURCES define missing
|
|
||||||
#endif
|
|
||||||
#define BOREALIS_ASSET(_str) BOREALIS_RESOURCES _str
|
|
||||||
|
|
||||||
// Library
|
|
||||||
#include <borealis/applet_frame.hpp>
|
|
||||||
#include <borealis/application.hpp>
|
|
||||||
#include <borealis/box_layout.hpp>
|
|
||||||
#include <borealis/button.hpp>
|
|
||||||
#include <borealis/crash_frame.hpp>
|
|
||||||
#include <borealis/dialog.hpp>
|
|
||||||
#include <borealis/dropdown.hpp>
|
|
||||||
#include <borealis/event.hpp>
|
|
||||||
#include <borealis/header.hpp>
|
|
||||||
#include <borealis/image.hpp>
|
|
||||||
#include <borealis/label.hpp>
|
|
||||||
#include <borealis/layer_view.hpp>
|
|
||||||
#include <borealis/list.hpp>
|
|
||||||
#include <borealis/logger.hpp>
|
|
||||||
#include <borealis/material_icon.hpp>
|
|
||||||
#include <borealis/notification_manager.hpp>
|
|
||||||
#include <borealis/popup_frame.hpp>
|
|
||||||
#include <borealis/progress_display.hpp>
|
|
||||||
#include <borealis/progress_spinner.hpp>
|
|
||||||
#include <borealis/rectangle.hpp>
|
|
||||||
#include <borealis/repeating_task.hpp>
|
|
||||||
#include <borealis/sidebar.hpp>
|
|
||||||
#include <borealis/staged_applet_frame.hpp>
|
|
||||||
#include <borealis/style.hpp>
|
|
||||||
#include <borealis/tab_frame.hpp>
|
|
||||||
#include <borealis/table.hpp>
|
|
||||||
#include <borealis/theme.hpp>
|
|
||||||
#include <borealis/thumbnail_frame.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2020 WerWolv
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#define GLFW_INCLUDE_NONE
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
class View;
|
|
||||||
|
|
||||||
typedef std::function<bool(void)> ActionListener;
|
|
||||||
|
|
||||||
// ZL and ZR do not exist here because GLFW doesn't know them
|
|
||||||
enum class Key
|
|
||||||
{
|
|
||||||
A = GLFW_GAMEPAD_BUTTON_A,
|
|
||||||
B = GLFW_GAMEPAD_BUTTON_B,
|
|
||||||
X = GLFW_GAMEPAD_BUTTON_X,
|
|
||||||
Y = GLFW_GAMEPAD_BUTTON_Y,
|
|
||||||
LSTICK = GLFW_GAMEPAD_BUTTON_LEFT_THUMB,
|
|
||||||
RSTICK = GLFW_GAMEPAD_BUTTON_RIGHT_THUMB,
|
|
||||||
L = GLFW_GAMEPAD_BUTTON_LEFT_BUMPER,
|
|
||||||
R = GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER,
|
|
||||||
PLUS = GLFW_GAMEPAD_BUTTON_START,
|
|
||||||
MINUS = GLFW_GAMEPAD_BUTTON_BACK,
|
|
||||||
DLEFT = GLFW_GAMEPAD_BUTTON_DPAD_LEFT,
|
|
||||||
DUP = GLFW_GAMEPAD_BUTTON_DPAD_UP,
|
|
||||||
DRIGHT = GLFW_GAMEPAD_BUTTON_DPAD_RIGHT,
|
|
||||||
DDOWN = GLFW_GAMEPAD_BUTTON_DPAD_DOWN,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Action
|
|
||||||
{
|
|
||||||
Key key;
|
|
||||||
|
|
||||||
std::string hintText;
|
|
||||||
bool available;
|
|
||||||
bool hidden;
|
|
||||||
ActionListener actionListener;
|
|
||||||
|
|
||||||
bool operator==(const Key other)
|
|
||||||
{
|
|
||||||
return this->key == other;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,178 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Borealis, a Nintendo Switch UI Library
|
|
||||||
* Copyright (C) 2014-2017 - Jean-André Santoni
|
|
||||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
|
||||||
* Copyright (C) 2019 - natinusala
|
|
||||||
Copyright (C) 2019 - p-sam
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
typedef float (*easing_cb)(float, float, float, float);
|
|
||||||
typedef std::function<void(void*)> tween_cb;
|
|
||||||
|
|
||||||
enum menu_animation_ctl_state
|
|
||||||
{
|
|
||||||
MENU_ANIMATION_CTL_NONE = 0,
|
|
||||||
MENU_ANIMATION_CTL_DEINIT,
|
|
||||||
MENU_ANIMATION_CTL_CLEAR_ACTIVE,
|
|
||||||
MENU_ANIMATION_CTL_SET_ACTIVE
|
|
||||||
};
|
|
||||||
|
|
||||||
enum menu_animation_easing_type
|
|
||||||
{
|
|
||||||
/* Linear */
|
|
||||||
EASING_LINEAR = 0,
|
|
||||||
/* Quad */
|
|
||||||
EASING_IN_QUAD,
|
|
||||||
EASING_OUT_QUAD,
|
|
||||||
EASING_IN_OUT_QUAD,
|
|
||||||
EASING_OUT_IN_QUAD,
|
|
||||||
/* Cubic */
|
|
||||||
EASING_IN_CUBIC,
|
|
||||||
EASING_OUT_CUBIC,
|
|
||||||
EASING_IN_OUT_CUBIC,
|
|
||||||
EASING_OUT_IN_CUBIC,
|
|
||||||
/* Quart */
|
|
||||||
EASING_IN_QUART,
|
|
||||||
EASING_OUT_QUART,
|
|
||||||
EASING_IN_OUT_QUART,
|
|
||||||
EASING_OUT_IN_QUART,
|
|
||||||
/* Quint */
|
|
||||||
EASING_IN_QUINT,
|
|
||||||
EASING_OUT_QUINT,
|
|
||||||
EASING_IN_OUT_QUINT,
|
|
||||||
EASING_OUT_IN_QUINT,
|
|
||||||
/* Sine */
|
|
||||||
EASING_IN_SINE,
|
|
||||||
EASING_OUT_SINE,
|
|
||||||
EASING_IN_OUT_SINE,
|
|
||||||
EASING_OUT_IN_SINE,
|
|
||||||
/* Expo */
|
|
||||||
EASING_IN_EXPO,
|
|
||||||
EASING_OUT_EXPO,
|
|
||||||
EASING_IN_OUT_EXPO,
|
|
||||||
EASING_OUT_IN_EXPO,
|
|
||||||
/* Circ */
|
|
||||||
EASING_IN_CIRC,
|
|
||||||
EASING_OUT_CIRC,
|
|
||||||
EASING_IN_OUT_CIRC,
|
|
||||||
EASING_OUT_IN_CIRC,
|
|
||||||
/* Bounce */
|
|
||||||
EASING_IN_BOUNCE,
|
|
||||||
EASING_OUT_BOUNCE,
|
|
||||||
EASING_IN_OUT_BOUNCE,
|
|
||||||
EASING_OUT_IN_BOUNCE,
|
|
||||||
|
|
||||||
EASING_LAST
|
|
||||||
};
|
|
||||||
|
|
||||||
/* TODO:
|
|
||||||
* Add a reverse loop ticker for languages
|
|
||||||
* that read right to left */
|
|
||||||
enum menu_animation_ticker_type
|
|
||||||
{
|
|
||||||
TICKER_TYPE_BOUNCE = 0,
|
|
||||||
TICKER_TYPE_LOOP,
|
|
||||||
TICKER_TYPE_LAST
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef uintptr_t menu_animation_ctx_tag;
|
|
||||||
|
|
||||||
typedef struct menu_animation_ctx_subject
|
|
||||||
{
|
|
||||||
size_t count;
|
|
||||||
const void* data;
|
|
||||||
} menu_animation_ctx_subject_t;
|
|
||||||
|
|
||||||
typedef struct menu_animation_ctx_entry
|
|
||||||
{
|
|
||||||
enum menu_animation_easing_type easing_enum;
|
|
||||||
uintptr_t tag;
|
|
||||||
float duration;
|
|
||||||
float target_value;
|
|
||||||
float* subject;
|
|
||||||
tween_cb cb;
|
|
||||||
tween_cb tick;
|
|
||||||
void* userdata;
|
|
||||||
} menu_animation_ctx_entry_t;
|
|
||||||
|
|
||||||
typedef struct menu_animation_ctx_ticker
|
|
||||||
{
|
|
||||||
bool selected;
|
|
||||||
size_t len;
|
|
||||||
uint64_t idx;
|
|
||||||
enum menu_animation_ticker_type type_enum;
|
|
||||||
char* s;
|
|
||||||
const char* str;
|
|
||||||
const char* spacer;
|
|
||||||
} menu_animation_ctx_ticker_t;
|
|
||||||
|
|
||||||
typedef float menu_timer_t;
|
|
||||||
|
|
||||||
typedef struct menu_timer_ctx_entry
|
|
||||||
{
|
|
||||||
float duration;
|
|
||||||
tween_cb cb;
|
|
||||||
tween_cb tick;
|
|
||||||
void* userdata;
|
|
||||||
} menu_timer_ctx_entry_t;
|
|
||||||
|
|
||||||
typedef struct menu_delayed_animation
|
|
||||||
{
|
|
||||||
menu_timer_t timer;
|
|
||||||
menu_animation_ctx_entry_t entry;
|
|
||||||
} menu_delayed_animation_t;
|
|
||||||
|
|
||||||
void menu_timer_start(menu_timer_t* timer, menu_timer_ctx_entry_t* timer_entry);
|
|
||||||
|
|
||||||
void menu_timer_kill(menu_timer_t* timer);
|
|
||||||
|
|
||||||
void menu_animation_init(void);
|
|
||||||
|
|
||||||
void menu_animation_free(void);
|
|
||||||
|
|
||||||
bool menu_animation_update(void);
|
|
||||||
|
|
||||||
bool menu_animation_ticker(menu_animation_ctx_ticker_t* ticker);
|
|
||||||
|
|
||||||
float menu_animation_get_delta_time(void);
|
|
||||||
|
|
||||||
bool menu_animation_is_active(void);
|
|
||||||
|
|
||||||
bool menu_animation_kill_by_tag(menu_animation_ctx_tag* tag);
|
|
||||||
|
|
||||||
void menu_animation_kill_by_subject(menu_animation_ctx_subject_t* subject);
|
|
||||||
|
|
||||||
bool menu_animation_push(menu_animation_ctx_entry_t* entry);
|
|
||||||
|
|
||||||
void menu_animation_push_delayed(unsigned delay, menu_animation_ctx_entry_t* entry);
|
|
||||||
|
|
||||||
bool menu_animation_ctl(enum menu_animation_ctl_state state, void* data);
|
|
||||||
|
|
||||||
uint64_t menu_animation_get_ticker_idx(void);
|
|
||||||
|
|
||||||
uint64_t menu_animation_get_ticker_slow_idx(void);
|
|
||||||
|
|
||||||
void menu_animation_get_highlight(float* gradient_x, float* gradient_y, float* color);
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/frame_context.hpp>
|
|
||||||
#include <borealis/hint.hpp>
|
|
||||||
#include <borealis/image.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
enum class HeaderStyle
|
|
||||||
{
|
|
||||||
REGULAR,
|
|
||||||
POPUP // Only meant for PopupFrames. Using it in other contexts might cause weird behaviour
|
|
||||||
};
|
|
||||||
|
|
||||||
// A Horizon settings-like frame, with header and footer (no sidebar)
|
|
||||||
class AppletFrame : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::string title = "";
|
|
||||||
std::string footerText = "";
|
|
||||||
|
|
||||||
std::string subTitleLeft = "", subTitleRight = "";
|
|
||||||
|
|
||||||
View* icon = nullptr;
|
|
||||||
Hint* hint = nullptr;
|
|
||||||
|
|
||||||
View* contentView = nullptr;
|
|
||||||
|
|
||||||
bool slideOut = false;
|
|
||||||
bool slideIn = false;
|
|
||||||
|
|
||||||
ViewAnimation animation;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
HeaderStyle headerStyle = HeaderStyle::REGULAR;
|
|
||||||
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
|
|
||||||
unsigned leftPadding = 0;
|
|
||||||
unsigned rightPadding = 0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
AppletFrame(bool padLeft, bool padRight);
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
virtual bool onCancel();
|
|
||||||
void willAppear(bool resetState = false) override;
|
|
||||||
void willDisappear(bool resetState = false) override;
|
|
||||||
void show(std::function<void(void)> cb, bool animate = true, ViewAnimation animation = ViewAnimation::FADE) override;
|
|
||||||
void hide(std::function<void(void)> cb, bool animated = true, ViewAnimation animation = ViewAnimation::FADE) override;
|
|
||||||
void onWindowSizeChanged() override;
|
|
||||||
|
|
||||||
void setTitle(std::string title);
|
|
||||||
void setFooterText(std::string footerText);
|
|
||||||
void setSubtitle(std::string left, std::string right);
|
|
||||||
void setIcon(unsigned char* buffer, size_t bufferSize);
|
|
||||||
void setIcon(std::string imagePath);
|
|
||||||
void setIcon(View* view);
|
|
||||||
virtual void setContentView(View* view);
|
|
||||||
bool hasContentView();
|
|
||||||
void setHeaderStyle(HeaderStyle headerStyle);
|
|
||||||
|
|
||||||
void setAnimateHint(bool animate)
|
|
||||||
{
|
|
||||||
this->hint->setAnimate(animate);
|
|
||||||
}
|
|
||||||
|
|
||||||
~AppletFrame();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019-2020 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#define GLFW_INCLUDE_NONE
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
#include <nanovg.h>
|
|
||||||
|
|
||||||
#include <borealis/animations.hpp>
|
|
||||||
#include <borealis/frame_context.hpp>
|
|
||||||
#include <borealis/hint.hpp>
|
|
||||||
#include <borealis/label.hpp>
|
|
||||||
#include <borealis/logger.hpp>
|
|
||||||
#include <borealis/notification_manager.hpp>
|
|
||||||
#include <borealis/style.hpp>
|
|
||||||
#include <borealis/task_manager.hpp>
|
|
||||||
#include <borealis/theme.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// The top-right framerate counter
|
|
||||||
class FramerateCounter : public Label
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
retro_time_t lastSecond = 0;
|
|
||||||
unsigned frames = 0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
FramerateCounter();
|
|
||||||
|
|
||||||
void frame(FrameContext* ctx) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Application
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//Init with default style and theme (as close to HOS as possible)
|
|
||||||
static bool init(std::string title);
|
|
||||||
|
|
||||||
// Init with given style and theme
|
|
||||||
static bool init(std::string title, Style style, Theme theme);
|
|
||||||
|
|
||||||
static bool mainLoop();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pushes a view on this applications's view stack
|
|
||||||
*
|
|
||||||
* The view will automatically be resized to take
|
|
||||||
* the whole screen and layout() will be called
|
|
||||||
*
|
|
||||||
* The view will gain focus if applicable
|
|
||||||
*/
|
|
||||||
static void pushView(View* view, ViewAnimation animation = ViewAnimation::FADE);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pops the last pushed view from the stack
|
|
||||||
* and gives focus back where it was before
|
|
||||||
*/
|
|
||||||
static void popView(
|
|
||||||
ViewAnimation animation = ViewAnimation::FADE, std::function<void(void)> cb = []() {});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gives the focus to the given view
|
|
||||||
* or clears the focus if given nullptr
|
|
||||||
*/
|
|
||||||
static void giveFocus(View* view);
|
|
||||||
|
|
||||||
static Style* getStyle();
|
|
||||||
static void setTheme(Theme theme);
|
|
||||||
static ThemeValues* getThemeValues();
|
|
||||||
static ThemeValues* getThemeValuesForVariant(ThemeVariant variant);
|
|
||||||
static ThemeVariant getThemeVariant();
|
|
||||||
|
|
||||||
static int loadFont(const char* fontName, const char* filePath);
|
|
||||||
static int loadFontFromMemory(const char* fontName, void* data, size_t size, bool freeData);
|
|
||||||
static int findFont(const char* fontName);
|
|
||||||
|
|
||||||
static FontStash* getFontStash();
|
|
||||||
|
|
||||||
static void notify(std::string text);
|
|
||||||
|
|
||||||
static void onGamepadButtonPressed(char button, bool repeating);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* "Crashes" the app (displays a fullscreen CrashFrame)
|
|
||||||
*/
|
|
||||||
static void crash(std::string text);
|
|
||||||
|
|
||||||
static void quit();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Blocks any and all user inputs
|
|
||||||
*/
|
|
||||||
static void blockInputs();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unblocks inputs after a call to
|
|
||||||
* blockInputs()
|
|
||||||
*/
|
|
||||||
static void unblockInputs();
|
|
||||||
|
|
||||||
static NVGcontext* getNVGContext();
|
|
||||||
static TaskManager* getTaskManager();
|
|
||||||
static NotificationManager* getNotificationManager();
|
|
||||||
|
|
||||||
static void setCommonFooter(std::string footer);
|
|
||||||
static std::string* getCommonFooter();
|
|
||||||
|
|
||||||
static void setDisplayFramerate(bool enabled);
|
|
||||||
static void toggleFramerateDisplay();
|
|
||||||
|
|
||||||
static void setMaximumFPS(unsigned fps);
|
|
||||||
|
|
||||||
// public so that the glfw callback can access it
|
|
||||||
inline static unsigned contentWidth, contentHeight;
|
|
||||||
inline static float windowScale;
|
|
||||||
|
|
||||||
static void resizeFramerateCounter();
|
|
||||||
static void resizeNotificationManager();
|
|
||||||
|
|
||||||
static GenericEvent* getGlobalFocusChangeEvent();
|
|
||||||
static VoidEvent* getGlobalHintsUpdateEvent();
|
|
||||||
|
|
||||||
static View* getCurrentFocus();
|
|
||||||
|
|
||||||
static std::string getTitle();
|
|
||||||
|
|
||||||
private:
|
|
||||||
inline static GLFWwindow* window;
|
|
||||||
inline static NVGcontext* vg;
|
|
||||||
|
|
||||||
inline static std::string title;
|
|
||||||
|
|
||||||
inline static TaskManager* taskManager;
|
|
||||||
inline static NotificationManager* notificationManager;
|
|
||||||
|
|
||||||
inline static FontStash fontStash;
|
|
||||||
|
|
||||||
inline static std::vector<View*> viewStack;
|
|
||||||
inline static std::vector<View*> focusStack;
|
|
||||||
|
|
||||||
inline static unsigned windowWidth, windowHeight;
|
|
||||||
|
|
||||||
inline static View* currentFocus;
|
|
||||||
|
|
||||||
inline static Theme currentTheme;
|
|
||||||
inline static ThemeVariant currentThemeVariant;
|
|
||||||
|
|
||||||
inline static GLFWgamepadstate oldGamepad;
|
|
||||||
inline static GLFWgamepadstate gamepad;
|
|
||||||
|
|
||||||
inline static Style currentStyle;
|
|
||||||
|
|
||||||
inline static unsigned blockInputsTokens = 0; // any value > 0 means inputs are blocked
|
|
||||||
|
|
||||||
inline static std::string commonFooter = "";
|
|
||||||
|
|
||||||
inline static FramerateCounter* framerateCounter = nullptr;
|
|
||||||
|
|
||||||
inline static float frameTime = 0.0f;
|
|
||||||
|
|
||||||
inline static View* repetitionOldFocus = nullptr;
|
|
||||||
|
|
||||||
inline static GenericEvent globalFocusChangeEvent;
|
|
||||||
inline static VoidEvent globalHintsUpdateEvent;
|
|
||||||
|
|
||||||
static void navigate(FocusDirection direction);
|
|
||||||
|
|
||||||
static void onWindowSizeChanged();
|
|
||||||
|
|
||||||
static void frame();
|
|
||||||
static void clear();
|
|
||||||
static void exit();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles actions for the currently focused view and
|
|
||||||
* the given button
|
|
||||||
* Returns true if at least one action has been fired
|
|
||||||
*/
|
|
||||||
static bool handleAction(char button);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 WerWolv
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
enum class BoxLayoutOrientation
|
|
||||||
{
|
|
||||||
VERTICAL,
|
|
||||||
HORIZONTAL
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: Implement all gravity options for both orientations
|
|
||||||
enum class BoxLayoutGravity
|
|
||||||
{
|
|
||||||
DEFAULT, // left for horizontal, top for vertical
|
|
||||||
LEFT,
|
|
||||||
RIGHT,
|
|
||||||
TOP,
|
|
||||||
BOTTOM,
|
|
||||||
CENTER
|
|
||||||
};
|
|
||||||
|
|
||||||
class BoxLayoutChild
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
View* view;
|
|
||||||
bool fill; // should the child fill the remaining space?
|
|
||||||
};
|
|
||||||
|
|
||||||
// A basic horizontal or vertical box layout :
|
|
||||||
// - Children can currently only be stretched to full width (vertical) or height (horizontal)
|
|
||||||
// - Only works with children with fixed width (horizontal) or height (vertical)
|
|
||||||
|
|
||||||
// TODO: More complex alignment and/or stretching parameters to children
|
|
||||||
class BoxLayout : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
BoxLayoutOrientation orientation;
|
|
||||||
|
|
||||||
unsigned spacing = 0;
|
|
||||||
|
|
||||||
bool resize = false; // should the view be resized according to children size after a layout?
|
|
||||||
|
|
||||||
BoxLayoutGravity gravity = BoxLayoutGravity::DEFAULT;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::vector<BoxLayoutChild*> children;
|
|
||||||
|
|
||||||
size_t originalDefaultFocus = 0;
|
|
||||||
size_t defaultFocusedIndex = 0;
|
|
||||||
bool childFocused = false;
|
|
||||||
|
|
||||||
bool rememberFocus = false;
|
|
||||||
|
|
||||||
unsigned marginTop = 0;
|
|
||||||
unsigned marginRight = 0;
|
|
||||||
unsigned marginBottom = 0;
|
|
||||||
unsigned marginLeft = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should the BoxLayout apply spacing after
|
|
||||||
* this view?
|
|
||||||
*/
|
|
||||||
virtual void customSpacing(View* current, View* next, int* spacing) {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
BoxLayout(BoxLayoutOrientation orientation, size_t defaultFocus = 0);
|
|
||||||
~BoxLayout();
|
|
||||||
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
View* getNextFocus(FocusDirection direction, void* parentUserdata) override;
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
void onChildFocusGained(View* child) override;
|
|
||||||
void onChildFocusLost(View* child) override;
|
|
||||||
void willAppear(bool resetState = false) override;
|
|
||||||
void willDisappear(bool resetState = false) override;
|
|
||||||
void onWindowSizeChanged() override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets gravity
|
|
||||||
*/
|
|
||||||
void setGravity(BoxLayoutGravity gravity);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets spacing between views
|
|
||||||
*/
|
|
||||||
void setSpacing(unsigned spacing);
|
|
||||||
unsigned getSpacing();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets margins around views
|
|
||||||
* Bottom (vertical) or right (horizontal) are
|
|
||||||
* only effective if the last child is set to fill
|
|
||||||
*/
|
|
||||||
void setMargins(unsigned top, unsigned right, unsigned bottom, unsigned left);
|
|
||||||
void setMarginBottom(unsigned bottom);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a view to this box layout
|
|
||||||
* If fill is set to true, the child will
|
|
||||||
* fill the remaining space
|
|
||||||
*/
|
|
||||||
void addView(View* view, bool fill = false, bool resetState = false);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the view at specified
|
|
||||||
* The view will be freed if free
|
|
||||||
* is set to true (defaults to true)
|
|
||||||
*
|
|
||||||
* Warning: this method isn't correctly
|
|
||||||
* implemented - currently removing a view will
|
|
||||||
* most likely result in memory corruption
|
|
||||||
*/
|
|
||||||
void removeView(int index, bool free = true);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all views
|
|
||||||
* from this layout
|
|
||||||
*/
|
|
||||||
void clear(bool free = true);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this layout
|
|
||||||
* doesn't contain any views
|
|
||||||
*/
|
|
||||||
bool isEmpty();
|
|
||||||
|
|
||||||
bool isChildFocused();
|
|
||||||
|
|
||||||
void setFocusedIndex(unsigned index);
|
|
||||||
size_t getViewsCount();
|
|
||||||
|
|
||||||
View* getChild(size_t i);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If enabled, will force the layout to resize itself
|
|
||||||
* to match the children size
|
|
||||||
* Mandatory for using in a ScrollView
|
|
||||||
*/
|
|
||||||
void setResize(bool resize);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should the default focus be set to the originally focused
|
|
||||||
* view (until the layout disappears)?
|
|
||||||
*/
|
|
||||||
void setRememberFocus(bool rememberFocus);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019-2020 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/image.hpp>
|
|
||||||
#include <borealis/label.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
enum class ButtonStyle
|
|
||||||
{
|
|
||||||
PLAIN = 0, // regular, plain button
|
|
||||||
BORDERED, // text and a border
|
|
||||||
BORDERLESS, // only text
|
|
||||||
CRASH, // same as borderless but with a different text color
|
|
||||||
DIALOG // same as borderless but with a different text color
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class ButtonState
|
|
||||||
{
|
|
||||||
ENABLED = 0,
|
|
||||||
DISABLED
|
|
||||||
};
|
|
||||||
|
|
||||||
// A button
|
|
||||||
class Button : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ButtonStyle style;
|
|
||||||
Label* label = nullptr;
|
|
||||||
Image* image = nullptr;
|
|
||||||
|
|
||||||
GenericEvent clickEvent;
|
|
||||||
|
|
||||||
LabelStyle getLabelStyle();
|
|
||||||
|
|
||||||
ButtonState state = ButtonState::ENABLED;
|
|
||||||
|
|
||||||
float cornerRadiusOverride = 0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Button(ButtonStyle style);
|
|
||||||
~Button();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
virtual bool onClick();
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash);
|
|
||||||
void getHighlightInsets(unsigned* top, unsigned* right, unsigned* bottom, unsigned* left) override;
|
|
||||||
|
|
||||||
ButtonState getState();
|
|
||||||
void setState(ButtonState state);
|
|
||||||
|
|
||||||
Button* setLabel(std::string label);
|
|
||||||
Button* setImage(std::string path);
|
|
||||||
Button* setImage(unsigned char* buffer, size_t bufferSize);
|
|
||||||
|
|
||||||
GenericEvent* getClickEvent();
|
|
||||||
|
|
||||||
View* getDefaultFocus() override
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setCornerRadius(float cornerRadius);
|
|
||||||
|
|
||||||
void getHighlightMetrics(Style* style, float* cornerRadius) override
|
|
||||||
{
|
|
||||||
if (cornerRadiusOverride)
|
|
||||||
*cornerRadius = cornerRadiusOverride;
|
|
||||||
else
|
|
||||||
*cornerRadius = style->Button.cornerRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isHighlightBackgroundEnabled() override
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019-2020 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/button.hpp>
|
|
||||||
#include <borealis/hint.hpp>
|
|
||||||
#include <borealis/label.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// A screen similar to the "The software has closed" dialog
|
|
||||||
// pressing OK will exit the app
|
|
||||||
class CrashFrame : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
Label* label;
|
|
||||||
Button* button;
|
|
||||||
Hint* hint;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CrashFrame(std::string text);
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
void onShowAnimationEnd() override;
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
|
|
||||||
bool isTranslucent() override
|
|
||||||
{
|
|
||||||
return true; // have it always translucent to disable fade out animation
|
|
||||||
}
|
|
||||||
|
|
||||||
~CrashFrame();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019-2020 natinusala
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/box_layout.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// TODO: Add a "can be cancelled with B" flag
|
|
||||||
// TODO: Add buttons at creation time
|
|
||||||
// TODO: Add the blurred dialog type once the blur is finished
|
|
||||||
|
|
||||||
class DialogButton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
std::string label;
|
|
||||||
GenericEvent::Callback cb;
|
|
||||||
};
|
|
||||||
|
|
||||||
// A modal dialog with zero to three buttons
|
|
||||||
// and anything as content
|
|
||||||
// Create the dialog then use open() and close()
|
|
||||||
class Dialog : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
View* contentView = nullptr;
|
|
||||||
|
|
||||||
unsigned frameX, frameY, frameWidth, frameHeight;
|
|
||||||
|
|
||||||
std::vector<DialogButton*> buttons;
|
|
||||||
BoxLayout* verticalButtonsLayout = nullptr;
|
|
||||||
BoxLayout* horizontalButtonsLayout = nullptr;
|
|
||||||
|
|
||||||
void rebuildButtons();
|
|
||||||
|
|
||||||
unsigned getButtonsHeight();
|
|
||||||
|
|
||||||
bool cancelable = true;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Dialog(std::string text);
|
|
||||||
Dialog(View* contentView);
|
|
||||||
~Dialog();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
virtual bool onCancel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a button to this dialog, with a maximum of three
|
|
||||||
* The position depends on the add order
|
|
||||||
*
|
|
||||||
* Adding a button after the dialog has been opened is
|
|
||||||
* NOT SUPPORTED
|
|
||||||
*/
|
|
||||||
void addButton(std::string label, GenericEvent::Callback cb);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A cancelable dialog is closed when
|
|
||||||
* the user presses B (defaults to true)
|
|
||||||
*
|
|
||||||
* A dialog without any buttons cannot
|
|
||||||
* be cancelable
|
|
||||||
*/
|
|
||||||
void setCancelable(bool cancelable);
|
|
||||||
|
|
||||||
void open();
|
|
||||||
void close(std::function<void(void)> cb = []() {});
|
|
||||||
|
|
||||||
bool isTranslucent() override
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019-2020 natinusala
|
|
||||||
Copyright (C) 2019-2020 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/event.hpp>
|
|
||||||
#include <borealis/list.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// Fired when the user has selected a value
|
|
||||||
//
|
|
||||||
// Parameter is either the selected value index
|
|
||||||
// or -1 if the user cancelled
|
|
||||||
//
|
|
||||||
// Assume that the Dropdown is deleted
|
|
||||||
// as soon as this function is called
|
|
||||||
typedef Event<int> ValueSelectedEvent;
|
|
||||||
|
|
||||||
// Allows the user to select between multiple
|
|
||||||
// values
|
|
||||||
// Use Dropdown::open()
|
|
||||||
class Dropdown : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
Dropdown(std::string title, std::vector<std::string> values, ValueSelectedEvent::Callback cb, size_t selected = 0);
|
|
||||||
|
|
||||||
std::string title;
|
|
||||||
|
|
||||||
int valuesCount;
|
|
||||||
|
|
||||||
ValueSelectedEvent valueEvent;
|
|
||||||
|
|
||||||
List* list;
|
|
||||||
Hint* hint;
|
|
||||||
|
|
||||||
float topOffset; // for slide in animation
|
|
||||||
|
|
||||||
protected:
|
|
||||||
unsigned getShowAnimationDuration(ViewAnimation animation) override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
~Dropdown();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
virtual bool onCancel();
|
|
||||||
void show(std::function<void(void)> cb, bool animate = true, ViewAnimation animation = ViewAnimation::FADE) override;
|
|
||||||
void willAppear(bool resetState = false) override;
|
|
||||||
void willDisappear(bool resetState = false) override;
|
|
||||||
|
|
||||||
static void open(std::string title, std::vector<std::string> values, ValueSelectedEvent::Callback cb, int selected = -1);
|
|
||||||
|
|
||||||
bool isTranslucent() override
|
|
||||||
{
|
|
||||||
return true || View::isTranslucent();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2020 natinusala
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <functional>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// Simple observer pattern implementation
|
|
||||||
//
|
|
||||||
// Usage:
|
|
||||||
// 1. typedef your event type
|
|
||||||
// 2. create as many events as you want using that type
|
|
||||||
// 3. call subscribe on the events with your observers
|
|
||||||
// 4. call fire when you want to fire the events
|
|
||||||
// it wil return true if at least one subscriber exists
|
|
||||||
// for that event
|
|
||||||
template <typename... Ts>
|
|
||||||
class Event
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef std::function<void(Ts...)> Callback;
|
|
||||||
typedef std::list<Callback> CallbacksList;
|
|
||||||
typedef typename CallbacksList::iterator Subscription;
|
|
||||||
|
|
||||||
Subscription subscribe(Callback cb);
|
|
||||||
void unsubscribe(Subscription subscription);
|
|
||||||
bool fire(Ts... args);
|
|
||||||
|
|
||||||
private:
|
|
||||||
CallbacksList callbacks;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename... Ts>
|
|
||||||
typename Event<Ts...>::Subscription Event<Ts...>::subscribe(Event<Ts...>::Callback cb)
|
|
||||||
{
|
|
||||||
this->callbacks.push_back(cb);
|
|
||||||
return --this->callbacks.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Ts>
|
|
||||||
void Event<Ts...>::unsubscribe(Event<Ts...>::Subscription subscription)
|
|
||||||
{
|
|
||||||
this->callbacks.erase(subscription);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Ts>
|
|
||||||
bool Event<Ts...>::fire(Ts... args)
|
|
||||||
{
|
|
||||||
for (Callback cb : this->callbacks)
|
|
||||||
cb(args...);
|
|
||||||
|
|
||||||
return !this->callbacks.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace brls
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,39 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2018 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (boolean.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_BOOLEAN_H
|
|
||||||
#define __LIBRETRO_SDK_BOOLEAN_H
|
|
||||||
|
|
||||||
#ifndef __cplusplus
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1800 && !defined(SN_TARGET_PS3)
|
|
||||||
/* Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. */
|
|
||||||
#define bool unsigned char
|
|
||||||
#define true 1
|
|
||||||
#define false 0
|
|
||||||
#else
|
|
||||||
#include <stdbool.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2018 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (strl.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_COMPAT_STRL_H
|
|
||||||
#define __LIBRETRO_SDK_COMPAT_STRL_H
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H)
|
|
||||||
#include "../../../config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
|
||||||
|
|
||||||
#ifdef __MACH__
|
|
||||||
#ifndef HAVE_STRL
|
|
||||||
#define HAVE_STRL
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRL
|
|
||||||
/* Avoid possible naming collisions during link since
|
|
||||||
* we prefer to use the actual name. */
|
|
||||||
#define strlcpy(dst, src, size) strlcpy_retro__(dst, src, size)
|
|
||||||
|
|
||||||
#define strlcat(dst, src, size) strlcat_retro__(dst, src, size)
|
|
||||||
|
|
||||||
size_t strlcpy(char *dest, const char *source, size_t size);
|
|
||||||
size_t strlcat(char *dest, const char *source, size_t size);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *strldup(const char *s, size_t n);
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2018 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (utf.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LIBRETRO_ENCODINGS_UTF_H
|
|
||||||
#define _LIBRETRO_ENCODINGS_UTF_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include <boolean.h>
|
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
|
||||||
|
|
||||||
enum CodePage
|
|
||||||
{
|
|
||||||
CODEPAGE_LOCAL = 0, /* CP_ACP */
|
|
||||||
CODEPAGE_UTF8 = 65001 /* CP_UTF8 */
|
|
||||||
};
|
|
||||||
|
|
||||||
size_t utf8_conv_utf32(uint32_t *out, size_t out_chars,
|
|
||||||
const char *in, size_t in_size);
|
|
||||||
|
|
||||||
bool utf16_conv_utf8(uint8_t *out, size_t *out_chars,
|
|
||||||
const uint16_t *in, size_t in_size);
|
|
||||||
|
|
||||||
size_t utf8len(const char *string);
|
|
||||||
|
|
||||||
size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars);
|
|
||||||
|
|
||||||
const char *utf8skip(const char *str, size_t chars);
|
|
||||||
|
|
||||||
uint32_t utf8_walk(const char **string);
|
|
||||||
|
|
||||||
bool utf16_to_char_string(const uint16_t *in, char *s, size_t len);
|
|
||||||
|
|
||||||
char* utf8_to_local_string_alloc(const char *str);
|
|
||||||
|
|
||||||
char* local_to_utf8_string_alloc(const char *str);
|
|
||||||
|
|
||||||
wchar_t* utf8_to_utf16_string_alloc(const char *str);
|
|
||||||
|
|
||||||
char* utf16_to_utf8_string_alloc(const wchar_t *str);
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2018 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (features_cpu.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LIBRETRO_SDK_CPU_INFO_H
|
|
||||||
#define _LIBRETRO_SDK_CPU_INFO_H
|
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <libretro.h>
|
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cpu_features_get_perf_counter:
|
|
||||||
*
|
|
||||||
* Gets performance counter.
|
|
||||||
*
|
|
||||||
* Returns: performance counter.
|
|
||||||
**/
|
|
||||||
retro_perf_tick_t cpu_features_get_perf_counter(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cpu_features_get_time_usec:
|
|
||||||
*
|
|
||||||
* Gets time in microseconds, from an undefined epoch.
|
|
||||||
* The epoch may change between computers or across reboots.
|
|
||||||
*
|
|
||||||
* Returns: time in microseconds
|
|
||||||
**/
|
|
||||||
retro_time_t cpu_features_get_time_usec(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cpu_features_get:
|
|
||||||
*
|
|
||||||
* Gets CPU features.
|
|
||||||
*
|
|
||||||
* Returns: bitmask of all CPU features available.
|
|
||||||
**/
|
|
||||||
uint64_t cpu_features_get(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cpu_features_get_core_amount:
|
|
||||||
*
|
|
||||||
* Gets the amount of available CPU cores.
|
|
||||||
*
|
|
||||||
* Returns: amount of CPU cores available.
|
|
||||||
**/
|
|
||||||
unsigned cpu_features_get_core_amount(void);
|
|
||||||
|
|
||||||
void cpu_features_get_model_name(char *name, int len);
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,37 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2018 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (retro_assert.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RETRO_ASSERT_H
|
|
||||||
#define __RETRO_ASSERT_H
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#ifdef RARCH_INTERNAL
|
|
||||||
#include <stdio.h>
|
|
||||||
#define retro_assert(cond) do { \
|
|
||||||
if (!(cond)) { printf("Assertion failed at %s:%d.\n", __FILE__, __LINE__); abort(); } \
|
|
||||||
} while(0)
|
|
||||||
#else
|
|
||||||
#define retro_assert(cond) assert(cond)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2018 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (retro_common_api.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LIBRETRO_COMMON_RETRO_COMMON_API_H
|
|
||||||
#define _LIBRETRO_COMMON_RETRO_COMMON_API_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
This file is designed to normalize the libretro-common compiling environment
|
|
||||||
for public API headers. This should be leaner than a normal compiling environment,
|
|
||||||
since it gets #included into other project's sources.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* ------------------------------------ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
Ordinarily we want to put #ifdef __cplusplus extern "C" in C library
|
|
||||||
headers to enable them to get used by c++ sources.
|
|
||||||
However, we want to support building this library as C++ as well, so a
|
|
||||||
special technique is called for.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define RETRO_BEGIN_DECLS
|
|
||||||
#define RETRO_END_DECLS
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
|
|
||||||
#ifdef CXX_BUILD
|
|
||||||
/* build wants everything to be built as c++, so no extern "C" */
|
|
||||||
#else
|
|
||||||
#undef RETRO_BEGIN_DECLS
|
|
||||||
#undef RETRO_END_DECLS
|
|
||||||
#define RETRO_BEGIN_DECLS extern "C" {
|
|
||||||
#define RETRO_END_DECLS }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* header is included by a C source file, so no extern "C" */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
IMO, this non-standard ssize_t should not be used.
|
|
||||||
However, it's a good example of how to handle something like this.
|
|
||||||
*/
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#ifndef HAVE_SSIZE_T
|
|
||||||
#define HAVE_SSIZE_T
|
|
||||||
#if defined(_WIN64)
|
|
||||||
typedef __int64 ssize_t;
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
typedef int ssize_t;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#elif defined(__MACH__)
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#if _MSC_VER >= 1800
|
|
||||||
#include <inttypes.h>
|
|
||||||
#else
|
|
||||||
#ifndef PRId64
|
|
||||||
#define PRId64 "I64d"
|
|
||||||
#define PRIu64 "I64u"
|
|
||||||
#define PRIuPTR "Iu"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
/* C++11 says this one isn't needed, but apparently (some versions of) mingw require it anyways */
|
|
||||||
/* https://stackoverflow.com/questions/8132399/how-to-printf-uint64-t-fails-with-spurious-trailing-in-format */
|
|
||||||
/* https://github.com/libretro/RetroArch/issues/6009 */
|
|
||||||
#define __STDC_FORMAT_MACROS
|
|
||||||
#include <inttypes.h>
|
|
||||||
#endif
|
|
||||||
#ifndef PRId64
|
|
||||||
#error "inttypes.h is being screwy"
|
|
||||||
#endif
|
|
||||||
#define STRING_REP_INT64 "%" PRId64
|
|
||||||
#define STRING_REP_UINT64 "%" PRIu64
|
|
||||||
#define STRING_REP_USIZE "%" PRIuPTR
|
|
||||||
|
|
||||||
/*
|
|
||||||
I would like to see retro_inline.h moved in here; possibly boolean too.
|
|
||||||
|
|
||||||
rationale: these are used in public APIs, and it is easier to find problems
|
|
||||||
and write code that works the first time portably when theyre included uniformly
|
|
||||||
than to do the analysis from scratch each time you think you need it, for each feature.
|
|
||||||
|
|
||||||
Moreover it helps force you to make hard decisions: if you EVER bring in boolean.h,
|
|
||||||
then you should pay the price everywhere, so you can see how much grief it will cause.
|
|
||||||
|
|
||||||
Of course, another school of thought is that you should do as little damage as possible
|
|
||||||
in as few places as possible...
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* _LIBRETRO_COMMON_RETRO_COMMON_API_H */
|
|
||||||
#endif
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2018 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (retro_inline.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_INLINE_H
|
|
||||||
#define __LIBRETRO_SDK_INLINE_H
|
|
||||||
|
|
||||||
#ifndef INLINE
|
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__INTEL_COMPILER)
|
|
||||||
#define INLINE __inline
|
|
||||||
#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
|
|
||||||
#define INLINE inline
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
#define INLINE __inline__
|
|
||||||
#else
|
|
||||||
#define INLINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2018 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (retro_math.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LIBRETRO_COMMON_MATH_H
|
|
||||||
#define _LIBRETRO_COMMON_MATH_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(_XBOX)
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
|
||||||
#elif defined(_WIN32) && defined(_XBOX)
|
|
||||||
#include <Xtl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include <compat/msvc.h>
|
|
||||||
#endif
|
|
||||||
#include <retro_inline.h>
|
|
||||||
|
|
||||||
#ifndef M_PI
|
|
||||||
#if !defined(USE_MATH_DEFINES)
|
|
||||||
#define M_PI 3.14159265358979323846264338327
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MAX
|
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MIN
|
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* next_pow2:
|
|
||||||
* @v : initial value
|
|
||||||
*
|
|
||||||
* Get next power of 2 value based on initial value.
|
|
||||||
*
|
|
||||||
* Returns: next power of 2 value (derived from @v).
|
|
||||||
**/
|
|
||||||
static INLINE uint32_t next_pow2(uint32_t v)
|
|
||||||
{
|
|
||||||
v--;
|
|
||||||
v |= v >> 1;
|
|
||||||
v |= v >> 2;
|
|
||||||
v |= v >> 4;
|
|
||||||
v |= v >> 8;
|
|
||||||
v |= v >> 16;
|
|
||||||
v++;
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* prev_pow2:
|
|
||||||
* @v : initial value
|
|
||||||
*
|
|
||||||
* Get previous power of 2 value based on initial value.
|
|
||||||
*
|
|
||||||
* Returns: previous power of 2 value (derived from @v).
|
|
||||||
**/
|
|
||||||
static INLINE uint32_t prev_pow2(uint32_t v)
|
|
||||||
{
|
|
||||||
v |= v >> 1;
|
|
||||||
v |= v >> 2;
|
|
||||||
v |= v >> 4;
|
|
||||||
v |= v >> 8;
|
|
||||||
v |= v >> 16;
|
|
||||||
return v - (v >> 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2018 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (retro_miscellaneous.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RARCH_MISCELLANEOUS_H
|
|
||||||
#define __RARCH_MISCELLANEOUS_H
|
|
||||||
|
|
||||||
#define RARCH_MAX_SUBSYSTEMS 10
|
|
||||||
#define RARCH_MAX_SUBSYSTEM_ROMS 10
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <boolean.h>
|
|
||||||
#include <retro_inline.h>
|
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(_XBOX)
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#elif defined(_WIN32) && defined(_XBOX)
|
|
||||||
#include <Xtl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__CELLOS_LV2__)
|
|
||||||
#include <sys/fs_external.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include <compat/msvc.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static INLINE void bits_or_bits(uint32_t *a, uint32_t *b, uint32_t count)
|
|
||||||
{
|
|
||||||
uint32_t i;
|
|
||||||
for (i = 0; i < count;i++)
|
|
||||||
a[i] |= b[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
static INLINE void bits_clear_bits(uint32_t *a, uint32_t *b, uint32_t count)
|
|
||||||
{
|
|
||||||
uint32_t i;
|
|
||||||
for (i = 0; i < count;i++)
|
|
||||||
a[i] &= ~b[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
static INLINE bool bits_any_set(uint32_t* ptr, uint32_t count)
|
|
||||||
{
|
|
||||||
uint32_t i;
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
if (ptr[i] != 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef PATH_MAX_LENGTH
|
|
||||||
#if defined(__CELLOS_LV2__)
|
|
||||||
#define PATH_MAX_LENGTH CELL_FS_MAX_FS_PATH_LENGTH
|
|
||||||
#elif defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(PS2) || defined(GEKKO)|| defined(WIIU) || defined(ORBIS)
|
|
||||||
#define PATH_MAX_LENGTH 512
|
|
||||||
#else
|
|
||||||
#define PATH_MAX_LENGTH 4096
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MAX
|
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MIN
|
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
|
||||||
|
|
||||||
#define BITS_GET_ELEM(a, i) ((a).data[i])
|
|
||||||
#define BITS_GET_ELEM_PTR(a, i) ((a)->data[i])
|
|
||||||
|
|
||||||
#define BIT_SET(a, bit) ((a)[(bit) >> 3] |= (1 << ((bit) & 7)))
|
|
||||||
#define BIT_CLEAR(a, bit) ((a)[(bit) >> 3] &= ~(1 << ((bit) & 7)))
|
|
||||||
#define BIT_GET(a, bit) (((a)[(bit) >> 3] >> ((bit) & 7)) & 1)
|
|
||||||
|
|
||||||
#define BIT16_SET(a, bit) ((a) |= (1 << ((bit) & 15)))
|
|
||||||
#define BIT16_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 15)))
|
|
||||||
#define BIT16_GET(a, bit) (((a) >> ((bit) & 15)) & 1)
|
|
||||||
#define BIT16_CLEAR_ALL(a) ((a) = 0)
|
|
||||||
|
|
||||||
#define BIT32_SET(a, bit) ((a) |= (1 << ((bit) & 31)))
|
|
||||||
#define BIT32_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 31)))
|
|
||||||
#define BIT32_GET(a, bit) (((a) >> ((bit) & 31)) & 1)
|
|
||||||
#define BIT32_CLEAR_ALL(a) ((a) = 0)
|
|
||||||
|
|
||||||
#define BIT64_SET(a, bit) ((a) |= (UINT64_C(1) << ((bit) & 63)))
|
|
||||||
#define BIT64_CLEAR(a, bit) ((a) &= ~(UINT64_C(1) << ((bit) & 63)))
|
|
||||||
#define BIT64_GET(a, bit) (((a) >> ((bit) & 63)) & 1)
|
|
||||||
#define BIT64_CLEAR_ALL(a) ((a) = 0)
|
|
||||||
|
|
||||||
#define BIT128_SET(a, bit) ((a).data[(bit) >> 5] |= (1 << ((bit) & 31)))
|
|
||||||
#define BIT128_CLEAR(a, bit) ((a).data[(bit) >> 5] &= ~(1 << ((bit) & 31)))
|
|
||||||
#define BIT128_GET(a, bit) (((a).data[(bit) >> 5] >> ((bit) & 31)) & 1)
|
|
||||||
#define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a))
|
|
||||||
|
|
||||||
#define BIT128_SET_PTR(a, bit) BIT128_SET(*a, bit)
|
|
||||||
#define BIT128_CLEAR_PTR(a, bit) BIT128_CLEAR(*a, bit)
|
|
||||||
#define BIT128_GET_PTR(a, bit) BIT128_GET(*a, bit)
|
|
||||||
#define BIT128_CLEAR_ALL_PTR(a) BIT128_CLEAR_ALL(*a)
|
|
||||||
|
|
||||||
#define BIT256_SET(a, bit) BIT128_SET(a, bit)
|
|
||||||
#define BIT256_CLEAR(a, bit) BIT128_CLEAR(a, bit)
|
|
||||||
#define BIT256_GET(a, bit) BIT128_GET(a, bit)
|
|
||||||
#define BIT256_CLEAR_ALL(a) BIT128_CLEAR_ALL(a)
|
|
||||||
|
|
||||||
#define BIT256_SET_PTR(a, bit) BIT256_SET(*a, bit)
|
|
||||||
#define BIT256_CLEAR_PTR(a, bit) BIT256_CLEAR(*a, bit)
|
|
||||||
#define BIT256_GET_PTR(a, bit) BIT256_GET(*a, bit)
|
|
||||||
#define BIT256_CLEAR_ALL_PTR(a) BIT256_CLEAR_ALL(*a)
|
|
||||||
|
|
||||||
#define BITS_COPY16_PTR(a,bits) \
|
|
||||||
{ \
|
|
||||||
BIT128_CLEAR_ALL_PTR(a); \
|
|
||||||
BITS_GET_ELEM_PTR(a, 0) = (bits) & 0xffff; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BITS_COPY32_PTR(a,bits) \
|
|
||||||
{ \
|
|
||||||
BIT128_CLEAR_ALL_PTR(a); \
|
|
||||||
BITS_GET_ELEM_PTR(a, 0) = (bits); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Helper macros and struct to keep track of many booleans. */
|
|
||||||
/* This struct has 256 bits. */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t data[8];
|
|
||||||
} retro_bits_t;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# ifdef _WIN64
|
|
||||||
# define PRI_SIZET PRIu64
|
|
||||||
# else
|
|
||||||
# if _MSC_VER == 1800
|
|
||||||
# define PRI_SIZET PRIu32
|
|
||||||
# else
|
|
||||||
# define PRI_SIZET "u"
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#elif PS2
|
|
||||||
# define PRI_SIZET "u"
|
|
||||||
#else
|
|
||||||
# if (SIZE_MAX == 0xFFFF)
|
|
||||||
# define PRI_SIZET "hu"
|
|
||||||
# elif (SIZE_MAX == 0xFFFFFFFF)
|
|
||||||
# define PRI_SIZET "u"
|
|
||||||
# elif (SIZE_MAX == 0xFFFFFFFFFFFFFFFF)
|
|
||||||
# define PRI_SIZET "lu"
|
|
||||||
# else
|
|
||||||
# error PRI_SIZET: unknown SIZE_MAX
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2018 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (retro_timers.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __LIBRETRO_COMMON_TIMERS_H
|
|
||||||
#define __LIBRETRO_COMMON_TIMERS_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
|
||||||
#include <sys/timer.h>
|
|
||||||
#elif defined(XENON)
|
|
||||||
#include <time/time.h>
|
|
||||||
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
|
||||||
#include <unistd.h>
|
|
||||||
#elif defined(WIIU)
|
|
||||||
#include <wiiu/os/thread.h>
|
|
||||||
#elif defined(PSP)
|
|
||||||
#include <pspthreadman.h>
|
|
||||||
#elif defined(VITA)
|
|
||||||
#include <psp2/kernel/threadmgr.h>
|
|
||||||
#elif defined(PS2)
|
|
||||||
#include <SDL/SDL_timer.h>
|
|
||||||
#elif defined(_3DS)
|
|
||||||
#include <3ds.h>
|
|
||||||
#else
|
|
||||||
#include <time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(_XBOX)
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
|
||||||
#elif defined(_WIN32) && defined(_XBOX)
|
|
||||||
#include <Xtl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include <compat/msvc.h>
|
|
||||||
#endif
|
|
||||||
#include <retro_inline.h>
|
|
||||||
|
|
||||||
#ifdef DJGPP
|
|
||||||
#define timespec timeval
|
|
||||||
#define tv_nsec tv_usec
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
extern int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
|
|
||||||
|
|
||||||
static int nanosleepDOS(const struct timespec *rqtp, struct timespec *rmtp)
|
|
||||||
{
|
|
||||||
usleep(1000000 * rqtp->tv_sec + rqtp->tv_nsec / 1000);
|
|
||||||
|
|
||||||
if (rmtp)
|
|
||||||
rmtp->tv_sec = rmtp->tv_nsec=0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define nanosleep nanosleepDOS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* retro_sleep:
|
|
||||||
* @msec : amount in milliseconds to sleep
|
|
||||||
*
|
|
||||||
* Sleeps for a specified amount of milliseconds (@msec).
|
|
||||||
**/
|
|
||||||
static INLINE void retro_sleep(unsigned msec)
|
|
||||||
{
|
|
||||||
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
|
||||||
sys_timer_usleep(1000 * msec);
|
|
||||||
#elif defined(PSP) || defined(VITA)
|
|
||||||
sceKernelDelayThread(1000 * msec);
|
|
||||||
#elif defined(PS2)
|
|
||||||
SDL_Delay(msec);
|
|
||||||
#elif defined(_3DS)
|
|
||||||
svcSleepThread(1000000 * (s64)msec);
|
|
||||||
#elif defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
|
||||||
SleepEx(msec, FALSE);
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
Sleep(msec);
|
|
||||||
#elif defined(XENON)
|
|
||||||
udelay(1000 * msec);
|
|
||||||
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
|
||||||
usleep(1000 * msec);
|
|
||||||
#elif defined(WIIU)
|
|
||||||
OSSleepTicks(ms_to_ticks(msec));
|
|
||||||
#else
|
|
||||||
struct timespec tv = {0};
|
|
||||||
tv.tv_sec = msec / 1000;
|
|
||||||
tv.tv_nsec = (msec % 1000) * 1000000;
|
|
||||||
nanosleep(&tv, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2018 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (file_stream.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_FILE_STREAM_H
|
|
||||||
#define __LIBRETRO_SDK_FILE_STREAM_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <libretro.h>
|
|
||||||
#include <retro_common_api.h>
|
|
||||||
#include <retro_inline.h>
|
|
||||||
#include <boolean.h>
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#define FILESTREAM_REQUIRED_VFS_VERSION 2
|
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
|
||||||
|
|
||||||
typedef struct RFILE RFILE;
|
|
||||||
|
|
||||||
#define FILESTREAM_REQUIRED_VFS_VERSION 2
|
|
||||||
|
|
||||||
void filestream_vfs_init(const struct retro_vfs_interface_info* vfs_info);
|
|
||||||
|
|
||||||
int64_t filestream_get_size(RFILE *stream);
|
|
||||||
|
|
||||||
int64_t filestream_truncate(RFILE *stream, int64_t length);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* filestream_open:
|
|
||||||
* @path : path to file
|
|
||||||
* @mode : file mode to use when opening (read/write)
|
|
||||||
* @bufsize : optional buffer size (-1 or 0 to use default)
|
|
||||||
*
|
|
||||||
* Opens a file for reading or writing, depending on the requested mode.
|
|
||||||
* Returns a pointer to an RFILE if opened successfully, otherwise NULL.
|
|
||||||
**/
|
|
||||||
RFILE *filestream_open(const char *path, unsigned mode, unsigned hints);
|
|
||||||
|
|
||||||
int64_t filestream_seek(RFILE *stream, int64_t offset, int seek_position);
|
|
||||||
|
|
||||||
int64_t filestream_read(RFILE *stream, void *data, int64_t len);
|
|
||||||
|
|
||||||
int64_t filestream_write(RFILE *stream, const void *data, int64_t len);
|
|
||||||
|
|
||||||
int64_t filestream_tell(RFILE *stream);
|
|
||||||
|
|
||||||
void filestream_rewind(RFILE *stream);
|
|
||||||
|
|
||||||
int filestream_close(RFILE *stream);
|
|
||||||
|
|
||||||
int64_t filestream_read_file(const char *path, void **buf, int64_t *len);
|
|
||||||
|
|
||||||
char *filestream_gets(RFILE *stream, char *s, size_t len);
|
|
||||||
|
|
||||||
int filestream_getc(RFILE *stream);
|
|
||||||
|
|
||||||
int filestream_scanf(RFILE *stream, const char* format, ...);
|
|
||||||
|
|
||||||
int filestream_eof(RFILE *stream);
|
|
||||||
|
|
||||||
bool filestream_write_file(const char *path, const void *data, int64_t size);
|
|
||||||
|
|
||||||
int filestream_putc(RFILE *stream, int c);
|
|
||||||
|
|
||||||
int filestream_vprintf(RFILE *stream, const char* format, va_list args);
|
|
||||||
|
|
||||||
int filestream_printf(RFILE *stream, const char* format, ...);
|
|
||||||
|
|
||||||
int filestream_error(RFILE *stream);
|
|
||||||
|
|
||||||
int filestream_flush(RFILE *stream);
|
|
||||||
|
|
||||||
int filestream_delete(const char *path);
|
|
||||||
|
|
||||||
int filestream_rename(const char *old_path, const char *new_path);
|
|
||||||
|
|
||||||
const char *filestream_get_path(RFILE *stream);
|
|
||||||
|
|
||||||
bool filestream_exists(const char *path);
|
|
||||||
|
|
||||||
char *filestream_getline(RFILE *stream);
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2019 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (stdstring.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_STDSTRING_H
|
|
||||||
#define __LIBRETRO_SDK_STDSTRING_H
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <boolean.h>
|
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
|
||||||
#include <retro_inline.h>
|
|
||||||
#include <compat/strl.h>
|
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
|
||||||
|
|
||||||
static INLINE bool string_is_empty(const char *data)
|
|
||||||
{
|
|
||||||
return !data || (*data == '\0');
|
|
||||||
}
|
|
||||||
|
|
||||||
static INLINE bool string_is_equal(const char *a, const char *b)
|
|
||||||
{
|
|
||||||
return (a && b) ? !strcmp(a, b) : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define STRLEN_CONST(x) ((sizeof((x))-1))
|
|
||||||
|
|
||||||
#define string_is_not_equal(a, b) !string_is_equal((a), (b))
|
|
||||||
|
|
||||||
#define string_add_pair_open(s, size) strlcat((s), " (", (size))
|
|
||||||
#define string_add_pair_close(s, size) strlcat((s), ")", (size))
|
|
||||||
#define string_add_bracket_open(s, size) strlcat((s), "{", (size))
|
|
||||||
#define string_add_bracket_close(s, size) strlcat((s), "}", (size))
|
|
||||||
#define string_add_single_quote(s, size) strlcat((s), "'", (size))
|
|
||||||
#define string_add_quote(s, size) strlcat((s), "\"", (size))
|
|
||||||
#define string_add_colon(s, size) strlcat((s), ":", (size))
|
|
||||||
#define string_add_glob_open(s, size) strlcat((s), "glob('*", (size))
|
|
||||||
#define string_add_glob_close(s, size) strlcat((s), "*')", (size))
|
|
||||||
|
|
||||||
#define string_is_not_equal_fast(a, b, size) (memcmp(a, b, size) != 0)
|
|
||||||
#define string_is_equal_fast(a, b, size) (memcmp(a, b, size) == 0)
|
|
||||||
|
|
||||||
static INLINE void string_add_between_pairs(char *s, const char *str,
|
|
||||||
size_t size)
|
|
||||||
{
|
|
||||||
string_add_pair_open(s, size);
|
|
||||||
strlcat(s, str, size);
|
|
||||||
string_add_pair_close(s, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static INLINE bool string_is_equal_case_insensitive(const char *a,
|
|
||||||
const char *b)
|
|
||||||
{
|
|
||||||
int result = 0;
|
|
||||||
const unsigned char *p1 = (const unsigned char*)a;
|
|
||||||
const unsigned char *p2 = (const unsigned char*)b;
|
|
||||||
|
|
||||||
if (!a || !b)
|
|
||||||
return false;
|
|
||||||
if (p1 == p2)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
while ((result = tolower (*p1) - tolower (*p2++)) == 0)
|
|
||||||
if (*p1++ == '\0')
|
|
||||||
break;
|
|
||||||
|
|
||||||
return (result == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static INLINE bool string_is_equal_noncase(const char *a, const char *b)
|
|
||||||
{
|
|
||||||
int result = 0;
|
|
||||||
const unsigned char *p1 = (const unsigned char*)a;
|
|
||||||
const unsigned char *p2 = (const unsigned char*)b;
|
|
||||||
|
|
||||||
if (!a || !b)
|
|
||||||
return false;
|
|
||||||
if (p1 == p2)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
while ((result = tolower (*p1) - tolower (*p2++)) == 0)
|
|
||||||
if (*p1++ == '\0')
|
|
||||||
break;
|
|
||||||
|
|
||||||
return (result == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *string_to_upper(char *s);
|
|
||||||
|
|
||||||
char *string_to_lower(char *s);
|
|
||||||
|
|
||||||
char *string_ucwords(char *s);
|
|
||||||
|
|
||||||
char *string_replace_substring(const char *in, const char *pattern,
|
|
||||||
const char *by);
|
|
||||||
|
|
||||||
/* Remove leading whitespaces */
|
|
||||||
char *string_trim_whitespace_left(char *const s);
|
|
||||||
|
|
||||||
/* Remove trailing whitespaces */
|
|
||||||
char *string_trim_whitespace_right(char *const s);
|
|
||||||
|
|
||||||
/* Remove leading and trailing whitespaces */
|
|
||||||
char *string_trim_whitespace(char *const s);
|
|
||||||
|
|
||||||
/* max_lines == 0 means no limit */
|
|
||||||
char *word_wrap(char *buffer, const char *string,
|
|
||||||
int line_width, bool unicode, unsigned max_lines);
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
Copyright (c) 2013 Mikko Mononen memon@inside.org
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,685 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2013 Mikko Mononen memon@inside.org
|
|
||||||
//
|
|
||||||
// This software is provided 'as-is', without any express or implied
|
|
||||||
// warranty. In no event will the authors be held liable for any damages
|
|
||||||
// arising from the use of this software.
|
|
||||||
// Permission is granted to anyone to use this software for any purpose,
|
|
||||||
// including commercial applications, and to alter it and redistribute it
|
|
||||||
// freely, subject to the following restrictions:
|
|
||||||
// 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
// claim that you wrote the original software. If you use this software
|
|
||||||
// in a product, an acknowledgment in the product documentation would be
|
|
||||||
// appreciated but is not required.
|
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
// misrepresented as being the original software.
|
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef NANOVG_H
|
|
||||||
#define NANOVG_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define NVG_PI 3.14159265358979323846264338327f
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct NVGcontext NVGcontext;
|
|
||||||
|
|
||||||
struct NVGcolor {
|
|
||||||
union {
|
|
||||||
float rgba[4];
|
|
||||||
struct {
|
|
||||||
float r,g,b,a;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
typedef struct NVGcolor NVGcolor;
|
|
||||||
|
|
||||||
struct NVGpaint {
|
|
||||||
float xform[6];
|
|
||||||
float extent[2];
|
|
||||||
float radius;
|
|
||||||
float feather;
|
|
||||||
NVGcolor innerColor;
|
|
||||||
NVGcolor outerColor;
|
|
||||||
int image;
|
|
||||||
};
|
|
||||||
typedef struct NVGpaint NVGpaint;
|
|
||||||
|
|
||||||
enum NVGwinding {
|
|
||||||
NVG_CCW = 1, // Winding for solid shapes
|
|
||||||
NVG_CW = 2, // Winding for holes
|
|
||||||
};
|
|
||||||
|
|
||||||
enum NVGsolidity {
|
|
||||||
NVG_SOLID = 1, // CCW
|
|
||||||
NVG_HOLE = 2, // CW
|
|
||||||
};
|
|
||||||
|
|
||||||
enum NVGlineCap {
|
|
||||||
NVG_BUTT,
|
|
||||||
NVG_ROUND,
|
|
||||||
NVG_SQUARE,
|
|
||||||
NVG_BEVEL,
|
|
||||||
NVG_MITER,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum NVGalign {
|
|
||||||
// Horizontal align
|
|
||||||
NVG_ALIGN_LEFT = 1<<0, // Default, align text horizontally to left.
|
|
||||||
NVG_ALIGN_CENTER = 1<<1, // Align text horizontally to center.
|
|
||||||
NVG_ALIGN_RIGHT = 1<<2, // Align text horizontally to right.
|
|
||||||
// Vertical align
|
|
||||||
NVG_ALIGN_TOP = 1<<3, // Align text vertically to top.
|
|
||||||
NVG_ALIGN_MIDDLE = 1<<4, // Align text vertically to middle.
|
|
||||||
NVG_ALIGN_BOTTOM = 1<<5, // Align text vertically to bottom.
|
|
||||||
NVG_ALIGN_BASELINE = 1<<6, // Default, align text vertically to baseline.
|
|
||||||
};
|
|
||||||
|
|
||||||
enum NVGblendFactor {
|
|
||||||
NVG_ZERO = 1<<0,
|
|
||||||
NVG_ONE = 1<<1,
|
|
||||||
NVG_SRC_COLOR = 1<<2,
|
|
||||||
NVG_ONE_MINUS_SRC_COLOR = 1<<3,
|
|
||||||
NVG_DST_COLOR = 1<<4,
|
|
||||||
NVG_ONE_MINUS_DST_COLOR = 1<<5,
|
|
||||||
NVG_SRC_ALPHA = 1<<6,
|
|
||||||
NVG_ONE_MINUS_SRC_ALPHA = 1<<7,
|
|
||||||
NVG_DST_ALPHA = 1<<8,
|
|
||||||
NVG_ONE_MINUS_DST_ALPHA = 1<<9,
|
|
||||||
NVG_SRC_ALPHA_SATURATE = 1<<10,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum NVGcompositeOperation {
|
|
||||||
NVG_SOURCE_OVER,
|
|
||||||
NVG_SOURCE_IN,
|
|
||||||
NVG_SOURCE_OUT,
|
|
||||||
NVG_ATOP,
|
|
||||||
NVG_DESTINATION_OVER,
|
|
||||||
NVG_DESTINATION_IN,
|
|
||||||
NVG_DESTINATION_OUT,
|
|
||||||
NVG_DESTINATION_ATOP,
|
|
||||||
NVG_LIGHTER,
|
|
||||||
NVG_COPY,
|
|
||||||
NVG_XOR,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct NVGcompositeOperationState {
|
|
||||||
int srcRGB;
|
|
||||||
int dstRGB;
|
|
||||||
int srcAlpha;
|
|
||||||
int dstAlpha;
|
|
||||||
};
|
|
||||||
typedef struct NVGcompositeOperationState NVGcompositeOperationState;
|
|
||||||
|
|
||||||
struct NVGglyphPosition {
|
|
||||||
const char* str; // Position of the glyph in the input string.
|
|
||||||
float x; // The x-coordinate of the logical glyph position.
|
|
||||||
float minx, maxx; // The bounds of the glyph shape.
|
|
||||||
};
|
|
||||||
typedef struct NVGglyphPosition NVGglyphPosition;
|
|
||||||
|
|
||||||
struct NVGtextRow {
|
|
||||||
const char* start; // Pointer to the input text where the row starts.
|
|
||||||
const char* end; // Pointer to the input text where the row ends (one past the last character).
|
|
||||||
const char* next; // Pointer to the beginning of the next row.
|
|
||||||
float width; // Logical width of the row.
|
|
||||||
float minx, maxx; // Actual bounds of the row. Logical with and bounds can differ because of kerning and some parts over extending.
|
|
||||||
};
|
|
||||||
typedef struct NVGtextRow NVGtextRow;
|
|
||||||
|
|
||||||
enum NVGimageFlags {
|
|
||||||
NVG_IMAGE_GENERATE_MIPMAPS = 1<<0, // Generate mipmaps during creation of the image.
|
|
||||||
NVG_IMAGE_REPEATX = 1<<1, // Repeat image in X direction.
|
|
||||||
NVG_IMAGE_REPEATY = 1<<2, // Repeat image in Y direction.
|
|
||||||
NVG_IMAGE_FLIPY = 1<<3, // Flips (inverses) image in Y direction when rendered.
|
|
||||||
NVG_IMAGE_PREMULTIPLIED = 1<<4, // Image data has premultiplied alpha.
|
|
||||||
NVG_IMAGE_NEAREST = 1<<5, // Image interpolation is Nearest instead Linear
|
|
||||||
};
|
|
||||||
|
|
||||||
// Begin drawing a new frame
|
|
||||||
// Calls to nanovg drawing API should be wrapped in nvgBeginFrame() & nvgEndFrame()
|
|
||||||
// nvgBeginFrame() defines the size of the window to render to in relation currently
|
|
||||||
// set viewport (i.e. glViewport on GL backends). Device pixel ration allows to
|
|
||||||
// control the rendering on Hi-DPI devices.
|
|
||||||
// For example, GLFW returns two dimension for an opened window: window size and
|
|
||||||
// frame buffer size. In that case you would set windowWidth/Height to the window size
|
|
||||||
// devicePixelRatio to: frameBufferWidth / windowWidth.
|
|
||||||
void nvgBeginFrame(NVGcontext* ctx, float windowWidth, float windowHeight, float devicePixelRatio);
|
|
||||||
|
|
||||||
// Cancels drawing the current frame.
|
|
||||||
void nvgCancelFrame(NVGcontext* ctx);
|
|
||||||
|
|
||||||
// Ends drawing flushing remaining render state.
|
|
||||||
void nvgEndFrame(NVGcontext* ctx);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Composite operation
|
|
||||||
//
|
|
||||||
// The composite operations in NanoVG are modeled after HTML Canvas API, and
|
|
||||||
// the blend func is based on OpenGL (see corresponding manuals for more info).
|
|
||||||
// The colors in the blending state have premultiplied alpha.
|
|
||||||
|
|
||||||
// Sets the composite operation. The op parameter should be one of NVGcompositeOperation.
|
|
||||||
void nvgGlobalCompositeOperation(NVGcontext* ctx, int op);
|
|
||||||
|
|
||||||
// Sets the composite operation with custom pixel arithmetic. The parameters should be one of NVGblendFactor.
|
|
||||||
void nvgGlobalCompositeBlendFunc(NVGcontext* ctx, int sfactor, int dfactor);
|
|
||||||
|
|
||||||
// Sets the composite operation with custom pixel arithmetic for RGB and alpha components separately. The parameters should be one of NVGblendFactor.
|
|
||||||
void nvgGlobalCompositeBlendFuncSeparate(NVGcontext* ctx, int srcRGB, int dstRGB, int srcAlpha, int dstAlpha);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Color utils
|
|
||||||
//
|
|
||||||
// Colors in NanoVG are stored as unsigned ints in ABGR format.
|
|
||||||
|
|
||||||
// Returns a color value from red, green, blue values. Alpha will be set to 255 (1.0f).
|
|
||||||
NVGcolor nvgRGB(unsigned char r, unsigned char g, unsigned char b);
|
|
||||||
|
|
||||||
// Returns a color value from red, green, blue values. Alpha will be set to 1.0f.
|
|
||||||
NVGcolor nvgRGBf(float r, float g, float b);
|
|
||||||
|
|
||||||
|
|
||||||
// Returns a color value from red, green, blue and alpha values.
|
|
||||||
NVGcolor nvgRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
|
||||||
|
|
||||||
// Returns a color value from red, green, blue and alpha values.
|
|
||||||
NVGcolor nvgRGBAf(float r, float g, float b, float a);
|
|
||||||
|
|
||||||
|
|
||||||
// Linearly interpolates from color c0 to c1, and returns resulting color value.
|
|
||||||
NVGcolor nvgLerpRGBA(NVGcolor c0, NVGcolor c1, float u);
|
|
||||||
|
|
||||||
// Sets transparency of a color value.
|
|
||||||
NVGcolor nvgTransRGBA(NVGcolor c0, unsigned char a);
|
|
||||||
|
|
||||||
// Sets transparency of a color value.
|
|
||||||
NVGcolor nvgTransRGBAf(NVGcolor c0, float a);
|
|
||||||
|
|
||||||
// Returns color value specified by hue, saturation and lightness.
|
|
||||||
// HSL values are all in range [0..1], alpha will be set to 255.
|
|
||||||
NVGcolor nvgHSL(float h, float s, float l);
|
|
||||||
|
|
||||||
// Returns color value specified by hue, saturation and lightness and alpha.
|
|
||||||
// HSL values are all in range [0..1], alpha in range [0..255]
|
|
||||||
NVGcolor nvgHSLA(float h, float s, float l, unsigned char a);
|
|
||||||
|
|
||||||
//
|
|
||||||
// State Handling
|
|
||||||
//
|
|
||||||
// NanoVG contains state which represents how paths will be rendered.
|
|
||||||
// The state contains transform, fill and stroke styles, text and font styles,
|
|
||||||
// and scissor clipping.
|
|
||||||
|
|
||||||
// Pushes and saves the current render state into a state stack.
|
|
||||||
// A matching nvgRestore() must be used to restore the state.
|
|
||||||
void nvgSave(NVGcontext* ctx);
|
|
||||||
|
|
||||||
// Pops and restores current render state.
|
|
||||||
void nvgRestore(NVGcontext* ctx);
|
|
||||||
|
|
||||||
// Resets current render state to default values. Does not affect the render state stack.
|
|
||||||
void nvgReset(NVGcontext* ctx);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Render styles
|
|
||||||
//
|
|
||||||
// Fill and stroke render style can be either a solid color or a paint which is a gradient or a pattern.
|
|
||||||
// Solid color is simply defined as a color value, different kinds of paints can be created
|
|
||||||
// using nvgLinearGradient(), nvgBoxGradient(), nvgRadialGradient() and nvgImagePattern().
|
|
||||||
//
|
|
||||||
// Current render style can be saved and restored using nvgSave() and nvgRestore().
|
|
||||||
|
|
||||||
// Sets whether to draw antialias for nvgStroke() and nvgFill(). It's enabled by default.
|
|
||||||
void nvgShapeAntiAlias(NVGcontext* ctx, int enabled);
|
|
||||||
|
|
||||||
// Sets current stroke style to a solid color.
|
|
||||||
void nvgStrokeColor(NVGcontext* ctx, NVGcolor color);
|
|
||||||
|
|
||||||
// Sets current stroke style to a paint, which can be a one of the gradients or a pattern.
|
|
||||||
void nvgStrokePaint(NVGcontext* ctx, NVGpaint paint);
|
|
||||||
|
|
||||||
// Sets current fill style to a solid color.
|
|
||||||
void nvgFillColor(NVGcontext* ctx, NVGcolor color);
|
|
||||||
|
|
||||||
// Sets current fill style to a paint, which can be a one of the gradients or a pattern.
|
|
||||||
void nvgFillPaint(NVGcontext* ctx, NVGpaint paint);
|
|
||||||
|
|
||||||
// Sets the miter limit of the stroke style.
|
|
||||||
// Miter limit controls when a sharp corner is beveled.
|
|
||||||
void nvgMiterLimit(NVGcontext* ctx, float limit);
|
|
||||||
|
|
||||||
// Sets the stroke width of the stroke style.
|
|
||||||
void nvgStrokeWidth(NVGcontext* ctx, float size);
|
|
||||||
|
|
||||||
// Sets how the end of the line (cap) is drawn,
|
|
||||||
// Can be one of: NVG_BUTT (default), NVG_ROUND, NVG_SQUARE.
|
|
||||||
void nvgLineCap(NVGcontext* ctx, int cap);
|
|
||||||
|
|
||||||
// Sets how sharp path corners are drawn.
|
|
||||||
// Can be one of NVG_MITER (default), NVG_ROUND, NVG_BEVEL.
|
|
||||||
void nvgLineJoin(NVGcontext* ctx, int join);
|
|
||||||
|
|
||||||
// Sets the transparency applied to all rendered shapes.
|
|
||||||
// Already transparent paths will get proportionally more transparent as well.
|
|
||||||
void nvgGlobalAlpha(NVGcontext* ctx, float alpha);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Transforms
|
|
||||||
//
|
|
||||||
// The paths, gradients, patterns and scissor region are transformed by an transformation
|
|
||||||
// matrix at the time when they are passed to the API.
|
|
||||||
// The current transformation matrix is a affine matrix:
|
|
||||||
// [sx kx tx]
|
|
||||||
// [ky sy ty]
|
|
||||||
// [ 0 0 1]
|
|
||||||
// Where: sx,sy define scaling, kx,ky skewing, and tx,ty translation.
|
|
||||||
// The last row is assumed to be 0,0,1 and is not stored.
|
|
||||||
//
|
|
||||||
// Apart from nvgResetTransform(), each transformation function first creates
|
|
||||||
// specific transformation matrix and pre-multiplies the current transformation by it.
|
|
||||||
//
|
|
||||||
// Current coordinate system (transformation) can be saved and restored using nvgSave() and nvgRestore().
|
|
||||||
|
|
||||||
// Resets current transform to a identity matrix.
|
|
||||||
void nvgResetTransform(NVGcontext* ctx);
|
|
||||||
|
|
||||||
// Premultiplies current coordinate system by specified matrix.
|
|
||||||
// The parameters are interpreted as matrix as follows:
|
|
||||||
// [a c e]
|
|
||||||
// [b d f]
|
|
||||||
// [0 0 1]
|
|
||||||
void nvgTransform(NVGcontext* ctx, float a, float b, float c, float d, float e, float f);
|
|
||||||
|
|
||||||
// Translates current coordinate system.
|
|
||||||
void nvgTranslate(NVGcontext* ctx, float x, float y);
|
|
||||||
|
|
||||||
// Rotates current coordinate system. Angle is specified in radians.
|
|
||||||
void nvgRotate(NVGcontext* ctx, float angle);
|
|
||||||
|
|
||||||
// Skews the current coordinate system along X axis. Angle is specified in radians.
|
|
||||||
void nvgSkewX(NVGcontext* ctx, float angle);
|
|
||||||
|
|
||||||
// Skews the current coordinate system along Y axis. Angle is specified in radians.
|
|
||||||
void nvgSkewY(NVGcontext* ctx, float angle);
|
|
||||||
|
|
||||||
// Scales the current coordinate system.
|
|
||||||
void nvgScale(NVGcontext* ctx, float x, float y);
|
|
||||||
|
|
||||||
// Stores the top part (a-f) of the current transformation matrix in to the specified buffer.
|
|
||||||
// [a c e]
|
|
||||||
// [b d f]
|
|
||||||
// [0 0 1]
|
|
||||||
// There should be space for 6 floats in the return buffer for the values a-f.
|
|
||||||
void nvgCurrentTransform(NVGcontext* ctx, float* xform);
|
|
||||||
|
|
||||||
|
|
||||||
// The following functions can be used to make calculations on 2x3 transformation matrices.
|
|
||||||
// A 2x3 matrix is represented as float[6].
|
|
||||||
|
|
||||||
// Sets the transform to identity matrix.
|
|
||||||
void nvgTransformIdentity(float* dst);
|
|
||||||
|
|
||||||
// Sets the transform to translation matrix matrix.
|
|
||||||
void nvgTransformTranslate(float* dst, float tx, float ty);
|
|
||||||
|
|
||||||
// Sets the transform to scale matrix.
|
|
||||||
void nvgTransformScale(float* dst, float sx, float sy);
|
|
||||||
|
|
||||||
// Sets the transform to rotate matrix. Angle is specified in radians.
|
|
||||||
void nvgTransformRotate(float* dst, float a);
|
|
||||||
|
|
||||||
// Sets the transform to skew-x matrix. Angle is specified in radians.
|
|
||||||
void nvgTransformSkewX(float* dst, float a);
|
|
||||||
|
|
||||||
// Sets the transform to skew-y matrix. Angle is specified in radians.
|
|
||||||
void nvgTransformSkewY(float* dst, float a);
|
|
||||||
|
|
||||||
// Sets the transform to the result of multiplication of two transforms, of A = A*B.
|
|
||||||
void nvgTransformMultiply(float* dst, const float* src);
|
|
||||||
|
|
||||||
// Sets the transform to the result of multiplication of two transforms, of A = B*A.
|
|
||||||
void nvgTransformPremultiply(float* dst, const float* src);
|
|
||||||
|
|
||||||
// Sets the destination to inverse of specified transform.
|
|
||||||
// Returns 1 if the inverse could be calculated, else 0.
|
|
||||||
int nvgTransformInverse(float* dst, const float* src);
|
|
||||||
|
|
||||||
// Transform a point by given transform.
|
|
||||||
void nvgTransformPoint(float* dstx, float* dsty, const float* xform, float srcx, float srcy);
|
|
||||||
|
|
||||||
// Converts degrees to radians and vice versa.
|
|
||||||
float nvgDegToRad(float deg);
|
|
||||||
float nvgRadToDeg(float rad);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Images
|
|
||||||
//
|
|
||||||
// NanoVG allows you to load jpg, png, psd, tga, pic and gif files to be used for rendering.
|
|
||||||
// In addition you can upload your own image. The image loading is provided by stb_image.
|
|
||||||
// The parameter imageFlags is combination of flags defined in NVGimageFlags.
|
|
||||||
|
|
||||||
// Creates image by loading it from the disk from specified file name.
|
|
||||||
// Returns handle to the image.
|
|
||||||
int nvgCreateImage(NVGcontext* ctx, const char* filename, int imageFlags);
|
|
||||||
|
|
||||||
// Creates image by loading it from the specified chunk of memory.
|
|
||||||
// Returns handle to the image.
|
|
||||||
int nvgCreateImageMem(NVGcontext* ctx, int imageFlags, unsigned char* data, int ndata);
|
|
||||||
|
|
||||||
// Creates image from specified image data.
|
|
||||||
// Returns handle to the image.
|
|
||||||
int nvgCreateImageRGBA(NVGcontext* ctx, int w, int h, int imageFlags, const unsigned char* data);
|
|
||||||
|
|
||||||
// Updates image data specified by image handle.
|
|
||||||
void nvgUpdateImage(NVGcontext* ctx, int image, const unsigned char* data);
|
|
||||||
|
|
||||||
// Returns the dimensions of a created image.
|
|
||||||
void nvgImageSize(NVGcontext* ctx, int image, int* w, int* h);
|
|
||||||
|
|
||||||
// Deletes created image.
|
|
||||||
void nvgDeleteImage(NVGcontext* ctx, int image);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Paints
|
|
||||||
//
|
|
||||||
// NanoVG supports four types of paints: linear gradient, box gradient, radial gradient and image pattern.
|
|
||||||
// These can be used as paints for strokes and fills.
|
|
||||||
|
|
||||||
// Creates and returns a linear gradient. Parameters (sx,sy)-(ex,ey) specify the start and end coordinates
|
|
||||||
// of the linear gradient, icol specifies the start color and ocol the end color.
|
|
||||||
// The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint().
|
|
||||||
NVGpaint nvgLinearGradient(NVGcontext* ctx, float sx, float sy, float ex, float ey,
|
|
||||||
NVGcolor icol, NVGcolor ocol);
|
|
||||||
|
|
||||||
// Creates and returns a box gradient. Box gradient is a feathered rounded rectangle, it is useful for rendering
|
|
||||||
// drop shadows or highlights for boxes. Parameters (x,y) define the top-left corner of the rectangle,
|
|
||||||
// (w,h) define the size of the rectangle, r defines the corner radius, and f feather. Feather defines how blurry
|
|
||||||
// the border of the rectangle is. Parameter icol specifies the inner color and ocol the outer color of the gradient.
|
|
||||||
// The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint().
|
|
||||||
NVGpaint nvgBoxGradient(NVGcontext* ctx, float x, float y, float w, float h,
|
|
||||||
float r, float f, NVGcolor icol, NVGcolor ocol);
|
|
||||||
|
|
||||||
// Creates and returns a radial gradient. Parameters (cx,cy) specify the center, inr and outr specify
|
|
||||||
// the inner and outer radius of the gradient, icol specifies the start color and ocol the end color.
|
|
||||||
// The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint().
|
|
||||||
NVGpaint nvgRadialGradient(NVGcontext* ctx, float cx, float cy, float inr, float outr,
|
|
||||||
NVGcolor icol, NVGcolor ocol);
|
|
||||||
|
|
||||||
// Creates and returns an image patter. Parameters (ox,oy) specify the left-top location of the image pattern,
|
|
||||||
// (ex,ey) the size of one image, angle rotation around the top-left corner, image is handle to the image to render.
|
|
||||||
// The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint().
|
|
||||||
NVGpaint nvgImagePattern(NVGcontext* ctx, float ox, float oy, float ex, float ey,
|
|
||||||
float angle, int image, float alpha);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Scissoring
|
|
||||||
//
|
|
||||||
// Scissoring allows you to clip the rendering into a rectangle. This is useful for various
|
|
||||||
// user interface cases like rendering a text edit or a timeline.
|
|
||||||
|
|
||||||
// Sets the current scissor rectangle.
|
|
||||||
// The scissor rectangle is transformed by the current transform.
|
|
||||||
void nvgScissor(NVGcontext* ctx, float x, float y, float w, float h);
|
|
||||||
|
|
||||||
// Intersects current scissor rectangle with the specified rectangle.
|
|
||||||
// The scissor rectangle is transformed by the current transform.
|
|
||||||
// Note: in case the rotation of previous scissor rect differs from
|
|
||||||
// the current one, the intersection will be done between the specified
|
|
||||||
// rectangle and the previous scissor rectangle transformed in the current
|
|
||||||
// transform space. The resulting shape is always rectangle.
|
|
||||||
void nvgIntersectScissor(NVGcontext* ctx, float x, float y, float w, float h);
|
|
||||||
|
|
||||||
// Reset and disables scissoring.
|
|
||||||
void nvgResetScissor(NVGcontext* ctx);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Paths
|
|
||||||
//
|
|
||||||
// Drawing a new shape starts with nvgBeginPath(), it clears all the currently defined paths.
|
|
||||||
// Then you define one or more paths and sub-paths which describe the shape. The are functions
|
|
||||||
// to draw common shapes like rectangles and circles, and lower level step-by-step functions,
|
|
||||||
// which allow to define a path curve by curve.
|
|
||||||
//
|
|
||||||
// NanoVG uses even-odd fill rule to draw the shapes. Solid shapes should have counter clockwise
|
|
||||||
// winding and holes should have counter clockwise order. To specify winding of a path you can
|
|
||||||
// call nvgPathWinding(). This is useful especially for the common shapes, which are drawn CCW.
|
|
||||||
//
|
|
||||||
// Finally you can fill the path using current fill style by calling nvgFill(), and stroke it
|
|
||||||
// with current stroke style by calling nvgStroke().
|
|
||||||
//
|
|
||||||
// The curve segments and sub-paths are transformed by the current transform.
|
|
||||||
|
|
||||||
// Clears the current path and sub-paths.
|
|
||||||
void nvgBeginPath(NVGcontext* ctx);
|
|
||||||
|
|
||||||
// Starts new sub-path with specified point as first point.
|
|
||||||
void nvgMoveTo(NVGcontext* ctx, float x, float y);
|
|
||||||
|
|
||||||
// Adds line segment from the last point in the path to the specified point.
|
|
||||||
void nvgLineTo(NVGcontext* ctx, float x, float y);
|
|
||||||
|
|
||||||
// Adds cubic bezier segment from last point in the path via two control points to the specified point.
|
|
||||||
void nvgBezierTo(NVGcontext* ctx, float c1x, float c1y, float c2x, float c2y, float x, float y);
|
|
||||||
|
|
||||||
// Adds quadratic bezier segment from last point in the path via a control point to the specified point.
|
|
||||||
void nvgQuadTo(NVGcontext* ctx, float cx, float cy, float x, float y);
|
|
||||||
|
|
||||||
// Adds an arc segment at the corner defined by the last path point, and two specified points.
|
|
||||||
void nvgArcTo(NVGcontext* ctx, float x1, float y1, float x2, float y2, float radius);
|
|
||||||
|
|
||||||
// Closes current sub-path with a line segment.
|
|
||||||
void nvgClosePath(NVGcontext* ctx);
|
|
||||||
|
|
||||||
// Sets the current sub-path winding, see NVGwinding and NVGsolidity.
|
|
||||||
void nvgPathWinding(NVGcontext* ctx, int dir);
|
|
||||||
|
|
||||||
// Creates new circle arc shaped sub-path. The arc center is at cx,cy, the arc radius is r,
|
|
||||||
// and the arc is drawn from angle a0 to a1, and swept in direction dir (NVG_CCW, or NVG_CW).
|
|
||||||
// Angles are specified in radians.
|
|
||||||
void nvgArc(NVGcontext* ctx, float cx, float cy, float r, float a0, float a1, int dir);
|
|
||||||
|
|
||||||
// Creates new rectangle shaped sub-path.
|
|
||||||
void nvgRect(NVGcontext* ctx, float x, float y, float w, float h);
|
|
||||||
|
|
||||||
// Creates new rounded rectangle shaped sub-path.
|
|
||||||
void nvgRoundedRect(NVGcontext* ctx, float x, float y, float w, float h, float r);
|
|
||||||
|
|
||||||
// Creates new rounded rectangle shaped sub-path with varying radii for each corner.
|
|
||||||
void nvgRoundedRectVarying(NVGcontext* ctx, float x, float y, float w, float h, float radTopLeft, float radTopRight, float radBottomRight, float radBottomLeft);
|
|
||||||
|
|
||||||
// Creates new ellipse shaped sub-path.
|
|
||||||
void nvgEllipse(NVGcontext* ctx, float cx, float cy, float rx, float ry);
|
|
||||||
|
|
||||||
// Creates new circle shaped sub-path.
|
|
||||||
void nvgCircle(NVGcontext* ctx, float cx, float cy, float r);
|
|
||||||
|
|
||||||
// Fills the current path with current fill style.
|
|
||||||
void nvgFill(NVGcontext* ctx);
|
|
||||||
|
|
||||||
// Fills the current path with current stroke style.
|
|
||||||
void nvgStroke(NVGcontext* ctx);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Text
|
|
||||||
//
|
|
||||||
// NanoVG allows you to load .ttf files and use the font to render text.
|
|
||||||
//
|
|
||||||
// The appearance of the text can be defined by setting the current text style
|
|
||||||
// and by specifying the fill color. Common text and font settings such as
|
|
||||||
// font size, letter spacing and text align are supported. Font blur allows you
|
|
||||||
// to create simple text effects such as drop shadows.
|
|
||||||
//
|
|
||||||
// At render time the font face can be set based on the font handles or name.
|
|
||||||
//
|
|
||||||
// Font measure functions return values in local space, the calculations are
|
|
||||||
// carried in the same resolution as the final rendering. This is done because
|
|
||||||
// the text glyph positions are snapped to the nearest pixels sharp rendering.
|
|
||||||
//
|
|
||||||
// The local space means that values are not rotated or scale as per the current
|
|
||||||
// transformation. For example if you set font size to 12, which would mean that
|
|
||||||
// line height is 16, then regardless of the current scaling and rotation, the
|
|
||||||
// returned line height is always 16. Some measures may vary because of the scaling
|
|
||||||
// since aforementioned pixel snapping.
|
|
||||||
//
|
|
||||||
// While this may sound a little odd, the setup allows you to always render the
|
|
||||||
// same way regardless of scaling. I.e. following works regardless of scaling:
|
|
||||||
//
|
|
||||||
// const char* txt = "Text me up.";
|
|
||||||
// nvgTextBounds(vg, x,y, txt, NULL, bounds);
|
|
||||||
// nvgBeginPath(vg);
|
|
||||||
// nvgRoundedRect(vg, bounds[0],bounds[1], bounds[2]-bounds[0], bounds[3]-bounds[1]);
|
|
||||||
// nvgFill(vg);
|
|
||||||
//
|
|
||||||
// Note: currently only solid color fill is supported for text.
|
|
||||||
|
|
||||||
// Creates font by loading it from the disk from specified file name.
|
|
||||||
// Returns handle to the font.
|
|
||||||
int nvgCreateFont(NVGcontext* ctx, const char* name, const char* filename);
|
|
||||||
|
|
||||||
// Creates font by loading it from the specified memory chunk.
|
|
||||||
// Returns handle to the font.
|
|
||||||
int nvgCreateFontMem(NVGcontext* ctx, const char* name, unsigned char* data, int ndata, int freeData);
|
|
||||||
|
|
||||||
// Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found.
|
|
||||||
int nvgFindFont(NVGcontext* ctx, const char* name);
|
|
||||||
|
|
||||||
// Adds a fallback font by handle.
|
|
||||||
int nvgAddFallbackFontId(NVGcontext* ctx, int baseFont, int fallbackFont);
|
|
||||||
|
|
||||||
// Adds a fallback font by name.
|
|
||||||
int nvgAddFallbackFont(NVGcontext* ctx, const char* baseFont, const char* fallbackFont);
|
|
||||||
|
|
||||||
// Sets the font size of current text style.
|
|
||||||
void nvgFontSize(NVGcontext* ctx, float size);
|
|
||||||
|
|
||||||
// Sets the blur of current text style.
|
|
||||||
void nvgFontBlur(NVGcontext* ctx, float blur);
|
|
||||||
|
|
||||||
// Sets the letter spacing of current text style.
|
|
||||||
void nvgTextLetterSpacing(NVGcontext* ctx, float spacing);
|
|
||||||
|
|
||||||
// Sets the proportional line height of current text style. The line height is specified as multiple of font size.
|
|
||||||
void nvgTextLineHeight(NVGcontext* ctx, float lineHeight);
|
|
||||||
|
|
||||||
// Sets the text align of current text style, see NVGalign for options.
|
|
||||||
void nvgTextAlign(NVGcontext* ctx, int align);
|
|
||||||
|
|
||||||
// Sets the font face based on specified id of current text style.
|
|
||||||
void nvgFontFaceId(NVGcontext* ctx, int font);
|
|
||||||
|
|
||||||
// Sets the font face based on specified name of current text style.
|
|
||||||
void nvgFontFace(NVGcontext* ctx, const char* font);
|
|
||||||
|
|
||||||
// Draws text string at specified location. If end is specified only the sub-string up to the end is drawn.
|
|
||||||
float nvgText(NVGcontext* ctx, float x, float y, const char* string, const char* end);
|
|
||||||
|
|
||||||
// Draws multi-line text string at specified location wrapped at the specified width. If end is specified only the sub-string up to the end is drawn.
|
|
||||||
// White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered.
|
|
||||||
// Words longer than the max width are slit at nearest character (i.e. no hyphenation).
|
|
||||||
void nvgTextBox(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end);
|
|
||||||
|
|
||||||
// Measures the specified text string. Parameter bounds should be a pointer to float[4],
|
|
||||||
// if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax]
|
|
||||||
// Returns the horizontal advance of the measured text (i.e. where the next character should drawn).
|
|
||||||
// Measured values are returned in local coordinate space.
|
|
||||||
float nvgTextBounds(NVGcontext* ctx, float x, float y, const char* string, const char* end, float* bounds);
|
|
||||||
|
|
||||||
// Measures the specified multi-text string. Parameter bounds should be a pointer to float[4],
|
|
||||||
// if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax]
|
|
||||||
// Measured values are returned in local coordinate space.
|
|
||||||
void nvgTextBoxBounds(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end, float* bounds);
|
|
||||||
|
|
||||||
// Calculates the glyph x positions of the specified text. If end is specified only the sub-string will be used.
|
|
||||||
// Measured values are returned in local coordinate space.
|
|
||||||
int nvgTextGlyphPositions(NVGcontext* ctx, float x, float y, const char* string, const char* end, NVGglyphPosition* positions, int maxPositions);
|
|
||||||
|
|
||||||
// Returns the vertical metrics based on the current text style.
|
|
||||||
// Measured values are returned in local coordinate space.
|
|
||||||
void nvgTextMetrics(NVGcontext* ctx, float* ascender, float* descender, float* lineh);
|
|
||||||
|
|
||||||
// Breaks the specified text into lines. If end is specified only the sub-string will be used.
|
|
||||||
// White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered.
|
|
||||||
// Words longer than the max width are slit at nearest character (i.e. no hyphenation).
|
|
||||||
int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, float breakRowWidth, NVGtextRow* rows, int maxRows);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Internal Render API
|
|
||||||
//
|
|
||||||
enum NVGtexture {
|
|
||||||
NVG_TEXTURE_ALPHA = 0x01,
|
|
||||||
NVG_TEXTURE_RGBA = 0x02,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct NVGscissor {
|
|
||||||
float xform[6];
|
|
||||||
float extent[2];
|
|
||||||
};
|
|
||||||
typedef struct NVGscissor NVGscissor;
|
|
||||||
|
|
||||||
struct NVGvertex {
|
|
||||||
float x,y,u,v;
|
|
||||||
};
|
|
||||||
typedef struct NVGvertex NVGvertex;
|
|
||||||
|
|
||||||
struct NVGpath {
|
|
||||||
int first;
|
|
||||||
int count;
|
|
||||||
unsigned char closed;
|
|
||||||
int nbevel;
|
|
||||||
NVGvertex* fill;
|
|
||||||
int nfill;
|
|
||||||
NVGvertex* stroke;
|
|
||||||
int nstroke;
|
|
||||||
int winding;
|
|
||||||
int convex;
|
|
||||||
};
|
|
||||||
typedef struct NVGpath NVGpath;
|
|
||||||
|
|
||||||
struct NVGparams {
|
|
||||||
void* userPtr;
|
|
||||||
int edgeAntiAlias;
|
|
||||||
int (*renderCreate)(void* uptr);
|
|
||||||
int (*renderCreateTexture)(void* uptr, int type, int w, int h, int imageFlags, const unsigned char* data);
|
|
||||||
int (*renderDeleteTexture)(void* uptr, int image);
|
|
||||||
int (*renderUpdateTexture)(void* uptr, int image, int x, int y, int w, int h, const unsigned char* data);
|
|
||||||
int (*renderGetTextureSize)(void* uptr, int image, int* w, int* h);
|
|
||||||
void (*renderViewport)(void* uptr, float width, float height, float devicePixelRatio);
|
|
||||||
void (*renderCancel)(void* uptr);
|
|
||||||
void (*renderFlush)(void* uptr);
|
|
||||||
void (*renderFill)(void* uptr, NVGpaint* paint, NVGcompositeOperationState compositeOperation, NVGscissor* scissor, float fringe, const float* bounds, const NVGpath* paths, int npaths);
|
|
||||||
void (*renderStroke)(void* uptr, NVGpaint* paint, NVGcompositeOperationState compositeOperation, NVGscissor* scissor, float fringe, float strokeWidth, const NVGpath* paths, int npaths);
|
|
||||||
void (*renderTriangles)(void* uptr, NVGpaint* paint, NVGcompositeOperationState compositeOperation, NVGscissor* scissor, const NVGvertex* verts, int nverts);
|
|
||||||
void (*renderDelete)(void* uptr);
|
|
||||||
};
|
|
||||||
typedef struct NVGparams NVGparams;
|
|
||||||
|
|
||||||
// Constructor and destructor, called by the render back-end.
|
|
||||||
NVGcontext* nvgCreateInternal(NVGparams* params);
|
|
||||||
void nvgDeleteInternal(NVGcontext* ctx);
|
|
||||||
|
|
||||||
NVGparams* nvgInternalParams(NVGcontext* ctx);
|
|
||||||
|
|
||||||
// Debug function to dump cached path data.
|
|
||||||
void nvgDebugDumpPathCache(NVGcontext* ctx);
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define NVG_NOTUSED(v) for (;;) { (void)(1 ? (void)0 : ( (void)(v) ) ); break; }
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // NANOVG_H
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,154 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2009-2013 Mikko Mononen memon@inside.org
|
|
||||||
//
|
|
||||||
// This software is provided 'as-is', without any express or implied
|
|
||||||
// warranty. In no event will the authors be held liable for any damages
|
|
||||||
// arising from the use of this software.
|
|
||||||
// Permission is granted to anyone to use this software for any purpose,
|
|
||||||
// including commercial applications, and to alter it and redistribute it
|
|
||||||
// freely, subject to the following restrictions:
|
|
||||||
// 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
// claim that you wrote the original software. If you use this software
|
|
||||||
// in a product, an acknowledgment in the product documentation would be
|
|
||||||
// appreciated but is not required.
|
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
// misrepresented as being the original software.
|
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
//
|
|
||||||
#ifndef NANOVG_GL_UTILS_H
|
|
||||||
#define NANOVG_GL_UTILS_H
|
|
||||||
|
|
||||||
struct NVGLUframebuffer {
|
|
||||||
NVGcontext* ctx;
|
|
||||||
GLuint fbo;
|
|
||||||
GLuint rbo;
|
|
||||||
GLuint texture;
|
|
||||||
int image;
|
|
||||||
};
|
|
||||||
typedef struct NVGLUframebuffer NVGLUframebuffer;
|
|
||||||
|
|
||||||
// Helper function to create GL frame buffer to render to.
|
|
||||||
void nvgluBindFramebuffer(NVGLUframebuffer* fb);
|
|
||||||
NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int w, int h, int imageFlags);
|
|
||||||
void nvgluDeleteFramebuffer(NVGLUframebuffer* fb);
|
|
||||||
|
|
||||||
#endif // NANOVG_GL_UTILS_H
|
|
||||||
|
|
||||||
#ifdef NANOVG_GL_IMPLEMENTATION
|
|
||||||
|
|
||||||
#if defined(NANOVG_GL3) || defined(NANOVG_GLES2) || defined(NANOVG_GLES3)
|
|
||||||
// FBO is core in OpenGL 3>.
|
|
||||||
# define NANOVG_FBO_VALID 1
|
|
||||||
#elif defined(NANOVG_GL2)
|
|
||||||
// On OS X including glext defines FBO on GL2 too.
|
|
||||||
# ifdef __APPLE__
|
|
||||||
# include <OpenGL/glext.h>
|
|
||||||
# define NANOVG_FBO_VALID 1
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static GLint defaultFBO = -1;
|
|
||||||
|
|
||||||
NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int w, int h, int imageFlags)
|
|
||||||
{
|
|
||||||
#ifdef NANOVG_FBO_VALID
|
|
||||||
GLint defaultFBO;
|
|
||||||
GLint defaultRBO;
|
|
||||||
NVGLUframebuffer* fb = NULL;
|
|
||||||
|
|
||||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO);
|
|
||||||
glGetIntegerv(GL_RENDERBUFFER_BINDING, &defaultRBO);
|
|
||||||
|
|
||||||
fb = (NVGLUframebuffer*)malloc(sizeof(NVGLUframebuffer));
|
|
||||||
if (fb == NULL) goto error;
|
|
||||||
memset(fb, 0, sizeof(NVGLUframebuffer));
|
|
||||||
|
|
||||||
fb->image = nvgCreateImageRGBA(ctx, w, h, imageFlags | NVG_IMAGE_FLIPY | NVG_IMAGE_PREMULTIPLIED, NULL);
|
|
||||||
|
|
||||||
#if defined NANOVG_GL2
|
|
||||||
fb->texture = nvglImageHandleGL2(ctx, fb->image);
|
|
||||||
#elif defined NANOVG_GL3
|
|
||||||
fb->texture = nvglImageHandleGL3(ctx, fb->image);
|
|
||||||
#elif defined NANOVG_GLES2
|
|
||||||
fb->texture = nvglImageHandleGLES2(ctx, fb->image);
|
|
||||||
#elif defined NANOVG_GLES3
|
|
||||||
fb->texture = nvglImageHandleGLES3(ctx, fb->image);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fb->ctx = ctx;
|
|
||||||
|
|
||||||
// frame buffer object
|
|
||||||
glGenFramebuffers(1, &fb->fbo);
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, fb->fbo);
|
|
||||||
|
|
||||||
// render buffer object
|
|
||||||
glGenRenderbuffers(1, &fb->rbo);
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, fb->rbo);
|
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, w, h);
|
|
||||||
|
|
||||||
// combine all
|
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fb->texture, 0);
|
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fb->rbo);
|
|
||||||
|
|
||||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
|
||||||
#ifdef GL_DEPTH24_STENCIL8
|
|
||||||
// If GL_STENCIL_INDEX8 is not supported, try GL_DEPTH24_STENCIL8 as a fallback.
|
|
||||||
// Some graphics cards require a depth buffer along with a stencil.
|
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, w, h);
|
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fb->texture, 0);
|
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fb->rbo);
|
|
||||||
|
|
||||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
|
||||||
#endif // GL_DEPTH24_STENCIL8
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, defaultRBO);
|
|
||||||
return fb;
|
|
||||||
error:
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, defaultRBO);
|
|
||||||
nvgluDeleteFramebuffer(fb);
|
|
||||||
return NULL;
|
|
||||||
#else
|
|
||||||
NVG_NOTUSED(ctx);
|
|
||||||
NVG_NOTUSED(w);
|
|
||||||
NVG_NOTUSED(h);
|
|
||||||
NVG_NOTUSED(imageFlags);
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void nvgluBindFramebuffer(NVGLUframebuffer* fb)
|
|
||||||
{
|
|
||||||
#ifdef NANOVG_FBO_VALID
|
|
||||||
if (defaultFBO == -1) glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO);
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, fb != NULL ? fb->fbo : defaultFBO);
|
|
||||||
#else
|
|
||||||
NVG_NOTUSED(fb);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void nvgluDeleteFramebuffer(NVGLUframebuffer* fb)
|
|
||||||
{
|
|
||||||
#ifdef NANOVG_FBO_VALID
|
|
||||||
if (fb == NULL) return;
|
|
||||||
if (fb->fbo != 0)
|
|
||||||
glDeleteFramebuffers(1, &fb->fbo);
|
|
||||||
if (fb->rbo != 0)
|
|
||||||
glDeleteRenderbuffers(1, &fb->rbo);
|
|
||||||
if (fb->image >= 0)
|
|
||||||
nvgDeleteImage(fb->ctx, fb->image);
|
|
||||||
fb->ctx = NULL;
|
|
||||||
fb->fbo = 0;
|
|
||||||
fb->rbo = 0;
|
|
||||||
fb->texture = 0;
|
|
||||||
fb->image = -1;
|
|
||||||
free(fb);
|
|
||||||
#else
|
|
||||||
NVG_NOTUSED(fb);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // NANOVG_GL_IMPLEMENTATION
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <nanovg.h>
|
|
||||||
|
|
||||||
#include <borealis/style.hpp>
|
|
||||||
#include <borealis/theme.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
class FontStash
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int regular = 0;
|
|
||||||
int korean = 0;
|
|
||||||
|
|
||||||
int material = 0;
|
|
||||||
int sharedSymbols = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class FrameContext
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NVGcontext* vg = nullptr;
|
|
||||||
float pixelRatio = 0.0;
|
|
||||||
FontStash* fontStash = nullptr;
|
|
||||||
ThemeValues* theme = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// A simple header with text, a rectangle on the left
|
|
||||||
// and a separator
|
|
||||||
class Header : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::string label;
|
|
||||||
std::string sublabel;
|
|
||||||
bool separator;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Header(std::string label, bool separator = true, std::string sublabel = "");
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2020 WerWolv
|
|
||||||
Copyright (C) 2020 natinusala
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/box_layout.hpp>
|
|
||||||
#include <borealis/label.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// Displays button hints for the currently focused view
|
|
||||||
// Depending on the view's available actions
|
|
||||||
// there can only be one Hint visible at any time
|
|
||||||
class Hint : public BoxLayout
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
bool animate;
|
|
||||||
|
|
||||||
GenericEvent::Subscription globalFocusEventSubscriptor;
|
|
||||||
VoidEvent::Subscription globalHintsUpdateEventSubscriptor;
|
|
||||||
|
|
||||||
static inline std::vector<Hint*> globalHintStack;
|
|
||||||
|
|
||||||
static void pushHint(Hint* hint);
|
|
||||||
static void popHint(Hint* hint);
|
|
||||||
static void animateHints();
|
|
||||||
|
|
||||||
static std::string getKeyIcon(Key key);
|
|
||||||
|
|
||||||
void rebuildHints();
|
|
||||||
|
|
||||||
public:
|
|
||||||
Hint(bool animate = true);
|
|
||||||
~Hint();
|
|
||||||
|
|
||||||
void willAppear(bool resetState = false) override;
|
|
||||||
void willDisappear(bool resetState = false) override;
|
|
||||||
|
|
||||||
void setAnimate(bool animate)
|
|
||||||
{
|
|
||||||
this->animate = animate;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 WerWolv
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/frame_context.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
enum class ImageScaleType
|
|
||||||
{
|
|
||||||
NO_RESIZE = 0, // Nothing is resized
|
|
||||||
FIT, // The image is shrinked to fit the view boundaries
|
|
||||||
CROP, // The image is not resized but is cropped if bigger than the view
|
|
||||||
SCALE, // The image is stretched to match the view boundaries
|
|
||||||
VIEW_RESIZE // The view is resized to match the image
|
|
||||||
};
|
|
||||||
|
|
||||||
// An image
|
|
||||||
class Image : public View
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Image(std::string imagePath);
|
|
||||||
Image(unsigned char* buffer, size_t bufferSize);
|
|
||||||
~Image();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
|
|
||||||
void setImage(unsigned char* buffer, size_t bufferSize);
|
|
||||||
void setImage(std::string imagePath);
|
|
||||||
|
|
||||||
void setScaleType(ImageScaleType imageScaleType);
|
|
||||||
void setOpacity(float opacity);
|
|
||||||
|
|
||||||
void setCornerRadius(float radius)
|
|
||||||
{
|
|
||||||
this->cornerRadius = radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string imagePath;
|
|
||||||
unsigned char* imageBuffer = nullptr;
|
|
||||||
size_t imageBufferSize = 0;
|
|
||||||
|
|
||||||
int texture = -1;
|
|
||||||
NVGpaint imgPaint;
|
|
||||||
|
|
||||||
ImageScaleType imageScaleType = ImageScaleType::FIT;
|
|
||||||
|
|
||||||
float cornerRadius = 0;
|
|
||||||
|
|
||||||
int imageX = 0, imageY = 0;
|
|
||||||
int imageWidth = 0, imageHeight = 0;
|
|
||||||
int origViewWidth = 0, origViewHeight = 0;
|
|
||||||
|
|
||||||
void reloadTexture();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019-2020 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
enum class LabelStyle
|
|
||||||
{
|
|
||||||
REGULAR = 0,
|
|
||||||
MEDIUM,
|
|
||||||
SMALL,
|
|
||||||
DESCRIPTION,
|
|
||||||
CRASH,
|
|
||||||
BUTTON_PLAIN,
|
|
||||||
BUTTON_PLAIN_DISABLED,
|
|
||||||
BUTTON_BORDERLESS,
|
|
||||||
LIST_ITEM,
|
|
||||||
NOTIFICATION,
|
|
||||||
DIALOG,
|
|
||||||
BUTTON_DIALOG,
|
|
||||||
HINT
|
|
||||||
};
|
|
||||||
|
|
||||||
// A Label, multiline or with a ticker
|
|
||||||
class Label : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::string text;
|
|
||||||
|
|
||||||
bool multiline;
|
|
||||||
unsigned fontSize;
|
|
||||||
float lineHeight;
|
|
||||||
LabelStyle labelStyle;
|
|
||||||
|
|
||||||
NVGalign horizontalAlign = NVG_ALIGN_LEFT;
|
|
||||||
NVGalign verticalAlign = NVG_ALIGN_MIDDLE;
|
|
||||||
|
|
||||||
NVGcolor customColor;
|
|
||||||
bool useCustomColor = false;
|
|
||||||
|
|
||||||
int customFont;
|
|
||||||
bool useCustomFont = false;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Label(LabelStyle labelStyle, std::string text, bool multiline = false);
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
|
|
||||||
void setVerticalAlign(NVGalign align);
|
|
||||||
void setHorizontalAlign(NVGalign align);
|
|
||||||
void setText(std::string text);
|
|
||||||
void setStyle(LabelStyle style);
|
|
||||||
void setFontSize(unsigned size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the label color
|
|
||||||
*/
|
|
||||||
void setColor(NVGcolor color);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unsets the label color - it
|
|
||||||
* will now use the default one
|
|
||||||
* for the label style
|
|
||||||
*/
|
|
||||||
void unsetColor();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the effective label color
|
|
||||||
* = custom or the style default
|
|
||||||
*/
|
|
||||||
NVGcolor getColor(ThemeValues* theme);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the font id
|
|
||||||
*/
|
|
||||||
void setFont(int fontId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unsets the font id - it
|
|
||||||
* will now use the regular one
|
|
||||||
*/
|
|
||||||
void unsetFont();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the font used
|
|
||||||
* = custom or the regular font
|
|
||||||
*/
|
|
||||||
int getFont(FontStash* stash);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 WerWolv
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// A view containing multiple children views with the ability to freely switch between these layers
|
|
||||||
class LayerView : public View
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LayerView();
|
|
||||||
~LayerView();
|
|
||||||
|
|
||||||
void addLayer(View* view);
|
|
||||||
void changeLayer(int index, bool focus = false);
|
|
||||||
int getLayerIndex();
|
|
||||||
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
|
|
||||||
void willAppear(bool resetState = false) override;
|
|
||||||
void willDisappear(bool resetState = false) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<View*> layers;
|
|
||||||
int selectedIndex = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,217 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019-2020 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/box_layout.hpp>
|
|
||||||
#include <borealis/image.hpp>
|
|
||||||
#include <borealis/label.hpp>
|
|
||||||
#include <borealis/rectangle.hpp>
|
|
||||||
#include <borealis/scroll_view.hpp>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// A list item
|
|
||||||
// TODO: Use a Label with integrated ticker
|
|
||||||
class ListItem : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::string label;
|
|
||||||
std::string subLabel;
|
|
||||||
std::string value;
|
|
||||||
bool valueFaint;
|
|
||||||
|
|
||||||
std::string oldValue;
|
|
||||||
bool oldValueFaint;
|
|
||||||
float valueAnimation = 0.0f;
|
|
||||||
|
|
||||||
bool checked = false; // check mark on the right
|
|
||||||
|
|
||||||
unsigned textSize;
|
|
||||||
|
|
||||||
bool drawTopSeparator = true;
|
|
||||||
|
|
||||||
Label* descriptionView = nullptr;
|
|
||||||
Image* thumbnailView = nullptr;
|
|
||||||
|
|
||||||
bool reduceDescriptionSpacing = false;
|
|
||||||
|
|
||||||
GenericEvent clickEvent;
|
|
||||||
|
|
||||||
bool indented = false;
|
|
||||||
|
|
||||||
void resetValueAnimation();
|
|
||||||
|
|
||||||
public:
|
|
||||||
ListItem(std::string label, std::string description = "", std::string subLabel = "");
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
void getHighlightInsets(unsigned* top, unsigned* right, unsigned* bottom, unsigned* left) override;
|
|
||||||
virtual bool onClick();
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
|
|
||||||
void setThumbnail(Image* image);
|
|
||||||
void setThumbnail(std::string imagePath);
|
|
||||||
void setThumbnail(unsigned char* buffer, size_t bufferSize);
|
|
||||||
|
|
||||||
bool hasDescription();
|
|
||||||
void setDrawTopSeparator(bool draw);
|
|
||||||
|
|
||||||
bool getReduceDescriptionSpacing();
|
|
||||||
void setReduceDescriptionSpacing(bool value);
|
|
||||||
|
|
||||||
void setIndented(bool indented);
|
|
||||||
|
|
||||||
void setTextSize(unsigned textSize);
|
|
||||||
|
|
||||||
void setChecked(bool checked);
|
|
||||||
|
|
||||||
std::string getLabel();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of this list item
|
|
||||||
* (the text on the right)
|
|
||||||
* Set faint to true to have the new value
|
|
||||||
* use a darker color (typically "OFF" labels)
|
|
||||||
*/
|
|
||||||
void setValue(std::string value, bool faint = false, bool animate = true);
|
|
||||||
std::string getValue();
|
|
||||||
|
|
||||||
GenericEvent* getClickEvent();
|
|
||||||
|
|
||||||
~ListItem();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Some spacing (to make groups of ListItems)
|
|
||||||
class ListItemGroupSpacing : public Rectangle
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ListItemGroupSpacing(bool separator = false);
|
|
||||||
};
|
|
||||||
|
|
||||||
// A list item with mutliple choices for its value
|
|
||||||
// (will open a Dropdown)
|
|
||||||
|
|
||||||
// Fired when the user has selected a value
|
|
||||||
//
|
|
||||||
// Parameter is either the selected value index
|
|
||||||
// or -1 if the user cancelled
|
|
||||||
typedef Event<int> ValueSelectedEvent;
|
|
||||||
|
|
||||||
class SelectListItem : public ListItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SelectListItem(std::string label, std::vector<std::string> values, unsigned selectedValue = 0);
|
|
||||||
|
|
||||||
void setSelectedValue(unsigned value);
|
|
||||||
|
|
||||||
ValueSelectedEvent* getValueSelectedEvent();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<std::string> values;
|
|
||||||
unsigned selectedValue;
|
|
||||||
|
|
||||||
ValueSelectedEvent valueEvent;
|
|
||||||
};
|
|
||||||
|
|
||||||
// A list item with a ON/OFF value
|
|
||||||
// that can be toggled
|
|
||||||
// Use the click event to detect when the value
|
|
||||||
// changes
|
|
||||||
class ToggleListItem : public ListItem
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
bool toggleState;
|
|
||||||
std::string onValue, offValue;
|
|
||||||
|
|
||||||
void updateValue();
|
|
||||||
|
|
||||||
public:
|
|
||||||
ToggleListItem(std::string label, bool initialValue, std::string description = "", std::string onValue = "On", std::string offValue = "Off");
|
|
||||||
|
|
||||||
virtual bool onClick() override;
|
|
||||||
|
|
||||||
bool getToggleState();
|
|
||||||
};
|
|
||||||
|
|
||||||
// A list item which spawns the swkbd
|
|
||||||
// to input its value (string)
|
|
||||||
class InputListItem : public ListItem
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
std::string helpText;
|
|
||||||
int maxInputLength;
|
|
||||||
|
|
||||||
public:
|
|
||||||
InputListItem(std::string label, std::string initialValue, std::string helpText, std::string description = "", int maxInputLength = 32);
|
|
||||||
|
|
||||||
virtual bool onClick() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
// A list item which spawns the swkbd
|
|
||||||
// to input its value (integer)
|
|
||||||
class IntegerInputListItem : public InputListItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
IntegerInputListItem(std::string label, int initialValue, std::string helpText, std::string description = "", int maxInputLength = 32);
|
|
||||||
|
|
||||||
virtual bool onClick() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class List; // forward declaration for ListContentView::list
|
|
||||||
|
|
||||||
// The content view of lists (used internally)
|
|
||||||
class ListContentView : public BoxLayout
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ListContentView(List* list, size_t defaultFocus = 0);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void customSpacing(View* current, View* next, int* spacing) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
List* list;
|
|
||||||
};
|
|
||||||
|
|
||||||
// A vertical list of various widgets, with proper margins and spacing
|
|
||||||
// and a scroll bar
|
|
||||||
// In practice it's a ScrollView which content view is
|
|
||||||
// a ListContentView (BoxLayout)
|
|
||||||
class List : public ScrollView
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ListContentView* layout;
|
|
||||||
|
|
||||||
public:
|
|
||||||
List(size_t defaultFocus = 0);
|
|
||||||
~List();
|
|
||||||
|
|
||||||
// Wrapped BoxLayout methods
|
|
||||||
void addView(View* view, bool fill = false);
|
|
||||||
void setMargins(unsigned top, unsigned right, unsigned bottom, unsigned left);
|
|
||||||
void setMarginBottom(unsigned bottom);
|
|
||||||
void setSpacing(unsigned spacing);
|
|
||||||
unsigned getSpacing();
|
|
||||||
virtual void customSpacing(View* current, View* next, int* spacing);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
enum class LogLevel
|
|
||||||
{
|
|
||||||
ERROR = 0,
|
|
||||||
INFO,
|
|
||||||
DEBUG
|
|
||||||
};
|
|
||||||
|
|
||||||
class Logger
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void setLogLevel(LogLevel logLevel);
|
|
||||||
|
|
||||||
static void error(const char* format, ...);
|
|
||||||
static void info(const char* format, ...);
|
|
||||||
static void debug(const char* format, ...);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static void log(LogLevel logLevel, const char* prefix, const char* color, const char* format, va_list ap);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// A Material icon (from the Material font)
|
|
||||||
class MaterialIcon : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::string icon;
|
|
||||||
unsigned middleX, middleY;
|
|
||||||
|
|
||||||
public:
|
|
||||||
MaterialIcon(std::string icon);
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/animations.hpp>
|
|
||||||
#include <borealis/label.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
#define BRLS_NOTIFICATIONS_MAX 8
|
|
||||||
|
|
||||||
// TODO: check in HOS that the animation duration + notification timeout are correct
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
class Notification : public View
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Notification(std::string text);
|
|
||||||
~Notification();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
|
|
||||||
menu_timer_t timeoutTimer;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Label* label;
|
|
||||||
};
|
|
||||||
|
|
||||||
class NotificationManager : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
Notification* notifications[BRLS_NOTIFICATIONS_MAX];
|
|
||||||
|
|
||||||
void layoutNotification(size_t i);
|
|
||||||
|
|
||||||
public:
|
|
||||||
NotificationManager();
|
|
||||||
~NotificationManager();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
|
|
||||||
void notify(std::string text);
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // namespace brls
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 WerWolv
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/applet_frame.hpp>
|
|
||||||
#include <borealis/list.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
class PopupFrame : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
PopupFrame(std::string title, unsigned char* imageBuffer, size_t imageBufferSize, AppletFrame* contentView, std::string subTitleLeft = "", std::string subTitleRight = "");
|
|
||||||
PopupFrame(std::string title, std::string imagePath, AppletFrame* contentView, std::string subTitleLeft = "", std::string subTitleRight = "");
|
|
||||||
PopupFrame(std::string title, AppletFrame* contentView, std::string subTitleLeft = "", std::string subTitleRight = "");
|
|
||||||
|
|
||||||
AppletFrame* contentView = nullptr;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
unsigned getShowAnimationDuration(ViewAnimation animation) override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
~PopupFrame();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
virtual bool onCancel();
|
|
||||||
void willAppear(bool resetState = false) override;
|
|
||||||
void willDisappear(bool resetState = false) override;
|
|
||||||
|
|
||||||
static void open(std::string title, unsigned char* imageBuffer, size_t imageBufferSize, AppletFrame* contentView, std::string subTitleLeft = "", std::string subTitleRight = "");
|
|
||||||
static void open(std::string title, std::string imagePath, AppletFrame* contentView, std::string subTitleLeft = "", std::string subTitleRight = "");
|
|
||||||
static void open(std::string title, AppletFrame* contentView, std::string subTitleLeft = "", std::string subTitleRight = "");
|
|
||||||
|
|
||||||
bool isTranslucent() override
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 Billy Laws
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/label.hpp>
|
|
||||||
#include <borealis/progress_spinner.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// TODO: Add the "ProgressDisplayFlags_" prefix to the members
|
|
||||||
enum ProgressDisplayFlags
|
|
||||||
{
|
|
||||||
SPINNER = 1u << 0,
|
|
||||||
PERCENTAGE = 1u << 1
|
|
||||||
};
|
|
||||||
|
|
||||||
inline constexpr ProgressDisplayFlags DEFAULT_PROGRESS_DISPLAY_FLAGS = (ProgressDisplayFlags)(ProgressDisplayFlags::SPINNER | ProgressDisplayFlags::PERCENTAGE);
|
|
||||||
|
|
||||||
// A progress bar with an optional spinner and percentage text.
|
|
||||||
class ProgressDisplay : public View
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProgressDisplay(ProgressDisplayFlags progressFlags = DEFAULT_PROGRESS_DISPLAY_FLAGS);
|
|
||||||
~ProgressDisplay();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
void willAppear(bool resetState = false) override;
|
|
||||||
void willDisappear(bool resetState = false) override;
|
|
||||||
|
|
||||||
void setProgress(int current, int max);
|
|
||||||
|
|
||||||
private:
|
|
||||||
float progressPercentage = 0.0f;
|
|
||||||
Label* label;
|
|
||||||
ProgressSpinner* spinner;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 Billy Laws
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// A progress spinner
|
|
||||||
class ProgressSpinner : public View
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProgressSpinner();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
void willAppear(bool resetState = false) override;
|
|
||||||
void willDisappear(bool resetState = false) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
float animationValue = 0.0f;
|
|
||||||
|
|
||||||
void restartAnimation();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/frame_context.hpp>
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// A solid color rectangle
|
|
||||||
class Rectangle : public View
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Rectangle(NVGcolor color);
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
|
|
||||||
void setColor(NVGcolor color);
|
|
||||||
|
|
||||||
~Rectangle() {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
NVGcolor color = nvgRGB(0, 0, 255);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <features/features_cpu.h>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// A task that is repeated at a given interval
|
|
||||||
// by the UI thread
|
|
||||||
class RepeatingTask
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
retro_time_t interval;
|
|
||||||
|
|
||||||
retro_time_t lastRun = 0;
|
|
||||||
|
|
||||||
bool running = false;
|
|
||||||
bool stopRequested = false;
|
|
||||||
|
|
||||||
public:
|
|
||||||
RepeatingTask(retro_time_t interval);
|
|
||||||
virtual ~RepeatingTask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Actual code to run by the task
|
|
||||||
* Must call RepeatingTask::run() !
|
|
||||||
*/
|
|
||||||
virtual void run(retro_time_t currentTime);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fired when the task starts
|
|
||||||
*/
|
|
||||||
virtual void onStart() {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fired when the task stops
|
|
||||||
*/
|
|
||||||
virtual void onStop() {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the task
|
|
||||||
*/
|
|
||||||
void start();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fires the task immediately and delays the
|
|
||||||
* next run
|
|
||||||
*/
|
|
||||||
void fireNow();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pauses the task without deleting it
|
|
||||||
*/
|
|
||||||
void pause();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stops and deletes the task
|
|
||||||
*/
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
retro_time_t getInterval();
|
|
||||||
retro_time_t getLastRun();
|
|
||||||
|
|
||||||
bool isRunning();
|
|
||||||
bool isStopRequested();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2020 natinusala
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// TODO: horizontal scrolling, either in ScrollView or in a separate class (like Android has)
|
|
||||||
|
|
||||||
// A view that automatically scrolls vertically
|
|
||||||
// when one of its children gains focus
|
|
||||||
class ScrollView : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
View* contentView = nullptr;
|
|
||||||
|
|
||||||
bool ready = false; // has layout been called at least once?
|
|
||||||
|
|
||||||
unsigned middleY = 0; // y + height/2
|
|
||||||
unsigned bottomY = 0; // y + height
|
|
||||||
|
|
||||||
float scrollY = 0.0f; // from 0.0f to 1.0f, in % of content view height
|
|
||||||
|
|
||||||
bool updateScrollingOnNextLayout = false;
|
|
||||||
bool updateScrollingOnNextFrame = false;
|
|
||||||
|
|
||||||
unsigned getYCenter(View* view);
|
|
||||||
|
|
||||||
void prebakeScrolling();
|
|
||||||
bool updateScrolling(bool animated);
|
|
||||||
void startScrolling(bool animated, float newScroll);
|
|
||||||
void scrollAnimationTick();
|
|
||||||
|
|
||||||
public:
|
|
||||||
~ScrollView();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
void willAppear(bool resetState = false) override;
|
|
||||||
void willDisappear(bool resetState = false) override;
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
void onChildFocusGained(View* child) override;
|
|
||||||
void onWindowSizeChanged() override;
|
|
||||||
|
|
||||||
void setContentView(View* view);
|
|
||||||
View* getContentView();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/box_layout.hpp>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// A sidebar with multiple tabs
|
|
||||||
class SidebarSeparator : public View
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SidebarSeparator();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Sidebar;
|
|
||||||
|
|
||||||
// TODO: Use a Label view with integrated ticker for label and sublabel
|
|
||||||
// TODO: Have the label always tick when active
|
|
||||||
class SidebarItem : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::string label;
|
|
||||||
bool active = false;
|
|
||||||
|
|
||||||
Sidebar* sidebar = nullptr;
|
|
||||||
View* associatedView = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
SidebarItem(std::string label, Sidebar* sidebar);
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
|
|
||||||
View* getDefaultFocus() override
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool onClick();
|
|
||||||
|
|
||||||
void setActive(bool active);
|
|
||||||
bool isActive();
|
|
||||||
|
|
||||||
void onFocusGained() override;
|
|
||||||
|
|
||||||
void setAssociatedView(View* view);
|
|
||||||
View* getAssociatedView();
|
|
||||||
|
|
||||||
~SidebarItem();
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: Add a style with icons, make it collapsible?
|
|
||||||
class Sidebar : public BoxLayout
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
SidebarItem* currentActive = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Sidebar();
|
|
||||||
|
|
||||||
SidebarItem* addItem(std::string label, View* view);
|
|
||||||
void addSeparator();
|
|
||||||
|
|
||||||
void setActive(SidebarItem* item);
|
|
||||||
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
void onChildFocusGained(View* child) override;
|
|
||||||
|
|
||||||
size_t lastFocus = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 Billy Laws
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/applet_frame.hpp>
|
|
||||||
#include <borealis/sidebar.hpp>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// An applet frame for implementing a stage based app with a progress display in top right
|
|
||||||
class StagedAppletFrame : public AppletFrame
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
StagedAppletFrame();
|
|
||||||
~StagedAppletFrame();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
|
|
||||||
void addStage(View* view);
|
|
||||||
void nextStage();
|
|
||||||
void previousStage();
|
|
||||||
|
|
||||||
unsigned getCurrentStage();
|
|
||||||
unsigned getStagesCount();
|
|
||||||
unsigned isLastStage();
|
|
||||||
|
|
||||||
private:
|
|
||||||
size_t currentStage = 0;
|
|
||||||
std::vector<View*> stageViews;
|
|
||||||
|
|
||||||
void enterStage(int index, bool requestFocus);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,323 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 WerWolv
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
class Style
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// AppletFrame
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned headerHeightRegular;
|
|
||||||
unsigned headerHeightPopup; // PopupFrame
|
|
||||||
unsigned footerHeight;
|
|
||||||
|
|
||||||
unsigned imageLeftPadding;
|
|
||||||
unsigned imageTopPadding;
|
|
||||||
unsigned imageSize;
|
|
||||||
unsigned separatorSpacing;
|
|
||||||
|
|
||||||
unsigned titleSize;
|
|
||||||
unsigned titleStart;
|
|
||||||
unsigned titleOffset;
|
|
||||||
|
|
||||||
unsigned footerTextSize;
|
|
||||||
unsigned footerTextSpacing;
|
|
||||||
|
|
||||||
unsigned slideAnimation;
|
|
||||||
} AppletFrame;
|
|
||||||
|
|
||||||
// Highlight
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned strokeWidth;
|
|
||||||
float cornerRadius;
|
|
||||||
|
|
||||||
unsigned shadowWidth;
|
|
||||||
unsigned shadowOffset;
|
|
||||||
unsigned shadowFeather;
|
|
||||||
unsigned shadowOpacity;
|
|
||||||
|
|
||||||
unsigned animationDuration;
|
|
||||||
} Highlight;
|
|
||||||
|
|
||||||
// Background
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned sidebarBorderHeight;
|
|
||||||
} Background;
|
|
||||||
|
|
||||||
// Sidebar
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned width;
|
|
||||||
unsigned spacing;
|
|
||||||
|
|
||||||
unsigned marginLeft;
|
|
||||||
unsigned marginRight;
|
|
||||||
unsigned marginTop;
|
|
||||||
unsigned marginBottom;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned height;
|
|
||||||
unsigned textSize;
|
|
||||||
unsigned padding;
|
|
||||||
|
|
||||||
unsigned textOffsetX;
|
|
||||||
unsigned activeMarkerWidth;
|
|
||||||
|
|
||||||
unsigned highlight;
|
|
||||||
} Item;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned height;
|
|
||||||
} Separator;
|
|
||||||
} Sidebar;
|
|
||||||
|
|
||||||
// List
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned marginLeftRight;
|
|
||||||
unsigned marginTopBottom;
|
|
||||||
unsigned spacing;
|
|
||||||
|
|
||||||
// Item
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned height;
|
|
||||||
unsigned heightWithSubLabel;
|
|
||||||
unsigned valueSize;
|
|
||||||
unsigned padding;
|
|
||||||
unsigned thumbnailPadding;
|
|
||||||
|
|
||||||
unsigned descriptionIndent;
|
|
||||||
unsigned descriptionSpacing;
|
|
||||||
|
|
||||||
unsigned indent;
|
|
||||||
|
|
||||||
unsigned selectRadius;
|
|
||||||
} Item;
|
|
||||||
} List;
|
|
||||||
|
|
||||||
// Label
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned regularFontSize;
|
|
||||||
unsigned mediumFontSize;
|
|
||||||
unsigned smallFontSize;
|
|
||||||
unsigned descriptionFontSize;
|
|
||||||
unsigned crashFontSize;
|
|
||||||
unsigned buttonFontSize;
|
|
||||||
unsigned listItemFontSize;
|
|
||||||
unsigned notificationFontSize;
|
|
||||||
unsigned dialogFontSize;
|
|
||||||
unsigned hintFontSize;
|
|
||||||
|
|
||||||
float lineHeight;
|
|
||||||
float notificationLineHeight;
|
|
||||||
} Label;
|
|
||||||
|
|
||||||
// CrashFrame
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
float labelWidth; // proportional to frame width, from 0 to 1
|
|
||||||
unsigned boxStrokeWidth;
|
|
||||||
unsigned boxSize;
|
|
||||||
unsigned boxSpacing;
|
|
||||||
unsigned buttonWidth;
|
|
||||||
unsigned buttonHeight;
|
|
||||||
unsigned buttonSpacing;
|
|
||||||
} CrashFrame;
|
|
||||||
|
|
||||||
// Button
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
float cornerRadius;
|
|
||||||
|
|
||||||
unsigned highlightInset;
|
|
||||||
|
|
||||||
float shadowWidth;
|
|
||||||
float shadowFeather;
|
|
||||||
float shadowOpacity;
|
|
||||||
float shadowOffset;
|
|
||||||
} Button;
|
|
||||||
|
|
||||||
// TableRow
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned headerHeight;
|
|
||||||
unsigned headerTextSize;
|
|
||||||
|
|
||||||
unsigned bodyHeight;
|
|
||||||
unsigned bodyIndent;
|
|
||||||
unsigned bodyTextSize;
|
|
||||||
|
|
||||||
unsigned padding;
|
|
||||||
} TableRow;
|
|
||||||
|
|
||||||
// Dropdown
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned listWidth;
|
|
||||||
unsigned listPadding;
|
|
||||||
|
|
||||||
unsigned listItemHeight;
|
|
||||||
unsigned listItemTextSize;
|
|
||||||
|
|
||||||
unsigned headerHeight;
|
|
||||||
unsigned headerFontSize;
|
|
||||||
unsigned headerPadding;
|
|
||||||
} Dropdown;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned edgePadding;
|
|
||||||
unsigned separatorSpacing;
|
|
||||||
unsigned footerHeight;
|
|
||||||
unsigned imageLeftPadding;
|
|
||||||
unsigned imageTopPadding;
|
|
||||||
unsigned imageSize;
|
|
||||||
unsigned contentWidth;
|
|
||||||
unsigned contentHeight;
|
|
||||||
|
|
||||||
unsigned headerTextLeftPadding;
|
|
||||||
unsigned headerTextTopPadding;
|
|
||||||
|
|
||||||
unsigned subTitleLeftPadding;
|
|
||||||
unsigned subTitleTopPadding;
|
|
||||||
unsigned subTitleSpacing;
|
|
||||||
|
|
||||||
unsigned subTitleSeparatorLeftPadding;
|
|
||||||
unsigned subTitleSeparatorTopPadding;
|
|
||||||
unsigned subTitleSeparatorHeight;
|
|
||||||
|
|
||||||
unsigned headerFontSize;
|
|
||||||
unsigned subTitleFontSize;
|
|
||||||
} PopupFrame;
|
|
||||||
|
|
||||||
// StagedAppletFrame
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned progressIndicatorSpacing;
|
|
||||||
unsigned progressIndicatorRadiusUnselected;
|
|
||||||
unsigned progressIndicatorRadiusSelected;
|
|
||||||
unsigned progressIndicatorBorderWidth;
|
|
||||||
} StagedAppletFrame;
|
|
||||||
|
|
||||||
// ProgressSpinner
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
float centerGapMultiplier;
|
|
||||||
float barWidthMultiplier;
|
|
||||||
unsigned animationDuration;
|
|
||||||
} ProgressSpinner;
|
|
||||||
|
|
||||||
// ProgressDisplay
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned percentageLabelWidth;
|
|
||||||
} ProgressDisplay;
|
|
||||||
|
|
||||||
// Header
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned height;
|
|
||||||
unsigned padding;
|
|
||||||
|
|
||||||
unsigned rectangleWidth;
|
|
||||||
|
|
||||||
unsigned fontSize;
|
|
||||||
} Header;
|
|
||||||
|
|
||||||
// FramerateCounter
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned width;
|
|
||||||
unsigned height;
|
|
||||||
} FramerateCounter;
|
|
||||||
|
|
||||||
// ThumbnailSidebar
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned marginLeftRight;
|
|
||||||
unsigned marginTopBottom;
|
|
||||||
|
|
||||||
unsigned buttonHeight;
|
|
||||||
unsigned buttonMargin;
|
|
||||||
} ThumbnailSidebar;
|
|
||||||
|
|
||||||
// AnimationDuration
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned show;
|
|
||||||
unsigned showSlide;
|
|
||||||
|
|
||||||
unsigned highlight;
|
|
||||||
unsigned shake;
|
|
||||||
|
|
||||||
unsigned collapse;
|
|
||||||
|
|
||||||
unsigned progress;
|
|
||||||
|
|
||||||
unsigned notificationTimeout;
|
|
||||||
} AnimationDuration;
|
|
||||||
|
|
||||||
// Notification
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned width;
|
|
||||||
unsigned padding;
|
|
||||||
|
|
||||||
unsigned slideAnimation;
|
|
||||||
} Notification;
|
|
||||||
|
|
||||||
// Dialog
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned width;
|
|
||||||
unsigned height;
|
|
||||||
|
|
||||||
unsigned paddingTopBottom;
|
|
||||||
unsigned paddingLeftRight;
|
|
||||||
|
|
||||||
float cornerRadius;
|
|
||||||
|
|
||||||
unsigned buttonHeight;
|
|
||||||
unsigned buttonSeparatorHeight;
|
|
||||||
|
|
||||||
float shadowWidth;
|
|
||||||
float shadowFeather;
|
|
||||||
float shadowOpacity;
|
|
||||||
float shadowOffset;
|
|
||||||
} Dialog;
|
|
||||||
|
|
||||||
// As close to HOS as possible
|
|
||||||
static Style horizon();
|
|
||||||
|
|
||||||
// TODO: Make a condensed style
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 WerWolv
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
class Swkbd
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static bool openForText(std::function<void(std::string)> f, std::string headerText = "", std::string subText = "", int maxStringLength = 32, std::string initialText = "");
|
|
||||||
static bool openForNumber(std::function<void(int)> f, std::string headerText = "", std::string subText = "", int maxStringLength = 32, std::string initialText = "", std::string leftButton = "", std::string rightButton = "");
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019-2020 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/applet_frame.hpp>
|
|
||||||
#include <borealis/sidebar.hpp>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// An applet frame containing a sidebar on the left with multiple tabs
|
|
||||||
class TabFrame : public AppletFrame
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TabFrame();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a tab with given label and view
|
|
||||||
* All tabs and separators must be added
|
|
||||||
* before the TabFrame is itself added to
|
|
||||||
* the view hierarchy
|
|
||||||
*/
|
|
||||||
void addTab(std::string label, View* view);
|
|
||||||
void addSeparator();
|
|
||||||
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
|
|
||||||
virtual bool onCancel() override;
|
|
||||||
|
|
||||||
~TabFrame();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Sidebar* sidebar;
|
|
||||||
BoxLayout* layout;
|
|
||||||
View* rightPane = nullptr;
|
|
||||||
|
|
||||||
void switchToView(View* view);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/view.hpp>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// The type of a Table Row
|
|
||||||
enum class TableRowType
|
|
||||||
{
|
|
||||||
HEADER = 0,
|
|
||||||
BODY
|
|
||||||
};
|
|
||||||
|
|
||||||
// A Table row
|
|
||||||
class TableRow
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
TableRowType type;
|
|
||||||
|
|
||||||
std::string label;
|
|
||||||
std::string value;
|
|
||||||
|
|
||||||
public:
|
|
||||||
TableRow(TableRowType type, std::string label, std::string value = "");
|
|
||||||
|
|
||||||
std::string* getLabel();
|
|
||||||
std::string* getValue();
|
|
||||||
TableRowType getType();
|
|
||||||
|
|
||||||
void setValue(std::string value);
|
|
||||||
};
|
|
||||||
|
|
||||||
// A simple, static two-columns table, as seen in
|
|
||||||
// the Settings app (Internet connection details)
|
|
||||||
// All rows must be added before adding the view
|
|
||||||
// to a layout (it's static)
|
|
||||||
class Table : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::vector<TableRow*> rows;
|
|
||||||
|
|
||||||
public:
|
|
||||||
~Table();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
|
|
||||||
TableRow* addRow(TableRowType type, std::string label, std::string value = "");
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/repeating_task.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
class TaskManager
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::vector<RepeatingTask*> repeatingTasks;
|
|
||||||
|
|
||||||
void stopRepeatingTask(RepeatingTask* task);
|
|
||||||
|
|
||||||
public:
|
|
||||||
void frame();
|
|
||||||
|
|
||||||
void registerRepeatingTask(RepeatingTask* task);
|
|
||||||
|
|
||||||
~TaskManager();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
Copyright (C) 2019 p-sam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <nanovg.h>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// Theme variants
|
|
||||||
// (used in Application)
|
|
||||||
//
|
|
||||||
// Not an enum class because it's used
|
|
||||||
// as an array index in Theme
|
|
||||||
enum ThemeVariant
|
|
||||||
{
|
|
||||||
ThemeVariant_LIGHT = 0,
|
|
||||||
ThemeVariant_DARK,
|
|
||||||
ThemeVariant_NUMBER_OF_VARIANTS
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
float backgroundColor[3]; // gl color
|
|
||||||
NVGcolor backgroundColorRGB;
|
|
||||||
|
|
||||||
NVGcolor textColor;
|
|
||||||
NVGcolor descriptionColor;
|
|
||||||
|
|
||||||
NVGcolor notificationTextColor;
|
|
||||||
NVGcolor backdropColor;
|
|
||||||
|
|
||||||
NVGcolor separatorColor;
|
|
||||||
|
|
||||||
NVGcolor sidebarColor;
|
|
||||||
NVGcolor activeTabColor;
|
|
||||||
NVGcolor sidebarSeparatorColor;
|
|
||||||
|
|
||||||
NVGcolor highlightBackgroundColor;
|
|
||||||
NVGcolor highlightColor1;
|
|
||||||
NVGcolor highlightColor2;
|
|
||||||
|
|
||||||
NVGcolor listItemSeparatorColor;
|
|
||||||
NVGcolor listItemValueColor;
|
|
||||||
NVGcolor listItemFaintValueColor;
|
|
||||||
|
|
||||||
NVGcolor tableEvenBackgroundColor;
|
|
||||||
NVGcolor tableBodyTextColor;
|
|
||||||
|
|
||||||
NVGcolor dropdownBackgroundColor;
|
|
||||||
|
|
||||||
NVGcolor nextStageBulletColor;
|
|
||||||
|
|
||||||
NVGcolor spinnerBarColor;
|
|
||||||
|
|
||||||
NVGcolor headerRectangleColor;
|
|
||||||
|
|
||||||
NVGcolor buttonPlainEnabledBackgroundColor;
|
|
||||||
NVGcolor buttonPlainDisabledBackgroundColor;
|
|
||||||
NVGcolor buttonPlainEnabledTextColor;
|
|
||||||
NVGcolor buttonPlainDisabledTextColor;
|
|
||||||
|
|
||||||
NVGcolor dialogColor;
|
|
||||||
NVGcolor dialogBackdrop;
|
|
||||||
NVGcolor dialogButtonColor;
|
|
||||||
NVGcolor dialogButtonSeparatorColor;
|
|
||||||
} ThemeValues;
|
|
||||||
|
|
||||||
// A theme contains colors for all variants
|
|
||||||
class Theme
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ThemeValues colors[ThemeVariant_NUMBER_OF_VARIANTS];
|
|
||||||
|
|
||||||
// As close to HOS as possible
|
|
||||||
static Theme horizon();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
Borealis, a Nintendo Switch UI Library
|
|
||||||
Copyright (C) 2019 natinusala
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <borealis/applet_frame.hpp>
|
|
||||||
#include <borealis/box_layout.hpp>
|
|
||||||
#include <borealis/button.hpp>
|
|
||||||
#include <borealis/image.hpp>
|
|
||||||
|
|
||||||
namespace brls
|
|
||||||
{
|
|
||||||
|
|
||||||
// The sidebar used in ThumbnailFrame
|
|
||||||
class ThumbnailSidebar : public View
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
Image* image = nullptr;
|
|
||||||
Button* button = nullptr;
|
|
||||||
|
|
||||||
Label* title = nullptr;
|
|
||||||
Label* subTitle = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ThumbnailSidebar();
|
|
||||||
~ThumbnailSidebar();
|
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
View* getDefaultFocus() override;
|
|
||||||
|
|
||||||
void setThumbnail(std::string imagePath);
|
|
||||||
void setThumbnail(unsigned char* buffer, size_t bufferSize);
|
|
||||||
|
|
||||||
void setTitle(std::string title);
|
|
||||||
void setSubtitle(std::string subTitle);
|
|
||||||
|
|
||||||
Button* getButton();
|
|
||||||
};
|
|
||||||
|
|
||||||
// An applet frame with a sidebar on the right, containing a thumbnail
|
|
||||||
// and a button (similar to the Wi-Fi settings in HOS)
|
|
||||||
class ThumbnailFrame : public AppletFrame
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ThumbnailSidebar* sidebar = nullptr;
|
|
||||||
BoxLayout* boxLayout = nullptr;
|
|
||||||
|
|
||||||
View* thumbnailContentView = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ThumbnailFrame();
|
|
||||||
~ThumbnailFrame();
|
|
||||||
|
|
||||||
void setContentView(View* view) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void layout(NVGcontext* vg, Style* style, FontStash* stash) override;
|
|
||||||
|
|
||||||
ThumbnailSidebar* getSidebar();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brls
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user