Compare commits
162 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa72176196 | ||
|
|
7af0721847 | ||
|
|
2a6320e646 | ||
|
|
fc212bb419 | ||
|
|
14e0053335 | ||
|
|
8f28daceef | ||
|
|
f1044673d0 | ||
|
|
61a0ebffee | ||
|
|
8de8f4013e | ||
|
|
dd447553d4 | ||
|
|
11c456e00c | ||
|
|
5efb4bdd6b | ||
|
|
e331f1249b | ||
|
|
786467d7ea | ||
|
|
496e77301b | ||
|
|
d657f1d156 | ||
|
|
7ab5c2f540 | ||
|
|
71900721cf | ||
|
|
0bc9547701 | ||
|
|
96ac254022 | ||
|
|
92f378a80f | ||
|
|
589af01ad8 | ||
|
|
e7f14b88e5 | ||
|
|
35a269e4a7 | ||
|
|
ff95ca527f | ||
|
|
550e4e5204 | ||
|
|
a088c4795a | ||
|
|
e8a264fa11 | ||
|
|
de681c20a0 | ||
|
|
22aef264ab | ||
|
|
309717c468 | ||
|
|
9b91d7487c | ||
|
|
c0b458243c | ||
|
|
7d9c60cdfe | ||
|
|
12c9effec2 | ||
|
|
6eeab63075 | ||
|
|
2d81c5e127 | ||
|
|
b1739cea74 | ||
|
|
aa607ab1a7 | ||
|
|
d1242a17d4 | ||
|
|
80701c2891 | ||
|
|
cfd0d84ac8 | ||
|
|
c33aabdc84 | ||
|
|
c70fd82e60 | ||
|
|
574c248d68 | ||
|
|
ebcf07dab8 | ||
|
|
d170ca92ad | ||
|
|
cab8a14b99 | ||
|
|
b623dabce5 | ||
|
|
e5eb49f2e5 | ||
|
|
9f0a609735 | ||
|
|
19a2e562bc | ||
|
|
73c3311251 | ||
|
|
eb7fca1c1a | ||
|
|
ad1f070a6b | ||
|
|
0ae65c8740 | ||
|
|
39fbe25afc | ||
|
|
3bad144280 | ||
|
|
123d4b6080 | ||
|
|
2f6ed69b92 | ||
|
|
337f7e6ac0 | ||
|
|
a5efa7ae72 | ||
|
|
a8ee389681 | ||
|
|
54554bacea | ||
|
|
3da2fc4b6d | ||
|
|
83287b1f5c | ||
|
|
4f6756c609 | ||
|
|
ef2434c457 | ||
|
|
b0237a2042 | ||
|
|
c6275eb977 | ||
|
|
72961aa2f1 | ||
|
|
9c60697344 | ||
|
|
f786d97de1 | ||
|
|
20389043ac | ||
|
|
00b9d8550e | ||
|
|
0c0a4b3d6b | ||
|
|
61fd9d74d3 | ||
|
|
f36383d0e7 | ||
|
|
606cafbaad | ||
|
|
cff4267a68 | ||
|
|
65e7d83972 | ||
|
|
e2533e2bb0 | ||
|
|
0d4ca24538 | ||
|
|
6c94f5754c | ||
|
|
aaf77997e1 | ||
|
|
c933e02aed | ||
|
|
770c25dbcb | ||
|
|
bf8a6c4785 | ||
|
|
dbb4d698a0 | ||
|
|
6ae084433f | ||
|
|
32f19c4f0e | ||
|
|
05cf2ab4dd | ||
|
|
13a4ea4ca0 | ||
|
|
e2ef52e095 | ||
|
|
bbd3b1a0fc | ||
|
|
8dcfb55646 | ||
|
|
ae0f4c7963 | ||
|
|
222db76200 | ||
|
|
2376b85d3a | ||
|
|
26fb76e448 | ||
|
|
159c7567c0 | ||
|
|
39366ce238 | ||
|
|
da631ad268 | ||
|
|
d508177d4b | ||
|
|
d8527410de | ||
|
|
bae7216de0 | ||
|
|
b3ddf172e8 | ||
|
|
cdaea8f729 | ||
|
|
918ca5757c | ||
|
|
93cb0e99c4 | ||
|
|
4692529346 | ||
|
|
8de1191ed5 | ||
|
|
1c21187f73 | ||
|
|
2646995b72 | ||
|
|
cf21342b2e | ||
|
|
3709fb3fba | ||
|
|
ea754707ee | ||
|
|
bb96267d6c | ||
|
|
a1fa16da3c | ||
|
|
aad126d611 | ||
|
|
835189febc | ||
|
|
a9cf59fe28 | ||
|
|
7708e4bae6 | ||
|
|
8c71227c63 | ||
|
|
627732326b | ||
|
|
f5d9761853 | ||
|
|
1d219e9425 | ||
|
|
2c14ddad5c | ||
|
|
fee7e7a4f4 | ||
|
|
caeee5920b | ||
|
|
71fbeef32a | ||
|
|
86fce20b27 | ||
|
|
5012836c7e | ||
|
|
af1c36d00a | ||
|
|
5dca0a9d9b | ||
|
|
d3b1e9d31d | ||
|
|
64301c6d33 | ||
|
|
9b4544856e | ||
|
|
d8104bfc6f | ||
|
|
39e666599d | ||
|
|
d3ff7857e7 | ||
|
|
662473b2c0 | ||
|
|
051c637dd8 | ||
|
|
28a772c546 | ||
|
|
4a06176897 | ||
|
|
7325905476 | ||
|
|
ed8eed2c57 | ||
|
|
9723fdc2e0 | ||
|
|
2856f6f778 | ||
|
|
4187daf029 | ||
|
|
c479f9c53c | ||
|
|
a5357e298a | ||
|
|
045bd81887 | ||
|
|
ae22e70602 | ||
|
|
12e6f114a8 | ||
|
|
d6fec8bdaa | ||
|
|
5a8a9ae79d | ||
|
|
6d0399f352 | ||
|
|
382f6d5834 | ||
|
|
679fd4fd79 | ||
|
|
c4a59d72b7 | ||
|
|
cc2f58f1d7 |
163
.github/workflows/build.yml
vendored
Normal file
163
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
name: Build Horizon OC Zeus
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ develop, main, master ]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Minimal devkitA64 container
|
||||
container:
|
||||
image: devkitpro/devkita64:20251231
|
||||
|
||||
steps:
|
||||
- name: Checkout repository and submodules # needed for hoc-clk
|
||||
uses: actions/checkout@v6.0.2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
|
||||
# -------------------------------------------------
|
||||
# Fix PATH for devkitA64 and devkitARM
|
||||
# -------------------------------------------------
|
||||
- name: Set devkitPro PATH
|
||||
run: |
|
||||
echo "DEVKITPRO=/opt/devkitpro" >> $GITHUB_ENV
|
||||
echo "DEVKITA64=/opt/devkitpro/devkitA64" >> $GITHUB_ENV
|
||||
echo "DEVKITARM=/opt/devkitpro/devkitARM" >> $GITHUB_ENV
|
||||
echo "PATH=/opt/devkitpro/devkitA64/bin:/opt/devkitpro/devkitARM/bin:$PATH" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: Check devkitPro gcc and g++ versions
|
||||
run: |
|
||||
aarch64-none-elf-gcc --version
|
||||
aarch64-none-elf-g++ --version
|
||||
shell: bash # is this even needed? but for consistency let's keep using it
|
||||
|
||||
- name: Install ccache
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y ccache
|
||||
shell: bash
|
||||
|
||||
# -------------------------------------------------
|
||||
# Get short commit SHA
|
||||
# -------------------------------------------------
|
||||
- name: Set commit SHA & dist
|
||||
id: vars
|
||||
run: |
|
||||
echo "SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
|
||||
echo $SHORT_SHA > dist/.commit
|
||||
echo $GITHUB_SHA >> dist/.commit
|
||||
|
||||
- name: Clone Atmosphere
|
||||
run: git clone --depth=1 --single-branch https://github.com/Atmosphere-NX/Atmosphere.git atmosphere -b $(cat ams_ver.txt)
|
||||
|
||||
- name: Prepare build folder
|
||||
run: |
|
||||
mkdir -p build
|
||||
cp -r atmosphere/* build/
|
||||
|
||||
- name: Override ldr_process_creation.cpp
|
||||
run: |
|
||||
cp -rf Source/Atmosphere/stratosphere/loader/source/* build/stratosphere/loader/source/
|
||||
|
||||
- name: Cache ccache
|
||||
uses: actions/cache@v5.0.3
|
||||
with:
|
||||
path: /root/.cache/ccache
|
||||
key: ccache-${{ runner.os }}-devkitpro-ams-${{ hashFiles('ams_ver.txt') }} # last key was utter garbage, stick to ams versions,
|
||||
restore-keys: |
|
||||
ccache-${{ runner.os }}-devkitpro-
|
||||
|
||||
- name: Configure ccache
|
||||
run: |
|
||||
export CCACHE_DIR=/root/.cache/ccache
|
||||
echo "CCACHE_DIR=/root/.cache/ccache" >> $GITHUB_ENV
|
||||
ccache --set-config=max_size=10G
|
||||
ccache --set-config=compiler_check=content
|
||||
ccache --zero-stats
|
||||
|
||||
- name: Build hoc-clk sysmodule and overlay
|
||||
shell: bash
|
||||
run: |
|
||||
export CC="ccache aarch64-none-elf-gcc"
|
||||
export CXX="ccache aarch64-none-elf-g++"
|
||||
|
||||
ROOT_DIR="$GITHUB_WORKSPACE/Source/sys-clk"
|
||||
DIST_DIR="$ROOT_DIR/dist"
|
||||
|
||||
mkdir -p "$DIST_DIR"
|
||||
|
||||
echo "*** sysmodule ***"
|
||||
|
||||
TITLE_ID="$(grep -oP '"title_id":\s*"0x\K(\w+)' \
|
||||
"$ROOT_DIR/sysmodule/perms.json")"
|
||||
|
||||
echo "TITLE_ID: $TITLE_ID"
|
||||
|
||||
pushd "$ROOT_DIR/sysmodule"
|
||||
make -j$(($(nproc) * 2)) CXX="ccache aarch64-none-elf-g++" CC="ccache aarch64-none-elf-gcc"
|
||||
popd
|
||||
|
||||
mkdir -p "$DIST_DIR/atmosphere/contents/$TITLE_ID/flags"
|
||||
|
||||
cp -vf \
|
||||
"$ROOT_DIR/sysmodule/out/horizon-oc.nsp" \
|
||||
"$DIST_DIR/atmosphere/contents/$TITLE_ID/exefs.nsp"
|
||||
|
||||
: >"$DIST_DIR/atmosphere/contents/$TITLE_ID/flags/boot2.flag"
|
||||
|
||||
cp -vf \
|
||||
"$ROOT_DIR/sysmodule/toolbox.json" \
|
||||
"$DIST_DIR/atmosphere/contents/$TITLE_ID/toolbox.json"
|
||||
|
||||
echo "*** overlay ***"
|
||||
|
||||
pushd "$ROOT_DIR/overlay"
|
||||
make -j$(($(nproc) * 2)) CXX="ccache aarch64-none-elf-g++" CC="ccache aarch64-none-elf-gcc"
|
||||
popd
|
||||
|
||||
mkdir -p "$DIST_DIR/switch/.overlays"
|
||||
|
||||
cp -vf \
|
||||
"$ROOT_DIR/overlay/out/horizon-oc-overlay.ovl" \
|
||||
"$DIST_DIR/switch/.overlays/horizon-oc-overlay.ovl"
|
||||
|
||||
echo "*** assets ***"
|
||||
|
||||
mkdir -p "$DIST_DIR/config/horizon-oc"
|
||||
|
||||
cp -vf \
|
||||
"$ROOT_DIR/config.ini.template" \
|
||||
"$DIST_DIR/config/horizon-oc/config.ini.template"
|
||||
|
||||
cp -vf \
|
||||
"$ROOT_DIR/README.md" \
|
||||
"$DIST_DIR/README.md"
|
||||
|
||||
- name: Build kip
|
||||
working-directory: build/stratosphere/loader
|
||||
run: |
|
||||
export CC="ccache aarch64-none-elf-gcc"
|
||||
export CXX="ccache aarch64-none-elf-g++"
|
||||
make -j$(($(nproc) * 4)) CXX="ccache aarch64-none-elf-g++" CC="ccache aarch64-none-elf-gcc"
|
||||
hactool -t kip1 out/nintendo_nx_arm64_armv8a/release/loader.kip --uncompress=hoc.kip
|
||||
cp hoc.kip ../../../dist/atmosphere/kips/hoc.kip
|
||||
|
||||
- name: ccache stats
|
||||
run: ccache --show-stats
|
||||
|
||||
# -------------------------------------------------
|
||||
# Upload ZIP artifact
|
||||
# -------------------------------------------------
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: horizon-oc-zeus-dist
|
||||
path: dist/
|
||||
compression-level: 3
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -4,3 +4,6 @@
|
||||
[submodule "Source/Horizon-OC-Monitor/lib/libultrahand"]
|
||||
path = Source/Horizon-OC-Monitor/lib/libultrahand
|
||||
url = https://github.com/ppkantorski/libultrahand
|
||||
[submodule "Source/sys-clk/overlay/lib/libultrahand"]
|
||||
path = Source/sys-clk/overlay/lib/libultrahand
|
||||
url = https://github.com/ppkantorski/libultrahand
|
||||
|
||||
80
README.md
80
README.md
@@ -7,7 +7,7 @@
|
||||
|
||||

|
||||

|
||||
[](https://discord.com/invite/S3eX47dHsB)
|
||||
[](https://dsc.gg/horizonoc)
|
||||

|
||||

|
||||

|
||||
@@ -41,9 +41,7 @@ It enables advanced CPU, GPU, and RAM tuning with user-friendly configuration to
|
||||
* Built-in configurator
|
||||
* Compatible with most homebrew
|
||||
|
||||
> *Higher (potentially dangerous) frequencies are unlockable via configuration.*
|
||||
> *Erista and Mariko units can usually push a bit further fully safely with a bit of undervolting, however this may not work on all units.*
|
||||
> *The exact maximum overclock possible varies per console, although most consoles should be able to do this safely.*
|
||||
> It is reccomended to read the [guide](https://rentry.co/howtoget60fps) before proceeding, as this can help you get a *significant* performance boost over the default settings, often times with less power draw and heat output
|
||||
|
||||
---
|
||||
|
||||
@@ -69,7 +67,7 @@ It enables advanced CPU, GPU, and RAM tuning with user-friendly configuration to
|
||||
|
||||
1. Open the Horizon OC Overlay
|
||||
2. Open the settings menu
|
||||
3. Adjust your overclocking settings as desired.
|
||||
3. Adjust your overclocking settings as desired. A helpful guide can be found [here.](https://rentry.co/mariko#oc-settings-for-horizon-oc)
|
||||
4. Click **Save KIP Settings** to apply your configuration.
|
||||
|
||||
---
|
||||
@@ -78,6 +76,73 @@ It enables advanced CPU, GPU, and RAM tuning with user-friendly configuration to
|
||||
|
||||
Refer to COMPILATION.md
|
||||
|
||||
---
|
||||
## Clock table
|
||||
|
||||
### MEM clocks
|
||||
* 3200 → max on mariko, JEDEC.
|
||||
* 2933 → JEDEC.
|
||||
* 2666 → JEDEC.
|
||||
* 2400 → max on erista, JEDEC.
|
||||
* 2133 → mariko safe max (4266 Modules), JEDEC.
|
||||
* 1996 → JEDEC.
|
||||
* 1866 → mariko safe max (3733 Modules), JEDEC.
|
||||
* 1600 → official docked, boost mode, erista safe max, JEDEC.
|
||||
* 1331 → official handheld, JEDEC.
|
||||
* 1065
|
||||
* 800
|
||||
* 665
|
||||
|
||||
### CPU clocks
|
||||
* 2601 → mariko absolute max, very dangerous
|
||||
* 2499
|
||||
* 2397 → mariko safe max with UV (low speedo)
|
||||
* 2295
|
||||
* 2193
|
||||
* 2091
|
||||
* 1963 → mariko no UV max clock
|
||||
* 1887
|
||||
* 1785 → erista no UV max clock, boost mode
|
||||
* 1683
|
||||
* 1581
|
||||
* 1428
|
||||
* 1326
|
||||
* 1224 → sdev oc
|
||||
* 1122
|
||||
* 1020 → official docked & handheld
|
||||
* 918
|
||||
* 816
|
||||
* 714
|
||||
* 612 → sleep mode
|
||||
|
||||
### GPU clocks
|
||||
* 1536 → absolute max clock on mariko. very dangerous
|
||||
* 1459
|
||||
* 1382
|
||||
* 1305
|
||||
* 1267 → NVIDIA T214 rating
|
||||
* 1228 → mariko HiOPT safe clock
|
||||
* 1152 → mariko SLT max clock
|
||||
* 1075 → mariko no UV max clock. absolute max clock on erista. very dangerous
|
||||
* 998 → NVIDIA T210 rating
|
||||
* 960 (erista only) → erista slt/hiopt safe max clock
|
||||
* 921 → erista no UV max clock
|
||||
* 844
|
||||
* 768 → official docked
|
||||
* 691
|
||||
* 614
|
||||
* 537
|
||||
* 460 → max handheld
|
||||
* 384 → official handheld
|
||||
* 307 → official handheld
|
||||
* 230
|
||||
* 153
|
||||
* 76 → boost mode
|
||||
|
||||
**Notes:**
|
||||
1. GPU overclock is capped at 460MHz in handheld and capped at 768MHz if charging, unless you're using the official charger.
|
||||
2. Clocks higher than 768MHz need the official charger is plugged in.
|
||||
|
||||
---
|
||||
|
||||
## Credits
|
||||
@@ -86,13 +151,14 @@ Refer to COMPILATION.md
|
||||
* **Souldbminer** – hoc-clk and loader development
|
||||
* **Lightos** – loader patches development
|
||||
* **SciresM** - Atmosphere CFW
|
||||
* **CTCaer** - L4T, Hekate, perfect ram timings
|
||||
* **KazushiMe** – Switch OC Suite
|
||||
* **hanai3bi (meha)** – Switch OC Suite, EOS, sys-clk-eos
|
||||
* **NaGaa95** – L4T-OC-kernel
|
||||
* **B3711 (halop)** – EOS
|
||||
* **sys-clk team (m4xw, p-sam, nautalis)** – sys-clk
|
||||
* **sys-clk team (m4xw, p-sam, natinusala)** – sys-clk
|
||||
* **b0rd2death** – Ultrahand sys-clk & Status Monitor fork
|
||||
* **MasaGratoR and ZachyCatGames** - General help
|
||||
* **MasaGratoR** - Status Monitor & Display Refresh Rate Driver
|
||||
* **Dom, Samybigio, Arcdelta, Miki, Happy, Flopsider, Winnerboi77, Blaise, Alvise, TDRR, agjeococh and Xenshen** - Testing
|
||||
* **Samybigio2011** - Italian translations
|
||||
* **Samybigio2011** - Italian translations
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
@@ -692,11 +694,11 @@ namespace ams::ldr {
|
||||
|
||||
/* Apply PCV and PTM patches */
|
||||
if (g_is_pcv) {
|
||||
oc::pcv::Patch(map_address, nso_size);
|
||||
hoc::pcv::Patch(map_address, nso_size);
|
||||
}
|
||||
|
||||
if (g_is_ptm) {
|
||||
oc::ptm::Patch(map_address, nso_size);
|
||||
hoc::ptm::Patch(map_address, nso_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2023 hanai3Bi
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -28,17 +28,17 @@
|
||||
#define GPU_MIN_MIN_VOLT 480000
|
||||
#define CPU_MAX_MAX_VOLT 1235000
|
||||
|
||||
namespace ams::ldr::oc {
|
||||
namespace ams::ldr::hoc {
|
||||
|
||||
volatile CustomizeTable C = {
|
||||
|
||||
/* Disables RAM powerdown */
|
||||
.hpMode = DISABLED,
|
||||
|
||||
.commonEmcMemVolt = 1175000, // LPDDR4X JEDEC Specification
|
||||
.eristaEmcMaxClock = 1600000, // Maximum HB-MGCH ram rating
|
||||
.commonEmcMemVolt = 1175000, /* LPDDR4X JEDEC Specification */
|
||||
.eristaEmcMaxClock = 1600000, /* Maximum HB-MGCH ram rating */
|
||||
|
||||
.marikoEmcMaxClock = 2133000,
|
||||
.marikoEmcVddqVolt = 600000,
|
||||
.marikoEmcMaxClock = 1866000, /* 1866MHz @ 1866tWRL is guaranteed to work on all Mariko units */
|
||||
.marikoEmcVddqVolt = 600000, /* Micron: 600mV, other manafacturers: 640mV */
|
||||
.emcDvbShift = 0,
|
||||
|
||||
// Primary
|
||||
@@ -52,10 +52,22 @@ volatile CustomizeTable C = {
|
||||
.t7_tWTR = 0,
|
||||
.t8_tREFI = 0,
|
||||
|
||||
/* Set to 4 read and 2 write for 1866b tWRL. */
|
||||
/* For 2133 tWRL: 8 read and 4 write. */
|
||||
.mem_burst_read_latency = 8,
|
||||
.mem_burst_write_latency = 4,
|
||||
/* You can mix and match different latencies if needed */
|
||||
/*
|
||||
* Read:
|
||||
* 2133RL = 40
|
||||
* 1866RL = 36
|
||||
* 1600RL = 32
|
||||
* 1331RL = 28
|
||||
* Write:
|
||||
* 2133WL = 18
|
||||
* 1866WL = 16
|
||||
* 1600WL = 14
|
||||
* 1331WL = 12
|
||||
*/
|
||||
|
||||
.mem_burst_read_latency = RL_1866,
|
||||
.mem_burst_write_latency = WL_1866,
|
||||
|
||||
.eristaCpuUV = 0,
|
||||
.eristaCpuVmin = 800,
|
||||
@@ -65,38 +77,47 @@ volatile CustomizeTable C = {
|
||||
|
||||
.marikoCpuUVLow = 0, // No undervolt
|
||||
.marikoCpuUVHigh = 0, // No undervolt
|
||||
.tableConf = DEFAULT_TABLE, /* TODO: Add AUTO */
|
||||
|
||||
.tableConf = DEFAULT_TABLE,
|
||||
.marikoCpuLowVmin = 620,
|
||||
.marikoCpuHighVmin = 750,
|
||||
/* 1120mV is NVIDIA rating */
|
||||
.marikoCpuMaxVolt = 1120,
|
||||
|
||||
/* Supported values: 2397000, 2499000, 2601000, 2703000. */
|
||||
/* Supported values: 1963000, 2091000, 2193000, 2295000, 2397000, 2499000, 2601000, 2703000. */
|
||||
/* 1963000 is official rating of T214/Mariko, fully safe. */
|
||||
/* 2091000-2295000 is a slight OC which should work on all units, but no guarantees. */
|
||||
/* 2397000 is the max safe OC for most average units with tuned undervolt. */
|
||||
/* 2499000 should be used with caution. */
|
||||
/* 2601000 exceeds pmic limit on most consoles. */
|
||||
/* 2703000 is potentially dangerous and not advised. */
|
||||
.marikoCpuMaxClock = 2397000,
|
||||
.marikoCpuMaxClock = 1963000,
|
||||
|
||||
.eristaCpuBoostClock = 1785000, // Default boost clock
|
||||
.marikoCpuBoostClock = 1963000, // Default boost clock
|
||||
|
||||
.eristaGpuUV = 0,
|
||||
.eristaGpuVmin = 800,
|
||||
.eristaGpuVmin = 810,
|
||||
|
||||
.marikoGpuUV = 0,
|
||||
|
||||
/* For automatic vmin detection, set this to AUTO. */
|
||||
.marikoGpuVmin = 610,
|
||||
/* vmin past 795mV won't work due to HOS limitation */
|
||||
/* Vmin is automatically set to 800mV when SoC temperature is below 20C */
|
||||
.marikoGpuVmin = AUTO,
|
||||
|
||||
.marikoGpuVmax = 800,
|
||||
|
||||
.commonGpuVoltOffset = 0,
|
||||
|
||||
/* Speedo is automatically set by hoc-clk on first boot */
|
||||
.gpuSpeedo = 1450,
|
||||
|
||||
/* This table is used with a gpu uv mode of 2. */
|
||||
/* Setting DEACTIVATED_GPU_FREQ on any freq will disable it and all freqs greater than it. (the latter is a bug :/) */
|
||||
/* AUTO: Voltage is optimally chosen; with commonGpuVoltOffset applied. */
|
||||
/* AUTO only works up to 1305 GPU */
|
||||
/* AUTO only works up to 1305 GPU on Mariko and 998 GPU on Erista (it is reccomended to manually set your 998MHz voltage though) */
|
||||
/* You can overwrite auto with any voltage (in mv) of your choice - offset will not be applied. */
|
||||
|
||||
.eristaGpuVoltArray = {
|
||||
AUTO /* 76 */,
|
||||
AUTO /* 115 */,
|
||||
@@ -142,8 +163,8 @@ volatile CustomizeTable C = {
|
||||
AUTO /* 921 */,
|
||||
AUTO /* 998 */,
|
||||
AUTO /* 1075 */,
|
||||
DEACTIVATED_GPU_FREQ /* 1152 */,
|
||||
DEACTIVATED_GPU_FREQ /* 1228 */,
|
||||
AUTO /* 1152 (SLT / HiOPT Only!) */,
|
||||
AUTO /* 1228 (HiOPT Only!) */,
|
||||
DEACTIVATED_GPU_FREQ /* 1267 (Disabled by default) */,
|
||||
DEACTIVATED_GPU_FREQ /* 1305 (Disabled by default) */,
|
||||
DEACTIVATED_GPU_FREQ /* 1344 (Disabled by default) */,
|
||||
@@ -154,6 +175,10 @@ volatile CustomizeTable C = {
|
||||
DEACTIVATED_GPU_FREQ /* 1536 (Disabled by default) */,
|
||||
},
|
||||
|
||||
/* Advanced. */
|
||||
.fineTune_t6_tRTW = 0,
|
||||
.fineTune_t7_tWTR = 0,
|
||||
|
||||
/* You shouldn't have to anything past here. */
|
||||
.eristaCpuDvfsTable = {
|
||||
{ 204000, { 721094, }, { } },
|
||||
@@ -310,7 +335,7 @@ volatile CustomizeTable C = {
|
||||
{ 2703000, { 1838820, -36648, 113, }, { CPU_MAX_MAX_VOLT, } },
|
||||
},
|
||||
|
||||
.marikoCpuDvfsTableHelios {
|
||||
.marikoCpuDvfsTableExtreme {
|
||||
{ 204000, { 732856, -17335, 113, }, { } },
|
||||
{ 306000, { 760024, -18195, 113, }, { } },
|
||||
{ 408000, { 789258, -19055, 113, }, { } },
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2023 hanai3Bi
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -20,25 +20,47 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CUST_REV 11
|
||||
#define CUST_REV 1
|
||||
|
||||
#include "oc_common.hpp"
|
||||
#include "pcv/pcv_common.hpp"
|
||||
|
||||
namespace ams::ldr::oc {
|
||||
namespace ams::ldr::hoc {
|
||||
|
||||
#include "mtc_timing_table.hpp"
|
||||
|
||||
enum MtcConfig: u32 {
|
||||
AUTO_ADJ = 0,
|
||||
AUTO_ADJ_BL = 1,
|
||||
};
|
||||
|
||||
enum TableConfig: u32 {
|
||||
DEFAULT_TABLE = 1,
|
||||
TBREAK_1581 = 2,
|
||||
TBREAK_1683 = 3,
|
||||
HELIOS_TABLE = 4,
|
||||
EXTREME_TABLE = 4,
|
||||
};
|
||||
|
||||
/*
|
||||
* Read:
|
||||
* 2133RL = 40
|
||||
* 1866RL = 36
|
||||
* 1600RL = 32
|
||||
* 1331RL = 28
|
||||
* Write:
|
||||
* 2133WL = 18
|
||||
* 1866WL = 16
|
||||
* 1600WL = 14
|
||||
* 1331WL = 12
|
||||
*/
|
||||
|
||||
enum ReadLatency: u32 {
|
||||
RL_2133 = 40,
|
||||
RL_1866 = 36,
|
||||
RL_1600 = 32,
|
||||
RL_1331 = 28,
|
||||
};
|
||||
|
||||
enum WriteLatency: u32 {
|
||||
WL_2133 = 18,
|
||||
WL_1866 = 16,
|
||||
WL_1600 = 14,
|
||||
WL_1331 = 12,
|
||||
};
|
||||
|
||||
using CustomizeCpuDvfsTable = pcv::cvb_entry_t[pcv::DvfsTableEntryLimit];
|
||||
@@ -53,16 +75,14 @@ typedef struct CustomizeTable {
|
||||
u8 cust[4] = {'C', 'U', 'S', 'T'};
|
||||
u32 custRev = CUST_REV;
|
||||
|
||||
u32 mtcConf;
|
||||
u32 placeholder;
|
||||
u32 hpMode;
|
||||
|
||||
u32 commonEmcMemVolt;
|
||||
u32 eristaEmcMaxClock;
|
||||
|
||||
u32 marikoEmcMaxClock;
|
||||
u32 marikoEmcVddqVolt;
|
||||
u32 emcDvbShift;
|
||||
|
||||
// advanced config
|
||||
u32 t1_tRCD;
|
||||
u32 t2_tRP;
|
||||
@@ -101,12 +121,16 @@ typedef struct CustomizeTable {
|
||||
|
||||
u32 commonGpuVoltOffset;
|
||||
|
||||
/* TODO: Automatically detect speedo. */
|
||||
u32 gpuSpeedo;
|
||||
|
||||
u32 eristaGpuVoltArray[27];
|
||||
u32 marikoGpuVoltArray[24];
|
||||
|
||||
u32 fineTune_t6_tRTW;
|
||||
u32 fineTune_t7_tWTR;
|
||||
|
||||
u32 reserved[60];
|
||||
|
||||
CustomizeCpuDvfsTable eristaCpuDvfsTable;
|
||||
CustomizeCpuDvfsTable eristaCpuDvfsTableSLT;
|
||||
|
||||
@@ -114,7 +138,7 @@ typedef struct CustomizeTable {
|
||||
CustomizeCpuDvfsTable marikoCpuDvfsTableSLT;
|
||||
CustomizeCpuDvfsTable marikoCpuDvfsTable1581Tbreak;
|
||||
CustomizeCpuDvfsTable marikoCpuDvfsTable1683Tbreak;
|
||||
CustomizeCpuDvfsTable marikoCpuDvfsTableHelios;
|
||||
CustomizeCpuDvfsTable marikoCpuDvfsTableExtreme;
|
||||
|
||||
CustomizeGpuDvfsTable eristaGpuDvfsTable;
|
||||
CustomizeGpuDvfsTable eristaGpuDvfsTableSLT;
|
||||
|
||||
@@ -18,96 +18,50 @@
|
||||
#include "../mtc_timing_value.hpp"
|
||||
#include "timing_tables.hpp"
|
||||
|
||||
namespace ams::ldr::oc::pcv::mariko {
|
||||
namespace ams::ldr::hoc::pcv::mariko {
|
||||
|
||||
u32 GetRext() {
|
||||
void GetRext() {
|
||||
if (auto r = FindRext()) {
|
||||
return r->correct;
|
||||
rext = r->rext;
|
||||
return;
|
||||
}
|
||||
return 0x1A;
|
||||
|
||||
/* Fallback. */
|
||||
rext = 0x1A;
|
||||
}
|
||||
|
||||
/* TODO: This function is quite uggly, refactor! */
|
||||
void CalculateMiscTimings() {
|
||||
einput_duration = 0x1C;
|
||||
void CalculateMrw2() {
|
||||
static const u8 rlMapDBI[8] = {
|
||||
6, 12, 16, 22, 28, 32, 36, 40
|
||||
};
|
||||
|
||||
for (u32 i = 0; i < g_misc_table_size; i++) {
|
||||
const auto& e = g_misc_table[i];
|
||||
if (C.marikoEmcMaxClock >= e.min_freq) {
|
||||
if (e.einput) einput_duration = e.einput;
|
||||
static const u8 wlMapSetA[8] = {
|
||||
4, 6, 8, 10, 12, 14, 16, 18
|
||||
};
|
||||
|
||||
u32 rlIndex = 0;
|
||||
u32 wlIndex = 0;
|
||||
|
||||
for (u32 i = 0; i < std::size(rlMapDBI); ++i) {
|
||||
if (rlMapDBI[i] == RL_DBI) {
|
||||
rlIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rext = GetRext();
|
||||
}
|
||||
|
||||
void CalculateIbdly() {
|
||||
/* Ibdly is so inconsistent, I am using the most common value and then checking with a lookup table. */
|
||||
ibdly = 0x1000001D + C.mem_burst_read_latency;
|
||||
|
||||
if (auto patch = FindIbdlyPatch()) {
|
||||
ibdly += patch->adjust;
|
||||
for (u32 i = 0; i < std::size(wlMapSetA); ++i) {
|
||||
if (wlMapSetA[i] == WL) {
|
||||
wlIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateTWTPDEN() {
|
||||
tWTPDEN = tW2P + 1 + CEIL(tDQSS_max / tCK_avg) + CEIL(tDQS2DQ_max / tCK_avg) + 6;
|
||||
if (C.marikoEmcMaxClock >= 2'233'000 && C.marikoEmcMaxClock < 2'533'000) tWTPDEN++;
|
||||
if (C.marikoEmcMaxClock >= 2'433'000 && C.marikoEmcMaxClock < 2'800'000) tWTPDEN--;
|
||||
}
|
||||
|
||||
void CalculateTR2W() {
|
||||
tR2W = CEIL(RL_DBI + (tDQSCK_max / tCK_avg) + (BL / 2) - WL + tWPRE + FLOOR(tRPST) + 9.0) - (C.t6_tRTW * 3);
|
||||
|
||||
if (auto patch = FindTR2WPatch()) {
|
||||
tR2W += patch->adjust;
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateQsafe() {
|
||||
qsafe = ROUND((C.marikoEmcMaxClock / 1000.0) / 138.0 + 37.4) + C.mem_burst_read_latency;
|
||||
if (auto patch = FindQsafePatch()) {
|
||||
qsafe += patch->adjust;
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateQpop() {
|
||||
qpop = FLOOR(((C.marikoEmcMaxClock / 1000.0) - 2133 + 167) / 200.0) + 0x2D + C.mem_burst_read_latency;
|
||||
|
||||
if (C.marikoEmcMaxClock >= 3'133'000) qpop++;
|
||||
}
|
||||
|
||||
void CalculatePdex2rw() {
|
||||
double freq_mhz = C.marikoEmcMaxClock / 1000.0;
|
||||
|
||||
double pdex_local = (0.011 * freq_mhz) - 1.443;
|
||||
pdex2rw = static_cast<u32>(ROUND(pdex_local));
|
||||
|
||||
if (pdex2rw < 22) pdex2rw = 22;
|
||||
if (pdex2rw > 33) pdex2rw = 33;
|
||||
|
||||
if (auto patch = FindPdex2rwPatch()) {
|
||||
pdex2rw += patch->adjust;
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateCke2pden() {
|
||||
cke2pden = (static_cast<double>((C.marikoEmcMaxClock / 1000.0) * 0.00875) - 0.65);
|
||||
|
||||
if (auto patch = FindCke2pdenPatch()) {
|
||||
cke2pden += patch->adjust;
|
||||
}
|
||||
mrw2 = static_cast<u8>(((rlIndex & 0x7) | ((wlIndex & 0x7) << 3) | ((0 & 0x1) << 6)));
|
||||
}
|
||||
|
||||
void CalculateTimings() {
|
||||
CalculateMiscTimings();
|
||||
CalculateIbdly();
|
||||
CalculateTWTPDEN();
|
||||
CalculateTR2W();
|
||||
CalculateQsafe();
|
||||
CalculateQpop();
|
||||
CalculatePdex2rw();
|
||||
CalculateCke2pden();
|
||||
GetRext();
|
||||
CalculateMrw2();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ams::ldr::oc::pcv::mariko {
|
||||
namespace ams::ldr::hoc::pcv::mariko {
|
||||
|
||||
void CalculateTimings();
|
||||
|
||||
|
||||
@@ -17,35 +17,7 @@
|
||||
#include "../mtc_timing_value.hpp"
|
||||
#include "timing_tables.hpp"
|
||||
|
||||
namespace ams::ldr::oc::pcv::mariko {
|
||||
|
||||
const MiscTimings g_misc_table[] = {
|
||||
{1'866'000, 0x20, },
|
||||
{2'133'000, 0x24, },
|
||||
{2'166'000, 0, },
|
||||
{2'233'000, 0x25, },
|
||||
{2'300'000, 0x26, },
|
||||
{2'333'000, 0x27, },
|
||||
{2'366'000, 0x26, },
|
||||
{2'433'000, 0x27, },
|
||||
{2'466'000, 0x2A, },
|
||||
{2'500'000, 0x28, },
|
||||
{2'533'000, 0x29, },
|
||||
{2'566'000, 0, },
|
||||
{2'633'000, 0x2A, },
|
||||
{2'700'000, 0x2B, },
|
||||
{2'733'000, 0x2C, },
|
||||
{2'766'000, 0x2B, },
|
||||
{2'833'000, 0x2C, },
|
||||
{2'866'000, 0, },
|
||||
{2'900'000, 0, },
|
||||
{2'933'000, 0x2E, },
|
||||
{2'966'000, 0, },
|
||||
{3'033'000, 0x2F, },
|
||||
{3'133'000, 0x31, },
|
||||
};
|
||||
|
||||
const u32 g_misc_table_size = sizeof(g_misc_table) / sizeof(g_misc_table[0]);
|
||||
namespace ams::ldr::hoc::pcv::mariko {
|
||||
|
||||
const ReplacePatch g_rext_table[] = {
|
||||
{2'133'000, 0x1A}, {2'166'000, 0x19}, {2'200'000, 0x19},
|
||||
@@ -64,137 +36,11 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
const u32 g_rext_table_size = sizeof(g_rext_table) / sizeof(g_rext_table[0]);
|
||||
|
||||
const ReplacePatch *FindRext() {
|
||||
for (u32 i = 0; i < g_rext_table_size; i++)
|
||||
if (g_rext_table[i].freq == C.marikoEmcMaxClock)
|
||||
for (u32 i = 0; i < g_rext_table_size; i++) {
|
||||
if (g_rext_table[i].freq >= C.marikoEmcMaxClock) {
|
||||
return &g_rext_table[i];
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const AdjustPatch g_ibdly_patches[] = {
|
||||
{2'133'000, -2},
|
||||
{2'166'000, -1},
|
||||
{2'200'000, -1},
|
||||
{2'233'000, -1},
|
||||
{2'266'000, -1},
|
||||
{2'300'000, -2},
|
||||
{2'333'000, -2},
|
||||
{2'500'000, -1},
|
||||
{2'533'000, -2},
|
||||
{2'566'000, -1},
|
||||
{2'600'000, -1},
|
||||
{2'633'000, -1},
|
||||
{2'666'000, -1},
|
||||
{2'700'000, -2},
|
||||
{2'733'000, -2},
|
||||
{2'933'000, -1},
|
||||
};
|
||||
|
||||
const u32 g_ibdly_table_size = sizeof(g_ibdly_patches) / sizeof(g_ibdly_patches[0]);
|
||||
|
||||
const AdjustPatch *FindIbdlyPatch() {
|
||||
for (u32 i = 0; i < g_ibdly_table_size; i++)
|
||||
if (g_ibdly_patches[i].freq == C.marikoEmcMaxClock)
|
||||
return &g_ibdly_patches[i];
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const AdjustPatch g_tr2w_patches[] = {
|
||||
{2'500'000, 1},
|
||||
{2'533'000, 1},
|
||||
{2'566'000, 1},
|
||||
{2'866'000, -1},
|
||||
{3'100'000, 1},
|
||||
{3'133'000, 1},
|
||||
};
|
||||
|
||||
const u32 g_tr2w_table_size = sizeof(g_tr2w_patches) / sizeof(g_tr2w_patches[0]);
|
||||
|
||||
const AdjustPatch *FindTR2WPatch() {
|
||||
for (u32 i = 0; i < g_tr2w_table_size; i++)
|
||||
if (g_tr2w_patches[i].freq == C.marikoEmcMaxClock)
|
||||
return &g_tr2w_patches[i];
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const AdjustPatch g_qsafe_patches[] = {
|
||||
{2'166'000, 1},
|
||||
{2'200'000, 1},
|
||||
{2'500'000, -1},
|
||||
{2'533'000, -1},
|
||||
{2'666'000, -1},
|
||||
{2'700'000, -1},
|
||||
{2'733'000, -1},
|
||||
{2'800'000, -1},
|
||||
{2'833'000, -1},
|
||||
{2'866'000, -1},
|
||||
{2'900'000, -1},
|
||||
{2'933'000, -2},
|
||||
{2'966'000, -1},
|
||||
{3'000'000, -1},
|
||||
{3'033'000, -1},
|
||||
{3'066'000, -2},
|
||||
{3'100'000, -2},
|
||||
{3'166'000, -1},
|
||||
{3'200'000, -1},
|
||||
};
|
||||
|
||||
const u32 g_qsafe_table_size = sizeof(g_qsafe_patches) / sizeof(g_qsafe_patches[0]);
|
||||
|
||||
const AdjustPatch *FindQsafePatch() {
|
||||
for (u32 i = 0; i < g_qsafe_table_size; i++)
|
||||
if (g_qsafe_patches[i].freq == C.marikoEmcMaxClock)
|
||||
return &g_qsafe_patches[i];
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const AdjustPatch g_pdex2rw_patches[] = {
|
||||
{2'166'000, 1},
|
||||
{2'300'000, 1},
|
||||
{2'333'000, 1},
|
||||
{2'433'000, 1},
|
||||
{2'533'000, 0},
|
||||
{2'633'000, -1},
|
||||
{2'666'000, -1},
|
||||
{2'733'000, -1},
|
||||
{2'766'000, -1},
|
||||
{2'800'000, -1},
|
||||
{2'833'000, -1},
|
||||
{2'933'000, -1},
|
||||
{3'066'000, 1},
|
||||
};
|
||||
|
||||
const u32 g_pdex2rw_table_size = sizeof(g_pdex2rw_patches) / sizeof(g_pdex2rw_patches[0]);
|
||||
|
||||
const AdjustPatch *FindPdex2rwPatch() {
|
||||
for (u32 i = 0; i < g_pdex2rw_table_size; i++)
|
||||
if (g_pdex2rw_patches[i].freq == C.marikoEmcMaxClock)
|
||||
return &g_pdex2rw_patches[i];
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const AdjustPatch g_cke2pden_patches[] = {
|
||||
{2'133'000, 1},
|
||||
{2'166'000, 1},
|
||||
{2'266'000, 1},
|
||||
{2'300'000, 1},
|
||||
{2'366'000, 1},
|
||||
{2'400'000, 1},
|
||||
{2'500'000, 1},
|
||||
{2'633'000, 1},
|
||||
{2'733'000, 1},
|
||||
{2'833'000, 1},
|
||||
{2'866'000, 1},
|
||||
{2'966'000, 1},
|
||||
{3'066'000, 1},
|
||||
{3'100'000, 1},
|
||||
};
|
||||
|
||||
const u32 g_cke2pden_table_size = sizeof(g_cke2pden_patches) / sizeof(g_cke2pden_patches[0]);
|
||||
|
||||
const AdjustPatch *FindCke2pdenPatch() {
|
||||
for (u32 i = 0; i < g_cke2pden_table_size; i++)
|
||||
if (g_cke2pden_patches[i].freq == C.marikoEmcMaxClock)
|
||||
return &g_cke2pden_patches[i];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,48 +17,15 @@
|
||||
#pragma once
|
||||
#include "../mtc_timing_value.hpp"
|
||||
|
||||
namespace ams::ldr::oc::pcv::mariko {
|
||||
namespace ams::ldr::hoc::pcv::mariko {
|
||||
|
||||
struct ReplacePatch {
|
||||
u32 freq;
|
||||
u32 correct;
|
||||
u32 rext;
|
||||
};
|
||||
|
||||
extern const ReplacePatch g_rext_table[];
|
||||
extern const u32 g_rext_table_size;
|
||||
const ReplacePatch *FindRext();
|
||||
|
||||
struct AdjustPatch {
|
||||
u32 freq;
|
||||
s32 adjust;
|
||||
};
|
||||
|
||||
extern const AdjustPatch g_ibdly_patches[];
|
||||
extern const u32 g_ibdly_table_size;
|
||||
const AdjustPatch *FindIbdlyPatch();
|
||||
|
||||
extern const AdjustPatch g_tr2w_patches[];
|
||||
extern const u32 g_tr2w_table_size;
|
||||
const AdjustPatch *FindTR2WPatch();
|
||||
|
||||
extern const AdjustPatch g_qsafe_patches[];
|
||||
extern const u32 g_qsafe_table_size;
|
||||
const AdjustPatch *FindQsafePatch();
|
||||
|
||||
extern const AdjustPatch g_pdex2rw_patches[];
|
||||
extern const u32 g_pdex2rw_table_size;
|
||||
const AdjustPatch *FindPdex2rwPatch();
|
||||
|
||||
extern const AdjustPatch g_cke2pden_patches[];
|
||||
extern const u32 g_cke2pden_table_size;
|
||||
const AdjustPatch *FindCke2pdenPatch();
|
||||
|
||||
struct MiscTimings {
|
||||
u32 min_freq;
|
||||
u32 einput;
|
||||
};
|
||||
|
||||
extern const MiscTimings g_misc_table[];
|
||||
extern const u32 g_misc_table_size;
|
||||
|
||||
}
|
||||
|
||||
@@ -20,19 +20,20 @@
|
||||
|
||||
#include "oc_common.hpp"
|
||||
|
||||
namespace ams::ldr::oc {
|
||||
#define MAX(A, B) std::max(A, B)
|
||||
#define MIN(A, B) std::min(A, B)
|
||||
#define CEIL(A) std::ceil(A)
|
||||
#define FLOOR(A) std::floor(A)
|
||||
#define ROUND(A) std::lround(A)
|
||||
namespace ams::ldr::hoc {
|
||||
#define MAX(A, B) std::max(A, B)
|
||||
#define MIN(A, B) std::min(A, B)
|
||||
#define CEIL(A) std::ceil(A)
|
||||
#define FLOOR(A) std::floor(A)
|
||||
#define ROUND(A) std::lround(A)
|
||||
|
||||
#define PACK_U32(high, low) ((static_cast<uint32_t>(high) << 16) | (static_cast<uint32_t>(low) & 0xFFFF))
|
||||
#define PACK_U32(high, low) ((static_cast<u32>(high) << 16) | (static_cast<u32>(low) & 0xFFFF))
|
||||
#define PACK_U32_NIBBLE_HIGH_BYTE_LOW(high, low) ((static_cast<u32>(high & 0xF) << 28) | (static_cast<u32>(low) & 0xFF))
|
||||
|
||||
/* Primary timings. */
|
||||
const std::array<u32, 8> tRCD_values = { 18, 17, 16, 15, 14, 13, 12, 11 };
|
||||
const std::array<u32, 8> tRP_values = { 18, 17, 16, 15, 14, 13, 12, 11 };
|
||||
const std::array<u32, 10> tRAS_values = { 42, 36, 34, 32, 30, 28, 26, 24, 22, 20 };
|
||||
const std::array<u32, 8> tRCD_values = { 18, 17, 16, 15, 14, 13, 12, 11 };
|
||||
const std::array<u32, 8> tRP_values = { 18, 17, 16, 15, 14, 13, 12, 11 };
|
||||
const std::array<u32, 10> tRAS_values = { 42, 36, 34, 32, 30, 28, 26, 24, 22, 20 };
|
||||
const std::array<double, 7> tRRD_values = { /*10.0,*/ 7.5, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 }; /* 10.0 is used for <2133mhz; do we care? 8gb uses 7.5 tRRD on >=1331. */
|
||||
const std::array<u32, 11> tRFC_values = { 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40 };
|
||||
const std::array<u32, 10> tWTR_values = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
|
||||
@@ -42,8 +43,8 @@ namespace ams::ldr::oc {
|
||||
const u32 BL = 16;
|
||||
|
||||
/* Base latency for read and write (tWRL). */
|
||||
const u32 RL = 28 + C.mem_burst_read_latency;
|
||||
const u32 WL = 14 + C.mem_burst_write_latency;
|
||||
const u32 RL = C.mem_burst_read_latency - 4; /* (This is a lazy fix for now) */
|
||||
const u32 WL = C.mem_burst_write_latency;
|
||||
|
||||
/* Switch uses RL_DBI, todo: get rid of non DBI_RL. */
|
||||
const u32 RL_DBI = RL + 4;
|
||||
@@ -76,11 +77,54 @@ namespace ams::ldr::oc {
|
||||
|
||||
/* TOOD: Fix erista */
|
||||
namespace pcv::erista {
|
||||
const double tCK_avg = 1000'000.0 / C.eristaEmcMaxClock;
|
||||
|
||||
const u32 tRCD = tRCD_values[C.t1_tRCD];
|
||||
const u32 tRPpb = tRP_values[C.t2_tRP];
|
||||
const u32 tRAS = tRAS_values[C.t3_tRAS];
|
||||
const double tRRD = tRRD_values[C.t4_tRRD];
|
||||
const u32 tRFCpb = tRFC_values[C.t5_tRFC];
|
||||
const u32 tWTR = 10 - tWTR_values[C.t7_tWTR];
|
||||
|
||||
const u32 tRC = tRAS + tRPpb;
|
||||
const u32 tRFCab = tRFCpb * 2;
|
||||
const double tXSR = (double) (tRFCab + 7.5);
|
||||
const u32 tFAW = static_cast<u32>(tRRD * 4.0);
|
||||
const double tRPab = tRPpb + 3;
|
||||
|
||||
const u32 tR2P = 12;
|
||||
|
||||
const u32 tW2P = (CEIL(WL * 1.7303) * 2) - 5;
|
||||
const u32 tW2R = CEIL(MAX(WL + (0.010322547033278747 * (C.eristaEmcMaxClock / 1000.0)), (WL * -0.2067922202979121) + FLOOR(((RL_DBI * -0.1331159971685554) + WL) * 3.654131957826108)) - (tWTR / tCK_avg));
|
||||
|
||||
const u32 wdv = WL;
|
||||
const u32 wsv = WL - 2;
|
||||
const u32 wev = 0xA + (WL - 14);
|
||||
|
||||
const double freq_mhz = C.eristaEmcMaxClock / 1000.0;
|
||||
|
||||
const u32 quse_width = CEIL(((3.7165006256863955 - freq_mhz) + (-0.002446584377651142 * freq_mhz)) - FLOOR(freq_mhz / -0.9952024303111688));
|
||||
const u32 quse = CEIL(MIN(RL_DBI + (2.991255208275918 - (quse_width + (-0.00511180626826906 * freq_mhz))), freq_mhz * 0.021333773138874437));
|
||||
const u32 ibdly = 0x10000000 + FLOOR(MAX(RL_DBI - 1.9999956603408224, quse - 5.9999987787411175) + (-0.0011929079761504341 * freq_mhz));
|
||||
const u32 obdlyHigh = 3 / FLOOR(MIN(static_cast<double>(2), tCK_avg * (WL - 7)));
|
||||
const u32 obdlyLow = WL - MIN(static_cast<double>(WL), 12 - (CEIL(-0.0003991 * freq_mhz) * 2));
|
||||
const u32 obdly = PACK_U32_NIBBLE_HIGH_BYTE_LOW(obdlyHigh, obdlyLow);
|
||||
const u32 tCKE = CEIL(1.0795 * CEIL(0.0074472 * (C.eristaEmcMaxClock / 1000.0)));
|
||||
|
||||
const double tMMRI = tRCD + (tCK_avg * 3);
|
||||
const double pdex2mrr = tMMRI + 10;
|
||||
const u32 tWTPDEN = tW2P + 1 + CEIL(tDQSS_max / tCK_avg) + CEIL(tDQS2DQ_max / tCK_avg) + 6;
|
||||
const u32 tR2W = CEIL(RL_DBI + (tDQSCK_max / tCK_avg) + (BL / 2) - WL + tWPRE + FLOOR(tRPST) + 9.0) - (C.t6_tRTW * 3);
|
||||
|
||||
const double pdex_local = (0.011 * freq_mhz) - 1.443;
|
||||
const u32 pdex2rw = static_cast<u32>(ROUND(pdex_local)) < 22 ? 22 : (static_cast<u32>(ROUND(pdex_local)) > 33 ? 33 : static_cast<u32>(ROUND(pdex_local)));
|
||||
|
||||
const double cke2pden = (static_cast<double>((C.eristaEmcMaxClock / 1000.0) * 0.00875) - 0.65);
|
||||
}
|
||||
|
||||
namespace pcv::mariko {
|
||||
const double tCK_avg = 1000'000.0 / C.marikoEmcMaxClock;
|
||||
const double ramFreqMhz = C.marikoEmcMaxClock / 1000.0;
|
||||
|
||||
const u32 tRCD = tRCD_values[C.t1_tRCD];
|
||||
const u32 tRPpb = tRP_values[C.t2_tRP];
|
||||
@@ -88,6 +132,8 @@ namespace ams::ldr::oc {
|
||||
const double tRRD = tRRD_values[C.t4_tRRD];
|
||||
const u32 tRFCpb = tRFC_values[C.t5_tRFC];
|
||||
const u32 tWTR = 10 - tWTR_values[C.t7_tWTR];
|
||||
const s32 finetRTW = C.fineTune_t6_tRTW;
|
||||
const s32 finetWTR = C.fineTune_t7_tWTR;
|
||||
|
||||
const u32 tRC = tRAS + tRPpb;
|
||||
const u32 tRFCab = tRFCpb * 2;
|
||||
@@ -95,44 +141,47 @@ namespace ams::ldr::oc {
|
||||
const u32 tFAW = static_cast<u32>(tRRD * 4.0);
|
||||
const double tRPab = tRPpb + 3;
|
||||
|
||||
const u32 tR2P = 12 + (C.mem_burst_read_latency / 2);
|
||||
inline u32 tR2W;
|
||||
const u32 tRTM = RL + 9 + (tDQSCK_max / tCK_avg) + FLOOR(tRPST) + CEIL(10 / tCK_avg); // Fix?
|
||||
const u32 tRATM = tRTM + CEIL(10 / tCK_avg) - 12; // Fix?
|
||||
const u32 rdv = FLOOR(17.02046755653219 + (RL_DBI + ((C.marikoEmcMaxClock / 1000.0) * 0.00510056573299173)));
|
||||
const u32 quse = FLOOR((-0.0048159 * (C.marikoEmcMaxClock / 1000.0)) + RL_DBI) + (FLOOR((C.marikoEmcMaxClock / 1000.0) * 0.0050997) * 1.5134);
|
||||
const u32 einput = quse - ((C.marikoEmcMaxClock / 1000.0) * 0.01);
|
||||
|
||||
inline u32 einput_duration;
|
||||
inline u32 ibdly;
|
||||
|
||||
const u32 obdly = 0x10000000 + CEIL(MAX((WL + (2.072347067198409 * CEIL(((C.marikoEmcMaxClock / 1000.0) * -0.0008701518090699537) + 1.1926184709583145))) - 12.368815500608948, -1.8792921762826563e-9));
|
||||
const u32 quse_width = CEIL(((3.7165006256863955 - (C.marikoEmcMaxClock / 1000.0)) + (-0.002446584377651142 * (C.marikoEmcMaxClock / 1000.0))) - FLOOR((C.marikoEmcMaxClock / 1000.0) / -0.9952024303111688));
|
||||
const u32 tR2P = CEIL((RL_DBI * 0.426) - 2.0);
|
||||
const u32 tR2W = FLOOR(FLOOR((5.0 / tCK_avg) + ((FLOOR(48.0 / WL) - 0.478) * 3.0)) / 1.501) + RL_DBI - (C.t6_tRTW * 3) + finetRTW;
|
||||
const u32 tRTM = FLOOR((10.0 + RL_DBI) + (3.502 / tCK_avg)) + FLOOR(7.489 / tCK_avg);
|
||||
const u32 tRATM = CEIL((tRTM - 10.0) + (RL_DBI * 0.426));
|
||||
inline u32 rext;
|
||||
const u32 qrstHighDuration = FLOOR(((C.marikoEmcMaxClock / 1000.0) * 0.001477125119082522) + 4.272302254983803);
|
||||
const u32 qrstLow = CEIL(MAX(((C.marikoEmcMaxClock / 1000.0) * -0.010085158701622026) + ((rdv + (-15.612107759528982 - quse_width)) - qrstHighDuration), -0.0004475366008085334));
|
||||
const u32 qrst = PACK_U32(qrstHighDuration, qrstLow);
|
||||
|
||||
inline u32 qsafe;
|
||||
inline u32 qpop;
|
||||
|
||||
const u32 tW2P = (CEIL(WL * 1.7303) * 2) - 5;
|
||||
inline u32 tWTPDEN;
|
||||
const u32 tW2R = CEIL(MAX(WL + (0.010322547033278747 * (C.marikoEmcMaxClock / 1000.0)), (WL * -0.2067922202979121) + FLOOR(((RL_DBI * -0.1331159971685554) + WL) * 3.654131957826108)) - (tWTR / tCK_avg));
|
||||
const u32 tWTM = WL + (BL / 2) + 1 + CEIL(7.5 / tCK_avg);
|
||||
const u32 tWATM = tWTM + CEIL(tWR / tCK_avg);
|
||||
const u32 rdv = RL_DBI + FLOOR((5.105 / tCK_avg) + 17.017);
|
||||
const u32 qpop = rdv - 14;
|
||||
const u32 quse_width = CEIL(((4.897 / tCK_avg) - FLOOR(2.538 / tCK_avg)) + 3.782);
|
||||
const u32 quse = FLOOR(RL_DBI + ((5.082 / tCK_avg) + FLOOR(2.560 / tCK_avg))) - CEIL(4.820 / tCK_avg);
|
||||
const u32 einput_duration = FLOOR(9.936 / tCK_avg) + 5.0 + quse_width;
|
||||
const u32 einput = quse - CEIL(9.928 / tCK_avg);
|
||||
const u32 qrst_duration = FLOOR(8.399 - tCK_avg);
|
||||
const u32 qrstLow = MAX(static_cast<s32>(einput - qrst_duration - 2), static_cast<s32>(0));
|
||||
const u32 qrst = PACK_U32(qrst_duration, qrstLow);
|
||||
const u32 ibdly = PACK_U32_NIBBLE_HIGH_BYTE_LOW(1, quse - qrst_duration - 2.0);
|
||||
const u32 qsafe = (einput_duration + 3) + MAX(MIN(qrstLow * rdv, qrst_duration + qrst_duration), einput);
|
||||
const u32 tW2P = (CEIL(WL * 1.7303) * 2) - 5;
|
||||
const u32 tWTPDEN = CEIL(((1.803 / tCK_avg) + MAX(RL_DBI + (2.694 / tCK_avg), static_cast<double>(tW2P))) + (BL / 2));
|
||||
const u32 tW2R = FLOOR(MAX((5.020 / tCK_avg) + 1.130, WL - MAX(-CEIL(0.258 * (WL - RL_DBI)), 1.964)) * 1.964) + WL - CEIL(tWTR / tCK_avg) + finetWTR;
|
||||
const u32 tWTM = CEIL(WL + ((7.570 / tCK_avg) + 8.753));
|
||||
const u32 tWATM = (tWTM + (FLOOR(WL / 0.816) * 2.0)) - 4.0;
|
||||
|
||||
const u32 wdv = WL;
|
||||
const u32 wsv = WL - 2;
|
||||
const u32 wev = 0xA + C.mem_burst_write_latency;
|
||||
const u32 wev = 0xA + (WL - 14);
|
||||
|
||||
inline u32 pdex2rw;
|
||||
inline u32 cke2pden;
|
||||
const u32 obdlyHigh = 3 / FLOOR(MIN(static_cast<double>(2), tCK_avg * (WL - 7)));
|
||||
const u32 obdlyLow = MAX(WL - FLOOR((126.0 / CEIL(tCK_avg + 8.601))), 0.0);
|
||||
|
||||
const u32 tCKE = CEIL(1.0795 * CEIL(0.0074472 * (C.marikoEmcMaxClock / 1000.0)));
|
||||
const u32 obdly = PACK_U32_NIBBLE_HIGH_BYTE_LOW(obdlyHigh, obdlyLow);
|
||||
|
||||
const u32 pdex2rw = CEIL((CEIL(12.335 - tCK_avg) + (7.430 / tCK_avg) - CEIL(tCK_avg * 11.361)));
|
||||
|
||||
const u32 tCLKSTOP = FLOOR(MIN(8.488 / tCK_avg, 23.0)) + 8.0;
|
||||
|
||||
const double tMMRI = tRCD + (tCK_avg * 3);
|
||||
const double pdex2mrr = tMMRI + 10; /* Do this properly? */
|
||||
|
||||
inline u8 mrw2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) Switch-OC-Suite
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -52,7 +52,7 @@ namespace ams::ldr {
|
||||
R_DEFINE_ERROR_RESULT(SafetyCheckFailure, 1015);
|
||||
}
|
||||
|
||||
namespace ams::ldr::oc {
|
||||
namespace ams::ldr::hoc {
|
||||
template<typename Pointer>
|
||||
struct PatcherEntry {
|
||||
using patternFn = bool(*)(Pointer* ptr);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) Switch-OC-Suite
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) Switch-OC-Suite
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -65,7 +65,7 @@ void saveExec(const char* file_loc, const void* buf, size_t size) {
|
||||
}
|
||||
|
||||
Result Test_PcvDvfsTable() {
|
||||
using namespace ams::ldr::oc::pcv;
|
||||
using namespace ams::ldr::hoc::pcv;
|
||||
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&mariko::CpuCvbTableDefault)) == 18);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&erista::CpuCvbTableDefault)) == 16);
|
||||
@@ -76,19 +76,19 @@ Result Test_PcvDvfsTable() {
|
||||
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);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.marikoCpuDvfsTableSLT)) == 25);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::hoc::C.marikoCpuDvfsTableSLT)) == 25);
|
||||
|
||||
// Customized table default
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.eristaCpuDvfsTable)) == 19);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.marikoCpuDvfsTable)) == 21);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.marikoCpuDvfsTableSLT)) == 22);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::hoc::C.eristaCpuDvfsTable)) == 19);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::hoc::C.marikoCpuDvfsTable)) == 21);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::hoc::C.marikoCpuDvfsTableSLT)) == 22);
|
||||
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.eristaGpuDvfsTable)) == 12);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.marikoGpuDvfsTable)) == 17);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.marikoGpuDvfsTableSLT)) == 17);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::oc::C.marikoGpuDvfsTableHiOPT)) == 17);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::hoc::C.eristaGpuDvfsTable)) == 12);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::hoc::C.marikoGpuDvfsTable)) == 17);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::hoc::C.marikoGpuDvfsTableSLT)) == 17);
|
||||
assert(GetDvfsTableEntryCount((cvb_entry_t *)(&ams::ldr::hoc::C.marikoGpuDvfsTableHiOPT)) == 17);
|
||||
|
||||
constexpr size_t limit = ams::ldr::oc::pcv::DvfsTableEntryLimit;
|
||||
constexpr size_t limit = ams::ldr::hoc::pcv::DvfsTableEntryLimit;
|
||||
cvb_entry_t customized_table[limit] = {};
|
||||
for (size_t i = 0; i < limit; i++) {
|
||||
assert(GetDvfsTableEntryCount(customized_table) == i);
|
||||
@@ -156,14 +156,14 @@ int main(int argc, char** argv) {
|
||||
size_t exec_path_patched_len = exec_path_len + std::max(strlen(mariko_ext), strlen(erista_ext)) + 1;
|
||||
|
||||
if (exe_opt == EXE_PCV) {
|
||||
ams::ldr::oc::pcv::SafetyCheck();
|
||||
ams::ldr::hoc::pcv::SafetyCheck();
|
||||
|
||||
{
|
||||
void* erista_buf = malloc(file_size);
|
||||
std::memcpy(erista_buf, file_buffer, file_size);
|
||||
|
||||
printf("Patching %s for Erista...\n", pcv_opt);
|
||||
ams::ldr::oc::pcv::erista::Patch(reinterpret_cast<uintptr_t>(erista_buf), file_size);
|
||||
ams::ldr::hoc::pcv::erista::Patch(reinterpret_cast<uintptr_t>(erista_buf), file_size);
|
||||
if (save_patched) {
|
||||
char* exec_path_erista = reinterpret_cast<char *>(malloc(exec_path_patched_len));
|
||||
strncpy(exec_path_erista, exec_path, exec_path_patched_len);
|
||||
@@ -179,7 +179,7 @@ int main(int argc, char** argv) {
|
||||
std::memcpy(mariko_buf, file_buffer, file_size);
|
||||
|
||||
printf("Patching %s for Mariko...\n", pcv_opt);
|
||||
ams::ldr::oc::pcv::mariko::Patch(reinterpret_cast<uintptr_t>(mariko_buf), file_size);
|
||||
ams::ldr::hoc::pcv::mariko::Patch(reinterpret_cast<uintptr_t>(mariko_buf), file_size);
|
||||
if (save_patched) {
|
||||
char* exec_path_mariko = reinterpret_cast<char *>(malloc(exec_path_patched_len));
|
||||
strncpy(exec_path_mariko, exec_path, exec_path_patched_len);
|
||||
@@ -196,7 +196,7 @@ int main(int argc, char** argv) {
|
||||
std::memcpy(mariko_buf, file_buffer, file_size);
|
||||
|
||||
printf("Patching %s (Mariko Only)...\n", ptm_opt);
|
||||
ams::ldr::oc::ptm::Patch(reinterpret_cast<uintptr_t>(mariko_buf), file_size);
|
||||
ams::ldr::hoc::ptm::Patch(reinterpret_cast<uintptr_t>(mariko_buf), file_size);
|
||||
if (save_patched) {
|
||||
char* exec_path_mariko = reinterpret_cast<char *>(malloc(exec_path_patched_len));
|
||||
strncpy(exec_path_mariko, exec_path, exec_path_patched_len);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) Switch-OC-Suite
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2023 hanai3Bi
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "pcv.hpp"
|
||||
|
||||
namespace ams::ldr::oc::pcv {
|
||||
namespace ams::ldr::hoc::pcv {
|
||||
|
||||
Result MemFreqPllmLimit(u32* ptr) {
|
||||
clk_pll_param* entry = reinterpret_cast<clk_pll_param *>(ptr);
|
||||
@@ -115,7 +115,6 @@ void SafetyCheck() {
|
||||
eristaGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.eristaGpuDvfsTableSLT)->freq);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
eristaGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.eristaGpuDvfsTableHiOPT)->freq);
|
||||
break;
|
||||
default:
|
||||
@@ -132,7 +131,6 @@ void SafetyCheck() {
|
||||
marikoGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.marikoGpuDvfsTableSLT)->freq);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
marikoGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.marikoGpuDvfsTableHiOPT)->freq);
|
||||
break;
|
||||
default:
|
||||
@@ -143,12 +141,12 @@ void SafetyCheck() {
|
||||
sValidator validators[] = {
|
||||
{ C.eristaCpuBoostClock, 1020'000, 2295'000, true },
|
||||
{ C.marikoCpuBoostClock, 1020'000, 2703'000, true },
|
||||
{ C.commonEmcMemVolt, 1100'000, 1350'000 }, // Official burst vmax for the RAMs is 1500mV
|
||||
{ C.eristaCpuMaxVolt, 1100, 1257 },
|
||||
{ C.eristaEmcMaxClock, 1600'000, 2600'200 },
|
||||
{ C.marikoCpuMaxVolt, 1100, 1235 },
|
||||
{ C.commonEmcMemVolt, 912'500, 1350'000 }, // Official burst vmax for the RAMs is 1500mV
|
||||
{ C.eristaCpuMaxVolt, 1000, 1257 },
|
||||
{ C.eristaEmcMaxClock, 1600'000, 2600'000 },
|
||||
{ C.marikoCpuMaxVolt, 1000, 1235 },
|
||||
{ C.marikoEmcMaxClock, 1600'000, 3500'000 },
|
||||
{ C.marikoEmcVddqVolt, 550'000, 700'000 },
|
||||
{ C.marikoEmcVddqVolt, 250'000, 700'000 },
|
||||
{ eristaCpuDvfsMaxFreq, 1785'000, 2295'000 },
|
||||
{ marikoCpuDvfsMaxFreq, 1785'000, 2703'000 },
|
||||
{ eristaGpuDvfsMaxFreq, 768'000, 1152'000 },
|
||||
@@ -168,7 +166,7 @@ void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
||||
if (isMariko)
|
||||
mariko::Patch(mapped_nso, nso_size);
|
||||
else
|
||||
mariko::Patch(mapped_nso, nso_size);
|
||||
erista::Patch(mapped_nso, nso_size);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2023 hanai3Bi
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "../oc_common.hpp"
|
||||
#include "pcv_common.hpp"
|
||||
|
||||
namespace ams::ldr::oc::pcv {
|
||||
namespace ams::ldr::hoc::pcv {
|
||||
|
||||
namespace mariko {
|
||||
constexpr cvb_entry_t CpuCvbTableDefault[] = {
|
||||
@@ -58,7 +58,7 @@ namespace ams::ldr::oc::pcv {
|
||||
|
||||
static const u32 cpuVoltThermalData[] = { 620, 1120, 20000, 620, 1120, 70000, 950, 1132, 0, 950, 1227, 0 };
|
||||
|
||||
static const u32 allowedCpuMaxFrequencies[] = { 2'397'000, 2'499'000, 2'601'000, 2'703'000, };
|
||||
static const u32 allowedCpuMaxFrequencies[] = { 1'963'000, 2'091'000, 2'193'000, 2'295'000, 2'397'000, 2'499'000, 2'601'000, 2'703'000, };
|
||||
|
||||
constexpr cvb_entry_t GpuCvbTableDefault[] = {
|
||||
// GPUB01_NA_CVB_TABLE
|
||||
@@ -101,6 +101,7 @@ namespace ams::ldr::oc::pcv {
|
||||
};
|
||||
|
||||
static const SpeedoVminTable vminTable[] {
|
||||
{1400, 610}, // LOW SPEEDO -> use stock vmin
|
||||
{1560, 590},
|
||||
{1583, 570},
|
||||
{1620, 565},
|
||||
@@ -206,7 +207,7 @@ namespace ams::ldr::oc::pcv {
|
||||
constexpr u32 CpuVoltL4T = 1235'000;
|
||||
|
||||
static const u32 cpuVoltDvfsPattern[] = { 1227, 1000, 100, 1000, 0 };
|
||||
static const u32 cpuVoltDvfsOffsets[] = { 5, 6, 7, 9, 8 };
|
||||
static const u32 cpuVoltDvfsOffsets[] = { 5, 6, 7, 8, 9 };
|
||||
static_assert(sizeof(cpuVoltDvfsPattern) == sizeof(cpuVoltDvfsOffsets), "Invalid cpuVoltDvfsPattern");
|
||||
|
||||
static const u32 cpuVoltageThermalPattern[] = { 950, 1132, 0, 950, 1227, 0, 825, 1227, 15000, 825, 1170, 60000, 825, 1132, 80000 };
|
||||
@@ -215,9 +216,8 @@ namespace ams::ldr::oc::pcv {
|
||||
constexpr u32 GpuClkPllLimit = 921'600'000;
|
||||
constexpr u32 GpuVminOfficial = 810;
|
||||
|
||||
static const u32 gpuVoltDvfsPattern[] = { 1150, 1000, 100, 1000, 10, };
|
||||
static const u32 gpuVoltDvfsOffsets[] = { 1, 2, 3, 4, 5, };
|
||||
static_assert(sizeof(gpuVoltDvfsPattern) == sizeof(gpuVoltDvfsOffsets), "Invalid gpuVoltDvfsPattern");
|
||||
static const u32 gpuVoltDvfsPattern[] = { 810, 1150, 1000, 100, 1000, 10, };
|
||||
static_assert(sizeof(gpuVoltDvfsPattern) == (sizeof(u32) * 6), "Invalid gpuVoltDvfsPattern");
|
||||
|
||||
static const u32 gpuVoltThermalPattern[] = { 950, 1132, 0, 810, 1132, 15000, 810, 1132, 30000, 810, 1132, 50000, 810, 1132, 70000, 810, 1132, 105000 };
|
||||
static_assert(sizeof(gpuVoltThermalPattern) == 0x48, "invalid gpuVoltageThermalPattern size");
|
||||
@@ -308,8 +308,8 @@ namespace ams::ldr::oc::pcv {
|
||||
customize_table = const_cast<cvb_entry_t *>(C.marikoCpuDvfsTable1581Tbreak);
|
||||
break;
|
||||
}
|
||||
case HELIOS_TABLE: {
|
||||
customize_table = const_cast<cvb_entry_t *>(C.marikoCpuDvfsTableHelios);
|
||||
case EXTREME_TABLE: {
|
||||
customize_table = const_cast<cvb_entry_t *>(C.marikoCpuDvfsTableExtreme);
|
||||
break;
|
||||
}
|
||||
case DEFAULT_TABLE:
|
||||
@@ -419,27 +419,26 @@ namespace ams::ldr::oc::pcv {
|
||||
std::memcpy(gpu_cvb_table_head, (void *)customize_table, customize_table_size);
|
||||
|
||||
// Patch GPU volt
|
||||
if (C.marikoGpuUV == 2 || C.eristaGpuUV == 2) {
|
||||
cvb_entry_t *entry = static_cast<cvb_entry_t *>(gpu_cvb_table_head);
|
||||
for (size_t i = 0; i < customize_entry_count; ++i) {
|
||||
if (isMariko) {
|
||||
if (C.marikoGpuVoltArray[i] != 0) {
|
||||
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (C.marikoGpuVoltArray[i] * 1000));
|
||||
ClearCvbPllEntry(entry);
|
||||
} else {
|
||||
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (entry->cvb_pll_param.c0 - C.commonGpuVoltOffset * 1000));
|
||||
}
|
||||
cvb_entry_t *entry = static_cast<cvb_entry_t *>(gpu_cvb_table_head);
|
||||
for (size_t i = 0; i < customize_entry_count; ++i) {
|
||||
if (isMariko) {
|
||||
if (C.marikoGpuVoltArray[i] != 0) {
|
||||
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (C.marikoGpuVoltArray[i] * 1000));
|
||||
ClearCvbPllEntry(entry);
|
||||
} else {
|
||||
if (C.eristaGpuVoltArray[i] != 0) {
|
||||
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (C.eristaGpuVoltArray[i] * 1000));
|
||||
ClearCvbPllEntry(entry);
|
||||
} else {
|
||||
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (entry->cvb_pll_param.c0 - C.commonGpuVoltOffset * 1000));
|
||||
}
|
||||
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (entry->cvb_pll_param.c0 - C.commonGpuVoltOffset * 1000));
|
||||
}
|
||||
} else {
|
||||
if (C.eristaGpuVoltArray[i] != 0) {
|
||||
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (C.eristaGpuVoltArray[i] * 1000));
|
||||
ClearCvbPllEntry(entry);
|
||||
} else {
|
||||
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (entry->cvb_pll_param.c0 - C.commonGpuVoltOffset * 1000));
|
||||
}
|
||||
++entry;
|
||||
}
|
||||
} else if (C.commonGpuVoltOffset) {
|
||||
++entry;
|
||||
}
|
||||
if (C.commonGpuVoltOffset && !(isMariko ? C.marikoGpuUV : C.eristaGpuUV)) {
|
||||
cvb_entry_t *entry = static_cast<cvb_entry_t *>(gpu_cvb_table_head);
|
||||
for (size_t i = 0; i < customize_entry_count; ++i) {
|
||||
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (entry->cvb_pll_param.c0 - C.commonGpuVoltOffset * 1000));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) Switch-OC-Suite
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ams::ldr::oc::pcv {
|
||||
namespace ams::ldr::hoc::pcv {
|
||||
|
||||
typedef struct cvb_coefficients {
|
||||
s32 c0 = 0;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2023 hanai3Bi
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "pcv.hpp"
|
||||
#include "../mtc_timing_value.hpp"
|
||||
|
||||
namespace ams::ldr::oc::pcv::erista {
|
||||
namespace ams::ldr::hoc::pcv::erista {
|
||||
|
||||
Result CpuVoltDvfs(u32 *ptr) {
|
||||
if (MatchesPattern(ptr, cpuVoltDvfsPattern, cpuVoltDvfsOffsets)) {
|
||||
@@ -45,7 +45,6 @@ namespace ams::ldr::oc::pcv::erista {
|
||||
|
||||
Result CpuVoltThermals(u32 *ptr) {
|
||||
if (std::memcmp(ptr - 6, cpuVoltageThermalPattern, sizeof(cpuVoltageThermalPattern))) {
|
||||
// AMS_ABORT_UNLESS(0);
|
||||
R_THROW(ldr::ResultInvalidCpuMinVolt());
|
||||
}
|
||||
|
||||
@@ -67,11 +66,10 @@ namespace ams::ldr::oc::pcv::erista {
|
||||
|
||||
Result CpuVoltDfll(u32* ptr) {
|
||||
cvb_cpu_dfll_data *entry = reinterpret_cast<cvb_cpu_dfll_data *>(ptr);
|
||||
|
||||
R_UNLESS(entry->tune0_low == 0x0000FFCF, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
R_UNLESS(entry->tune0_high == 0x00000000, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
R_UNLESS(entry->tune1_low == 0x012207FF, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
R_UNLESS(entry->tune1_high == 0x03FFF7FF, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
R_UNLESS(entry->tune0_low == 0xFFEAD0FF, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
R_UNLESS(entry->tune0_high == 0x0, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
R_UNLESS(entry->tune1_low == 0x0, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
R_UNLESS(entry->tune1_high == 0x0, ldr::ResultInvalidCpuVoltDfllEntry());
|
||||
|
||||
if( !C.eristaCpuUV) {
|
||||
R_SKIP();
|
||||
@@ -105,14 +103,15 @@ namespace ams::ldr::oc::pcv::erista {
|
||||
}
|
||||
|
||||
Result GpuVoltDVFS(u32 *ptr) {
|
||||
if (MatchesPattern(ptr, gpuVoltDvfsPattern, gpuVoltDvfsOffsets)) {
|
||||
if (C.eristaGpuVmin) {
|
||||
PATCH_OFFSET(ptr, C.eristaGpuVmin);
|
||||
}
|
||||
R_SUCCEED();
|
||||
}
|
||||
u32 result = std::memcmp(ptr, gpuVoltDvfsPattern, sizeof(gpuVoltDvfsPattern));
|
||||
|
||||
R_THROW(ldr::ResultInvalidGpuDvfs());
|
||||
if (result)
|
||||
R_THROW(ldr::ResultInvalidGpuDvfs());
|
||||
|
||||
if (C.eristaGpuVmin)
|
||||
PATCH_OFFSET(ptr, C.eristaGpuVmin);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result GpuVoltThermals(u32 *ptr) {
|
||||
@@ -494,206 +493,154 @@ namespace ams::ldr::oc::pcv::erista {
|
||||
|
||||
/* These timings are slightly off from eos, I am not sure why but I am going to figure it out at some point. */
|
||||
void MemMtcTableAutoAdjust(EristaMtcTable *table) {
|
||||
(void) table;
|
||||
|
||||
// using namespace pcv::erista;
|
||||
//
|
||||
/* #define WRITE_PARAM_ALL_REG(TABLE, PARAM, VALUE) // note: add backslashes to make the macro definition work
|
||||
TABLE->burst_regs.PARAM = VALUE; \
|
||||
TABLE->shadow_regs_ca_train.PARAM = VALUE; \
|
||||
TABLE->shadow_regs_quse_train.PARAM = VALUE; \
|
||||
#define WRITE_PARAM_ALL_REG(TABLE, PARAM, VALUE) \
|
||||
TABLE->burst_regs.PARAM = VALUE; \
|
||||
TABLE->shadow_regs_ca_train.PARAM = VALUE; \
|
||||
TABLE->shadow_regs_rdwr_train.PARAM = VALUE;
|
||||
*/
|
||||
// #define GET_CYCLE(PARAM) ((u32)((double)(PARAM) / (1000000.0 / 1600000.0)))
|
||||
//
|
||||
// /* This condition is insane but it's done in eos. */
|
||||
// /* Need to clean up at some point. */
|
||||
// u32 rext;
|
||||
// u32 wext;
|
||||
// if (C.eristaEmcMaxClock < 3200001) {
|
||||
// if (C.eristaEmcMaxClock < 2133001) {
|
||||
// rext = 26;
|
||||
// wext = 22;
|
||||
// } else {
|
||||
// rext = 28;
|
||||
// wext = 22;
|
||||
//
|
||||
// if (2400000 < C.eristaEmcMaxClock) {
|
||||
// wext = 25;
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// rext = 30;
|
||||
// wext = 25;
|
||||
// }
|
||||
//
|
||||
// u32 refresh_raw = 0xFFFF;
|
||||
// u32 trefbw = 0;
|
||||
//
|
||||
// if (C.t8_tREFI != 6) {
|
||||
// refresh_raw = static_cast<u32>(std::floor(static_cast<double>(tREFpb_values[C.t8_tREFI]) / tCK_avg)) - 0x40;
|
||||
// refresh_raw = MIN(refresh_raw, static_cast<u32>(0xFFFF));
|
||||
// }
|
||||
//
|
||||
// trefbw = refresh_raw + 0x40;
|
||||
// trefbw = MIN(trefbw, static_cast<u32>(0x3FFF));
|
||||
//
|
||||
// /* Primary timings. */
|
||||
// WRITE_PARAM_ALL_REG(table, emc_rd_rcd, GET_CYCLE(tRCD));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_wr_rcd, GET_CYCLE(tRCD));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_ras, GET_CYCLE(tRAS));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_rp, GET_CYCLE(tRPpb));
|
||||
//
|
||||
// /* Secondary timings. */
|
||||
// WRITE_PARAM_ALL_REG(table, emc_rrd, GET_CYCLE(tRRD));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_rfc, GET_CYCLE(tRFCab));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_rfcpb, GET_CYCLE(tRFCpb));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_r2w, tR2W);
|
||||
// WRITE_PARAM_ALL_REG(table, emc_w2r, tW2R);
|
||||
// WRITE_PARAM_ALL_REG(table, emc_r2p, (u32) 0xC);
|
||||
// WRITE_PARAM_ALL_REG(table, emc_w2p, (u32) 0x2D);
|
||||
//
|
||||
// WRITE_PARAM_ALL_REG(table, emc_rext, rext);
|
||||
// WRITE_PARAM_ALL_REG(table, emc_wext, wext);
|
||||
//
|
||||
// WRITE_PARAM_ALL_REG(table, emc_trpab, GET_CYCLE(tRPab));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_tfaw, GET_CYCLE(tFAW));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_rc, GET_CYCLE(tRC));
|
||||
//
|
||||
// WRITE_PARAM_ALL_REG(table, emc_tckesr, GET_CYCLE(tSR));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_tcke, GET_CYCLE(tXP) + 1);
|
||||
// WRITE_PARAM_ALL_REG(table, emc_tpd, GET_CYCLE(tXP));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_tclkstop, GET_CYCLE(tXP) + 8);
|
||||
//
|
||||
// WRITE_PARAM_ALL_REG(table, emc_txsr, MIN(GET_CYCLE(tXSR), (u32) 1022));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_txsrdll, MIN(GET_CYCLE(tXSR), (u32) 1022));
|
||||
//
|
||||
// const u32 dyn_self_ref_control = (((u32)(7605.0 / tCK_avg)) + 260U) | (table->burst_regs.emc_dyn_self_ref_control & 0xffff0000U);
|
||||
// WRITE_PARAM_ALL_REG(table, emc_dyn_self_ref_control, dyn_self_ref_control);
|
||||
//
|
||||
// WRITE_PARAM_ALL_REG(table, emc_rw2pden, tRW2PDEN);
|
||||
// WRITE_PARAM_ALL_REG(table, emc_pdex2wr, GET_CYCLE(10.0));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_pdex2rd, GET_CYCLE(10.0));
|
||||
//
|
||||
// WRITE_PARAM_ALL_REG(table, emc_pchg2pden, GET_CYCLE(1.75));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_ar2pden, GET_CYCLE(1.75));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_pdex2cke, GET_CYCLE(1.75));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_act2pden, GET_CYCLE(14.0));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_cke2pden, GET_CYCLE(5.0));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_pdex2mrr, GET_CYCLE(pdex2mrr));
|
||||
//
|
||||
// WRITE_PARAM_ALL_REG(table, emc_refresh, refresh_raw);
|
||||
// WRITE_PARAM_ALL_REG(table, emc_pre_refresh_req_cnt, (u32) (refresh_raw / 4));
|
||||
// WRITE_PARAM_ALL_REG(table, emc_trefbw, trefbw);
|
||||
//
|
||||
// const u32 mc_tRCD = (int)((double)(GET_CYCLE(tRCD) >> 2) - 2.0);
|
||||
// const u32 mc_tRPpb = (int)(((double)(GET_CYCLE(tRPpb) >> 2) - 1.0) + 2.0);
|
||||
// const u32 mc_tRC = (uint)((double)(GET_CYCLE(tRC) >> 2) - 1.0);
|
||||
// const u32 mc_tR2W = (uint)(((double)((uint)tR2W >> 2) - 1.0) + 2.0);
|
||||
// const u32 mc_tW2R = (uint)(((double)(tW2R >> 2) - 1.0) + 2.0);
|
||||
// const u32 mc_tRAS = MIN(GET_CYCLE(tRAS), (u32) 0x7F);
|
||||
// const u32 mc_tRRD = MIN(GET_CYCLE(tRRD), (u32) 31);
|
||||
//
|
||||
// table->burst_mc_regs.mc_emem_arb_cfg = (int)(((double) C.eristaEmcMaxClock / 33300.0) * 0.25);
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_ras = (int) ((double) (mc_tRAS >> 2) - 2.0);
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_rcd = (int) ((double) (GET_CYCLE(tRCD) >> 2) - 2.0);
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_rp = (int) (((double) (GET_CYCLE(tRPpb) >> 2) - 1.0) + 2.0);
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_rc = (int) ((double) (GET_CYCLE(tRC) >> 2) - 1.0);
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_faw = (int) ((double)(GET_CYCLE(tFAW) >> 2) - 1.0);
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_rrd = (int)((double)(mc_tRRD >> 2) - 1.0);
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_rap2pre = 3;
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_wap2pre = 11;
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_r2w = (uint)(((double)((uint)tR2W >> 2) - 1.0) + 2.0);
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_w2r = (uint)(((double)(tW2R >> 2) - 1.0) + 2.0);
|
||||
//
|
||||
// u32 mc_r2r = table->burst_mc_regs.mc_emem_arb_timing_r2r;
|
||||
// if (mc_r2r > 1) {
|
||||
// mc_r2r = (uint)(((double)(long)((double)rext * 0.25) - 1.0) + 2.0);
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_r2r = mc_r2r;
|
||||
// }
|
||||
//
|
||||
// u32 mc_w2w = table->burst_mc_regs.mc_emem_arb_timing_w2w;
|
||||
// if (mc_w2w > 1) {
|
||||
// mc_w2w = (uint)(((double)(long)((double)wext / 4.0) - 1.0) + 2.0);
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_w2w = mc_w2w;
|
||||
// }
|
||||
//
|
||||
// table->burst_mc_regs.mc_emem_arb_da_turns = ((mc_tW2R >> 1) << 0x18) | ((mc_tR2W >> 1) << 0x10) | ((mc_r2r >> 1) << 8) | ((mc_w2w >> 1));
|
||||
// table->burst_mc_regs.mc_emem_arb_da_covers = (((uint)(mc_tRCD + 3 + mc_tRPpb) >> 1 & 0xff) << 8) | (((uint)(mc_tRCD + 11 + mc_tRPpb) >> 1 & 0xff) << 0x10) | ((mc_tRC >> 1) & 0xff);
|
||||
// table->burst_mc_regs.mc_emem_arb_misc0 = (table->burst_mc_regs.mc_emem_arb_misc0 & 0xffe08000U) | ((mc_tRC + 1) & 0xff);
|
||||
// table->la_scale_regs.mc_mll_mpcorer_ptsa_rate = MIN((u32)((C.eristaEmcMaxClock / 1600000) * 0xd0U), (u32)0x115);
|
||||
// table->la_scale_regs.mc_ftop_ptsa_rate = MIN((u32)((C.eristaEmcMaxClock / 1600000) * 0x18U), (u32)0x1f);
|
||||
// table->la_scale_regs.mc_ptsa_grant_decrement = MIN((u32)((C.eristaEmcMaxClock / 1600000) * 0x1203U), (u32)0x17ff);
|
||||
//
|
||||
// u32 mc_latency_allowance = 0;
|
||||
// if (C.eristaEmcMaxClock / 1000 != 0) {
|
||||
// mc_latency_allowance = 204800 / (C.eristaEmcMaxClock / 1000);
|
||||
// }
|
||||
//
|
||||
// const u32 mc_latency_allowance2 = mc_latency_allowance & 0xFF;
|
||||
// const u32 mc_latency_allowance3 = (mc_latency_allowance & 0xFF) << 0x10;
|
||||
// table->la_scale_regs.mc_latency_allowance_xusb_0 = (table->la_scale_regs.mc_latency_allowance_xusb_0 & 0xff00ffffU) | mc_latency_allowance3;
|
||||
// table->la_scale_regs.mc_latency_allowance_sdmmc_0 = (table->la_scale_regs.mc_latency_allowance_sdmmc_0 & 0xff00ffffU) | mc_latency_allowance3;
|
||||
// table->la_scale_regs.mc_latency_allowance_xusb_1 = (table->la_scale_regs.mc_latency_allowance_xusb_1 & 0xff00ffffU) | mc_latency_allowance3;
|
||||
// table->la_scale_regs.mc_latency_allowance_tsec_0 = (table->la_scale_regs.mc_latency_allowance_tsec_0 & 0xff00ffffU) | mc_latency_allowance3;
|
||||
// table->la_scale_regs.mc_latency_allowance_sdmmca_0 = (table->la_scale_regs.mc_latency_allowance_sdmmca_0 & 0xff00ffffU) | mc_latency_allowance3;
|
||||
// table->la_scale_regs.mc_latency_allowance_sdmmcaa_0 = (table->la_scale_regs.mc_latency_allowance_sdmmcaa_0 & 0xff00ffffU) | mc_latency_allowance3;
|
||||
// table->la_scale_regs.mc_latency_allowance_sdmmcab_0 = (table->la_scale_regs.mc_latency_allowance_sdmmcab_0 & 0xff00ffffU) | mc_latency_allowance3;
|
||||
// table->la_scale_regs.mc_latency_allowance_ppcs_1 = (table->la_scale_regs.mc_latency_allowance_ppcs_1 & 0xff00ffffU) | mc_latency_allowance3;
|
||||
// table->la_scale_regs.mc_latency_allowance_mpcore_0 = (table->la_scale_regs.mc_latency_allowance_mpcore_0 & 0xff00ffffU) | mc_latency_allowance3;
|
||||
// table->la_scale_regs.mc_latency_allowance_avpc_0 = (table->la_scale_regs.mc_latency_allowance_avpc_0 & 0xff00ffffU) | mc_latency_allowance3;
|
||||
//
|
||||
// u32 mc_latency_allowance_hc_0 = 0;
|
||||
// if (C.eristaEmcMaxClock / 1000 != 0) {
|
||||
// mc_latency_allowance_hc_0 = 35200 / (C.eristaEmcMaxClock / 1000);
|
||||
// }
|
||||
//
|
||||
// table->la_scale_regs.mc_latency_allowance_nvdec_0 = (table->la_scale_regs.mc_latency_allowance_nvdec_0 & 0xff00ffffU) | mc_latency_allowance3;
|
||||
// table->la_scale_regs.mc_latency_allowance_hc_0 = (table->la_scale_regs.mc_latency_allowance_hc_0 & 0xffffff00U) | mc_latency_allowance_hc_0;
|
||||
//
|
||||
// table->la_scale_regs.mc_latency_allowance_isp2_1 = (table->la_scale_regs.mc_latency_allowance_isp2_1 & 0xff00ff00U) | mc_latency_allowance3 | mc_latency_allowance2;
|
||||
// table->la_scale_regs.mc_latency_allowance_hc_1 = (table->la_scale_regs.mc_latency_allowance_hc_1 & 0xffffff00U) | mc_latency_allowance2;
|
||||
//
|
||||
// u32 mc_latency_allowance_gpu_0 = 0;
|
||||
// if (C.eristaEmcMaxClock / 1000 != 0) {
|
||||
// mc_latency_allowance_gpu_0 = 40000 / (C.eristaEmcMaxClock / 1000);
|
||||
// }
|
||||
//
|
||||
// table->la_scale_regs.mc_latency_allowance_gpu_0 = ((mc_latency_allowance_gpu_0 | table->la_scale_regs.mc_latency_allowance_gpu_0) & 0xff00ff00U) | mc_latency_allowance3;
|
||||
//
|
||||
// u32 mc_latency_allowance_gpu2_0 = 0;
|
||||
// if (C.eristaEmcMaxClock / 1000 != 0) {
|
||||
// mc_latency_allowance_gpu2_0 = 40000 / (C.eristaEmcMaxClock / 1000);
|
||||
// }
|
||||
//
|
||||
// table->la_scale_regs.mc_latency_allowance_gpu2_0 = ((mc_latency_allowance_gpu2_0 | table->la_scale_regs.mc_latency_allowance_gpu2_0) & 0xff00ff00U) | mc_latency_allowance3;
|
||||
//
|
||||
// u32 mc_latency_allowance_nvenc_0 = 0;
|
||||
// if (C.eristaEmcMaxClock / 1000 != 0) {
|
||||
// mc_latency_allowance_nvenc_0 = 38400 / (C.eristaEmcMaxClock / 1000);
|
||||
// }
|
||||
//
|
||||
// table->la_scale_regs.mc_latency_allowance_nvenc_0 = ((mc_latency_allowance_nvenc_0 | table->la_scale_regs.mc_latency_allowance_nvenc_0) & 0xff00ff00U) | mc_latency_allowance3;
|
||||
//
|
||||
// u32 mc_latency_allowance_vic_0 = 0;
|
||||
// if (C.eristaEmcMaxClock / 1000 != 0) {
|
||||
// mc_latency_allowance_vic_0 = 0xb540 / (C.eristaEmcMaxClock / 1000);
|
||||
// }
|
||||
//
|
||||
// table->la_scale_regs.mc_latency_allowance_vic_0 = ((mc_latency_allowance_vic_0 | table->la_scale_regs.mc_latency_allowance_vic_0) & 0xff00ff00U) | mc_latency_allowance3;
|
||||
// table->la_scale_regs.mc_latency_allowance_vi2_0 = (table->la_scale_regs.mc_latency_allowance_vi2_0 & 0xffffff00U) | mc_latency_allowance2;
|
||||
//
|
||||
// table->burst_mc_regs.mc_emem_arb_timing_rfcpb = GET_CYCLE(tRFCpb) >> 2;
|
||||
//
|
||||
// if (C.hpMode) {
|
||||
// WRITE_PARAM_ALL_REG(table, emc_cfg, 0x13200000);
|
||||
// }
|
||||
//
|
||||
// table->dram_timings.t_rp = tRFCpb;
|
||||
// table->dram_timings.t_rfc = tRFCab;
|
||||
// table->emc_cfg_2 = 0x11083d;
|
||||
// #undef GET_CYCLE
|
||||
}
|
||||
|
||||
#define GET_CYCLE_CEIL(PARAM) u32(CEIL(double(PARAM) / tCK_avg))
|
||||
/* Ram power down */
|
||||
/* B31: DRAM_CLKSTOP_PD */
|
||||
/* B30: DRAM_CLKSTOP_SR */
|
||||
/* B29: DRAM_ACPD */
|
||||
if (C.hpMode) {
|
||||
WRITE_PARAM_ALL_REG(table, emc_cfg, 0x13200000);
|
||||
} else {
|
||||
WRITE_PARAM_ALL_REG(table, emc_cfg, 0xF3200000);
|
||||
}
|
||||
|
||||
u32 refresh_raw = 0xFFFF;
|
||||
if (C.t8_tREFI != 6) {
|
||||
refresh_raw = CEIL(tREFpb_values[C.t8_tREFI] / tCK_avg) - 0x40;
|
||||
refresh_raw = MIN(refresh_raw, static_cast<u32>(0xFFFF));
|
||||
}
|
||||
|
||||
u32 trefbw = refresh_raw + 0x40;
|
||||
trefbw = MIN(trefbw, static_cast<u32>(0x3FFF));
|
||||
|
||||
WRITE_PARAM_ALL_REG(table, emc_rd_rcd, GET_CYCLE_CEIL(tRCD));
|
||||
WRITE_PARAM_ALL_REG(table, emc_wr_rcd, GET_CYCLE_CEIL(tRCD));
|
||||
WRITE_PARAM_ALL_REG(table, emc_rc, MIN(GET_CYCLE_CEIL(tRC), static_cast<u32>(0xB8)));
|
||||
WRITE_PARAM_ALL_REG(table, emc_ras, MIN(GET_CYCLE_CEIL(tRAS), static_cast<u32>(0x7F)));
|
||||
WRITE_PARAM_ALL_REG(table, emc_rrd, GET_CYCLE_CEIL(tRRD));
|
||||
WRITE_PARAM_ALL_REG(table, emc_rfcpb, GET_CYCLE_CEIL(tRFCpb));
|
||||
WRITE_PARAM_ALL_REG(table, emc_rfc, GET_CYCLE_CEIL(tRFCab));
|
||||
WRITE_PARAM_ALL_REG(table, emc_rp, GET_CYCLE_CEIL(tRPpb));
|
||||
WRITE_PARAM_ALL_REG(table, emc_txsr, MIN(GET_CYCLE_CEIL(tXSR), static_cast<u32>(0x3fe)));
|
||||
WRITE_PARAM_ALL_REG(table, emc_txsrdll, MIN(GET_CYCLE_CEIL(tXSR), static_cast<u32>(0x3fe)));
|
||||
WRITE_PARAM_ALL_REG(table, emc_tfaw, GET_CYCLE_CEIL(tFAW));
|
||||
WRITE_PARAM_ALL_REG(table, emc_trpab, MIN(GET_CYCLE_CEIL(tRPab), static_cast<u32>(0x3F)));
|
||||
WRITE_PARAM_ALL_REG(table, emc_tckesr, GET_CYCLE_CEIL(tSR));
|
||||
WRITE_PARAM_ALL_REG(table, emc_tcke, tCKE);
|
||||
WRITE_PARAM_ALL_REG(table, emc_tpd, GET_CYCLE_CEIL(tXP));
|
||||
WRITE_PARAM_ALL_REG(table, emc_tclkstop, GET_CYCLE_CEIL(tXP) + 8);
|
||||
WRITE_PARAM_ALL_REG(table, emc_r2p, tR2P);
|
||||
WRITE_PARAM_ALL_REG(table, emc_r2w, tR2W);
|
||||
WRITE_PARAM_ALL_REG(table, emc_w2p, tW2P);
|
||||
WRITE_PARAM_ALL_REG(table, emc_w2r, tW2R);
|
||||
WRITE_PARAM_ALL_REG(table, emc_rext, C.eristaEmcMaxClock < 2133001 ? 26 : 28); // rext shouldn't be causing issues?
|
||||
WRITE_PARAM_ALL_REG(table, emc_wext, (C.eristaEmcMaxClock >= 2533000) ? 0x19 : 0x16);
|
||||
WRITE_PARAM_ALL_REG(table, emc_refresh, refresh_raw);
|
||||
WRITE_PARAM_ALL_REG(table, emc_pre_refresh_req_cnt, refresh_raw / 4);
|
||||
WRITE_PARAM_ALL_REG(table, emc_trefbw, trefbw);
|
||||
const u32 dyn_self_ref_control = (static_cast<u32>(7605.0 / tCK_avg) + 260) | (table->burst_regs.emc_dyn_self_ref_control & 0xffff0000);
|
||||
WRITE_PARAM_ALL_REG(table, emc_dyn_self_ref_control, dyn_self_ref_control);
|
||||
WRITE_PARAM_ALL_REG(table, emc_pdex2wr, pdex2rw);
|
||||
WRITE_PARAM_ALL_REG(table, emc_pdex2rd, pdex2rw);
|
||||
WRITE_PARAM_ALL_REG(table, emc_pchg2pden, GET_CYCLE_CEIL(1.75));
|
||||
WRITE_PARAM_ALL_REG(table, emc_ar2pden, GET_CYCLE_CEIL(1.75));
|
||||
WRITE_PARAM_ALL_REG(table, emc_pdex2cke, GET_CYCLE_CEIL(1.05));
|
||||
WRITE_PARAM_ALL_REG(table, emc_act2pden, GET_CYCLE_CEIL(14.0));
|
||||
WRITE_PARAM_ALL_REG(table, emc_cke2pden, /* cke2pden */ GET_CYCLE_CEIL(8.5));
|
||||
(void) cke2pden;
|
||||
WRITE_PARAM_ALL_REG(table, emc_pdex2mrr, GET_CYCLE_CEIL(pdex2mrr));
|
||||
WRITE_PARAM_ALL_REG(table, emc_rw2pden, tWTPDEN);
|
||||
|
||||
/* This needs some clean up. */
|
||||
constexpr double MC_ARB_DIV = 4.0;
|
||||
constexpr u32 MC_ARB_SFA = 2;
|
||||
|
||||
table->burst_mc_regs.mc_emem_arb_cfg = C.eristaEmcMaxClock / (33.3 * 1000) / MC_ARB_DIV;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_rcd = CEIL(GET_CYCLE_CEIL(tRCD) / MC_ARB_DIV) - 2;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_rp = CEIL(GET_CYCLE_CEIL(tRPpb) / MC_ARB_DIV) - 1;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_rc = CEIL(GET_CYCLE_CEIL(tRC) / MC_ARB_DIV) - 1;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_ras = CEIL(GET_CYCLE_CEIL(tRAS) / MC_ARB_DIV) - 2;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_faw = CEIL(GET_CYCLE_CEIL(tFAW) / MC_ARB_DIV) - 1;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_rrd = CEIL(GET_CYCLE_CEIL(tRRD) / MC_ARB_DIV) - 1;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_rfcpb = CEIL(GET_CYCLE_CEIL(tRFCpb) / MC_ARB_DIV) - 1;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_rap2pre = CEIL(tR2P / MC_ARB_DIV);
|
||||
table->burst_mc_regs.mc_emem_arb_timing_wap2pre = CEIL(tW2P / MC_ARB_DIV) + MC_ARB_SFA;
|
||||
|
||||
if (table->burst_mc_regs.mc_emem_arb_timing_r2r > 1) {
|
||||
table->burst_mc_regs.mc_emem_arb_timing_r2r = CEIL(table->burst_regs.emc_rext / 4) - 1 + MC_ARB_SFA;
|
||||
}
|
||||
|
||||
table->burst_mc_regs.mc_emem_arb_timing_r2w = CEIL(tR2W / MC_ARB_DIV) - 1 + MC_ARB_SFA;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_w2r = CEIL(tW2R / MC_ARB_DIV) - 1 + MC_ARB_SFA;
|
||||
|
||||
u32 da_turns = 0;
|
||||
da_turns |= u8(table->burst_mc_regs.mc_emem_arb_timing_r2w / 2) << 16;
|
||||
da_turns |= u8(table->burst_mc_regs.mc_emem_arb_timing_w2r / 2) << 24;
|
||||
table->burst_mc_regs.mc_emem_arb_da_turns = da_turns;
|
||||
|
||||
u32 da_covers = 0;
|
||||
u8 r_cover = (table->burst_mc_regs.mc_emem_arb_timing_rap2pre + table->burst_mc_regs.mc_emem_arb_timing_rp + table->burst_mc_regs.mc_emem_arb_timing_rcd) / 2;
|
||||
u8 w_cover = (table->burst_mc_regs.mc_emem_arb_timing_wap2pre + table->burst_mc_regs.mc_emem_arb_timing_rp + table->burst_mc_regs.mc_emem_arb_timing_rcd) / 2;
|
||||
da_covers |= (table->burst_mc_regs.mc_emem_arb_timing_rc / 2);
|
||||
da_covers |= (r_cover << 8);
|
||||
da_covers |= (w_cover << 16);
|
||||
table->burst_mc_regs.mc_emem_arb_da_covers = da_covers;
|
||||
|
||||
table->burst_mc_regs.mc_emem_arb_misc0 = (table->burst_mc_regs.mc_emem_arb_misc0 & 0xFFE08000) | (table->burst_mc_regs.mc_emem_arb_timing_rc + 1);
|
||||
|
||||
table->la_scale_regs.mc_mll_mpcorer_ptsa_rate = 0x115;
|
||||
|
||||
if (C.eristaEmcMaxClock >= 2133000) {
|
||||
table->la_scale_regs.mc_ftop_ptsa_rate = 0x1F;
|
||||
} else {
|
||||
table->la_scale_regs.mc_ftop_ptsa_rate = 0x1B;
|
||||
}
|
||||
|
||||
table->la_scale_regs.mc_ptsa_grant_decrement = 0x17ff;
|
||||
|
||||
constexpr u32 MaskHigh = 0xFF00FFFF;
|
||||
constexpr u32 Mask2 = 0xFFFFFF00;
|
||||
constexpr u32 Mask3 = 0xFF00FF00;
|
||||
|
||||
const u32 allowance1 = static_cast<u32>(0x32000 / (C.eristaEmcMaxClock / 0x3E8)) & 0xFF;
|
||||
const u32 allowance2 = static_cast<u32>(0x9C40 / (C.eristaEmcMaxClock / 0x3E8)) & 0xFF;
|
||||
const u32 allowance3 = static_cast<u32>(0xB540 / (C.eristaEmcMaxClock / 0x3E8)) & 0xFF;
|
||||
const u32 allowance4 = static_cast<u32>(0x9600 / (C.eristaEmcMaxClock / 0x3E8)) & 0xFF;
|
||||
const u32 allowance5 = static_cast<u32>(0x8980 / (C.eristaEmcMaxClock / 0x3E8)) & 0xFF;
|
||||
|
||||
table->la_scale_regs.mc_latency_allowance_xusb_0 = (table->la_scale_regs.mc_latency_allowance_xusb_0 & MaskHigh) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_xusb_1 = (table->la_scale_regs.mc_latency_allowance_xusb_1 & MaskHigh) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_tsec_0 = (table->la_scale_regs.mc_latency_allowance_tsec_0 & MaskHigh) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_sdmmcaa_0 = (table->la_scale_regs.mc_latency_allowance_sdmmcaa_0 & MaskHigh) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_sdmmcab_0 = (table->la_scale_regs.mc_latency_allowance_sdmmcab_0 & MaskHigh) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_sdmmc_0 = (table->la_scale_regs.mc_latency_allowance_sdmmc_0 & MaskHigh) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_sdmmca_0 = (table->la_scale_regs.mc_latency_allowance_sdmmca_0 & MaskHigh) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_ppcs_1 = (table->la_scale_regs.mc_latency_allowance_ppcs_1 & MaskHigh) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_nvdec_0 = (table->la_scale_regs.mc_latency_allowance_nvdec_0 & MaskHigh) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_mpcore_0 = (table->la_scale_regs.mc_latency_allowance_mpcore_0 & MaskHigh) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_avpc_0 = (table->la_scale_regs.mc_latency_allowance_avpc_0 & MaskHigh) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_vic_0 = allowance3 | (table->la_scale_regs.mc_latency_allowance_vic_0 & Mask3) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_isp2_1 = (table->la_scale_regs.mc_latency_allowance_isp2_1 & Mask3) | (allowance1 << 16) | allowance1;
|
||||
table->la_scale_regs.mc_latency_allowance_nvenc_0 = allowance4 | (table->la_scale_regs.mc_latency_allowance_nvenc_0 & Mask3) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_hc_0 = (table->la_scale_regs.mc_latency_allowance_hc_0 & Mask2) | allowance5;
|
||||
table->la_scale_regs.mc_latency_allowance_gpu_0 = allowance2 | (table->la_scale_regs.mc_latency_allowance_gpu_0 & Mask3) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_gpu2_0 = allowance2 | (table->la_scale_regs.mc_latency_allowance_gpu2_0 & Mask3) | (allowance1 << 16);
|
||||
table->la_scale_regs.mc_latency_allowance_hc_1 = (table->la_scale_regs.mc_latency_allowance_hc_1 & Mask2) | allowance1;
|
||||
table->la_scale_regs.mc_latency_allowance_vi2_0 = (table->la_scale_regs.mc_latency_allowance_vi2_0 & Mask2) | allowance1;
|
||||
|
||||
table->dram_timings.t_rp = tRFCpb;
|
||||
table->dram_timings.t_rfc = tRFCab;
|
||||
table->dram_timings.rl = RL_DBI;
|
||||
// WRITE_PARAM_ALL_REG(table, emc_obdly, obdly);
|
||||
// WRITE_PARAM_ALL_REG(table, emc_ibdly, ibdly);
|
||||
|
||||
table->emc_cfg_2 = 0x11083D;
|
||||
}
|
||||
|
||||
Result MemFreqMtcTable(u32 *ptr) {
|
||||
u32 khz_list[] = {1600000, 1331200, 1065600, 800000, 665600, 408000, 204000, 102000, 68000, 40800};
|
||||
@@ -732,17 +679,14 @@ namespace ams::ldr::oc::pcv::erista {
|
||||
}
|
||||
|
||||
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[] = {
|
||||
{"CPU Freq Table", CpuFreqCvbTable<false>, 1, nullptr, CpuCvbDefaultMaxFreq},
|
||||
{"CPU Freq Table", CpuFreqCvbTable<false>, 1, nullptr, static_cast<u32>(GetDvfsTableLastEntry(CpuCvbTableDefault)->freq)},
|
||||
{"CPU Volt DVFS", &CpuVoltDvfs, 1, nullptr, 825},
|
||||
{"CPU Volt Thermals", &CpuVoltThermals, 1, nullptr, 825},
|
||||
{"CPU Volt Dfll", &CpuVoltDfll, 1, nullptr, 0xFFD0EAFF},
|
||||
{"CPU Volt Dfll", &CpuVoltDfll, 1, nullptr, 0xFFEAD0FF},
|
||||
{"GPU Volt DVFS", &GpuVoltDVFS, 1, nullptr, 810},
|
||||
{"GPU Volt Thermals", &GpuVoltThermals, 1, nullptr, 810},
|
||||
{"GPU Freq Table", GpuFreqCvbTable<false>, 1, nullptr, GpuCvbDefaultMaxFreq},
|
||||
{"GPU Freq Table", GpuFreqCvbTable<false>, 1, nullptr, static_cast<u32>(GetDvfsTableLastEntry(GpuCvbTableDefault)->freq)},
|
||||
{"GPU Freq Asm", &GpuFreqMaxAsm, 2, &GpuMaxClockPatternFn},
|
||||
{"GPU Freq PLL", &GpuFreqPllLimit, 1, nullptr, GpuClkPllLimit},
|
||||
{"MEM Freq Mtc", &MemFreqMtcTable, 0, nullptr, EmcClkOSLimit},
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "../mtc_timing_value.hpp"
|
||||
#include "../mariko/calculate_timings.hpp"
|
||||
|
||||
namespace ams::ldr::oc::pcv::mariko {
|
||||
namespace ams::ldr::hoc::pcv::mariko {
|
||||
|
||||
u32 GetGpuVminVoltage() {
|
||||
for (auto e : vminTable) {
|
||||
@@ -84,18 +84,18 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
}
|
||||
|
||||
/* C.marikoGpuVmin is zero, auto voltage is applied. */
|
||||
/* Get vmin depending on speedo and ram clock. */
|
||||
u32 autoVmin = GetAutoVoltage();
|
||||
PATCH_OFFSET(ptr, autoVmin);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result GpuVoltThermals(u32 *ptr) {
|
||||
u32 vmin = std::memcmp(ptr - 3, gpuVoltThermalPattern, sizeof(gpuVoltThermalPattern));
|
||||
if (vmin) {
|
||||
if (std::memcmp(ptr - 3, gpuVoltThermalPattern, sizeof(gpuVoltThermalPattern))) {
|
||||
R_THROW(ldr::ResultInvalidGpuDvfs());
|
||||
}
|
||||
|
||||
u32 vmin = C.marikoGpuVmin;
|
||||
|
||||
/* Automatic voltage. */
|
||||
if (!C.marikoGpuVmin) {
|
||||
vmin = GetAutoVoltage();
|
||||
@@ -105,11 +105,10 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
PATCH_OFFSET(ptr + 9, vmin);
|
||||
} else {
|
||||
/* Manual voltage. */
|
||||
PATCH_OFFSET(ptr, C.marikoGpuVmin);
|
||||
PATCH_OFFSET(ptr + 3, C.marikoGpuVmin);
|
||||
PATCH_OFFSET(ptr + 6, C.marikoGpuVmin);
|
||||
PATCH_OFFSET(ptr + 9, C.marikoGpuVmin);
|
||||
vmin = C.marikoGpuVmin;
|
||||
PATCH_OFFSET(ptr, vmin);
|
||||
PATCH_OFFSET(ptr + 3, vmin);
|
||||
PATCH_OFFSET(ptr + 6, vmin);
|
||||
PATCH_OFFSET(ptr + 9, vmin);
|
||||
}
|
||||
|
||||
PATCH_OFFSET(ptr + 12, vmin);
|
||||
@@ -432,9 +431,9 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
WRITE_PARAM_ALL_REG(table, emc_tfaw, GET_CYCLE_CEIL(tFAW));
|
||||
WRITE_PARAM_ALL_REG(table, emc_trpab, MIN(GET_CYCLE_CEIL(tRPab), static_cast<u32>(0x3F)));
|
||||
WRITE_PARAM_ALL_REG(table, emc_tckesr, GET_CYCLE_CEIL(tSR));
|
||||
WRITE_PARAM_ALL_REG(table, emc_tcke, tCKE);
|
||||
WRITE_PARAM_ALL_REG(table, emc_tcke, GET_CYCLE_CEIL(7.425) + 2);
|
||||
WRITE_PARAM_ALL_REG(table, emc_tpd, GET_CYCLE_CEIL(tXP));
|
||||
WRITE_PARAM_ALL_REG(table, emc_tclkstop, GET_CYCLE_CEIL(tXP) + 8);
|
||||
WRITE_PARAM_ALL_REG(table, emc_tclkstop, tCLKSTOP);
|
||||
WRITE_PARAM_ALL_REG(table, emc_r2p, tR2P);
|
||||
WRITE_PARAM_ALL_REG(table, emc_r2w, tR2W);
|
||||
WRITE_PARAM_ALL_REG(table, emc_trtm, tRTM);
|
||||
@@ -452,12 +451,11 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
WRITE_PARAM_ALL_REG(table, emc_dyn_self_ref_control, dyn_self_ref_control);
|
||||
WRITE_PARAM_ALL_REG(table, emc_pdex2wr, pdex2rw);
|
||||
WRITE_PARAM_ALL_REG(table, emc_pdex2rd, pdex2rw);
|
||||
WRITE_PARAM_ALL_REG(table, emc_pchg2pden, GET_CYCLE_CEIL(1.75));
|
||||
WRITE_PARAM_ALL_REG(table, emc_pchg2pden, GET_CYCLE_CEIL(1.763));
|
||||
WRITE_PARAM_ALL_REG(table, emc_ar2pden, GET_CYCLE_CEIL(1.75));
|
||||
WRITE_PARAM_ALL_REG(table, emc_pdex2cke, GET_CYCLE_CEIL(1.05));
|
||||
WRITE_PARAM_ALL_REG(table, emc_act2pden, GET_CYCLE_CEIL(14.0));
|
||||
WRITE_PARAM_ALL_REG(table, emc_cke2pden, /* cke2pden */ GET_CYCLE_CEIL(8.5));
|
||||
(void) cke2pden;
|
||||
WRITE_PARAM_ALL_REG(table, emc_cke2pden, GET_CYCLE_CEIL(8.499));
|
||||
WRITE_PARAM_ALL_REG(table, emc_pdex2mrr, GET_CYCLE_CEIL(pdex2mrr));
|
||||
WRITE_PARAM_ALL_REG(table, emc_rw2pden, tWTPDEN);
|
||||
WRITE_PARAM_ALL_REG(table, emc_einput, einput);
|
||||
@@ -484,14 +482,12 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
WRITE_PARAM_ALL_REG(table, emc_tr_rdv, rdv);
|
||||
WRITE_PARAM_ALL_REG(table, emc_cmd_brlshft_2, 0x24)
|
||||
WRITE_PARAM_ALL_REG(table, emc_cmd_brlshft_3, 0x24)
|
||||
// WRITE_PARAM_ALL_REG(table, emc_mrs_wait_cnt, 0x07FF003C);
|
||||
// WRITE_PARAM_ALL_REG(table, emc_mrs_wait_cnt2, 0x02DE002A);
|
||||
|
||||
/* This needs some clean up. */
|
||||
constexpr double MC_ARB_DIV = 4.0;
|
||||
constexpr u32 MC_ARB_SFA = 2;
|
||||
|
||||
table->burst_mc_regs.mc_emem_arb_cfg = C.marikoEmcMaxClock / (33.3 * 1000) / MC_ARB_DIV;
|
||||
table->burst_mc_regs.mc_emem_arb_cfg = C.marikoEmcMaxClock / (33.3 * 1000) / MC_ARB_DIV;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_rcd = CEIL(GET_CYCLE_CEIL(tRCD) / MC_ARB_DIV) - 2;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_rp = CEIL(GET_CYCLE_CEIL(tRPpb) / MC_ARB_DIV) - 1;
|
||||
table->burst_mc_regs.mc_emem_arb_timing_rc = CEIL(GET_CYCLE_CEIL(tRC) / MC_ARB_DIV) - 1;
|
||||
@@ -574,7 +570,8 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
table->dram_timings.t_rp = tRFCpb;
|
||||
table->dram_timings.t_rfc = tRFCab;
|
||||
table->dram_timings.rl = RL_DBI;
|
||||
table->emc_mrw2 = 0x8802003F;
|
||||
|
||||
table->emc_mrw2 = (table->emc_mrw2 & ~0xFFu) | static_cast<u32>(mrw2);
|
||||
table->emc_cfg_2 = 0x11083D;
|
||||
}
|
||||
|
||||
@@ -776,10 +773,14 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
PATCH_OFFSET(ptr, emc_uv);
|
||||
|
||||
i2cInitialize();
|
||||
I2cSet_U8(I2cDevice_Max77812_2, 0x25, (emc_uv - uv_min) / uv_step);
|
||||
Result resultI2C = I2cSet_U8(I2cDevice_Max77812_2, 0x25, (emc_uv - uv_min) / uv_step);
|
||||
i2cExit();
|
||||
|
||||
R_SUCCEED();
|
||||
if (R_SUCCEEDED(resultI2C)) {
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
return resultI2C;
|
||||
}
|
||||
|
||||
void Patch(uintptr_t mapped_nso, size_t nso_size) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) Switch-OC-Suite
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "ptm.hpp"
|
||||
|
||||
namespace ams::ldr::oc::ptm {
|
||||
namespace ams::ldr::hoc::ptm {
|
||||
|
||||
Result CpuPtmBoost(perf_conf_entry* entry) {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) Switch-OC-Suite
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "../oc_common.hpp"
|
||||
|
||||
namespace ams::ldr::oc::ptm {
|
||||
namespace ams::ldr::hoc::ptm {
|
||||
|
||||
typedef struct {
|
||||
u32 conf_id;
|
||||
|
||||
@@ -83,7 +83,7 @@ Result nvdecCheck = 1;
|
||||
Result nvencCheck = 1;
|
||||
Result nvjpgCheck = 1;
|
||||
Result nifmCheck = 1;
|
||||
Result sysclkCheck = 1;
|
||||
Result sysclkCheck = 0;
|
||||
Result pwmDutyCycleCheck = 1;
|
||||
|
||||
//Wi-Fi
|
||||
@@ -572,21 +572,19 @@ void Misc(void*) {
|
||||
}
|
||||
|
||||
// Get sys-clk data
|
||||
if (R_SUCCEEDED(sysclkCheck)) {
|
||||
SysClkContext sysclkCTX;
|
||||
if (R_SUCCEEDED(sysclkIpcGetCurrentContext(&sysclkCTX))) {
|
||||
realCPU_Hz = sysclkCTX.realFreqs[SysClkModule_CPU];
|
||||
realGPU_Hz = sysclkCTX.realFreqs[SysClkModule_GPU];
|
||||
realRAM_Hz = sysclkCTX.realFreqs[SysClkModule_MEM];
|
||||
partLoad[SysClkPartLoad_EMC] = sysclkCTX.partLoad[SysClkPartLoad_EMC];
|
||||
partLoad[SysClkPartLoad_EMCCpu] = sysclkCTX.partLoad[SysClkPartLoad_EMCCpu];
|
||||
|
||||
realCPU_mV = sysclkCTX.voltages[HocClkVoltage_CPU];
|
||||
realGPU_mV = sysclkCTX.voltages[HocClkVoltage_GPU];
|
||||
realVDD2_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDD2];
|
||||
realVDDQ_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDDQ_MarikoOnly];
|
||||
realSOC_mV = sysclkCTX.voltages[HocClkVoltage_SOC];
|
||||
}
|
||||
SysClkContext sysclkCTX;
|
||||
if (R_SUCCEEDED(sysclkIpcGetCurrentContext(&sysclkCTX))) {
|
||||
realCPU_Hz = sysclkCTX.realFreqs[SysClkModule_CPU];
|
||||
realGPU_Hz = sysclkCTX.realFreqs[SysClkModule_GPU];
|
||||
realRAM_Hz = sysclkCTX.realFreqs[SysClkModule_MEM];
|
||||
partLoad[SysClkPartLoad_EMC] = sysclkCTX.partLoad[SysClkPartLoad_EMC];
|
||||
partLoad[SysClkPartLoad_EMCCpu] = sysclkCTX.partLoad[SysClkPartLoad_EMCCpu];
|
||||
|
||||
realCPU_mV = sysclkCTX.voltages[HocClkVoltage_CPU];
|
||||
realGPU_mV = sysclkCTX.voltages[HocClkVoltage_GPU];
|
||||
realVDD2_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDD2];
|
||||
realVDDQ_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDDQ_MarikoOnly];
|
||||
realSOC_mV = sysclkCTX.voltages[HocClkVoltage_SOC];
|
||||
}
|
||||
|
||||
// Temperatures
|
||||
@@ -699,21 +697,7 @@ void Misc3(void*) {
|
||||
|
||||
do {
|
||||
mutexLock(&mutex_Misc);
|
||||
|
||||
// Get sys-clk data
|
||||
if (R_SUCCEEDED(sysclkCheck)) {
|
||||
SysClkContext sysclkCTX;
|
||||
if (R_SUCCEEDED(sysclkIpcGetCurrentContext(&sysclkCTX))) {
|
||||
partLoad[SysClkPartLoad_EMC] = sysclkCTX.partLoad[SysClkPartLoad_EMC];
|
||||
partLoad[SysClkPartLoad_EMCCpu] = sysclkCTX.partLoad[SysClkPartLoad_EMCCpu];
|
||||
|
||||
realCPU_mV = sysclkCTX.voltages[HocClkVoltage_CPU];
|
||||
realGPU_mV = sysclkCTX.voltages[HocClkVoltage_GPU];
|
||||
realSOC_mV = sysclkCTX.voltages[HocClkVoltage_SOC];
|
||||
realVDD2_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDD2];
|
||||
realVDDQ_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDDQ_MarikoOnly];
|
||||
}
|
||||
}
|
||||
|
||||
// Temperatures
|
||||
if (R_SUCCEEDED(i2cCheck)) {
|
||||
Tmp451GetSocTemp(&SOC_temperatureF);
|
||||
|
||||
@@ -446,14 +446,6 @@ public:
|
||||
if (SaltySD) {
|
||||
LoadSharedMemoryAndRefreshRate();
|
||||
}
|
||||
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
|
||||
uint32_t sysClkApiVer = 0;
|
||||
sysclkIpcGetAPIVersion(&sysClkApiVer);
|
||||
if (sysClkApiVer < 4) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
else sysclkCheck = 0;
|
||||
}
|
||||
if (R_SUCCEEDED(splInitialize())) {
|
||||
u64 sku = 0;
|
||||
splGetConfig(SplConfigItem_HardwareType, &sku);
|
||||
@@ -466,16 +458,14 @@ public:
|
||||
}
|
||||
}
|
||||
splExit();
|
||||
|
||||
sysclkIpcInitialize();
|
||||
});
|
||||
Hinted = envIsSyscallHinted(0x6F);
|
||||
}
|
||||
|
||||
virtual void exitServices() override {
|
||||
CloseThreads();
|
||||
if (R_SUCCEEDED(sysclkCheck)) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
sysclkIpcExit();
|
||||
shmemClose(&_sharedmemory);
|
||||
//Exit services
|
||||
clkrstExit();
|
||||
@@ -530,14 +520,6 @@ public:
|
||||
if (SaltySD) {
|
||||
LoadSharedMemory();
|
||||
}
|
||||
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
|
||||
uint32_t sysClkApiVer = 0;
|
||||
sysclkIpcGetAPIVersion(&sysClkApiVer);
|
||||
if (sysClkApiVer < 4) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
else sysclkCheck = 0;
|
||||
}
|
||||
if (R_SUCCEEDED(splInitialize())) {
|
||||
u64 sku = 0;
|
||||
splGetConfig(SplConfigItem_HardwareType, &sku);
|
||||
@@ -550,6 +532,7 @@ public:
|
||||
}
|
||||
}
|
||||
splExit();
|
||||
sysclkIpcInitialize();
|
||||
});
|
||||
Hinted = envIsSyscallHinted(0x6F);
|
||||
}
|
||||
@@ -557,9 +540,7 @@ public:
|
||||
virtual void exitServices() override {
|
||||
CloseThreads();
|
||||
shmemClose(&_sharedmemory);
|
||||
if (R_SUCCEEDED(sysclkCheck)) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
sysclkIpcExit();
|
||||
//Exit services
|
||||
clkrstExit();
|
||||
pcvExit();
|
||||
@@ -617,14 +598,6 @@ public:
|
||||
if (SaltySD) {
|
||||
LoadSharedMemory();
|
||||
}
|
||||
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
|
||||
uint32_t sysClkApiVer = 0;
|
||||
sysclkIpcGetAPIVersion(&sysClkApiVer);
|
||||
if (sysClkApiVer < 4) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
else sysclkCheck = 0;
|
||||
}
|
||||
if (R_SUCCEEDED(splInitialize())) {
|
||||
u64 sku = 0;
|
||||
splGetConfig(SplConfigItem_HardwareType, &sku);
|
||||
@@ -637,6 +610,7 @@ public:
|
||||
}
|
||||
}
|
||||
splExit();
|
||||
sysclkIpcInitialize();
|
||||
});
|
||||
Hinted = envIsSyscallHinted(0x6F);
|
||||
|
||||
@@ -645,9 +619,7 @@ public:
|
||||
virtual void exitServices() override {
|
||||
CloseThreads();
|
||||
shmemClose(&_sharedmemory);
|
||||
if (R_SUCCEEDED(sysclkCheck)) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
sysclkIpcExit();
|
||||
// Exit services
|
||||
clkrstExit();
|
||||
pcvExit();
|
||||
@@ -707,14 +679,6 @@ public:
|
||||
if (SaltySD) {
|
||||
LoadSharedMemoryAndRefreshRate();
|
||||
}
|
||||
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
|
||||
uint32_t sysClkApiVer = 0;
|
||||
sysclkIpcGetAPIVersion(&sysClkApiVer);
|
||||
if (sysClkApiVer < 4) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
else sysclkCheck = 0;
|
||||
}
|
||||
if (R_SUCCEEDED(splInitialize())) {
|
||||
u64 sku = 0;
|
||||
splGetConfig(SplConfigItem_HardwareType, &sku);
|
||||
@@ -727,6 +691,7 @@ public:
|
||||
}
|
||||
}
|
||||
splExit();
|
||||
sysclkIpcInitialize();
|
||||
});
|
||||
Hinted = envIsSyscallHinted(0x6F);
|
||||
}
|
||||
@@ -734,9 +699,7 @@ public:
|
||||
virtual void exitServices() override {
|
||||
CloseThreads();
|
||||
shmemClose(&_sharedmemory);
|
||||
if (R_SUCCEEDED(sysclkCheck)) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
sysclkIpcExit();
|
||||
clkrstExit();
|
||||
pcvExit();
|
||||
tsExit();
|
||||
@@ -790,14 +753,6 @@ public:
|
||||
if (SaltySD) {
|
||||
LoadSharedMemoryAndRefreshRate();
|
||||
}
|
||||
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
|
||||
uint32_t sysClkApiVer = 0;
|
||||
sysclkIpcGetAPIVersion(&sysClkApiVer);
|
||||
if (sysClkApiVer < 4) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
else sysclkCheck = 0;
|
||||
}
|
||||
if (R_SUCCEEDED(splInitialize())) {
|
||||
u64 sku = 0;
|
||||
splGetConfig(SplConfigItem_HardwareType, &sku);
|
||||
@@ -810,6 +765,7 @@ public:
|
||||
}
|
||||
}
|
||||
splExit();
|
||||
sysclkIpcInitialize();
|
||||
});
|
||||
Hinted = envIsSyscallHinted(0x6F);
|
||||
}
|
||||
@@ -817,9 +773,7 @@ public:
|
||||
virtual void exitServices() override {
|
||||
CloseThreads();
|
||||
shmemClose(&_sharedmemory);
|
||||
if (R_SUCCEEDED(sysclkCheck)) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
sysclkIpcExit();
|
||||
clkrstExit();
|
||||
pcvExit();
|
||||
tsExit();
|
||||
@@ -873,14 +827,6 @@ public:
|
||||
if (SaltySD) {
|
||||
LoadSharedMemoryAndRefreshRate();
|
||||
}
|
||||
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
|
||||
uint32_t sysClkApiVer = 0;
|
||||
sysclkIpcGetAPIVersion(&sysClkApiVer);
|
||||
if (sysClkApiVer < 4) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
else sysclkCheck = 0;
|
||||
}
|
||||
if (R_SUCCEEDED(splInitialize())) {
|
||||
u64 sku = 0;
|
||||
splGetConfig(SplConfigItem_HardwareType, &sku);
|
||||
@@ -893,6 +839,7 @@ public:
|
||||
}
|
||||
}
|
||||
splExit();
|
||||
sysclkIpcInitialize();
|
||||
});
|
||||
Hinted = envIsSyscallHinted(0x6F);
|
||||
}
|
||||
@@ -900,9 +847,7 @@ public:
|
||||
virtual void exitServices() override {
|
||||
CloseThreads();
|
||||
shmemClose(&_sharedmemory);
|
||||
if (R_SUCCEEDED(sysclkCheck)) {
|
||||
sysclkIpcExit();
|
||||
}
|
||||
sysclkIpcExit();
|
||||
clkrstExit();
|
||||
pcvExit();
|
||||
tsExit();
|
||||
|
||||
@@ -233,12 +233,10 @@ public:
|
||||
else if (realRAM_Hz && settings.showDeltas && (settings.showRealFreqs || settings.showTargetFreqs)) {
|
||||
renderer->drawString(DeltaRAM_c, false, COMMON_MARGIN + deltaOffset, height_offset, 15, (settings.textColor));
|
||||
}
|
||||
if (R_SUCCEEDED(sysclkCheck)) {
|
||||
static std::vector<std::string> PartLoadColoredChars = {"CPU", "GPU"};
|
||||
//static auto loadLabelWidth = renderer->getTextDimensions("Load: ", false, 15).first;
|
||||
renderer->drawString("Load", false, COMMON_MARGIN, height_offset+15, 15, (settings.catColor2));
|
||||
renderer->drawStringWithColoredSections(RAM_load_c, false, PartLoadColoredChars, COMMON_MARGIN + valueOffset, height_offset+15, 15, (settings.textColor), settings.catColor2);
|
||||
}
|
||||
static std::vector<std::string> PartLoadColoredChars = {"CPU", "GPU"};
|
||||
//static auto loadLabelWidth = renderer->getTextDimensions("Load: ", false, 15).first;
|
||||
renderer->drawString("Load", false, COMMON_MARGIN, height_offset+15, 15, (settings.catColor2));
|
||||
renderer->drawStringWithColoredSections(RAM_load_c, false, PartLoadColoredChars, COMMON_MARGIN + valueOffset, height_offset+15, 15, (settings.textColor), settings.catColor2);
|
||||
}
|
||||
if (R_SUCCEEDED(Hinted)) {
|
||||
//static auto textWidth = renderer->getTextDimensions("Total \nApplication \nApplet \nSystem \nSystem Unsafe ", false, 15).first;
|
||||
|
||||
@@ -354,7 +354,7 @@ public:
|
||||
else
|
||||
width = renderer->getTextDimensions("100%@4444.4444 mV", false, fontsize).first;
|
||||
}
|
||||
} else if (key == "GPU" || (key == "RAM" && settings.showRAMLoad && R_SUCCEEDED(sysclkCheck))) {
|
||||
} else if (key == "GPU" || (key == "RAM" && settings.showRAMLoad)) {
|
||||
//dimensions = renderer->drawString("100.0%@4444.4", false, 0, 0, fontsize, renderer->a(0x0000));
|
||||
|
||||
if (!settings.showRAMLoadCPUGPU) {
|
||||
@@ -370,7 +370,7 @@ public:
|
||||
width = renderer->getTextDimensions("100%[100%,100%]@4444.4444 mV", false, fontsize).first;
|
||||
}
|
||||
}
|
||||
} else if (key == "RAM" && (!settings.showRAMLoad || R_FAILED(sysclkCheck))) {
|
||||
} else if (key == "RAM" && (!settings.showRAMLoad)) {
|
||||
//dimensions = renderer->drawString("44444444MB@4444.4", false, 0, 0, fontsize, renderer->a(0x0000));
|
||||
if (!settings.realVolts) {
|
||||
width = renderer->getTextDimensions("100%@4444.4", false, fontsize).first;
|
||||
@@ -993,51 +993,33 @@ public:
|
||||
} else {
|
||||
unsigned PartLoadInt;
|
||||
|
||||
if (R_SUCCEEDED(sysclkCheck)) {
|
||||
PartLoadInt = partLoad[SysClkPartLoad_EMC] / 10;
|
||||
|
||||
if (settings.showRAMLoadCPUGPU) {
|
||||
unsigned ramCpuLoadInt = partLoad[SysClkPartLoad_EMCCpu] / 10;
|
||||
int RAM_GPU_Load = partLoad[SysClkPartLoad_EMC] - partLoad[SysClkPartLoad_EMCCpu];
|
||||
unsigned ramGpuLoadInt = RAM_GPU_Load / 10;
|
||||
|
||||
if (settings.realFrequencies && realRAM_Hz) {
|
||||
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
|
||||
"%u%%[%u%%,%u%%]@%hu.%hhu",
|
||||
PartLoadInt, ramCpuLoadInt, ramGpuLoadInt,
|
||||
realRAM_Hz / 1000000, (realRAM_Hz / 100000) % 10);
|
||||
} else {
|
||||
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
|
||||
"%u%%[%u%%,%u%%]@%hu.%hhu",
|
||||
PartLoadInt, ramCpuLoadInt, ramGpuLoadInt,
|
||||
RAM_Hz / 1000000, (RAM_Hz / 100000) % 10);
|
||||
}
|
||||
} else {
|
||||
if (settings.realFrequencies && realRAM_Hz) {
|
||||
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
|
||||
"%u%%@%hu.%hhu", PartLoadInt,
|
||||
realRAM_Hz / 1000000, (realRAM_Hz / 100000) % 10);
|
||||
} else {
|
||||
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
|
||||
"%u%%@%hu.%hhu", PartLoadInt,
|
||||
RAM_Hz / 1000000, (RAM_Hz / 100000) % 10);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const uint64_t RAM_Total_all = RAM_Total_application_u + RAM_Total_applet_u +
|
||||
RAM_Total_system_u + RAM_Total_systemunsafe_u;
|
||||
const uint64_t RAM_Used_all = RAM_Used_application_u + RAM_Used_applet_u +
|
||||
RAM_Used_system_u + RAM_Used_systemunsafe_u;
|
||||
PartLoadInt = (RAM_Total_all > 0) ? (unsigned)((RAM_Used_all * 100) / RAM_Total_all) : 0;
|
||||
PartLoadInt = partLoad[SysClkPartLoad_EMC] / 10;
|
||||
|
||||
if (settings.showRAMLoadCPUGPU) {
|
||||
unsigned ramCpuLoadInt = partLoad[SysClkPartLoad_EMCCpu] / 10;
|
||||
int RAM_GPU_Load = partLoad[SysClkPartLoad_EMC] - partLoad[SysClkPartLoad_EMCCpu];
|
||||
unsigned ramGpuLoadInt = RAM_GPU_Load / 10;
|
||||
|
||||
if (settings.realFrequencies && realRAM_Hz) {
|
||||
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
|
||||
"%u%%@%hu.%hhu", PartLoadInt,
|
||||
realRAM_Hz / 1000000, (realRAM_Hz / 100000) % 10);
|
||||
"%u%%[%u%%,%u%%]@%hu.%hhu",
|
||||
PartLoadInt, ramCpuLoadInt, ramGpuLoadInt,
|
||||
realRAM_Hz / 1000000, (realRAM_Hz / 100000) % 10);
|
||||
} else {
|
||||
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
|
||||
"%u%%@%hu.%hhu", PartLoadInt,
|
||||
RAM_Hz / 1000000, (RAM_Hz / 100000) % 10);
|
||||
"%u%%[%u%%,%u%%]@%hu.%hhu",
|
||||
PartLoadInt, ramCpuLoadInt, ramGpuLoadInt,
|
||||
RAM_Hz / 1000000, (RAM_Hz / 100000) % 10);
|
||||
}
|
||||
} else {
|
||||
if (settings.realFrequencies && realRAM_Hz) {
|
||||
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
|
||||
"%u%%@%hu.%hhu", PartLoadInt,
|
||||
realRAM_Hz / 1000000, (realRAM_Hz / 100000) % 10);
|
||||
} else {
|
||||
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
|
||||
"%u%%@%hu.%hhu", PartLoadInt,
|
||||
RAM_Hz / 1000000, (RAM_Hz / 100000) % 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "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
|
||||
@@ -8,11 +24,12 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||
#include <sysclk/client/ipc.h>
|
||||
#include <switch.h>
|
||||
#include <string.h>
|
||||
#include <stdatomic.h>
|
||||
#include <sysclk/client/ipc.h>
|
||||
|
||||
static Service g_sysclkSrv;
|
||||
static atomic_size_t g_refCnt;
|
||||
@@ -20,7 +37,7 @@ static atomic_size_t g_refCnt;
|
||||
bool sysclkIpcRunning()
|
||||
{
|
||||
Handle handle;
|
||||
const bool running = R_FAILED(smRegisterService(&handle, smEncodeName(SYSCLK_IPC_SERVICE_NAME), false, 1));
|
||||
bool running = R_FAILED(smRegisterService(&handle, smEncodeName(SYSCLK_IPC_SERVICE_NAME), false, 1));
|
||||
|
||||
if (!running)
|
||||
{
|
||||
@@ -94,7 +111,10 @@ Result sysclkIpcSetOverride(SysClkModule module, u32 hz)
|
||||
|
||||
Result sysclkIpcGetProfiles(u64 tid, SysClkTitleProfileList* out_profiles)
|
||||
{
|
||||
return serviceDispatchInOut(&g_sysclkSrv, SysClkIpcCmd_GetProfiles, tid, *out_profiles);
|
||||
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_GetProfiles, tid,
|
||||
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
|
||||
.buffers = {{out_profiles, sizeof(SysClkTitleProfileList)}},
|
||||
);
|
||||
}
|
||||
|
||||
Result sysclkIpcSetProfiles(u64 tid, SysClkTitleProfileList* profiles)
|
||||
@@ -107,12 +127,18 @@ Result sysclkIpcSetProfiles(u64 tid, SysClkTitleProfileList* profiles)
|
||||
|
||||
Result sysclkIpcGetConfigValues(SysClkConfigValueList* out_configValues)
|
||||
{
|
||||
return serviceDispatchOut(&g_sysclkSrv, SysClkIpcCmd_GetConfigValues, *out_configValues);
|
||||
return serviceDispatch(&g_sysclkSrv, SysClkIpcCmd_GetConfigValues,
|
||||
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
|
||||
.buffers = {{out_configValues, sizeof(SysClkConfigValueList)}},
|
||||
);
|
||||
}
|
||||
|
||||
Result sysclkIpcSetConfigValues(SysClkConfigValueList* configValues)
|
||||
{
|
||||
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetConfigValues, *configValues);
|
||||
return serviceDispatch(&g_sysclkSrv, SysClkIpcCmd_SetConfigValues,
|
||||
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
|
||||
.buffers = {{configValues, sizeof(SysClkConfigValueList)}},
|
||||
);
|
||||
}
|
||||
|
||||
Result sysclkIpcGetFreqList(SysClkModule module, u32* list, u32 maxCount, u32* outCount)
|
||||
@@ -125,4 +151,33 @@ Result sysclkIpcGetFreqList(SysClkModule module, u32* list, u32 maxCount, u32* o
|
||||
.buffer_attrs = { SfBufferAttr_HipcAutoSelect | SfBufferAttr_Out },
|
||||
.buffers = {{list, maxCount * sizeof(u32)}},
|
||||
);
|
||||
}
|
||||
|
||||
Result sysclkIpcSetReverseNXRTMode(ReverseNXMode mode)
|
||||
{
|
||||
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetReverseNXRTMode, mode);
|
||||
}
|
||||
|
||||
|
||||
Result hocClkIpcSetKipData()
|
||||
{
|
||||
u32 temp = 0;
|
||||
return serviceDispatchIn(&g_sysclkSrv, HocClkIpcCmd_SetKipData, temp);
|
||||
}
|
||||
|
||||
Result hocClkIpcGetKipData()
|
||||
{
|
||||
u32 temp = 0;
|
||||
return serviceDispatchIn(&g_sysclkSrv, HocClkIpcCmd_GetKipData, temp);
|
||||
}
|
||||
|
||||
Result hocClkIpcUpdateEmcRegs()
|
||||
{
|
||||
u32 temp = 0;
|
||||
return serviceDispatchIn(&g_sysclkSrv, HocClkIpcCmd_UpdateEmcRegs, temp);
|
||||
}
|
||||
Result hocClkIpcCalculateGpuVmin()
|
||||
{
|
||||
u32 temp = 0;
|
||||
return serviceDispatchIn(&g_sysclkSrv, HocClkIpcCmd_CalculateGpuVmin, temp);
|
||||
}
|
||||
@@ -1,287 +0,0 @@
|
||||
diff --git a/Overlay/Makefile b/Overlay/Makefile
|
||||
index 9656834..3b2ebd5 100644
|
||||
--- a/Overlay/Makefile
|
||||
+++ b/Overlay/Makefile
|
||||
@@ -38,7 +38,7 @@ include $(DEVKITPRO)/libnx/switch_rules
|
||||
# NACP building is skipped as well.
|
||||
#---------------------------------------------------------------------------------
|
||||
APP_TITLE := ReverseNX-RT
|
||||
-APP_VERSION := 1.1.1
|
||||
+APP_VERSION := 1.1.1-OC
|
||||
|
||||
TARGET := ReverseNX-RT-ovl
|
||||
BUILD := build
|
||||
diff --git a/Overlay/source/main.cpp b/Overlay/source/main.cpp
|
||||
index 810295c..2b3aa52 100644
|
||||
--- a/Overlay/source/main.cpp
|
||||
+++ b/Overlay/source/main.cpp
|
||||
@@ -1,7 +1,202 @@
|
||||
#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 <atomic>
|
||||
#include "SaltyNX.h"
|
||||
|
||||
+class ModeSync {
|
||||
+public:
|
||||
+ enum ReverseNXMode {
|
||||
+ ReverseNX_NotValid = 0,
|
||||
+ ReverseNX_SystemDefault = 0,
|
||||
+ ReverseNX_Handheld,
|
||||
+ ReverseNX_Docked,
|
||||
+ 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;
|
||||
+
|
||||
+ rc = IpcInitialize();
|
||||
+
|
||||
+ 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 IpcInitialize(void) {
|
||||
+ Result rc = 0;
|
||||
+ refCnt++;
|
||||
+
|
||||
+ if (serviceIsActive(&service))
|
||||
+ return 0;
|
||||
+
|
||||
+ rc = smGetService(&service, SERVICE_NAME);
|
||||
+
|
||||
+ if (R_FAILED(rc)) {
|
||||
+ this->ipcStatus = IpcStatus_InitFailed;
|
||||
+ rc = this->ipcStatus;
|
||||
+ this->Exit();
|
||||
+ return rc;
|
||||
+ }
|
||||
+
|
||||
+ return rc;
|
||||
+ }
|
||||
+
|
||||
+ 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;
|
||||
+ }
|
||||
+
|
||||
+ 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 = 0;
|
||||
+ IpcStatus ipcStatus = IpcStatus_Unknown;
|
||||
+ bool shouldSync = false;
|
||||
+ };
|
||||
+
|
||||
+ Ipc* ipc = nullptr;
|
||||
+ ReverseNXMode currentMode = ReverseNX_Undefined;
|
||||
+};
|
||||
+
|
||||
bool* def = 0;
|
||||
bool* isDocked = 0;
|
||||
bool* pluginActive = 0;
|
||||
@@ -17,6 +212,7 @@ bool plugin = false;
|
||||
char DockedChar[32];
|
||||
char SystemChar[32];
|
||||
char PluginChar[36];
|
||||
+char SysclkChar[0x40];
|
||||
uint64_t PID = 0;
|
||||
Handle remoteSharedMemory = 1;
|
||||
SharedMemory _sharedmemory = {};
|
||||
@@ -73,7 +269,7 @@ bool CheckPort () {
|
||||
|
||||
class GuiTest : public tsl::Gui {
|
||||
public:
|
||||
- GuiTest(u8 arg1, u8 arg2, bool arg3) { }
|
||||
+ GuiTest(ModeSync* p) : modeSync(p) { }
|
||||
|
||||
// Called when this Gui gets loaded to create the UI
|
||||
// Allocate all elements on the heap. libtesla will make sure to clean them up when not needed anymore
|
||||
@@ -112,6 +308,7 @@ public:
|
||||
else {
|
||||
renderer->drawString(SystemChar, false, x, y+40, 20, renderer->a(0xFFFF));
|
||||
renderer->drawString(DockedChar, false, x, y+60, 20, renderer->a(0xFFFF));
|
||||
+ renderer->drawString(SysclkChar, false, x, y+80, 20, renderer->a(0xFFFF));
|
||||
}
|
||||
}
|
||||
}), 100);
|
||||
@@ -190,6 +387,8 @@ public:
|
||||
|
||||
if (_def) sprintf(SystemChar, "Controlled by system: Yes");
|
||||
else sprintf(SystemChar, "Controlled by system: No");
|
||||
+
|
||||
+ modeSync->SetMode(_def, _isDocked, SysclkChar, sizeof(SysclkChar));
|
||||
}
|
||||
else i++;
|
||||
}
|
||||
@@ -200,6 +399,8 @@ public:
|
||||
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
|
||||
}
|
||||
+
|
||||
+ ModeSync* modeSync;
|
||||
};
|
||||
|
||||
class OverlayTest : public tsl::Overlay {
|
||||
@@ -248,9 +449,11 @@ public:
|
||||
|
||||
});
|
||||
|
||||
+ modeSync = new ModeSync;
|
||||
} // Called at the start to initialize all services necessary for this Overlay
|
||||
|
||||
virtual void exitServices() override {
|
||||
+ delete modeSync;
|
||||
shmemClose(&_sharedmemory);
|
||||
fsdevUnmountDevice("sdmc");
|
||||
} // Callet at the end to clean up all services previously initialized
|
||||
@@ -260,8 +463,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) {
|
||||
@@ -1,241 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include <switch.h>
|
||||
|
||||
/* Recompile nx-hbloader with following added in config.json "kernel_capabilities"
|
||||
{
|
||||
"type": "map",
|
||||
"value": {
|
||||
"address": "0x60006000",
|
||||
"size": "0x1000",
|
||||
"is_ro": false,
|
||||
"is_io": true
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void waitForKey(PadState pad) {
|
||||
while (appletMainLoop())
|
||||
{
|
||||
padUpdate(&pad);
|
||||
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & HidNpadButton_A)
|
||||
break;
|
||||
|
||||
if (kDown & HidNpadButton_Plus || kDown & HidNpadButton_B) {
|
||||
consoleExit(NULL);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#define CLK_RST_IO_BASE 0x60006000
|
||||
#define CLK_RST_IO_SIZE 0x1000
|
||||
|
||||
#define REG(OFFSET) (*reinterpret_cast<volatile u32 *>(OFFSET))
|
||||
#define GET_BITS(VAL, HIGH, LOW) ((VAL & ((1UL << (HIGH + 1UL)) - 1UL)) >> LOW)
|
||||
#define GET_BIT(VAL, BIT) GET_BITS(VAL, BIT, BIT)
|
||||
|
||||
static u64 clkrst_base = 0;
|
||||
static u64 clkrst_size = 0;
|
||||
|
||||
// From jetson nano kernel
|
||||
typedef enum {
|
||||
/* divider = 2 */
|
||||
CLK_PLLX = 5,
|
||||
CLK_PLLM = 2,
|
||||
CLK_PLLMB = 37,
|
||||
/* PLLX & PLLG are backup PLLs for CPU & GPU */
|
||||
/* divider = 1 */
|
||||
CLK_CCLK_G = 18, // A57 CPU cluster
|
||||
CLK_EMC = 36,
|
||||
} PTO_ID; // PLL Test Output Register ID
|
||||
|
||||
/* See if GM20B clock GPC PLL regs are accessible. */
|
||||
|
||||
#define PLLX_MISC0 0xE4
|
||||
#define PLLM_MISC2 0x9C
|
||||
|
||||
double ptoGetMHz(PTO_ID pto_id, u32 divider = 1, u32 presel_reg = 0, u32 presel_mask = 0) {
|
||||
u32 pre_val, val, presel_val;
|
||||
|
||||
if (presel_reg) {
|
||||
val = REG(clkrst_base + presel_reg);
|
||||
usleep(10);
|
||||
presel_val = val & presel_mask;
|
||||
val &= ~presel_mask;
|
||||
val |= presel_mask;
|
||||
REG(clkrst_base + presel_reg) = val;
|
||||
usleep(10);
|
||||
}
|
||||
|
||||
constexpr u32 cycle_count = 16;
|
||||
pre_val = REG(clkrst_base + 0x60);
|
||||
val = BIT(23) | BIT(13) | (cycle_count - 1);
|
||||
val |= pto_id << 14;
|
||||
|
||||
REG(clkrst_base + 0x60) = val;
|
||||
usleep(10);
|
||||
REG(clkrst_base + 0x60) = val | BIT(10);
|
||||
usleep(10);
|
||||
REG(clkrst_base + 0x60) = val;
|
||||
usleep(10);
|
||||
REG(clkrst_base + 0x60) = val | BIT(9);
|
||||
usleep(500);
|
||||
|
||||
while(REG(clkrst_base + 0x64) & BIT(31))
|
||||
;
|
||||
|
||||
val = REG(clkrst_base + 0x64);
|
||||
val &= 0xFFFFFF;
|
||||
val *= divider;
|
||||
|
||||
double rate_mhz = (u64)val * 32768. / cycle_count / 1000. / 1000.;
|
||||
usleep(10);
|
||||
REG(clkrst_base + 0x60) = pre_val;
|
||||
usleep(10);
|
||||
|
||||
if (presel_reg) {
|
||||
val = REG(clkrst_base + presel_reg);
|
||||
usleep(10);
|
||||
val &= ~presel_mask;
|
||||
val |= presel_val;
|
||||
REG(clkrst_base + presel_reg) = val;
|
||||
usleep(10);
|
||||
}
|
||||
|
||||
return rate_mhz;
|
||||
}
|
||||
|
||||
int main() {
|
||||
consoleInit(NULL);
|
||||
PadState pad;
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
// Get clkrst MMIO virtual address
|
||||
Result rc = svcQueryIoMapping(&clkrst_base, &clkrst_size, CLK_RST_IO_BASE, CLK_RST_IO_SIZE);
|
||||
if (R_FAILED(rc)) {
|
||||
printf("[ERROR] svcQueryIoMapping: 0x%X\n", rc);
|
||||
consoleUpdate(NULL);
|
||||
waitForKey(pad);
|
||||
consoleExit(NULL);
|
||||
}
|
||||
|
||||
printf("clkrst_base: 0x%lX\nclkrst_size: 0x%lX\n", clkrst_base, clkrst_size);
|
||||
|
||||
{
|
||||
#define CLKRST_PLLX_BASE 0xE0
|
||||
u32 pllx_base = REG(clkrst_base + CLKRST_PLLX_BASE);
|
||||
printf("\n"\
|
||||
"PLLX_BASE: 0x%X\n"\
|
||||
"PLLX_ENABLE: %lu\n"\
|
||||
"PLLX_REF_DIS: %lu\n"\
|
||||
"PLLX_LOCK: %lu\n"\
|
||||
"PLLX_DIVP: %lu\n"\
|
||||
"PLLX_DIVN: %lu\n"\
|
||||
"PLLX_DIVM: %lu\n",
|
||||
pllx_base,
|
||||
GET_BIT(pllx_base, 30),
|
||||
GET_BIT(pllx_base, 29),
|
||||
GET_BIT(pllx_base, 27),
|
||||
GET_BITS(pllx_base, 24, 20),
|
||||
GET_BITS(pllx_base, 15, 8),
|
||||
GET_BITS(pllx_base, 7, 0));
|
||||
}
|
||||
|
||||
{
|
||||
#define CLKRST_PLLX_MISC 0xE4
|
||||
u32 pllx_misc = REG(clkrst_base + CLKRST_PLLX_MISC);
|
||||
printf("\n"\
|
||||
"PLLX_MISC: 0x%X\n"\
|
||||
"PLLX_FO_G_DISABLE: %lu\n"\
|
||||
"PLLX_PTS: %lu\n"\
|
||||
"PLLX_LOCK_ENABLE: %lu\n",
|
||||
pllx_misc,
|
||||
GET_BIT(pllx_misc, 28),
|
||||
GET_BITS(pllx_misc, 23, 22),
|
||||
GET_BIT(pllx_misc, 18));
|
||||
}
|
||||
|
||||
{
|
||||
#define CLKRST_PLLMB_SS_CFG 0x780
|
||||
u32 pllmb_ss_cfg = REG(clkrst_base + CLKRST_PLLMB_SS_CFG);
|
||||
printf("\n"\
|
||||
"PLLMB_SS_CFG: 0x%X\n"\
|
||||
"PLLMB_EN_SDM: %lu\n"\
|
||||
"PLLMB_EN_SSC: %lu\n",
|
||||
pllmb_ss_cfg,
|
||||
GET_BIT(pllmb_ss_cfg, 31),
|
||||
GET_BIT(pllmb_ss_cfg, 30));
|
||||
}
|
||||
|
||||
{
|
||||
#define CLKRST_PLLMB_SS_CTRL1 0x784
|
||||
u32 pllmb_ss_ctrl1 = REG(clkrst_base + CLKRST_PLLMB_SS_CTRL1);
|
||||
printf("\n"\
|
||||
"PLLMB_SS_CTRL1: 0x%X\n"\
|
||||
"PLLMB_SDM_SSC_MAX: %lu\n"\
|
||||
"PLLMB_SDM_SSC_MIN: %lu\n",
|
||||
pllmb_ss_ctrl1,
|
||||
GET_BITS(pllmb_ss_ctrl1, 31, 16),
|
||||
GET_BITS(pllmb_ss_ctrl1, 15, 0));
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
#define CLKRST_PLLM_BASE 0x90
|
||||
u32 pllm_base = REG(clkrst_base + CLKRST_PLLM_BASE);
|
||||
printf("\n"\
|
||||
"PLLM_BASE: 0x%X\n"\
|
||||
"PLLM_DIVP: %lu\n"\
|
||||
"PLLM_DIVN: %lu\n"\
|
||||
"PLLM_DIVM: %lu\n",
|
||||
pllm_base,
|
||||
GET_BITS(pllm_base, 24, 20),
|
||||
GET_BITS(pllm_base, 15, 8),
|
||||
GET_BITS(pllm_base, 7, 0));
|
||||
}
|
||||
|
||||
{
|
||||
#define CLKRST_PLLMB_BASE 0x5e8
|
||||
u32 pllmb_base = REG(clkrst_base + CLKRST_PLLMB_BASE);
|
||||
printf("\n"\
|
||||
"PLLMB_BASE: 0x%X\n"\
|
||||
"PLLMB_DIVP: %lu\n"\
|
||||
"PLLMB_DIVN: %lu\n"\
|
||||
"PLLMB_DIVM: %lu\n",
|
||||
pllmb_base,
|
||||
GET_BITS(pllmb_base, 24, 20),
|
||||
GET_BITS(pllmb_base, 15, 8),
|
||||
GET_BITS(pllmb_base, 7, 0));
|
||||
}
|
||||
|
||||
printf("\n"\
|
||||
"EMC: %6.1f MHz\n"\
|
||||
"CCLK_G: %6.1f MHz\n"\
|
||||
"PLLX: %6.1f MHz\n"\
|
||||
"PLLM: %6.1f MHz\n"\
|
||||
"PLLMB: %6.1f MHz\n",
|
||||
ptoGetMHz(CLK_EMC),
|
||||
ptoGetMHz(CLK_CCLK_G),
|
||||
ptoGetMHz(CLK_PLLX, 2, PLLX_MISC0, BIT(22)),
|
||||
ptoGetMHz(CLK_PLLM, 2, PLLM_MISC2, BIT(8)),
|
||||
ptoGetMHz(CLK_PLLMB, 2, PLLM_MISC2, BIT(9))
|
||||
);
|
||||
|
||||
waitForKey(pad);
|
||||
|
||||
consoleExit(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
53
Source/sys-clk/bitmap.py
Normal file
53
Source/sys-clk/bitmap.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from PIL import Image
|
||||
import argparse
|
||||
import os
|
||||
|
||||
def image_to_rgba8888_array(image_path, output_path):
|
||||
# Open and convert to RGBA
|
||||
img = Image.open(image_path).convert('RGBA')
|
||||
width, height = img.size
|
||||
|
||||
# Get pixel data
|
||||
pixels = img.tobytes()
|
||||
|
||||
# Write as C header file
|
||||
with open(output_path, 'w') as f:
|
||||
f.write('// This is a automatically generated file, do not edit manually.\n')
|
||||
f.write(f'// {os.path.basename(image_path)} - {width}x{height}\n')
|
||||
f.write(f'const unsigned int IMG_WIDTH = {width};\n')
|
||||
f.write(f'const unsigned int IMG_HEIGHT = {height};\n')
|
||||
f.write('const unsigned char IMG_DATA[] = {\n ')
|
||||
|
||||
for i, byte in enumerate(pixels):
|
||||
f.write(f'0x{byte:02X}')
|
||||
if i < len(pixels) - 1:
|
||||
f.write(', ')
|
||||
if (i + 1) % 12 == 0:
|
||||
f.write('\n ')
|
||||
|
||||
f.write('\n};\n')
|
||||
|
||||
print(f'Converted: {width}x{height} -> {len(pixels)} bytes')
|
||||
print(f'Output: {output_path}')
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='PNG to RGB8888 script'
|
||||
)
|
||||
parser.add_argument('input', help='Input image file (e.g. cat.png)')
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
help='Output header file (default: <input>.h)'
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
output_path = args.output
|
||||
if not output_path:
|
||||
base, _ = os.path.splitext(args.input)
|
||||
output_path = base + '.h'
|
||||
|
||||
image_to_rgba8888_array(args.input, output_path)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,12 +1,20 @@
|
||||
/*
|
||||
* Battery Info Driver for Nintendo Switch
|
||||
* Single-header library for accessing battery information
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Usage:
|
||||
* #define BATTERY_INFO_IMPLEMENTATION
|
||||
* #include "battery_info.h"
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) meha3945 (hanai3bi)
|
||||
*
|
||||
* 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 <utility>
|
||||
|
||||
56
Source/sys-clk/common/include/crc32.h
Normal file
56
Source/sys-clk/common/include/crc32.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
uint32_t crc32(const uint8_t *data, size_t length) {
|
||||
uint32_t crc = 0xFFFFFFFF;
|
||||
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
crc ^= data[i];
|
||||
for (int j = 0; j < 8; j++) {
|
||||
crc = (crc >> 1) ^ (0xEDB88320 & -(crc & 1));
|
||||
}
|
||||
}
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
uint32_t checksum_file(const char *filename) {
|
||||
FILE *file = fopen(filename, "rb");
|
||||
if (!file) {
|
||||
perror("[crc32] Error opening file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t buffer[1024];
|
||||
uint32_t crc = 0xFFFFFFFF;
|
||||
size_t bytes_read;
|
||||
|
||||
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file)) > 0) {
|
||||
for (size_t i = 0; i < bytes_read; i++) {
|
||||
crc ^= buffer[i];
|
||||
for (int j = 0; j < 8; j++) {
|
||||
crc = (crc >> 1) ^ (0xEDB88320 & -(crc & 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
return ~crc;
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, based on reasearch by MasaGratoR and Cooler3D
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DISPLAY_REFRESH_RATE_H
|
||||
#define DISPLAY_REFRESH_RATE_H
|
||||
|
||||
|
||||
41
Source/sys-clk/common/include/memmem.h
Normal file
41
Source/sys-clk/common/include/memmem.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Roy Merkel
|
||||
|
||||
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 MEMMEM_IMPL_H
|
||||
#define MEMMEM_IMPL_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void *memmem_impl(void *haystack, size_t haystacklen,
|
||||
const void *needle, size_t needlelen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) ppkantorski (bord2death)
|
||||
*
|
||||
* 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 <string>
|
||||
@@ -5,7 +22,7 @@
|
||||
#include <cstdio>
|
||||
|
||||
static void writeNotification(const std::string& message) {
|
||||
const char* flagPath = "sdmc:/config/ultrahand/flags/NOTIFICATIONS.flag";
|
||||
static const char* flagPath = "sdmc:/config/ultrahand/flags/NOTIFICATIONS.flag";
|
||||
|
||||
FILE* flagFile = fopen(flagPath, "r");
|
||||
if (!flagFile) {
|
||||
|
||||
@@ -1,4 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) ppkantorski (bord2death)
|
||||
*
|
||||
* 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
|
||||
|
||||
/*
|
||||
* SDx actual min is 625 mV. Multipliers 0/1 reserved.
|
||||
* SD0 max is 1400 mV
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) MasaGratoR
|
||||
*
|
||||
* 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 <switch.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) ppkantorski (bord2death)
|
||||
*
|
||||
* 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 <switch.h>
|
||||
#include "pcv_types.h"
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) ppkantorski (bord2death)
|
||||
*
|
||||
* 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 <switch.h> // for Service, Result, hosversionBefore(), smGetService(), serviceClose(), etc.
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) MasaGratoR
|
||||
*
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -27,19 +27,20 @@
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <switch.h> // include libnx
|
||||
#ifdef __cplusplus
|
||||
#include "cpp_util.hpp"
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef std::uint32_t Result;
|
||||
typedef std::uint32_t u32;
|
||||
typedef std::int32_t s32;
|
||||
typedef std::uint64_t u64;
|
||||
typedef std::int64_t s64;
|
||||
typedef std::uint8_t u8;
|
||||
typedef std::int16_t s16;
|
||||
typedef std::uint16_t u16;
|
||||
// typedef std::uint32_t Result;
|
||||
// typedef std::uint32_t u32;
|
||||
// typedef std::int32_t s32;
|
||||
// typedef std::uint64_t u64;
|
||||
// typedef std::int64_t s64;
|
||||
// typedef std::uint8_t u8;
|
||||
// typedef std::int16_t s16;
|
||||
// typedef std::uint16_t u16;
|
||||
|
||||
#include "sysclk/ipc.h"
|
||||
#include "sysclk/board.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -125,6 +125,21 @@ typedef enum {
|
||||
HorizonOCSpeedo_EnumMax,
|
||||
} HorizonOCSpeedo;
|
||||
|
||||
typedef enum {
|
||||
GPUUVLevel_NoUV = 0,
|
||||
GPUUVLevel_SLT,
|
||||
GPUUVLevel_HiOPT,
|
||||
GPUUVLevel_EnumMax,
|
||||
} GPUUndervoltLevel;
|
||||
|
||||
enum {
|
||||
DVFSMode_Disabled,
|
||||
DVFSMode_Hijack,
|
||||
// DVFSMode_OfficialService,
|
||||
// DVFSMode_Hack,
|
||||
DVFSMode_EnumMax,
|
||||
};
|
||||
|
||||
#define SYSCLK_ENUM_VALID(n, v) ((v) < n##_EnumMax)
|
||||
|
||||
static inline const char* sysclkFormatModule(SysClkModule module, bool pretty)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -12,9 +12,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -41,11 +41,7 @@ typedef enum {
|
||||
HocClkConfigValue_OverwriteBoostMode,
|
||||
|
||||
HocClkConfigValue_EristaMaxCpuClock,
|
||||
HocClkConfigValue_EristaMaxGpuClock,
|
||||
HocClkConfigValue_EristaMaxMemClock,
|
||||
HocClkConfigValue_MarikoMaxCpuClock,
|
||||
HocClkConfigValue_MarikoMaxGpuClock,
|
||||
HocClkConfigValue_MarikoMaxMemClock,
|
||||
|
||||
HocClkConfigValue_ThermalThrottle,
|
||||
HocClkConfigValue_ThermalThrottleThreshold,
|
||||
@@ -56,18 +52,19 @@ typedef enum {
|
||||
HocClkConfigValue_LiteTDPLimit,
|
||||
|
||||
HocClkConfigValue_EnforceBoardLimit,
|
||||
|
||||
HocClkConfigValue_KipEditing,
|
||||
HocClkConfigValue_KipFileName,
|
||||
|
||||
HorizonOCConfigValue_BatteryChargeCurrent,
|
||||
|
||||
HorizonOCConfigValue_OverwriteRefreshRate,
|
||||
HorizonOCConfigValue_EnableUnsafeDisplayFreqs,
|
||||
|
||||
HorizonOCConfigValue_DVFSMode,
|
||||
HorizonOCConfigValue_DVFSOffset,
|
||||
|
||||
HocClkConfigValue_FixCpuVoltBug,
|
||||
|
||||
KipConfigValue_custRev,
|
||||
KipConfigValue_mtcConf,
|
||||
// KipConfigValue_mtcConf,
|
||||
KipConfigValue_hpMode,
|
||||
|
||||
KipConfigValue_commonEmcMemVolt,
|
||||
@@ -165,6 +162,11 @@ typedef enum {
|
||||
KipConfigValue_g_volt_e_1036800,
|
||||
KipConfigValue_g_volt_e_1075200,
|
||||
|
||||
KipConfigValue_t6_tRTW_fine_tune,
|
||||
KipConfigValue_t7_tWTR_fine_tune,
|
||||
|
||||
KipCrc32,
|
||||
HocClkConfigValue_IsFirstLoad,
|
||||
SysClkConfigValue_EnumMax,
|
||||
} SysClkConfigValue;
|
||||
|
||||
@@ -194,17 +196,9 @@ static inline const char* sysclkFormatConfigValue(SysClkConfigValue val, bool pr
|
||||
|
||||
case HocClkConfigValue_EristaMaxCpuClock:
|
||||
return pretty ? "CPU Max Display Clock" : "cpu_max_e";
|
||||
case HocClkConfigValue_EristaMaxGpuClock:
|
||||
return pretty ? "Max GPU Clock" : "gpu_max_e";
|
||||
case HocClkConfigValue_EristaMaxMemClock:
|
||||
return pretty ? "Erista Max MEM Clock" : "mem_max_e";
|
||||
|
||||
case HocClkConfigValue_MarikoMaxCpuClock:
|
||||
return pretty ? "CPU Max Display Clock" : "cpu_max_m";
|
||||
case HocClkConfigValue_MarikoMaxGpuClock:
|
||||
return pretty ? "Mariko Max GPU Clock" : "gpu_max_m";
|
||||
case HocClkConfigValue_MarikoMaxMemClock:
|
||||
return pretty ? "Mariko Max MEM Clock" : "mem_max_m";
|
||||
|
||||
case HocClkConfigValue_ThermalThrottle:
|
||||
return pretty ? "Thermal Throttle" : "thermal_throttle";
|
||||
@@ -224,12 +218,6 @@ static inline const char* sysclkFormatConfigValue(SysClkConfigValue val, bool pr
|
||||
case HocClkConfigValue_EnforceBoardLimit:
|
||||
return pretty ? "Enforce Board Limit" : "enforce_board_limit";
|
||||
|
||||
case HocClkConfigValue_KipEditing:
|
||||
return pretty ? "Enable KIP Editing" : "kip_editing";
|
||||
|
||||
case HocClkConfigValue_KipFileName:
|
||||
return pretty ? "KIP File Name" : "kip_file_name";
|
||||
|
||||
case HorizonOCConfigValue_BatteryChargeCurrent:
|
||||
return pretty ? "Battery Charge Current" : "bat_charge_current";
|
||||
|
||||
@@ -239,11 +227,20 @@ static inline const char* sysclkFormatConfigValue(SysClkConfigValue val, bool pr
|
||||
case HocClkConfigValue_FixCpuVoltBug:
|
||||
return pretty ? "Fix CPU Volt Bug" : "cpu_volt_bugfix";
|
||||
|
||||
case HorizonOCConfigValue_EnableUnsafeDisplayFreqs:
|
||||
return pretty ? "Enable Unsafe Display Frequencies" : "drr_unsafe";
|
||||
|
||||
case HorizonOCConfigValue_DVFSMode:
|
||||
return pretty ? "DVFS Mode" : "dvfs_mode";
|
||||
|
||||
case HorizonOCConfigValue_DVFSOffset:
|
||||
return pretty ? "DVFS Offset" : "dvfs_offset";
|
||||
|
||||
// KIP config values
|
||||
case KipConfigValue_custRev:
|
||||
return pretty ? "Custom Revision" : "kip_cust_rev";
|
||||
case KipConfigValue_mtcConf:
|
||||
return pretty ? "MTC Config" : "kip_mtc_conf";
|
||||
// case KipConfigValue_mtcConf:
|
||||
// return pretty ? "MTC Config" : "kip_mtc_conf";
|
||||
case KipConfigValue_hpMode:
|
||||
return pretty ? "HP Mode" : "kip_hp_mode";
|
||||
|
||||
@@ -386,7 +383,12 @@ static inline const char* sysclkFormatConfigValue(SysClkConfigValue val, bool pr
|
||||
case KipConfigValue_g_volt_e_998400: return pretty ? "Erista GPU Volt 998 MHz" : "g_volt_e_998400";
|
||||
case KipConfigValue_g_volt_e_1036800: return pretty ? "Erista GPU Volt 1036 MHz" : "g_volt_e_1036800";
|
||||
case KipConfigValue_g_volt_e_1075200: return pretty ? "Erista GPU Volt 1075 MHz" : "g_volt_e_1075200";
|
||||
|
||||
case KipConfigValue_t6_tRTW_fine_tune: return pretty ? "t6 - tRTW Fine Tune" : "t6_tRTW_fine_fune";
|
||||
case KipConfigValue_t7_tWTR_fine_tune: return pretty ? "t7 - tWTR Fine Tune" : "t7_tWTR_fine_tune";
|
||||
case KipCrc32:
|
||||
return pretty ? "CRC32" : "crc32";
|
||||
case HocClkConfigValue_IsFirstLoad:
|
||||
return pretty ? "Is First Load" : "is_first_load";
|
||||
default:
|
||||
return pretty ? "[cfg] no enum format string" : "err_no_format_string";
|
||||
}
|
||||
@@ -404,36 +406,29 @@ static inline uint64_t sysclkDefaultConfigValue(SysClkConfigValue val)
|
||||
case SysClkConfigValue_CsvWriteIntervalMs:
|
||||
case HocClkConfigValue_UncappedClocks:
|
||||
case HocClkConfigValue_OverwriteBoostMode:
|
||||
case HocClkConfigValue_KipFileName:
|
||||
case HorizonOCConfigValue_BatteryChargeCurrent:
|
||||
case HorizonOCConfigValue_OverwriteRefreshRate:
|
||||
case HorizonOCConfigValue_EnableUnsafeDisplayFreqs:
|
||||
return 0ULL;
|
||||
case HocClkConfigValue_EristaMaxCpuClock:
|
||||
return 1785ULL;
|
||||
case HocClkConfigValue_EristaMaxGpuClock:
|
||||
return 921ULL;
|
||||
case HocClkConfigValue_EristaMaxMemClock:
|
||||
return 1600ULL;
|
||||
|
||||
case HocClkConfigValue_MarikoMaxCpuClock:
|
||||
return 1963ULL;
|
||||
case HocClkConfigValue_MarikoMaxGpuClock:
|
||||
return 1075ULL;
|
||||
case HocClkConfigValue_MarikoMaxMemClock:
|
||||
return 1862ULL;
|
||||
|
||||
case HocClkConfigValue_ThermalThrottle:
|
||||
case HocClkConfigValue_HandheldTDP:
|
||||
case HocClkConfigValue_EnforceBoardLimit:
|
||||
case HocClkConfigValue_KipEditing:
|
||||
case HocClkConfigValue_FixCpuVoltBug:
|
||||
case HocClkConfigValue_IsFirstLoad:
|
||||
case HorizonOCConfigValue_DVFSMode:
|
||||
return 1ULL;
|
||||
case HocClkConfigValue_ThermalThrottleThreshold:
|
||||
return 70ULL;
|
||||
case HocClkConfigValue_HandheldTDPLimit:
|
||||
return 8600ULL;
|
||||
return 9600ULL; // 8600mW will trigger on erista stock, so raise it a bit
|
||||
case HocClkConfigValue_LiteTDPLimit:
|
||||
return 6400ULL;
|
||||
return 6400ULL; // 0.5C
|
||||
default:
|
||||
return 0ULL;
|
||||
}
|
||||
@@ -444,17 +439,13 @@ static inline uint64_t sysclkValidConfigValue(SysClkConfigValue val, uint64_t in
|
||||
switch(val)
|
||||
{
|
||||
case HocClkConfigValue_EristaMaxCpuClock:
|
||||
case HocClkConfigValue_EristaMaxGpuClock:
|
||||
case HocClkConfigValue_EristaMaxMemClock:
|
||||
case HocClkConfigValue_MarikoMaxCpuClock:
|
||||
case HocClkConfigValue_MarikoMaxGpuClock:
|
||||
case HocClkConfigValue_MarikoMaxMemClock:
|
||||
case HocClkConfigValue_ThermalThrottleThreshold:
|
||||
case HocClkConfigValue_HandheldTDPLimit:
|
||||
case HocClkConfigValue_LiteTDPLimit:
|
||||
case SysClkConfigValue_PollingIntervalMs:
|
||||
return input > 0;
|
||||
|
||||
|
||||
case SysClkConfigValue_TempLogIntervalMs:
|
||||
case SysClkConfigValue_FreqLogIntervalMs:
|
||||
case SysClkConfigValue_PowerLogIntervalMs:
|
||||
@@ -464,14 +455,14 @@ static inline uint64_t sysclkValidConfigValue(SysClkConfigValue val, uint64_t in
|
||||
case HocClkConfigValue_ThermalThrottle:
|
||||
case HocClkConfigValue_HandheldTDP:
|
||||
case HocClkConfigValue_EnforceBoardLimit:
|
||||
case HocClkConfigValue_KipEditing:
|
||||
case HocClkConfigValue_KipFileName:
|
||||
case HorizonOCConfigValue_OverwriteRefreshRate:
|
||||
case HocClkConfigValue_FixCpuVoltBug:
|
||||
case HorizonOCConfigValue_EnableUnsafeDisplayFreqs:
|
||||
case HocClkConfigValue_IsFirstLoad:
|
||||
return (input & 0x1) == input;
|
||||
|
||||
|
||||
case KipConfigValue_custRev:
|
||||
case KipConfigValue_mtcConf:
|
||||
// case KipConfigValue_mtcConf:
|
||||
case KipConfigValue_hpMode:
|
||||
case KipConfigValue_commonEmcMemVolt:
|
||||
case KipConfigValue_eristaEmcMaxClock:
|
||||
@@ -559,6 +550,11 @@ static inline uint64_t sysclkValidConfigValue(SysClkConfigValue val, uint64_t in
|
||||
case KipConfigValue_g_volt_e_1075200:
|
||||
case KipConfigValue_eristaCpuVmin:
|
||||
case KipConfigValue_eristaCpuUnlock:
|
||||
case KipConfigValue_t6_tRTW_fine_tune:
|
||||
case KipConfigValue_t7_tWTR_fine_tune:
|
||||
case KipCrc32:
|
||||
case HorizonOCConfigValue_DVFSMode:
|
||||
case HorizonOCConfigValue_DVFSOffset:
|
||||
return true;
|
||||
case HorizonOCConfigValue_BatteryChargeCurrent:
|
||||
return ((input >= 1024) && (input <= 3072)) || !input;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -35,5 +35,5 @@ typedef enum
|
||||
SysClkError_Generic = 0,
|
||||
SysClkError_ConfigNotLoaded = 1,
|
||||
SysClkError_ConfigSaveFailed = 2,
|
||||
HocClkError_SocThermFail = 3,
|
||||
// HocClkError_SocThermFail = 3,
|
||||
} SysClkError;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -31,8 +31,8 @@
|
||||
#include "board.h"
|
||||
#include "clock_manager.h"
|
||||
|
||||
#define SYSCLK_IPC_API_VERSION 4
|
||||
#define SYSCLK_IPC_SERVICE_NAME "sys:clk"
|
||||
#define SYSCLK_IPC_API_VERSION 1
|
||||
#define SYSCLK_IPC_SERVICE_NAME "hoc:clk"
|
||||
|
||||
enum SysClkIpcCmd
|
||||
{
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) KazushiMe
|
||||
*
|
||||
* 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 <switch.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, based on reasearch by MasaGratoR and Cooler3D
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "display_refresh_rate.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2023 KazushiMe
|
||||
* Licensed under the GPLv2
|
||||
* Copyright (c) KazushiMe
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "i2c.h"
|
||||
|
||||
Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val) {
|
||||
|
||||
83
Source/sys-clk/common/src/memmem.c
Normal file
83
Source/sys-clk/common/src/memmem.c
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Roy Merkel
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "memmem.h"
|
||||
|
||||
void *memmem_impl(void *haystack, size_t haystacklen, const void *needle, size_t needlelen)
|
||||
{
|
||||
const unsigned char *cmpp;
|
||||
const unsigned char *p;
|
||||
const unsigned char *endp;
|
||||
const unsigned char *q;
|
||||
const unsigned char *endq;
|
||||
unsigned char found;
|
||||
|
||||
if(haystack == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if(needle == NULL)
|
||||
{
|
||||
return haystack;
|
||||
}
|
||||
if(haystacklen == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if(needlelen == 0)
|
||||
{
|
||||
return haystack;
|
||||
}
|
||||
|
||||
if(needlelen > haystacklen)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
endp = haystack + haystacklen - needlelen;
|
||||
endq = needle + needlelen;
|
||||
for(p = haystack; p <= endp; p++)
|
||||
{
|
||||
found = 1;
|
||||
cmpp = p;
|
||||
for(q = needle; q < endq; q++)
|
||||
{
|
||||
if(*cmpp != *q)
|
||||
{
|
||||
found = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmpp++;
|
||||
}
|
||||
}
|
||||
if(found)
|
||||
{
|
||||
return (void*)p;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) KazushiMe
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sysclk/psm_ext.h>
|
||||
|
||||
const char* PsmPowerRoleToStr(PsmPowerRole role) {
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) MasaGratoR
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||
#include <switch.h>
|
||||
#include "service_guard.h"
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) ppkantorski (bord2death)
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include "rgltr.h"
|
||||
#include "rgltr_services.h" // for extern Service g_rgltrSrv, etc.
|
||||
|
||||
@@ -39,7 +39,7 @@ include ${TOPDIR}/lib/libultrahand/ultrahand.mk
|
||||
# version control constants
|
||||
#---------------------------------------------------------------------------------
|
||||
#TARGET_VERSION := $(shell git describe --dirty --always --tags)
|
||||
APP_VERSION := 0.29
|
||||
APP_VERSION := 0.37
|
||||
TARGET_VERSION := $(APP_VERSION)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
1
Source/sys-clk/overlay/lib/libultrahand
Submodule
1
Source/sys-clk/overlay/lib/libultrahand
Submodule
Submodule Source/sys-clk/overlay/lib/libultrahand added at f053eaa5c1
@@ -1,2 +0,0 @@
|
||||
github: ppkantorski
|
||||
ko_fi: ppkantorski
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 381 KiB |
@@ -1,339 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) 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
|
||||
this service 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 make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. 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.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the 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 a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE 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.
|
||||
|
||||
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
|
||||
convey 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 2 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, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision 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, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This 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.
|
||||
@@ -1,211 +0,0 @@
|
||||
# ☆ libultrahand
|
||||
[](https://gbatemp.net/forums/nintendo-switch.283/?prefix_id=44)
|
||||
[](https://github.com/topics/cpp)
|
||||
[](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
|
||||
[](https://github.com/ppkantorski/libultrahand/releases/latest)
|
||||
[](https://github.com/ppkantorski/libultrahand/graphs/traffic)
|
||||
[](https://github.com/ppkantorski/libultrahand/issues)
|
||||
[](https://github.com/ppkantorski/libultrahand/stargazers)
|
||||
|
||||
|
||||
Expanded [**libtesla**](https://github.com/WerWolv/libtesla) (originally by [WerWolv](https://github.com/WerWolv)) + **libultra** libraries for overlay development on the Nintendo Switch
|
||||
|
||||

|
||||
|
||||
## Compiling
|
||||
|
||||
### Necessary Libraries and Imports
|
||||
For easy importing and inclusion, try using `ultrahand.mk`. These lines must go after your projects `SOURCES` and `INCLUDES` definitions.
|
||||
```sh
|
||||
include $(TOPDIR)/lib/libultrahand/ultrahand.mk
|
||||
```
|
||||
This location should reflect where you place the `libultrahand` directory (`lib` can vary between projects).
|
||||
|
||||
##
|
||||
|
||||
Otherwise developers should include the following `SOURCES` and `INCLUDES` lines.
|
||||
```sh
|
||||
SOURCES += lib/libultrahand/common lib/libultrahand/libultra/source
|
||||
INCLUDES += lib/libultrahand/common lib/libultrahand/libultra/include lib/libultrahand/libtesla/include
|
||||
```
|
||||
##
|
||||
|
||||
Including the following libraries are also essential for compilation.
|
||||
```sh
|
||||
LIBS := -lcurl -lz -lminizip -lmbedtls -lmbedx509 -lmbedcrypto -lnx
|
||||
```
|
||||
|
||||
### Active Services
|
||||
Service conflictions can occur, so if you are already using the following libnx services, you may want to remove them from your project.
|
||||
```cpp
|
||||
i2cInitialize();
|
||||
fsdevMountSdmc();
|
||||
splInitialize();
|
||||
spsmInitialize();
|
||||
ASSERT_FATAL(socketInitializeDefault());
|
||||
ASSERT_FATAL(nifmInitialize(NifmServiceType_User));
|
||||
ASSERT_FATAL(smInitialize()); // needed to prevent issues with powering device into sleep
|
||||
```
|
||||
Service `i2cInitialize` however is only utilized in accordance with `USING_WIDGET_DIRECTIVE`.
|
||||
|
||||
### Optional Compilation Flags
|
||||
```
|
||||
-ffunction-sections -fdata-sections
|
||||
```
|
||||
These options are present in both CFLAGS and CXXFLAGS. They instruct the compiler to place each function and data item in its own section, which allows the linker to more easily identify and remove unused code.
|
||||
|
||||
```
|
||||
-Wl,--gc-sections
|
||||
```
|
||||
Included in LDFLAGS. This linker flag instructs the linker to remove unused sections that were created by -ffunction-sections and -fdata-sections. This ensures that functions or data that are not used are removed from the final executable.
|
||||
|
||||
```
|
||||
-flto (Link Time Optimization)
|
||||
```
|
||||
Present in CFLAGS, CXXFLAGS, and LDFLAGS. It enables link-time optimization, allowing the compiler to optimize across different translation units and remove any unused code during the linking phase. You also use -flto=6 to control the number of threads for parallel LTO, which helps speed up the process.
|
||||
|
||||
```
|
||||
-fuse-linker-plugin
|
||||
```
|
||||
This flag allows the compiler and linker to better collaborate when using LTO, which further helps in optimizing and eliminating unused code.
|
||||
Together, these flags (-ffunction-sections, -fdata-sections, -Wl,--gc-sections, and -flto) ensure that any unused functions or data are stripped out during the build process, leading to a smaller and more optimized final binary.
|
||||
|
||||
|
||||
## Build Examples
|
||||
- [Ultrahand Overlay](https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
|
||||
- [Tetris Overlay](https://github.com/ppkantorski/Tetris-Overlay)
|
||||
|
||||
- [Status Monitor Overlay](https://github.com/ppkantorski/Status-Monitor-Overlay)
|
||||
|
||||
- [Edizon Overlay](https://github.com/proferabg/EdiZon-Overlay)
|
||||
|
||||
- [Sysmodules](https://github.com/ppkantorski/ovl-sysmodules)
|
||||
|
||||
- [sys-clk](https://github.com/ppkantorski/sys-clk)
|
||||
|
||||
- [FPSLocker](https://github.com/ppkantorski/FPSLocker)
|
||||
|
||||
- [ReverseNX-RT](https://github.com/ppkantorski/ReverseNX-RT)
|
||||
|
||||
- [QuickNTP](https://github.com/ppkantorski/QuickNTP)
|
||||
|
||||
- [SysDVR Overlay](https://github.com/ppkantorski/sysdvr-overlay)
|
||||
|
||||
- [Fizeau](https://github.com/ppkantorski/Fizeau)
|
||||
|
||||
- [NX-FanControl](https://github.com/ppkantorski/NX-FanControl)
|
||||
|
||||
- [DNS-MITM_Manager](https://github.com/ppkantorski/DNS-MITM_Manager)
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
### Overriding Themes and Wallpapers
|
||||
|
||||
To customize theme, wallpaper and / or allow direct language translations for your overlay, you can override the default settings by adding the following lines to your `Makefile`:
|
||||
|
||||
```
|
||||
# Enable appearance overriding
|
||||
UI_OVERRIDE_PATH := /config/<OVERLAY_NAME>/
|
||||
CFLAGS += -DUI_OVERRIDE_PATH="\"$(UI_OVERRIDE_PATH)\""
|
||||
```
|
||||
|
||||
Replace `<OVERLAY_NAME>` with the desired name of your overlay config directory.
|
||||
|
||||
Users can specify custom Ultrahand `theme.ini` and `wallpaper.rgba` files for the overlay to use located in your SD card's `/config/<OVERLAY_NAME>/` or `{UI_OVERRIDE_PATH}` directory.
|
||||
|
||||
#### **Troubleshooting**
|
||||
**Notice:** Makefile directives also must be added to `CXXFLAGS`.
|
||||
You can do this by adding the directives before `CXXFLAGS := $(CFLAGS)` gets defined, or include `CXXFLAGS += ...`.
|
||||
|
||||
|
||||
There are rare occurences where the theme and wallpaper are still not being loaded. This may have to do with how the GUI class is used in some projects. For a work around, you can try adding the `INITIALIZE_IN_GUI_DIRECTIVE` directive.
|
||||
|
||||
```
|
||||
# For theme / wallpaper loading in GUI class method (add to project if theme does not appear)
|
||||
INITIALIZE_IN_GUI_DIRECTIVE := 1
|
||||
CFLAGS += -DINITIALIZE_IN_GUI_DIRECTIVE=$(INITIALIZE_IN_GUI_DIRECTIVE)
|
||||
```
|
||||
|
||||
This fix will work for many projects, but other projects may not like this directive or may not need it at all so use with that in mind.
|
||||
|
||||
---
|
||||
|
||||
### Overriding Languages
|
||||
For language translation, `UI_OVERRIDE_PATH` must be defined. Translations are performed direction on the rederer's `drawString` method. Direct strings can be added to a json located in `/config/<OVERLAY_NAME>/lang/` or `{UI_OVERRIDE_PATH}/lang/`.
|
||||
|
||||
Jsons will need to be named ISO 639-1 format (en, de, fr, es, etc...) and will only be used in accordance with the current language set in the Ultrahand Overlay `/config/ultrahand/config.ini`.
|
||||
|
||||
The format for language jsons is as follows.
|
||||
```json
|
||||
{
|
||||
"English String": "Translated String",
|
||||
"Another String": "Another Translation",
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Ultrahand Overlay Widget
|
||||
|
||||
To add the Ultrahand Overlay widget to your `OverlayFrame`'s, add the following directive to your `Makefile`:
|
||||
|
||||
```
|
||||
# Enable Widget
|
||||
USING_WIDGET_DIRECTIVE := 1
|
||||
CFLAGS += -DUSING_WIDGET_DIRECTIVE=$(USING_WIDGET_DIRECTIVE)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Forcing use of `<fstream>` instead of `<stdio.h>` (unnecessary)
|
||||
|
||||
To compile utilizing `fstream`, add the following directive to your `Makefile`:
|
||||
|
||||
```
|
||||
# Enable fstream
|
||||
USING_FSTREAM_DIRECTIVE := 1
|
||||
CFLAGS += -DUSING_FSTREAM_DIRECTIVE=$(USING_FSTREAM_DIRECTIVE)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Initializing Settings
|
||||
|
||||
Ultrahand Overlay theme variables and settings for your overlay are read automatically upon initialization. Themes loading implementation is currently set within `OverlayFrame` and `HeaderOverlayFrame`.
|
||||
|
||||
However if you are breaking your project up into individual parts that only import `tesla.hpp` and modify elements, you may need to declare `/libultrahand/libultra/include` at the start of your `INCLUDES` in your make file.
|
||||
|
||||
If that still is not working, then you may need to add this line somewhere for the theme to be applied to that element.
|
||||
|
||||
```cpp
|
||||
tsl::initializeThemeVars(); // Initialize variables for ultrahand themes
|
||||
```
|
||||
|
||||
### Download Methods
|
||||
|
||||
To utilize the `libultra` download methods in your project, you will need to add the following line to your `initServices` function:
|
||||
```cpp
|
||||
initializeCurl();
|
||||
```
|
||||
As well as the following line to your `exetServices` function:
|
||||
```cpp
|
||||
cleanupCurl();
|
||||
```
|
||||
|
||||
These lines will ensure `curl` functions properly within the overlay.
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please raise an [issue](https://github.com/ppkantorski/libultrahand/issues/new/choose), submit a [pull request](https://github.com/ppkantorski/libultrahand/compare) or reach out to me directly on [GBATemp](https://gbatemp.net/threads/ultrahand-overlay-the-fully-craft-able-overlay-executor.633560/).
|
||||
|
||||
[](https://ko-fi.com/X8X3VR194)
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed and distributed under [GPLv2](LICENSE) with a [custom library](libultra) utilizing [CC-BY-4.0](SUB_LICENSE).
|
||||
|
||||
Copyright (c) 2023-2025 ppkantorski
|
||||
@@ -1,395 +0,0 @@
|
||||
Attribution 4.0 International
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
||||
does not provide legal services or legal advice. Distribution of
|
||||
Creative Commons public licenses does not create a lawyer-client or
|
||||
other relationship. Creative Commons makes its licenses and related
|
||||
information available on an "as-is" basis. Creative Commons gives no
|
||||
warranties regarding its licenses, any material licensed under their
|
||||
terms and conditions, or any related information. Creative Commons
|
||||
disclaims all liability for damages resulting from their use to the
|
||||
fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and
|
||||
conditions that creators and other rights holders may use to share
|
||||
original works of authorship and other material subject to copyright
|
||||
and certain other rights specified in the public license below. The
|
||||
following considerations are for informational purposes only, are not
|
||||
exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are
|
||||
intended for use by those authorized to give the public
|
||||
permission to use material in ways otherwise restricted by
|
||||
copyright and certain other rights. Our licenses are
|
||||
irrevocable. Licensors should read and understand the terms
|
||||
and conditions of the license they choose before applying it.
|
||||
Licensors should also secure all rights necessary before
|
||||
applying our licenses so that the public can reuse the
|
||||
material as expected. Licensors should clearly mark any
|
||||
material not subject to the license. This includes other CC-
|
||||
licensed material, or material used under an exception or
|
||||
limitation to copyright. More considerations for licensors:
|
||||
wiki.creativecommons.org/Considerations_for_licensors
|
||||
|
||||
Considerations for the public: By using one of our public
|
||||
licenses, a licensor grants the public permission to use the
|
||||
licensed material under specified terms and conditions. If
|
||||
the licensor's permission is not necessary for any reason--for
|
||||
example, because of any applicable exception or limitation to
|
||||
copyright--then that use is not regulated by the license. Our
|
||||
licenses grant only permissions under copyright and certain
|
||||
other rights that a licensor has authority to grant. Use of
|
||||
the licensed material may still be restricted for other
|
||||
reasons, including because others have copyright or other
|
||||
rights in the material. A licensor may make special requests,
|
||||
such as asking that all changes be marked or described.
|
||||
Although not required by our licenses, you are encouraged to
|
||||
respect those requests where reasonable. More_considerations
|
||||
for the public:
|
||||
wiki.creativecommons.org/Considerations_for_licensees
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution 4.0 International Public License ("Public License"). To the
|
||||
extent this Public License may be interpreted as a contract, You are
|
||||
granted the Licensed Rights in consideration of Your acceptance of
|
||||
these terms and conditions, and the Licensor grants You such rights in
|
||||
consideration of benefits the Licensor receives from making the
|
||||
Licensed Material available under these terms and conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
d. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
f. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
g. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
h. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
i. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
4. If You Share Adapted Material You produce, the Adapter's
|
||||
License You apply must not prevent recipients of the Adapted
|
||||
Material from complying with this Public License.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons is not a party to its public
|
||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
||||
its public licenses to material it publishes and in those instances
|
||||
will be considered the “Licensor.” The text of the Creative Commons
|
||||
public licenses is dedicated to the public domain under the CC0 Public
|
||||
Domain Dedication. Except for the limited purpose of indicating that
|
||||
material is shared under a Creative Commons public license or as
|
||||
otherwise permitted by the Creative Commons policies published at
|
||||
creativecommons.org/policies, Creative Commons does not authorize the
|
||||
use of the trademark "Creative Commons" or any other trademark or logo
|
||||
of Creative Commons without its prior written consent including,
|
||||
without limitation, in connection with any unauthorized modifications
|
||||
to any of its public licenses or any other arrangements,
|
||||
understandings, or agreements concerning use of licensed material. For
|
||||
the avoidance of doubt, this paragraph does not form part of the
|
||||
public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,306 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
||||
|
||||
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 cJSON__h
|
||||
#define cJSON__h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
|
||||
|
||||
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
|
||||
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
|
||||
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
|
||||
|
||||
For *nix builds that support visibility attribute, you can define similar behavior by
|
||||
|
||||
setting default visibility to hidden by adding
|
||||
-fvisibility=hidden (for gcc)
|
||||
or
|
||||
-xldscope=hidden (for sun cc)
|
||||
to CFLAGS
|
||||
|
||||
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
|
||||
|
||||
*/
|
||||
|
||||
#define CJSON_CDECL __cdecl
|
||||
#define CJSON_STDCALL __stdcall
|
||||
|
||||
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
||||
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_EXPORT_SYMBOLS
|
||||
#endif
|
||||
|
||||
#if defined(CJSON_HIDE_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
||||
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
||||
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
||||
#endif
|
||||
#else /* !__WINDOWS__ */
|
||||
#define CJSON_CDECL
|
||||
#define CJSON_STDCALL
|
||||
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||
#else
|
||||
#define CJSON_PUBLIC(type) type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* project version */
|
||||
#define CJSON_VERSION_MAJOR 1
|
||||
#define CJSON_VERSION_MINOR 7
|
||||
#define CJSON_VERSION_PATCH 18
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_Invalid (0)
|
||||
#define cJSON_False (1 << 0)
|
||||
#define cJSON_True (1 << 1)
|
||||
#define cJSON_NULL (1 << 2)
|
||||
#define cJSON_Number (1 << 3)
|
||||
#define cJSON_String (1 << 4)
|
||||
#define cJSON_Array (1 << 5)
|
||||
#define cJSON_Object (1 << 6)
|
||||
#define cJSON_Raw (1 << 7) /* raw json */
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_StringIsConst 512
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON
|
||||
{
|
||||
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *next;
|
||||
struct cJSON *prev;
|
||||
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
struct cJSON *child;
|
||||
|
||||
/* The type of the item, as above. */
|
||||
int type;
|
||||
|
||||
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
|
||||
char *valuestring;
|
||||
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
|
||||
int valueint;
|
||||
/* The item's number, if type==cJSON_Number */
|
||||
double valuedouble;
|
||||
|
||||
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
char *string;
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks
|
||||
{
|
||||
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
|
||||
void *(CJSON_CDECL *malloc_fn)(size_t sz);
|
||||
void (CJSON_CDECL *free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
typedef int cJSON_bool;
|
||||
|
||||
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
|
||||
* This is to prevent stack overflows. */
|
||||
#ifndef CJSON_NESTING_LIMIT
|
||||
#define CJSON_NESTING_LIMIT 1000
|
||||
#endif
|
||||
|
||||
/* Limits the length of circular references can be before cJSON rejects to parse them.
|
||||
* This is to prevent stack overflows. */
|
||||
#ifndef CJSON_CIRCULAR_LIMIT
|
||||
#define CJSON_CIRCULAR_LIMIT 10000
|
||||
#endif
|
||||
|
||||
/* returns the version of cJSON as a string */
|
||||
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
|
||||
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
|
||||
/* Render a cJSON entity to text for transfer/storage. */
|
||||
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
||||
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
||||
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
|
||||
|
||||
/* Returns the number of items in an array (or object). */
|
||||
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
||||
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||
|
||||
/* Check item type and return its value */
|
||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
|
||||
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
|
||||
|
||||
/* These functions check the type of an item */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
||||
/* raw json */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
||||
|
||||
/* Create a string where valuestring references a string so
|
||||
* it will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
|
||||
/* Create an object/array that only references it's elements so
|
||||
* they will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
|
||||
|
||||
/* These utilities create an Array of count items.
|
||||
* The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
|
||||
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
|
||||
* writing to `item->string` */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
|
||||
/* Remove/Detach items from Arrays/Objects. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
* need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
* The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
||||
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
|
||||
|
||||
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
|
||||
* The input pointer json cannot point to a read-only address area, such as a string constant,
|
||||
* but should point to a readable and writable address area. */
|
||||
CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
||||
|
||||
/* Helper functions for creating and adding items to an object at the same time.
|
||||
* They return the added item or NULL on failure. */
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||
/* helper for the cJSON_SetNumberValue macro */
|
||||
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||
/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */
|
||||
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
|
||||
|
||||
/* If the object is not a boolean type this does nothing and returns cJSON_Invalid else it returns the new type*/
|
||||
#define cJSON_SetBoolValue(object, boolValue) ( \
|
||||
(object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \
|
||||
(object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \
|
||||
cJSON_Invalid\
|
||||
)
|
||||
|
||||
/* Macro for iterating over an array or object */
|
||||
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||
|
||||
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
||||
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
||||
CJSON_PUBLIC(void) cJSON_free(void *object);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,339 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) 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
|
||||
this service 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 make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. 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.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the 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 a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE 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.
|
||||
|
||||
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
|
||||
convey 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 2 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, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision 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, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This 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.
|
||||
@@ -1,32 +0,0 @@
|
||||
# libtesla
|
||||
|
||||
<p align="center">
|
||||
<img src="https://i.imgur.com/fhwyjbd.png">
|
||||
</p>
|
||||
|
||||
libtesla is the interface between the Tesla overlay loader and user-made Overlays. It handles all layer creation, UI creation, drawing and input management.
|
||||
It's main goal is to make sure all overlays look and feel similar and don't differenciate themselves from the switch's native overlays.
|
||||
|
||||
## Screenshots
|
||||
|
||||
<div>
|
||||
<img src="https://i.imgur.com/jJpxYjb.jpg" style="width: 50%; float: center">
|
||||
<img src="https://i.imgur.com/nBUc7ps.jpg" style="width: 50%; float: right">
|
||||
</div>
|
||||
|
||||
`Overlays do NOT show up on Screenshots. These pictures were taken using a capture card`
|
||||
|
||||
## Example
|
||||
|
||||
An example for how to use libtesla can be found here: https://github.com/WerWolv/libtesla/tree/master/example
|
||||
To create your own Overlay, please consider creating a new repository using the official Tesla overlay template: https://github.com/WerWolv/Tesla-Template
|
||||
|
||||
**Please Note:** While it is possible to create overlays without libtesla, it's highly recommended to not do so. libtesla handles showing and hiding of overlays, button combo detection, layer creation and a lot more. Not using it will lead to an inconsistent user experience when using multiple different overlays ultimately making it worse for the end user. If something's missing, please consider opening a PR here.
|
||||
|
||||
## Credits
|
||||
|
||||
- **switchbrew** for nx-hbloader which is used as basis for overlay loading
|
||||
- **kardch** for the amazing icon
|
||||
- **All the devs on AtlasNX, RetroNX and Switchbrew** for their feedback
|
||||
- **All overlay devs** for making something awesome out of this :)
|
||||
|
||||
@@ -1,209 +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.
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
APP_TITLE := Tesla Example
|
||||
APP_VERSION := 1.3.0
|
||||
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := ../include
|
||||
|
||||
NO_ICON := 1
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# 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__
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-exceptions -std=c++20
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lnx
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(PORTLIBS) $(LIBNX)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# 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:
|
||||
@rm -fr $(BUILD) $(TARGET).ovl $(TARGET).nro $(TARGET).nacp $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
.PHONY: all
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
all : $(OUTPUT).ovl
|
||||
|
||||
$(OUTPUT).ovl : $(OUTPUT).elf $(OUTPUT).nacp
|
||||
@elf2nro $< $@ $(NROFLAGS)
|
||||
@echo "built ... $(notdir $(OUTPUT).ovl)"
|
||||
|
||||
$(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,100 +0,0 @@
|
||||
#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
|
||||
|
||||
|
||||
class GuiSecondary : public tsl::Gui {
|
||||
public:
|
||||
GuiSecondary() {}
|
||||
|
||||
virtual tsl::elm::Element* createUI() override {
|
||||
auto *rootFrame = new tsl::elm::OverlayFrame("Tesla Example", "v1.3.2 - Secondary Gui");
|
||||
|
||||
rootFrame->setContent(new tsl::elm::DebugRectangle(tsl::Color{ 0x8, 0x3, 0x8, 0xF }));
|
||||
|
||||
return rootFrame;
|
||||
}
|
||||
};
|
||||
|
||||
class GuiTest : public tsl::Gui {
|
||||
public:
|
||||
GuiTest(u8 arg1, u8 arg2, bool arg3) { }
|
||||
|
||||
// Called when this Gui gets loaded to create the UI
|
||||
// Allocate all elements on the heap. libtesla will make sure to clean them up when not needed anymore
|
||||
virtual tsl::elm::Element* createUI() override {
|
||||
// A OverlayFrame is the base element every overlay consists of. This will draw the default Title and Subtitle.
|
||||
// If you need more information in the header or want to change it's look, use a HeaderOverlayFrame.
|
||||
auto frame = new tsl::elm::OverlayFrame("Tesla Example", "v1.3.2");
|
||||
|
||||
// A list that can contain sub elements and handles scrolling
|
||||
auto list = new tsl::elm::List();
|
||||
|
||||
// List Items
|
||||
list->addItem(new tsl::elm::CategoryHeader("List items"));
|
||||
|
||||
auto *clickableListItem = new tsl::elm::ListItem("Clickable List Item", "...");
|
||||
clickableListItem->setClickListener([](u64 keys) {
|
||||
if (keys & HidNpadButton_A) {
|
||||
tsl::changeTo<GuiSecondary>();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
list->addItem(clickableListItem);
|
||||
list->addItem(new tsl::elm::ListItem("Default List Item"));
|
||||
list->addItem(new tsl::elm::ListItem("Default List Item with an extra long name to trigger truncation and scrolling"));
|
||||
list->addItem(new tsl::elm::ToggleListItem("Toggle List Item", true));
|
||||
|
||||
// Custom Drawer, a element that gives direct access to the renderer
|
||||
list->addItem(new tsl::elm::CategoryHeader("Custom Drawer", true));
|
||||
list->addItem(new tsl::elm::CustomDrawer([](tsl::gfx::Renderer *renderer, s32 x, s32 y, s32 w, s32 h) {
|
||||
renderer->drawCircle(x + 40, y + 40, 20, true, renderer->a(0xF00F));
|
||||
renderer->drawCircle(x + 50, y + 50, 20, true, renderer->a(0xF0F0));
|
||||
renderer->drawRect(x + 130, y + 30, 60, 40, renderer->a(0xFF00));
|
||||
renderer->drawString("Hello :)", false, x + 250, y + 70, 20, renderer->a(0xFF0F));
|
||||
renderer->drawRect(x + 40, y + 90, 300, 10, renderer->a(0xF0FF));
|
||||
}), 100);
|
||||
|
||||
// Track bars
|
||||
list->addItem(new tsl::elm::CategoryHeader("Track bars"));
|
||||
list->addItem(new tsl::elm::TrackBar("\u2600"));
|
||||
list->addItem(new tsl::elm::StepTrackBar("\uE13C", 20));
|
||||
list->addItem(new tsl::elm::NamedStepTrackBar("\uE132", { "Selection 1", "Selection 2", "Selection 3" }));
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Called once every frame to update values
|
||||
virtual void update() override {
|
||||
|
||||
}
|
||||
|
||||
// Called once every frame to handle inputs not handled by other UI elements
|
||||
virtual bool handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft, HidAnalogStickState joyStickPosRight) override {
|
||||
return false; // Return true here to signal the inputs have been consumed
|
||||
}
|
||||
};
|
||||
|
||||
class OverlayTest : public tsl::Overlay {
|
||||
public:
|
||||
// libtesla already initialized fs, hid, pl, pmdmnt, hid:sys and set:sys
|
||||
virtual void initServices() override {} // Called at the start to initialize all services necessary for this Overlay
|
||||
virtual void exitServices() override {} // Called at the end to clean up all services previously initialized
|
||||
|
||||
virtual void onShow() override {} // Called before overlay wants to change from invisible to visible state
|
||||
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
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
return tsl::loop<OverlayTest>(argc, argv);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,339 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) 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
|
||||
this service 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 make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. 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.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the 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 a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE 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.
|
||||
|
||||
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
|
||||
convey 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 2 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, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision 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, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This 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.
|
||||
@@ -1,69 +0,0 @@
|
||||
# libultra
|
||||
|
||||

|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
`libultra` is a powerful collection of helper functions designed specifically for the Ultrahand Overlay project. This library offers a comprehensive set of utilities aimed at simplifying common tasks and enhancing the efficiency of your projects within the Ultrahand Overlay ecosystem.
|
||||
|
||||
## Features
|
||||
|
||||
### [Ultra Header](/libultra/include/ultra.hpp)
|
||||
|
||||
- **ultra.hpp**: The main header file for the `libultra` library, including all essential functions and declarations for seamless integration into your projects.
|
||||
|
||||
### [Debug Functions](/libultra/include/debug_funcs.hpp)
|
||||
|
||||
- **debug_funcs.hpp**: A collection of functions tailored for debugging purposes, aiding in identifying and resolving issues within your codebase.
|
||||
|
||||
### [Download Functions](/libultra/include/download_funcs.hpp)
|
||||
|
||||
- **download_funcs.hpp**: Utilities for managing file downloads, enabling seamless retrieval of resources from external sources.
|
||||
|
||||
### [Get Functions](/libultra/include/get_funcs.hpp)
|
||||
|
||||
- **get_funcs.hpp**: Functions for retrieving data from various sources, simplifying the process of fetching information within your applications.
|
||||
|
||||
### [Hex Functions](/libultra/include/hex_funcs.hpp)
|
||||
|
||||
- **hex_funcs.hpp**: Tools for working with hexadecimal data, facilitating operations such as conversion and manipulation of hexadecimal values.
|
||||
|
||||
### [INI Functions](/libultra/include/ini_funcs.hpp)
|
||||
|
||||
- **ini_funcs.hpp**: Helper functions for handling INI configuration files, offering a convenient way to manage application settings.
|
||||
|
||||
### [JSON Functions](/libultra/include/json_funcs.hpp)
|
||||
|
||||
- **json_funcs.hpp**: Utilities for parsing and manipulating JSON data, providing easy integration with JSON-based APIs and services.
|
||||
|
||||
### [List Functions](/libultra/include/list_funcs.hpp)
|
||||
|
||||
- **list_funcs.hpp**: Functions for working with lists and arrays, offering essential operations like sorting, searching, and manipulation of list elements.
|
||||
|
||||
### [Mod Functions](/libultra/include/mod_funcs.hpp)
|
||||
|
||||
- **mod_funcs.hpp**: Functions for manipulating game mods, facilitating operations and management tasks related to modifications in gaming environments.
|
||||
|
||||
### [Path Functions](/libultra/include/path_funcs.hpp)
|
||||
|
||||
- **path_funcs.hpp**: Tools for working with file paths and directories, simplifying file system operations within your applications.
|
||||
|
||||
### [String Functions](/libultra/include/string_funcs.hpp)
|
||||
|
||||
- **string_funcs.hpp**: A collection of string manipulation functions, providing utilities for tasks such as formatting, searching, and modification of strings.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
To build Ultrahand overlays with `libultra` + `libtesla`, simply add the `lib` folder to your project, then import `tesla.hpp`.
|
||||
|
||||
## Contribution
|
||||
|
||||
Contributions to `libultra` are welcome. If you have ideas for additional helper functions or improvements to existing ones, feel free to submit a pull request or open an issue on GitHub.
|
||||
|
||||
## License
|
||||
|
||||
Licensed under both [GPLv2](LICENSE) and [CC-BY-4.0](SUB_LICENSE).
|
||||
|
||||
Copyright (c) 2024 ppkantorski
|
||||
@@ -1,395 +0,0 @@
|
||||
Attribution 4.0 International
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
||||
does not provide legal services or legal advice. Distribution of
|
||||
Creative Commons public licenses does not create a lawyer-client or
|
||||
other relationship. Creative Commons makes its licenses and related
|
||||
information available on an "as-is" basis. Creative Commons gives no
|
||||
warranties regarding its licenses, any material licensed under their
|
||||
terms and conditions, or any related information. Creative Commons
|
||||
disclaims all liability for damages resulting from their use to the
|
||||
fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and
|
||||
conditions that creators and other rights holders may use to share
|
||||
original works of authorship and other material subject to copyright
|
||||
and certain other rights specified in the public license below. The
|
||||
following considerations are for informational purposes only, are not
|
||||
exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are
|
||||
intended for use by those authorized to give the public
|
||||
permission to use material in ways otherwise restricted by
|
||||
copyright and certain other rights. Our licenses are
|
||||
irrevocable. Licensors should read and understand the terms
|
||||
and conditions of the license they choose before applying it.
|
||||
Licensors should also secure all rights necessary before
|
||||
applying our licenses so that the public can reuse the
|
||||
material as expected. Licensors should clearly mark any
|
||||
material not subject to the license. This includes other CC-
|
||||
licensed material, or material used under an exception or
|
||||
limitation to copyright. More considerations for licensors:
|
||||
wiki.creativecommons.org/Considerations_for_licensors
|
||||
|
||||
Considerations for the public: By using one of our public
|
||||
licenses, a licensor grants the public permission to use the
|
||||
licensed material under specified terms and conditions. If
|
||||
the licensor's permission is not necessary for any reason--for
|
||||
example, because of any applicable exception or limitation to
|
||||
copyright--then that use is not regulated by the license. Our
|
||||
licenses grant only permissions under copyright and certain
|
||||
other rights that a licensor has authority to grant. Use of
|
||||
the licensed material may still be restricted for other
|
||||
reasons, including because others have copyright or other
|
||||
rights in the material. A licensor may make special requests,
|
||||
such as asking that all changes be marked or described.
|
||||
Although not required by our licenses, you are encouraged to
|
||||
respect those requests where reasonable. More_considerations
|
||||
for the public:
|
||||
wiki.creativecommons.org/Considerations_for_licensees
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution 4.0 International Public License ("Public License"). To the
|
||||
extent this Public License may be interpreted as a contract, You are
|
||||
granted the Licensed Rights in consideration of Your acceptance of
|
||||
these terms and conditions, and the Licensor grants You such rights in
|
||||
consideration of benefits the Licensor receives from making the
|
||||
Licensed Material available under these terms and conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
d. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
f. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
g. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
h. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
i. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
4. If You Share Adapted Material You produce, the Adapter's
|
||||
License You apply must not prevent recipients of the Adapted
|
||||
Material from complying with this Public License.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons is not a party to its public
|
||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
||||
its public licenses to material it publishes and in those instances
|
||||
will be considered the “Licensor.” The text of the Creative Commons
|
||||
public licenses is dedicated to the public domain under the CC0 Public
|
||||
Domain Dedication. Except for the limited purpose of indicating that
|
||||
material is shared under a Creative Commons public license or as
|
||||
otherwise permitted by the Creative Commons policies published at
|
||||
creativecommons.org/policies, Creative Commons does not authorize the
|
||||
use of the trademark "Creative Commons" or any other trademark or logo
|
||||
of Creative Commons without its prior written consent including,
|
||||
without limitation, in connection with any unauthorized modifications
|
||||
to any of its public licenses or any other arrangements,
|
||||
understandings, or agreements concerning use of licensed material. For
|
||||
the avoidance of doubt, this paragraph does not form part of the
|
||||
public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
@@ -1,97 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: audio.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header defines the Audio class and related structures used for
|
||||
* handling sound playback within the Ultrahand Overlay. It provides interfaces
|
||||
* for loading, caching, and playing WAV audio through libnx’s audout service,
|
||||
* along with basic sound type management and synchronization support.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include "tsl_utils.hpp"
|
||||
|
||||
namespace ult {
|
||||
class Audio {
|
||||
public:
|
||||
enum class SoundType : uint8_t { // <- uint8_t saves space
|
||||
Navigate,
|
||||
Enter,
|
||||
Exit,
|
||||
Wall,
|
||||
On,
|
||||
Off,
|
||||
Settings,
|
||||
Move,
|
||||
Count
|
||||
};
|
||||
|
||||
struct CachedSound {
|
||||
void* buffer = nullptr;
|
||||
uint32_t bufferSize = 0;
|
||||
uint32_t dataSize = 0;
|
||||
};
|
||||
|
||||
static bool initialize();
|
||||
static void exit();
|
||||
static void playSound(SoundType type);
|
||||
|
||||
// Inline wrappers - same API, zero overhead
|
||||
static inline void playNavigateSound() { playSound(SoundType::Navigate); }
|
||||
static inline void playEnterSound() { playSound(SoundType::Enter); }
|
||||
static inline void playExitSound() { playSound(SoundType::Exit); }
|
||||
static inline void playWallSound() { playSound(SoundType::Wall); }
|
||||
static inline void playOnSound() { playSound(SoundType::On); }
|
||||
static inline void playOffSound() { playSound(SoundType::Off); }
|
||||
static inline void playSettingsSound() { playSound(SoundType::Settings); }
|
||||
static inline void playMoveSound() { playSound(SoundType::Move); }
|
||||
|
||||
static void setMasterVolume(float volume);
|
||||
static void setEnabled(bool enabled);
|
||||
static bool isEnabled();
|
||||
//static bool isDocked();
|
||||
static bool reloadIfDockedChanged();
|
||||
static void reloadAllSounds();
|
||||
static void unloadAllSounds(const std::initializer_list<SoundType>& excludeSounds = {});
|
||||
static std::mutex m_audioMutex;
|
||||
|
||||
private:
|
||||
static bool m_initialized;
|
||||
static std::atomic<bool> m_enabled; // <- atomic for lock-free reads
|
||||
static float m_masterVolume;
|
||||
static std::vector<CachedSound> m_cachedSounds;
|
||||
|
||||
static bool m_lastDockedState;
|
||||
|
||||
inline static constexpr const char* m_soundPaths[static_cast<size_t>(SoundType::Count)] = {
|
||||
"sdmc:/config/ultrahand/sounds/tick.wav",
|
||||
"sdmc:/config/ultrahand/sounds/enter.wav",
|
||||
"sdmc:/config/ultrahand/sounds/exit.wav",
|
||||
"sdmc:/config/ultrahand/sounds/wall.wav",
|
||||
"sdmc:/config/ultrahand/sounds/on.wav",
|
||||
"sdmc:/config/ultrahand/sounds/off.wav",
|
||||
"sdmc:/config/ultrahand/sounds/settings.wav",
|
||||
"sdmc:/config/ultrahand/sounds/move.wav"
|
||||
};
|
||||
|
||||
//static void playAudioBuffer(void* buffer, uint32_t bufferSize);
|
||||
static bool loadSoundFromWav(SoundType type, const char* path);
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: debug_funcs.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header file contains debugging functions for the Ultrahand Overlay project.
|
||||
* These functions allow logging messages with timestamps to a log file.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2023-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef DEBUG_FUNCS_HPP
|
||||
#define DEBUG_FUNCS_HPP
|
||||
|
||||
#if !USING_FSTREAM_DIRECTIVE // For not using fstream (needs implementing)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <fstream>
|
||||
#endif
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
|
||||
namespace ult {
|
||||
#if USING_LOGGING_DIRECTIVE
|
||||
|
||||
// Specify the log file path
|
||||
extern const std::string defaultLogFilePath;
|
||||
|
||||
extern std::string logFilePath; // Declare logFilePath as extern
|
||||
extern bool disableLogging; // Declare disableLogging as extern
|
||||
|
||||
// Global mutex for thread-safe logging
|
||||
extern std::mutex logMutex; // Declare logMutex as extern
|
||||
|
||||
/**
|
||||
* @brief Logs a message with a timestamp to a log file in a thread-safe manner.
|
||||
*
|
||||
* @param message The message to be logged.
|
||||
*/
|
||||
void logMessage(const char* message);
|
||||
void logMessage(const std::string& message);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // DEBUG_FUNCS_HPP
|
||||
@@ -1,83 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: download_funcs.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header file contains functions for downloading and extracting files
|
||||
* using libcurl and miniz. It includes functions for downloading files from URLs,
|
||||
* writing received data to a file, and extracting files from ZIP archives.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2023-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef DOWNLOAD_FUNCS_HPP
|
||||
#define DOWNLOAD_FUNCS_HPP
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <switch.h>
|
||||
|
||||
#define CURL_DISABLE_DEFLATE
|
||||
#include <curl/curl.h>
|
||||
#include <zlib.h>
|
||||
#include <minizip/unzip.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
#include "global_vars.hpp"
|
||||
#include "string_funcs.hpp"
|
||||
#include "get_funcs.hpp"
|
||||
#include "path_funcs.hpp"
|
||||
#include "debug_funcs.hpp"
|
||||
|
||||
namespace ult {
|
||||
// Constants for buffer sizes
|
||||
|
||||
extern size_t DOWNLOAD_READ_BUFFER;
|
||||
extern size_t DOWNLOAD_WRITE_BUFFER;
|
||||
extern size_t UNZIP_READ_BUFFER;
|
||||
extern size_t UNZIP_WRITE_BUFFER;
|
||||
|
||||
// Path to the CA certificate
|
||||
//extern const std::string cacertPath;
|
||||
//extern const std::string cacertURL;
|
||||
|
||||
// Thread-safe atomic flags for operation control
|
||||
extern std::atomic<bool> abortDownload;
|
||||
extern std::atomic<bool> abortUnzip;
|
||||
extern std::atomic<int> downloadPercentage;
|
||||
extern std::atomic<int> unzipPercentage;
|
||||
|
||||
|
||||
// Thread-safe callback functions
|
||||
//#if !USING_FSTREAM_DIRECTIVE
|
||||
//size_t writeCallback(void* ptr, size_t size, size_t nmemb, FILE* stream);
|
||||
//#else
|
||||
//size_t writeCallback(void* ptr, size_t size, size_t nmemb, std::ostream* stream);
|
||||
//#endif
|
||||
|
||||
//int progressCallback(void* ptr, curl_off_t totalToDownload, curl_off_t nowDownloaded, curl_off_t totalToUpload, curl_off_t nowUploaded);
|
||||
|
||||
|
||||
// Thread-safe initialization and cleanup functions
|
||||
//void initializeCurl();
|
||||
//void cleanupCurl();
|
||||
|
||||
// Main API functions - thread-safe and optimized
|
||||
bool downloadFile(const std::string& url, const std::string& toDestination, bool noPercentagePolling=false);
|
||||
bool unzipFile(const std::string& zipFilePath, const std::string& extractTo);
|
||||
}
|
||||
|
||||
#endif // DOWNLOAD_FUNCS_HPP
|
||||
@@ -1,160 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: get_funcs.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header file contains functions for retrieving information and data
|
||||
* from various sources, including file system and JSON files. It includes
|
||||
* functions for obtaining overlay module information, reading file contents,
|
||||
* and parsing JSON data.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2023-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef GET_FUNCS_HPP
|
||||
#define GET_FUNCS_HPP
|
||||
|
||||
|
||||
#include <cstring>
|
||||
#include <dirent.h>
|
||||
#include <fnmatch.h>
|
||||
#include "debug_funcs.hpp"
|
||||
#include "string_funcs.hpp"
|
||||
|
||||
|
||||
namespace ult {
|
||||
struct DirCloser {
|
||||
void operator()(DIR* dir) const {
|
||||
if (dir) closedir(dir);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads the contents of a file and returns it as a string, normalizing line endings.
|
||||
*
|
||||
* @param filePath The path to the file to be read.
|
||||
* @return The content of the file as a string with line endings normalized to '\n'.
|
||||
*/
|
||||
//std::string getFileContents(const std::string& filePath);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Concatenates the provided directory and file names to form a destination path.
|
||||
*
|
||||
* @param destinationDir The directory where the file should be placed.
|
||||
* @param fileName The name of the file.
|
||||
* @return The destination path as a string.
|
||||
*/
|
||||
std::string getDestinationPath(const std::string& destinationDir, const std::string& fileName);
|
||||
|
||||
/**
|
||||
* @brief Extracts the value part from a string line containing a key-value pair.
|
||||
*
|
||||
* @param line The string line containing a key-value pair (e.g., "key=value").
|
||||
* @return The extracted value as a string. If no value is found, an empty string is returned.
|
||||
*/
|
||||
std::string getValueFromLine(const std::string& line);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Extracts the name from a file path, including handling directories.
|
||||
*
|
||||
* @param path The file path from which to extract the name.
|
||||
* @return The extracted name as a string. If the path indicates a directory, it extracts the last directory name.
|
||||
* If the path is empty or no name is found, an empty string is returned.
|
||||
*/
|
||||
std::string getNameFromPath(const std::string& path);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Extracts the file name from a full file path.
|
||||
*
|
||||
* This function takes a filesystem path and returns only the file name,
|
||||
* stripping away any directory paths that precede it.
|
||||
*
|
||||
* @param path The full path to the file.
|
||||
* @return The file name extracted from the full path.
|
||||
*/
|
||||
std::string getFileName(const std::string& path);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Extracts the name of the parent directory from a given file path at a specified level.
|
||||
*
|
||||
* @param path The file path from which to extract the parent directory name.
|
||||
* @param level The level of the parent directory to extract (0 for immediate parent, 1 for grandparent, and so on).
|
||||
* @return The name of the parent directory at the specified level.
|
||||
*/
|
||||
std::string getParentDirNameFromPath(const std::string& path, size_t level = 0);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Extracts the parent directory path from a given file path.
|
||||
*
|
||||
* @param path The file path from which to extract the parent directory path.
|
||||
* @return The parent directory path.
|
||||
*/
|
||||
std::string getParentDirFromPath(const std::string& path);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gets a list of subdirectories in a directory.
|
||||
*
|
||||
* @param directoryPath The path of the directory to search.
|
||||
* @return A vector of strings containing the names of subdirectories.
|
||||
*/
|
||||
std::vector<std::string> getSubdirectories(const std::string& directoryPath);
|
||||
|
||||
// Cache to store directory status
|
||||
// Assuming a very simple cache implementation
|
||||
//extern std::vector<std::pair<std::string, bool>> directoryCache;
|
||||
|
||||
bool isDirectory(struct dirent* entry, const std::string& path);
|
||||
|
||||
/**
|
||||
* @brief Recursively retrieves a list of files from a directory.
|
||||
*
|
||||
* @param directoryPath The path of the directory to search.
|
||||
* @return A vector of strings containing the paths of the files.
|
||||
*/
|
||||
std::vector<std::string> getFilesListFromDirectory(const std::string& directoryPath);
|
||||
|
||||
// Helper function to check if a path is a directory
|
||||
//bool isDirectoryCached(const struct dirent* entry, const std::string& fullPath) {
|
||||
// struct stat st;
|
||||
// if (stat(fullPath.c_str(), &st) != 0) return false;
|
||||
// return S_ISDIR(st.st_mode);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
void handleDirectory(const std::string& basePath, const std::vector<std::string>& parts, size_t partIndex, std::vector<std::string>& results, bool directoryOnly, size_t maxLines=0);
|
||||
/**
|
||||
* @brief Gets a list of files and folders based on a wildcard pattern.
|
||||
*
|
||||
* This function searches for files and folders in a directory that match the
|
||||
* specified wildcard pattern.
|
||||
*
|
||||
* @param pathPattern The wildcard pattern to match files and folders.
|
||||
* @return A vector of strings containing the paths of matching files and folders.
|
||||
*/
|
||||
std::vector<std::string> getFilesListByWildcards(const std::string& pathPattern, size_t maxLines=0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,182 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: global_vars.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header file provides the definitions of global constants and paths used
|
||||
* throughout the Ultrahand Overlay project. These constants are essential for
|
||||
* file management and configuration settings within the application.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository:
|
||||
* GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay
|
||||
*
|
||||
* Note: This notice is integral to the project's documentation and must not be
|
||||
* altered or removed.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2023-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
#include <set>
|
||||
|
||||
// Auto-detect constexpr std::string support based on C++ version
|
||||
#if __cplusplus >= 202400L
|
||||
#define CONSTEXPR_STRING constexpr
|
||||
#else
|
||||
#define CONSTEXPR_STRING const
|
||||
#endif
|
||||
|
||||
namespace ult {
|
||||
extern const std::string CONFIG_FILENAME;
|
||||
|
||||
extern const std::string ULTRAHAND_PROJECT_NAME;
|
||||
extern const std::string CAPITAL_ULTRAHAND_PROJECT_NAME;
|
||||
|
||||
extern const std::string ROOT_PATH;
|
||||
extern const std::string SETTINGS_PATH;
|
||||
|
||||
extern const std::string NX_OVLLOADER_PATH;
|
||||
extern const std::string OVL_HEAP_CONFIG_PATH;
|
||||
extern const std::string OVL_EXIT_FLAG_PATH;
|
||||
|
||||
extern const std::string ULTRAHAND_CONFIG_INI_PATH;
|
||||
extern const std::string TESLA_CONFIG_INI_PATH;
|
||||
extern const std::string LANG_PATH;
|
||||
extern const std::string THEMES_PATH;
|
||||
extern const std::string WALLPAPERS_PATH;
|
||||
extern const std::string SOUNDS_PATH;
|
||||
extern const std::string FLAGS_PATH;
|
||||
extern const std::string NOTIFICATIONS_PATH;
|
||||
extern const std::string PAYLOADS_PATH;
|
||||
extern const std::string HB_APPSTORE_JSON;
|
||||
|
||||
// Can be overriden with APPEARANCE_OVERRIDE_PATH directive
|
||||
extern std::string THEME_CONFIG_INI_PATH;
|
||||
extern std::string WALLPAPER_PATH;
|
||||
|
||||
|
||||
//#if IS_LAUNCHER_DIRECTIVE
|
||||
extern const std::string SPLIT_PROJECT_NAME_1;
|
||||
extern const std::string SPLIT_PROJECT_NAME_2;
|
||||
extern const std::string BOOT_PACKAGE_FILENAME;
|
||||
extern const std::string EXIT_PACKAGE_FILENAME;
|
||||
extern const std::string PACKAGE_FILENAME;
|
||||
|
||||
extern const std::string DOWNLOADS_PATH;
|
||||
|
||||
//extern const std::string EXPANSION_PATH;
|
||||
extern const std::string FUSE_DATA_INI_PATH;
|
||||
extern const std::string PACKAGE_PATH;
|
||||
extern const std::string OVERLAY_PATH;
|
||||
extern const std::string OVERLAYS_INI_FILEPATH;
|
||||
extern const std::string PACKAGES_INI_FILEPATH;
|
||||
|
||||
extern const std::string NOTIFICATIONS_FLAG_FILEPATH;
|
||||
|
||||
extern const std::set<std::string> PROTECTED_FILES;
|
||||
|
||||
extern const std::string ULTRAHAND_REPO_URL;
|
||||
extern const std::string INCLUDED_THEME_FOLDER_URL;
|
||||
extern const std::string LATEST_RELEASE_INFO_URL;
|
||||
extern const std::string LATEST_UPDATER_INI_URL;
|
||||
//extern const std::string NX_OVLLOADER_ZIP_URL;
|
||||
//extern const std::string NX_OVLLOADER_PLUS_ZIP_URL;
|
||||
extern const std::string OLD_NX_OVLLOADER_ZIP_URL;
|
||||
//extern const std::string OLD_NX_OVLLOADER_PLUS_ZIP_URL;
|
||||
extern const std::string UPDATER_PAYLOAD_URL;
|
||||
//extern const std::string SOUND_EFFECTS_URL;
|
||||
|
||||
extern const std::string LAUNCH_ARGS_STR;
|
||||
extern const std::string USE_LAUNCH_ARGS_STR;
|
||||
extern const std::string USE_QUICK_LAUNCH_STR;
|
||||
extern const std::string USE_BOOT_PACKAGE_STR;
|
||||
extern const std::string USE_EXIT_PACKAGE_STR;
|
||||
extern const std::string USE_LOGGING_STR;
|
||||
|
||||
//#endif
|
||||
|
||||
extern const std::string TESLA_COMBO_STR;
|
||||
extern const std::string ULTRAHAND_COMBO_STR;
|
||||
|
||||
extern const std::string FUSE_STR;
|
||||
extern const std::string TESLA_STR;
|
||||
extern const std::string ERISTA_STR;
|
||||
extern const std::string MARIKO_STR;
|
||||
extern const std::string KEY_COMBO_STR;
|
||||
extern const std::string DEFAULT_LANG_STR;
|
||||
|
||||
|
||||
extern const std::string LIST_STR;
|
||||
extern const std::string LIST_FILE_STR;
|
||||
extern const std::string JSON_STR;
|
||||
extern const std::string JSON_FILE_STR;
|
||||
extern const std::string INI_FILE_STR;
|
||||
extern const std::string HEX_FILE_STR;
|
||||
extern const std::string PACKAGE_STR;
|
||||
extern const std::string PACKAGES_STR;
|
||||
extern const std::string OVERLAY_STR;
|
||||
extern const std::string OVERLAYS_STR;
|
||||
extern const std::string IN_OVERLAY_STR;
|
||||
extern const std::string IN_HIDDEN_OVERLAY_STR;
|
||||
extern const std::string IN_HIDDEN_PACKAGE_STR;
|
||||
extern const std::string FILE_STR;
|
||||
extern const std::string SYSTEM_STR;
|
||||
extern const std::string MODE_STR;
|
||||
extern const std::string GROUPING_STR;
|
||||
extern const std::string FOOTER_STR;
|
||||
extern const std::string TOGGLE_STR;
|
||||
extern const std::string LEFT_STR;
|
||||
extern const std::string RIGHT_STR;
|
||||
extern const std::string CENTER_STR;
|
||||
extern const std::string HIDE_STR;
|
||||
extern const std::string STAR_STR;
|
||||
extern const std::string PRIORITY_STR;
|
||||
extern const std::string ON_STR;
|
||||
extern const std::string OFF_STR;
|
||||
extern const std::string CAPITAL_ON_STR;
|
||||
extern const std::string CAPITAL_OFF_STR;
|
||||
extern const std::string TRUE_STR;
|
||||
extern const std::string FALSE_STR;
|
||||
extern const std::string GLOBAL_STR;
|
||||
extern const std::string DEFAULT_STR;
|
||||
extern const std::string HOLD_STR;
|
||||
extern const std::string SLOT_STR;
|
||||
extern const std::string OPTION_STR;
|
||||
extern const std::string FORWARDER_STR;
|
||||
extern const std::string TEXT_STR;
|
||||
extern const std::string TABLE_STR;
|
||||
extern const std::string TRACKBAR_STR;
|
||||
extern const std::string STEP_TRACKBAR_STR;
|
||||
extern const std::string NAMED_STEP_TRACKBAR_STR;
|
||||
extern const std::string NULL_STR;
|
||||
extern const std::string THEME_STR;
|
||||
extern const std::string NOT_AVAILABLE_STR;
|
||||
extern const std::string MEMORY_STR;
|
||||
|
||||
// Pre-defined symbols
|
||||
extern const std::string OPTION_SYMBOL;
|
||||
extern const std::string DROPDOWN_SYMBOL;
|
||||
extern const std::string CHECKMARK_SYMBOL;
|
||||
extern const std::string CROSSMARK_SYMBOL;
|
||||
extern const std::string DOWNLOAD_SYMBOL;
|
||||
extern const std::string UNZIP_SYMBOL;
|
||||
extern const std::string COPY_SYMBOL;
|
||||
extern const std::string INPROGRESS_SYMBOL;
|
||||
extern const std::string STAR_SYMBOL;
|
||||
extern const std::string DIVIDER_SYMBOL;
|
||||
extern const std::string NOTIFY_HEADER;
|
||||
|
||||
extern const std::vector<std::string> THROBBER_SYMBOLS;
|
||||
|
||||
extern std::atomic<int> downloadPercentage;
|
||||
extern std::atomic<int> unzipPercentage;
|
||||
extern std::atomic<int> copyPercentage;
|
||||
extern std::atomic<int> displayPercentage;
|
||||
|
||||
void resetPercentages();
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: haptics.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header declares functions and shared flags for managing haptic feedback
|
||||
* in the Ultrahand Overlay. It includes routines for initializing vibration
|
||||
* devices, sending rumble and double-click patterns, and controlling timing
|
||||
* for single and double pulse haptics. Atomic flags ensure safe access across
|
||||
* threads.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
namespace ult {
|
||||
|
||||
//extern bool rumbleInitialized;
|
||||
extern std::atomic<bool> clickActive;
|
||||
extern std::atomic<bool> doubleClickActive;
|
||||
|
||||
void initHaptics();
|
||||
void deinitHaptics();
|
||||
void checkAndReinitHaptics();
|
||||
|
||||
void rumbleClick();
|
||||
void rumbleDoubleClick();
|
||||
void processRumbleStop(u64 nowNs);
|
||||
void processRumbleDoubleClick(u64 nowNs);
|
||||
void rumbleDoubleClickStandalone();
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: hex_funcs.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header file provides functions for working with hexadecimal data in C++.
|
||||
* It includes functions for converting between ASCII and hexadecimal strings,
|
||||
* finding hexadecimal data offsets in a file, and editing hexadecimal data in a file.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2023-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef HEX_FUNCS_HPP
|
||||
#define HEX_FUNCS_HPP
|
||||
|
||||
#if !USING_FSTREAM_DIRECTIVE // For not using fstream (needs implementing)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
//#include <cstdio> // Added for FILE and fopen
|
||||
#include <cstring> // Added for std::memcmp
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
|
||||
#include <global_vars.hpp>
|
||||
#include <debug_funcs.hpp>
|
||||
#include <string_funcs.hpp>
|
||||
|
||||
|
||||
namespace ult {
|
||||
extern size_t HEX_BUFFER_SIZE;
|
||||
|
||||
|
||||
// For improving the speed of hexing consecutively with the same file and asciiPattern.
|
||||
extern std::unordered_map<std::string, std::string> hexSumCache; // MOVED TO main.cpp
|
||||
|
||||
// Lookup table for hex characters
|
||||
inline constexpr char hexLookup[] = "0123456789ABCDEF";
|
||||
|
||||
|
||||
// ULTRA-FAST hex conversion with lookup table
|
||||
inline constexpr unsigned char hexTable[256] = {
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,
|
||||
0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
|
||||
extern void clearHexSumCache();
|
||||
extern size_t getHexSumCacheSize();
|
||||
|
||||
/**
|
||||
* @brief Converts an ASCII string to a hexadecimal string.
|
||||
*
|
||||
* This function takes an ASCII string as input and converts it into a hexadecimal string.
|
||||
*
|
||||
* @param asciiStr The ASCII string to convert.
|
||||
* @return The corresponding hexadecimal string.
|
||||
*/
|
||||
|
||||
|
||||
// Function to convert ASCII string to Hex string
|
||||
std::string asciiToHex(const std::string& asciiStr);
|
||||
|
||||
/**
|
||||
* @brief Converts a decimal string to a hexadecimal string.
|
||||
*
|
||||
* This function takes a decimal string as input and converts it into a hexadecimal string.
|
||||
*
|
||||
* @param decimalStr The decimal string to convert.
|
||||
* @return The corresponding hexadecimal string.
|
||||
*/
|
||||
std::string decimalToHex(const std::string& decimalStr, int byteGroupSize = 2);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Converts a hexadecimal string to a decimal string.
|
||||
*
|
||||
* This function takes a hexadecimal string as input and converts it into a decimal string.
|
||||
*
|
||||
* @param hexStr The hexadecimal string to convert.
|
||||
* @return The corresponding decimal string.
|
||||
*/
|
||||
std::string hexToDecimal(const std::string& hexStr);
|
||||
|
||||
|
||||
|
||||
std::string hexToReversedHex(const std::string& hexadecimal, int order = 2);
|
||||
|
||||
/**
|
||||
* @brief Converts a decimal string to a reversed hexadecimal string.
|
||||
*
|
||||
* This function takes a decimal string as input, converts it into a hexadecimal
|
||||
* string, and reverses the resulting hexadecimal string in groups of byteGroupSize.
|
||||
*
|
||||
* @param decimalStr The decimal string to convert.
|
||||
* @param byteGroupSize The grouping byteGroupSize for reversing the hexadecimal string.
|
||||
* @return The reversed hexadecimal string.
|
||||
*/
|
||||
std::string decimalToReversedHex(const std::string& decimalStr, int byteGroupSize = 2);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Finds the offsets of hexadecimal data in a file.
|
||||
*
|
||||
* This function searches for occurrences of hexadecimal data in a binary file
|
||||
* and returns the file offsets where the data is found.
|
||||
*
|
||||
* @param filePath The path to the binary file.
|
||||
* @param hexData The hexadecimal data to search for.
|
||||
* @return A vector of strings containing the file offsets where the data is found.
|
||||
*/
|
||||
std::vector<std::string> findHexDataOffsets(const std::string& filePath, const std::string& hexData);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Edits hexadecimal data in a file at a specified offset.
|
||||
*
|
||||
* This function opens a binary file, seeks to a specified offset, and replaces
|
||||
* the data at that offset with the provided hexadecimal data.
|
||||
*
|
||||
* @param filePath The path to the binary file.
|
||||
* @param offsetStr The offset in the file to performthe edit.
|
||||
* @param hexData The hexadecimal data to replace at the offset.
|
||||
*/
|
||||
void hexEditByOffset(const std::string& filePath, const std::string& offsetStr, const std::string& hexData);
|
||||
|
||||
/**
|
||||
* @brief Edits a specific offset in a file with custom hexadecimal data.
|
||||
*
|
||||
* This function searches for a custom pattern in the file and calculates a new offset
|
||||
* based on user-provided offsetStr and the found pattern. It then replaces the data
|
||||
* at the calculated offset with the provided hexadecimal data.
|
||||
*
|
||||
* @param filePath The path to the binary file.
|
||||
* @param offsetStr The user-provided offset for the edit.
|
||||
* @param customPattern The custom pattern to search for in the file.
|
||||
* @param hexDataReplacement The hexadecimal data to replace at the calculated offset.
|
||||
* @param occurrence The occurrence/index of the data to replace (default is "0" to replace all occurrences).
|
||||
*/
|
||||
void hexEditByCustomOffset(const std::string& filePath, const std::string& customAsciiPattern, const std::string& offsetStr, const std::string& hexDataReplacement, size_t occurrence = 0);
|
||||
|
||||
/**
|
||||
* @brief Finds and replaces hexadecimal data in a file.
|
||||
*
|
||||
* This function searches for occurrences of hexadecimal data in a binary file
|
||||
* and replaces them with a specified hexadecimal replacement data.
|
||||
*
|
||||
* @param filePath The path to the binary file.
|
||||
* @param hexDataToReplace The hexadecimal data to search for and replace.
|
||||
* @param hexDataReplacement The hexadecimal data to replace with.
|
||||
* @param occurrence The occurrence/index of the data to replace (default is "0" to replace all occurrences).
|
||||
*/
|
||||
void hexEditFindReplace(const std::string& filePath, const std::string& hexDataToReplace, const std::string& hexDataReplacement, size_t occurrence = 0);
|
||||
|
||||
/**
|
||||
* @brief Finds and replaces hexadecimal data in a file.
|
||||
*
|
||||
* This function searches for occurrences of hexadecimal data in a binary file
|
||||
* and replaces them with a specified hexadecimal replacement data.
|
||||
*
|
||||
* @param filePath The path to the binary file.
|
||||
* @param hexDataToReplace The hexadecimal data to search for and replace.
|
||||
* @param hexDataReplacement The hexadecimal data to replace with.
|
||||
* @param occurrence The occurrence/index of the data to replace (default is "0" to replace all occurrences).
|
||||
*/
|
||||
std::string parseHexDataAtCustomOffset(const std::string& filePath, const std::string& customAsciiPattern, const std::string& offsetStr, size_t length, size_t occurrence = 0);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Finds and replaces hexadecimal data in a file.
|
||||
*
|
||||
* This function searches for occurrences of hexadecimal data in a binary file
|
||||
* and replaces them with a specified hexadecimal replacement data.
|
||||
*
|
||||
* @param filePath The path to the binary file.
|
||||
* @param hexDataToReplace The hexadecimal data to search for and replace.
|
||||
* @param hexDataReplacement The hexadecimal data to replace with.
|
||||
* @param occurrence The occurrence/index of the data to replace (default is "0" to replace all occurrences).
|
||||
*/
|
||||
|
||||
std::string replaceHexPlaceholder(const std::string& arg, const std::string& hexPath);
|
||||
|
||||
|
||||
|
||||
std::string extractVersionFromBinary(const std::string &filePath);
|
||||
|
||||
|
||||
std::string decodeBase64ToString(const std::string& b64);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,374 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: ini_funcs.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header file provides functions for working with INI (Initialization) files
|
||||
* in C++. It includes functions for reading, parsing, and editing INI files,
|
||||
* as well as cleaning INI file formatting.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2023-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef INI_FUNCS_HPP
|
||||
#define INI_FUNCS_HPP
|
||||
|
||||
#if !USING_FSTREAM_DIRECTIVE // For not using fstream (needs implementing)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <fstream>
|
||||
//#include "nx_fstream.hpp"
|
||||
#endif
|
||||
|
||||
#include <cstring> // For std::string, strlen(), etc.
|
||||
#include <string> // For std::string
|
||||
#include <vector> // For std::vector
|
||||
#include <map> // For std::map
|
||||
//#include <sstream> // For std::istringstream
|
||||
#include <algorithm> // For std::remove_if
|
||||
//#include <cctype> // For ::isspace
|
||||
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
#include <mutex>
|
||||
|
||||
#include "get_funcs.hpp"
|
||||
#include "path_funcs.hpp"
|
||||
|
||||
namespace ult {
|
||||
|
||||
extern void clearIniMutexCache();
|
||||
|
||||
extern size_t INI_BUFFER_SIZE;
|
||||
extern size_t INI_BUFFER_LARGE;
|
||||
|
||||
/**
|
||||
* @brief Represents a package header structure.
|
||||
*
|
||||
* This structure holds information about a package header, including version,
|
||||
* creator, and description.
|
||||
*/
|
||||
struct PackageHeader {
|
||||
std::string title;
|
||||
std::string display_title;
|
||||
std::string version;
|
||||
std::string creator;
|
||||
std::string about;
|
||||
std::string credits;
|
||||
std::string color;
|
||||
std::string show_version;
|
||||
std::string show_widget;
|
||||
|
||||
void clear() {
|
||||
title.clear();
|
||||
display_title.clear();
|
||||
version.clear();
|
||||
creator.clear();
|
||||
about.clear();
|
||||
credits.clear();
|
||||
color.clear();
|
||||
show_version.clear();
|
||||
show_widget.clear();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Retrieves the package header information from an INI file.
|
||||
*
|
||||
* This function parses an INI file and extracts the package header information.
|
||||
*
|
||||
* @param filePath The path to the INI file.
|
||||
* @return The package header structure.
|
||||
*/
|
||||
PackageHeader getPackageHeaderFromIni(const std::string& filePath);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Splits a string into a vector of substrings using a specified delimiter.
|
||||
*
|
||||
* This function splits a given string into multiple substrings based on the specified delimiter.
|
||||
*
|
||||
* @param str The input string to be split.
|
||||
* @param delim The delimiter character used for splitting (default is space ' ').
|
||||
* @return A vector of substrings obtained by splitting the input string.
|
||||
*/
|
||||
std::vector<std::string> split(const std::string& str, char delim = ' ');
|
||||
|
||||
|
||||
/**
|
||||
* @brief Parses an INI-formatted string into a map of sections and key-value pairs.
|
||||
*
|
||||
* This function parses an INI-formatted string and organizes the data into a map,
|
||||
* where sections are keys and key-value pairs are stored within each section.
|
||||
*
|
||||
* @param str The INI-formatted string to parse.
|
||||
* @return A map representing the parsed INI data.
|
||||
*/
|
||||
std::map<std::string, std::map<std::string, std::string>> parseIni(const std::string &str);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Parses an INI file and returns its content as a map of sections and key-value pairs.
|
||||
*
|
||||
* This function reads the contents of an INI file located at the specified path,
|
||||
* parses it into a map structure, where section names are keys and key-value pairs
|
||||
* are stored within each section.
|
||||
*
|
||||
* @param configIniPath The path to the INI file to be parsed.
|
||||
* @return A map representing the parsed INI data.
|
||||
*/
|
||||
std::map<std::string, std::map<std::string, std::string>> getParsedDataFromIniFile(const std::string& configIniPath);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Parses an INI file and retrieves key-value pairs from a specific section.
|
||||
*
|
||||
* This function reads the contents of an INI file located at the specified path,
|
||||
* and returns the key-value pairs within a specific section.
|
||||
*
|
||||
* @param configIniPath The path to the INI file to be parsed.
|
||||
* @param sectionName The name of the section to retrieve key-value pairs from.
|
||||
* @return A map representing the key-value pairs in the specified section.
|
||||
*/
|
||||
std::map<std::string, std::string> getKeyValuePairsFromSection(const std::string& configIniPath, const std::string& sectionName);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Parses sections from an INI file and returns them as a list of strings.
|
||||
*
|
||||
* This function reads an INI file and extracts the section names from it.
|
||||
*
|
||||
* @param filePath The path to the INI file.
|
||||
* @return A vector of section names.
|
||||
*/
|
||||
std::vector<std::string> parseSectionsFromIni(const std::string& filePath);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Parses a specific value from a section and key in an INI file.
|
||||
*
|
||||
* @param filePath The path to the INI file.
|
||||
* @param sectionName The name of the section containing the desired key.
|
||||
* @param keyName The name of the key whose value is to be retrieved.
|
||||
* @return The value as a string, or an empty string if the key or section isn't found.
|
||||
*/
|
||||
std::string parseValueFromIniSection(const std::string& filePath, const std::string& sectionName, const std::string& keyName);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Cleans the formatting of an INI file by removing empty lines and standardizing section formatting.
|
||||
*
|
||||
* This function takes an INI file located at the specified path, removes empty lines,
|
||||
* and standardizes the formatting of sections by ensuring that there is a newline
|
||||
* between each section's closing ']' and the next section's opening '['.
|
||||
*
|
||||
* @param filePath The path to the INI file to be cleaned.
|
||||
*/
|
||||
void cleanIniFormatting(const std::string& filePath);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Modifies or creates an INI file by adding or updating key-value pairs in the specified section.
|
||||
*
|
||||
* This function attempts to open the specified INI file for reading. If the file doesn't exist,
|
||||
* it creates a new file and adds the specified section and key-value pair. If the file exists,
|
||||
* it reads its contents, modifies or adds the key-value pair in the specified section, and saves
|
||||
* the changes back to the original file.
|
||||
*
|
||||
* @param fileToEdit The path to the INI file to be modified or created.
|
||||
* @param desiredSection The name of the section in which the key-value pair should be added or updated.
|
||||
* @param desiredKey The key for the key-value pair to be added or updated.
|
||||
* @param desiredValue The new value for the key-value pair.
|
||||
* @param desiredNewKey (Optional) If provided, the function will rename the key while preserving the original value.
|
||||
*/
|
||||
void setIniFile(const std::string& fileToEdit, const std::string& desiredSection, const std::string& desiredKey, const std::string& desiredValue, const std::string& desiredNewKey = "", const std::string& comment = "");
|
||||
|
||||
|
||||
/**
|
||||
* @brief Sets the value of a key in an INI file within the specified section and cleans the formatting.
|
||||
*
|
||||
* This function sets the value of the specified key within the given section of the INI file.
|
||||
* If the key or section does not exist, it creates them. After updating the INI file,
|
||||
* it cleans the formatting to ensure proper INI file structure.
|
||||
*
|
||||
* @param fileToEdit The path to the INI file to be modified or created.
|
||||
* @param desiredSection The name of the section in which the key-value pair should be added or updated.
|
||||
* @param desiredKey The key for the key-value pair to be added or updated.
|
||||
* @param desiredValue The new value for the key-value pair.
|
||||
*/
|
||||
void setIniFileValue(const std::string& fileToEdit, const std::string& desiredSection, const std::string& desiredKey, const std::string& desiredValue, const std::string& comment="");
|
||||
|
||||
/**
|
||||
* @brief Sets the key name to a new name in an INI file within the specified section and cleans the formatting.
|
||||
*
|
||||
* This function sets the key name to a new name within the given section of the INI file.
|
||||
* If the key or section does not exist, it creates them. After updating the INI file,
|
||||
* it cleans the formatting to ensure proper INI file structure.
|
||||
*
|
||||
* @param fileToEdit The path to the INI file to be modified or created.
|
||||
* @param desiredSection The name of the section in which the key-name change should occur.
|
||||
* @param desiredKey The key name to be changed.
|
||||
* @param desiredNewKey The new key name to replace the original key name.
|
||||
*/
|
||||
void setIniFileKey(const std::string& fileToEdit, const std::string& desiredSection, const std::string& desiredKey, const std::string& desiredNewKey, const std::string& comment="");
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Adds a new section to an INI file.
|
||||
*
|
||||
* This function adds a new section with the specified name to the INI file located at the
|
||||
* specified path. If the section already exists, it does nothing.
|
||||
*
|
||||
* @param filePath The path to the INI file.
|
||||
* @param sectionName The name of the section to add.
|
||||
*/
|
||||
void addIniSection(const std::string& filePath, const std::string& sectionName);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Renames a section in an INI file.
|
||||
*
|
||||
* This function renames the section with the specified current name to the specified new name
|
||||
* in the INI file located at the specified path. If the current section does not exist, or if the
|
||||
* new section name already exists, it does nothing.
|
||||
*
|
||||
* @param filePath The path to the INI file.
|
||||
* @param currentSectionName The name of the section to rename.
|
||||
* @param newSectionName The new name for the section.
|
||||
*/
|
||||
void renameIniSection(const std::string& filePath, const std::string& currentSectionName, const std::string& newSectionName);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Removes a section from an INI file.
|
||||
*
|
||||
* This function removes the section with the specified name, including all its associated key-value
|
||||
* pairs, from the INI file located at the specified path. If the section does not exist in the file,
|
||||
* it does nothing.
|
||||
*
|
||||
* @param filePath The path to the INI file.
|
||||
* @param sectionName The name of the section to remove.
|
||||
*/
|
||||
void removeIniSection(const std::string& filePath, const std::string& sectionName);
|
||||
|
||||
|
||||
// Removes a key-value pair from an ini accordingly.
|
||||
void removeIniKey(const std::string& filePath, const std::string& sectionName, const std::string& keyName);
|
||||
|
||||
|
||||
//void saveIniFileData(const std::string& filePath, const std::map<std::string, std::map<std::string, std::string>>& data) {
|
||||
// std::ofstream file(filePath);
|
||||
// if (!file.is_open()) {
|
||||
// // Handle error: could not open file
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// for (const auto& section : data) {
|
||||
// file << "[" << section.first << "]\n";
|
||||
// for (const auto& kv : section.second) {
|
||||
// file << kv.first << "=" << kv.second << "\n";
|
||||
// }
|
||||
// file << "\n"; // Separate sections with a newline
|
||||
// }
|
||||
//
|
||||
// file.close();
|
||||
//}
|
||||
|
||||
|
||||
bool syncIniValue(std::map<std::string, std::map<std::string, std::string>>& packageConfigData,
|
||||
const std::string& packageConfigIniPath,
|
||||
const std::string& optionName,
|
||||
const std::string& key,
|
||||
std::string& value);
|
||||
|
||||
/**
|
||||
* @brief Parses a command line into individual parts, handling quoted strings.
|
||||
*
|
||||
* @param line The command line to parse.
|
||||
* @return A vector of strings containing the parsed command parts.
|
||||
*/
|
||||
std::vector<std::string> parseCommandLine(const std::string& line);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Loads and parses options from an INI file.
|
||||
*
|
||||
* This function reads and parses options from an INI file, organizing them by section.
|
||||
*
|
||||
* @param packageIniPath The path to the INI file.
|
||||
* @return A vector containing pairs of section names and their associated key-value pairs.
|
||||
*/
|
||||
std::vector<std::pair<std::string, std::vector<std::vector<std::string>>>> loadOptionsFromIni(const std::string& packageIniPath);
|
||||
|
||||
/**
|
||||
* @brief Loads a specific section from an INI file.
|
||||
*
|
||||
* This function reads and parses a specific section from an INI file.
|
||||
*
|
||||
* @param packageIniPath The path to the INI file.
|
||||
* @param sectionName The name of the section to load.
|
||||
* @return A vector of commands within the specified section.
|
||||
*/
|
||||
std::vector<std::vector<std::string>> loadSpecificSectionFromIni(const std::string& packageIniPath, const std::string& sectionName);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Saves INI data structure to a file.
|
||||
*
|
||||
* This function writes a complete INI data structure to the specified file path.
|
||||
* The data structure should be organized as sections containing key-value pairs.
|
||||
*
|
||||
* @param filePath The path to the INI file to write.
|
||||
* @param data The complete INI data structure to save.
|
||||
*/
|
||||
void saveIniFileData(const std::string& filePath, const std::map<std::string, std::map<std::string, std::string>>& data);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Adds a key-value pair to all sections that contain a specified pattern key.
|
||||
*
|
||||
* If patternKey is empty, the key-value pair will be added to ALL sections.
|
||||
* If patternKey is specified, only sections containing that key will be modified.
|
||||
*
|
||||
* @param filePath The path to the INI file.
|
||||
* @param patternKey The key to search for (empty = all sections).
|
||||
* @param newKey The new key to add.
|
||||
* @param newValue The value for the new key.
|
||||
*/
|
||||
void addKeyToMatchingSections(const std::string& filePath, const std::string& patternKey,
|
||||
const std::string& newKey, const std::string& newValue);
|
||||
|
||||
/**
|
||||
* @brief Removes a key from all sections that contain a specified pattern key.
|
||||
*
|
||||
* If patternKey is empty, the key will be removed from ALL sections.
|
||||
* If patternKey is specified, only sections containing that key will have keyToRemove deleted.
|
||||
*
|
||||
* @param filePath The path to the INI file.
|
||||
* @param patternKey The key to search for (empty = all sections).
|
||||
* @param keyToRemove The key to remove from matching sections.
|
||||
*/
|
||||
void removeKeyFromMatchingSections(const std::string& filePath, const std::string& patternKey,
|
||||
const std::string& keyToRemove);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,108 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: json_funcs.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header file provides functions for working with JSON files in C++ using
|
||||
* the `cJSON` library. It includes a function to read JSON data from a file.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2023-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef JSON_FUNCS_HPP
|
||||
#define JSON_FUNCS_HPP
|
||||
#if !USING_FSTREAM_DIRECTIVE // For not using fstream (needs implementing)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <fstream>
|
||||
#endif
|
||||
#include <string>
|
||||
#include <cJSON.h>
|
||||
#include "string_funcs.hpp"
|
||||
#include <switch.h>
|
||||
|
||||
namespace ult {
|
||||
// Define json_t as an opaque type to maintain API compatibility
|
||||
typedef void json_t;
|
||||
|
||||
// Define a custom deleter for json_t*
|
||||
struct JsonDeleter {
|
||||
void operator()(json_t* json) const {
|
||||
if (json) {
|
||||
cJSON_Delete(reinterpret_cast<cJSON*>(json));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads JSON data from a file and returns it as a `json_t` object.
|
||||
*
|
||||
* @param filePath The path to the JSON file.
|
||||
* @return A `json_t` object representing the parsed JSON data. Returns `nullptr` on error.
|
||||
*/
|
||||
json_t* readJsonFromFile(const std::string& filePath);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Parses a JSON string into a json_t object.
|
||||
*
|
||||
* This function takes a JSON string as input and parses it into a json_t object using cJSON library's `cJSON_Parse` function.
|
||||
* If parsing fails, it logs the error and returns nullptr.
|
||||
*
|
||||
* @param input The input JSON string to parse.
|
||||
* @return A json_t object representing the parsed JSON, or nullptr if parsing fails.
|
||||
*/
|
||||
json_t* stringToJson(const std::string& input);
|
||||
|
||||
|
||||
// Function to get a string from a JSON object
|
||||
std::string getStringFromJson(const json_t* root, const char* key);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Loads a JSON file from the specified path and retrieves a string value for a given key.
|
||||
*
|
||||
* This function combines the functionality of loading a JSON file and retrieving a string value associated
|
||||
* with a given key in a single step.
|
||||
*
|
||||
* @param filePath The path to the JSON file.
|
||||
* @param key The key whose associated string value is to be retrieved.
|
||||
* @return A string containing the value associated with the given key, or an empty string if the key is not found.
|
||||
*/
|
||||
std::string getStringFromJsonFile(const std::string& filePath, const std::string& key);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Sets a value in a JSON file, creating the file if it doesn't exist.
|
||||
*
|
||||
* @param filePath The path to the JSON file.
|
||||
* @param key The key to set.
|
||||
* @param value The value to set (auto-detected type).
|
||||
* @param createIfNotExists Whether to create the file if it doesn't exist.
|
||||
* @return true if successful, false otherwise.
|
||||
*/
|
||||
bool setJsonValue(const std::string& filePath, const std::string& key, const std::string& value, bool createIfNotExists = false);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Renames a key in a JSON file.
|
||||
*
|
||||
* @param filePath The path to the JSON file.
|
||||
* @param oldKey The current key name.
|
||||
* @param newKey The new key name.
|
||||
* @return true if successful, false otherwise.
|
||||
*/
|
||||
bool renameJsonKey(const std::string& filePath, const std::string& oldKey, const std::string& newKey);
|
||||
|
||||
|
||||
void pushNotificationJson(const std::string& appID, const std::string& text, size_t fontSize=28);
|
||||
}
|
||||
#endif
|
||||
@@ -1,110 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: list_funcs.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header file contains function declarations and utility functions related
|
||||
* to working with lists and vectors of strings. These functions are used in the
|
||||
* Ultrahand Overlay project to perform various operations on lists, such as
|
||||
* removing entries, filtering, and more.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2023-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef LIST_FUNCS_HPP
|
||||
#define LIST_FUNCS_HPP
|
||||
|
||||
#if !USING_FSTREAM_DIRECTIVE // For not using fstream (needs implementing)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include "debug_funcs.hpp"
|
||||
#include "string_funcs.hpp"
|
||||
#include "get_funcs.hpp"
|
||||
|
||||
|
||||
namespace ult {
|
||||
|
||||
std::vector<std::string> splitIniList(const std::string& value);
|
||||
|
||||
|
||||
std::string joinIniList(const std::vector<std::string>& list);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Removes entries from a vector of strings that match a specified entry.
|
||||
*
|
||||
* This function removes entries from the `itemsList` vector of strings that match the `entry`.
|
||||
*
|
||||
* @param entry The entry to be compared against the elements in `itemsList`.
|
||||
* @param itemsList The vector of strings from which matching entries will be removed.
|
||||
*/
|
||||
void removeEntryFromList(const std::string& entry, std::vector<std::string>& itemsList);
|
||||
|
||||
/**
|
||||
* @brief Filters a list of strings based on a specified filter list.
|
||||
*
|
||||
* This function filters a list of strings (`itemsList`) by removing entries that match any
|
||||
* of the criteria specified in the `filterList`. It uses the `removeEntryFromList` function
|
||||
* to perform the removal.
|
||||
*
|
||||
* @param filterList The list of entries to filter by. Entries in `itemsList` matching any entry in this list will be removed.
|
||||
* @param itemsList The list of stringsto be filtered.
|
||||
*/
|
||||
void filterItemsList(const std::vector<std::string>& filterList, std::vector<std::string>& itemsList);
|
||||
|
||||
|
||||
// Function to read file into a vector of strings
|
||||
std::vector<std::string> readListFromFile(const std::string& filePath, size_t maxLines=0, bool preserveNewlines = false);
|
||||
|
||||
|
||||
// Function to get an entry from the list based on the index
|
||||
std::string getEntryFromListFile(const std::string& listPath, size_t listIndex);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Splits a string into a vector of strings using a delimiter.
|
||||
*
|
||||
* This function splits the input string into multiple strings using the specified delimiter.
|
||||
*
|
||||
* @param str The input string to split.
|
||||
* @return A vector of strings containing the split values.
|
||||
*/
|
||||
std::vector<std::string> stringToList(const std::string& str);
|
||||
|
||||
|
||||
// Function to read file into a set of strings
|
||||
std::unordered_set<std::string> readSetFromFile(const std::string& filePath, const std::string& packagePath = "");
|
||||
|
||||
|
||||
// Function to write a set to a file
|
||||
void writeSetToFile(const std::unordered_set<std::string>& fileSet, const std::string& filePath);
|
||||
|
||||
|
||||
// Function to compare two file lists and save duplicates to an output file
|
||||
void compareFilesLists(const std::string& txtFilePath1, const std::string& txtFilePath2, const std::string& outputTxtFilePath);
|
||||
|
||||
|
||||
// Helper function to read a text file and process each line with a callback
|
||||
//void processFileLines(const std::string& filePath, const std::function<void(const std::string&)>& callback);
|
||||
|
||||
|
||||
void compareWildcardFilesLists(const std::string& wildcardPatternFilePath, const std::string& txtFilePath, const std::string& outputTxtFilePath);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,121 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: mod_funcs.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header file contains function declarations and utility functions for IPS
|
||||
* binary generations. These functions are used in the Ultrahand Overlay project
|
||||
* to convert `.pchtxt` mods into `.ips` binaries.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2024-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MOD_FUNCS_HPP
|
||||
#define MOD_FUNCS_HPP
|
||||
|
||||
#if !USING_FSTREAM_DIRECTIVE // For not using fstream (needs implementing)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
//#include <sstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include "debug_funcs.hpp"
|
||||
#include "path_funcs.hpp"
|
||||
#include "hex_funcs.hpp"
|
||||
#include <iomanip> // Include this header for std::setw and std::setfill
|
||||
|
||||
namespace ult {
|
||||
inline constexpr const char* IPS32_HEAD_MAGIC = "IPS32";
|
||||
inline constexpr const char* IPS32_FOOT_MAGIC = "EEOF";
|
||||
|
||||
//const std::string CHEAT_HEADER = "// auto generated by pchtxt2cheat\n\n";
|
||||
//extern const std::string CHEAT_TYPE;
|
||||
//extern const std::string CHEAT_EXT;
|
||||
//extern const std::string CHEAT_ENCODING;
|
||||
|
||||
/**
|
||||
* @brief Checks if a cheat already exists in the cheat file.
|
||||
* @param cheatFilePath The path to the cheat file.
|
||||
* @param newCheat The new cheat to check.
|
||||
* @return True if the cheat exists, otherwise false.
|
||||
*/
|
||||
bool cheatExists(const std::string &cheatFilePath, const std::string &newCheat);
|
||||
|
||||
/**
|
||||
* @brief Appends a new cheat to the cheat file.
|
||||
* @param cheatFilePath The path to the cheat file.
|
||||
* @param newCheat The new cheat to append.
|
||||
*/
|
||||
void appendCheatToFile(const std::string &cheatFilePath, const std::string &newCheat);
|
||||
|
||||
/**
|
||||
* @brief Extracts the cheat name from the given file path.
|
||||
* @param filePath The full file path.
|
||||
* @return The extracted cheat name.
|
||||
*/
|
||||
std::string extractCheatName(const std::string &filePath);
|
||||
|
||||
// Helper function to determine if a string is a valid title ID
|
||||
bool isValidTitleID(const std::string &str);
|
||||
|
||||
// Function to find the title ID in the text, avoiding the @nsobid- line
|
||||
std::string findTitleID(const std::string &text);
|
||||
|
||||
/**
|
||||
* @brief Converts a .pchtxt file to a cheat file.
|
||||
* @param pchtxtPath The file path to the .pchtxt file.
|
||||
* @param cheatName The name of the cheat.
|
||||
* @param outCheatPath The file path for the output cheat file.
|
||||
* @return True if the conversion was successful, false otherwise.
|
||||
*/
|
||||
bool pchtxt2cheat(const std::string &pchtxtPath, std::string cheatName = "", std::string outCheatPath = "");
|
||||
|
||||
// Corrected helper function to convert values to big-endian format
|
||||
//uint32_t toBigEndian(uint32_t value);
|
||||
//
|
||||
//uint16_t toBigEndian(uint16_t value);
|
||||
|
||||
// Corrected helper function to convert values to big-endian format
|
||||
inline uint32_t toBigEndian(uint32_t value) {
|
||||
return ((value & 0x000000FF) << 24) |
|
||||
((value & 0x0000FF00) << 8) |
|
||||
((value & 0x00FF0000) >> 8) |
|
||||
((value & 0xFF000000) >> 24);
|
||||
}
|
||||
|
||||
inline uint16_t toBigEndian(uint16_t value) {
|
||||
return ((value & 0x00FF) << 8) |
|
||||
((value & 0xFF00) >> 8);
|
||||
}
|
||||
|
||||
// Helper function to convert a vector of bytes to a hex string for logging
|
||||
|
||||
//std::string hexToString(const std::vector<uint8_t>& bytes);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Converts a .pchtxt file to an IPS file using fstream.
|
||||
*
|
||||
* This function reads the contents of a .pchtxt file, extracts the address-value pairs,
|
||||
* and generates an IPS file with the provided output folder.
|
||||
*
|
||||
* @param pchtxtPath The file path to the .pchtxt file.
|
||||
* @param outputFolder The folder path for the output IPS file.
|
||||
* @return True if the conversion was successful, false otherwise.
|
||||
*/
|
||||
bool pchtxt2ips(const std::string& pchtxtPath, const std::string& outputFolder);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,288 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: path_funcs.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header file contains function declarations and utility functions related
|
||||
* to file and directory path manipulation. These functions are used in the
|
||||
* Ultrahand Overlay project to handle file operations, such as creating
|
||||
* directories, moving files, and more.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2023-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef PATH_FUNCS_HPP
|
||||
#define PATH_FUNCS_HPP
|
||||
|
||||
#if !USING_FSTREAM_DIRECTIVE // For not using fstream (needs implementing)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include "global_vars.hpp"
|
||||
#include "string_funcs.hpp"
|
||||
#include "get_funcs.hpp"
|
||||
#include <queue>
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
|
||||
namespace ult {
|
||||
extern std::atomic<bool> abortFileOp;
|
||||
|
||||
extern size_t COPY_BUFFER_SIZE; // Made const for thread safety
|
||||
extern std::atomic<int> copyPercentage;
|
||||
|
||||
// Mutex for thread-safe logging operations
|
||||
extern std::mutex logMutex;
|
||||
|
||||
/**
|
||||
* @brief Checks if a path points to a directory.
|
||||
*
|
||||
* This function checks if the specified path points to a directory.
|
||||
*
|
||||
* @param path The path to check.
|
||||
* @return True if the path is a directory, false otherwise.
|
||||
*/
|
||||
bool isDirectory(const std::string& path);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Checks if a path points to a file.
|
||||
*
|
||||
* This function checks if the specified path points to a file.
|
||||
*
|
||||
* @param path The path to check.
|
||||
* @return True if the path is a file, false otherwise.
|
||||
*/
|
||||
bool isFile(const std::string& path);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Checks if a path points to a file or directory.
|
||||
*
|
||||
* This function checks if the specified path points to either a file or a directory.
|
||||
*
|
||||
* @param path The path to check.
|
||||
* @return True if the path points to a file or directory, false otherwise.
|
||||
*/
|
||||
bool isFileOrDirectory(const std::string& path);
|
||||
|
||||
|
||||
bool isDirectoryEmpty(const std::string& dirPath);
|
||||
|
||||
/**
|
||||
* @brief Creates a single directory if it doesn't exist.
|
||||
*
|
||||
* This function checks if the specified directory exists, and if not, it creates the directory.
|
||||
*
|
||||
* @param directoryPath The path of the directory to be created.
|
||||
*/
|
||||
void createSingleDirectory(const std::string& directoryPath);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Creates a directory and its parent directories if they don't exist.
|
||||
*
|
||||
* This function creates a directory specified by `directoryPath` and also creates any parent directories
|
||||
* if they don't exist. It handles nested directory creation.
|
||||
*
|
||||
* @param directoryPath The path of the directory to be created.
|
||||
*/
|
||||
void createDirectory(const std::string& directoryPath);
|
||||
|
||||
|
||||
#if !USING_FSTREAM_DIRECTIVE
|
||||
void writeLog(FILE* logFile, const std::string& line);
|
||||
#else
|
||||
void writeLog(std::ofstream& logFile, const std::string& line);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Creates a text file with the specified content.
|
||||
*
|
||||
* This function creates a text file specified by `filePath` and writes the given `content` to the file.
|
||||
*
|
||||
* @param filePath The path of the text file to be created.
|
||||
* @param content The content to be written to the text file.
|
||||
*/
|
||||
void createTextFile(const std::string& filePath, const std::string& content);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Deletes a file or directory.
|
||||
*
|
||||
* This function deletes the file or directory specified by `path`. It can delete both files and directories.
|
||||
*
|
||||
* @param path The path of the file or directory to be deleted.
|
||||
*/
|
||||
void deleteFileOrDirectory(const std::string& pathToDelete, const std::string& logSource = "");
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Deletes files or directories that match a specified pattern.
|
||||
*
|
||||
* This function deletes files or directories specified by `pathPattern` by matching against a pattern.
|
||||
* It identifies files or directories that match the pattern and deletes them.
|
||||
*
|
||||
* @param pathPattern The pattern used to match and delete files or directories.
|
||||
*/
|
||||
void deleteFileOrDirectoryByPattern(const std::string& pathPattern, const std::string& logSourc = "", const std::unordered_set<std::string>* filterSet = nullptr);
|
||||
|
||||
|
||||
void moveDirectory(const std::string& sourcePath, const std::string& destinationPath,
|
||||
const std::string& logSource = "", const std::string& logDestination = "");
|
||||
|
||||
|
||||
|
||||
bool moveFile(const std::string& sourcePath, const std::string& destinationPath,
|
||||
const std::string& logSource = "", const std::string& logDestination = "");
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Moves a file or directory to a new destination.
|
||||
*
|
||||
* This function moves a file or directory from the `sourcePath` to the `destinationPath`. It can handle both
|
||||
* files and directories and ensures that the destination directory exists before moving.
|
||||
*
|
||||
* @param sourcePath The path of the source file or directory.
|
||||
* @param destinationPath The path of the destination where the file or directory will be moved.
|
||||
*/
|
||||
void moveFileOrDirectory(const std::string& sourcePath, const std::string& destinationPath,
|
||||
const std::string& logSource = "", const std::string& logDestination = "");
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Moves files or directories matching a specified pattern to a destination directory.
|
||||
*
|
||||
* This function identifies files or directories that match the `sourcePathPattern` and moves them to the `destinationPath`.
|
||||
* It processes each matching entry in the source directory pattern and moves them to the specified destination.
|
||||
* Files/directories in the filterSet will be skipped.
|
||||
*
|
||||
* @param sourcePathPattern The pattern used to match files or directories to be moved.
|
||||
* @param destinationPath The destination directory where matching files or directories will be moved.
|
||||
* @param logSource Optional log source identifier.
|
||||
* @param logDestination Optional log destination identifier.
|
||||
* @param filterSet Optional set of paths to exclude from moving (nullptr to move all).
|
||||
*/
|
||||
void moveFilesOrDirectoriesByPattern(const std::string& sourcePathPattern, const std::string& destinationPath,
|
||||
const std::string& logSource = "", const std::string& logDestination = "", const std::unordered_set<std::string>* filterSet = nullptr);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Copies a single file from the source path to the destination path.
|
||||
*
|
||||
* This function copies a single file specified by `fromFile` to the location specified by `toFile`.
|
||||
*
|
||||
* @param fromFile The path of the source file to be copied.
|
||||
* @param toFile The path of the destination where the file will be copied.
|
||||
*/
|
||||
void copySingleFile(const std::string& fromFile, const std::string& toFile, long long& totalBytesCopied, const long long totalSize,
|
||||
const std::string& logSource = "", const std::string& logDestination = "");
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Recursively calculates the total size of the given file or directory.
|
||||
* @param path The path to the file or directory.
|
||||
* @return The total size in bytes of all files within the directory or the size of a file.
|
||||
*/
|
||||
long long getTotalSize(const std::string& path);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Copies a file or directory from the source path to the destination path.
|
||||
*
|
||||
* This function copies a file or directory specified by `fromFileOrDirectory` to the location specified by `toFileOrDirectory`.
|
||||
* If the source is a regular file, it copies the file to the destination. If the source is a directory, it recursively copies
|
||||
* the entire directory and its contents to the destination.
|
||||
*
|
||||
* @param fromPath The path of the source file or directory to be copied.
|
||||
* @param toPath The path of the destination where the file or directory will be copied.
|
||||
*/
|
||||
void copyFileOrDirectory(const std::string& fromPath, const std::string& toPath, long long* totalBytesCopied = nullptr, long long totalSize = 0,
|
||||
const std::string& logSource = "", const std::string& logDestination = "");
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Copies files or directories matching a specified pattern to a destination directory.
|
||||
*
|
||||
* This function identifies files or directories that match the `sourcePathPattern` and copies them to the `toDirectory`.
|
||||
* It processes each matching entry in the source directory pattern and copies them to the specified destination.
|
||||
* Files/directories in the filterSet will be skipped.
|
||||
*
|
||||
* @param sourcePathPattern The pattern used to match files or directories to be copied.
|
||||
* @param toDirectory The destination directory where matching files or directories will be copied.
|
||||
* @param logSource Optional log source identifier.
|
||||
* @param logDestination Optional log destination identifier.
|
||||
* @param filterSet Optional set of paths to exclude from copying (nullptr to copy all).
|
||||
*/
|
||||
void copyFileOrDirectoryByPattern(const std::string& sourcePathPattern, const std::string& toDirectory,
|
||||
const std::string& logSource = "", const std::string& logDestination = "", const std::unordered_set<std::string>* filterSet = nullptr);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Mirrors the deletion of files from a source directory to a target directory.
|
||||
*
|
||||
* This function mirrors the deletion of files from a `sourcePath` directory to a `targetPath` directory.
|
||||
* It deletes corresponding files in the `targetPath` that match the source directory structure.
|
||||
*
|
||||
* @param sourcePath The path of the source directory.
|
||||
* @param targetPath The path of the target directory where files will be mirrored and deleted.
|
||||
* Default is "sdmc:/". You can specify a different target path if needed.
|
||||
*/
|
||||
void mirrorFiles(const std::string& sourcePath, const std::string targetPath, const std::string mode);
|
||||
|
||||
|
||||
/**
|
||||
* @brief For each match of the wildcard pattern, creates an empty text file
|
||||
* named basename.txt inside the output directory.
|
||||
* Uses FILE* if !USING_FSTREAM_DIRECTIVE is defined, otherwise uses std::ofstream.
|
||||
*
|
||||
* @param wildcardPattern A path with a wildcard, such as /some/path/[*].
|
||||
* Each match results in a file named after the basename.
|
||||
* @param outputDir Directory where the output files will be written.
|
||||
* Created if it doesn't already exist.
|
||||
*/
|
||||
void createFlagFiles(const std::string& wildcardPattern, const std::string& outputDir);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Removes all files starting with "._" from a directory and its subdirectories.
|
||||
*
|
||||
* This function recursively scans the specified directory and removes all files
|
||||
* whose names start with "._" (commonly macOS metadata files). It processes
|
||||
* all subdirectories recursively.
|
||||
*
|
||||
* @param sourcePath The path of the directory to clean.
|
||||
*/
|
||||
void dotCleanDirectory(const std::string& sourcePath);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,274 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: string_funcs.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* This header file contains function declarations and utility functions for string
|
||||
* manipulation. These functions are used in the Ultrahand Overlay project to
|
||||
* perform operations like trimming whitespaces, removing quotes, replacing
|
||||
* multiple slashes, and more.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository.
|
||||
* (GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay)
|
||||
*
|
||||
* Note: Please be aware that this notice cannot be altered or removed. It is a part
|
||||
* of the project's documentation and must remain intact.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2023-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef STRING_FUNCS_HPP
|
||||
#define STRING_FUNCS_HPP
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
//#include <jansson.h>
|
||||
//#include <regex>
|
||||
#include <algorithm>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include "global_vars.hpp"
|
||||
#include "debug_funcs.hpp"
|
||||
|
||||
namespace ult {
|
||||
|
||||
extern std::string to_string(int value);
|
||||
extern int stoi(const std::string& str, std::size_t* pos = nullptr, int base = 10);
|
||||
extern float stof(const std::string& str);
|
||||
|
||||
//extern bool canConvertToInt(const std::string& str);
|
||||
|
||||
/**
|
||||
* @brief A lightweight string stream class that mimics basic functionality of std::istringstream.
|
||||
*/
|
||||
class StringStream {
|
||||
public:
|
||||
StringStream() : position(0), hexMode(false), validState(true) {}
|
||||
|
||||
|
||||
// Add this constructor to accept a string
|
||||
StringStream(const std::string& input) : data(input), position(0), hexMode(false) {}
|
||||
|
||||
// Set hex mode
|
||||
StringStream& hex() {
|
||||
hexMode = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Reset hex mode
|
||||
StringStream& resetHex() {
|
||||
hexMode = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Mimics std::getline() with a delimiter
|
||||
bool getline(std::string& output, char delimiter);
|
||||
|
||||
// Mimics operator >> to split by whitespace
|
||||
StringStream& operator>>(std::string& output);
|
||||
|
||||
// Overload the << operator to insert strings and integers
|
||||
StringStream& operator<<(const std::string& input);
|
||||
StringStream& operator<<(const char* input);
|
||||
StringStream& operator<<(char input);
|
||||
StringStream& operator<<(int input); // Handles int insertion with hex support
|
||||
StringStream& operator<<(long long input); // for long long
|
||||
|
||||
// Conversion to bool for checking stream state (success/failure)
|
||||
explicit operator bool() const {
|
||||
return validState;
|
||||
}
|
||||
|
||||
std::string str() const;
|
||||
void clear() { data.clear(); position = 0; } // Add clear function
|
||||
|
||||
private:
|
||||
std::string data;
|
||||
size_t position;
|
||||
bool hexMode;
|
||||
bool validState; // Track if the stream is in a valid state
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Trims leading and trailing whitespaces from a string.
|
||||
*
|
||||
* This function removes leading and trailing whitespaces, tabs, newlines, carriage returns, form feeds,
|
||||
* and vertical tabs from the input string.
|
||||
*
|
||||
* @param str The input string to trim.
|
||||
* @return The trimmed string.
|
||||
*/
|
||||
void trim(std::string& str);
|
||||
|
||||
|
||||
|
||||
// Function to trim newline characters from the end of a string
|
||||
void trimNewline(std::string& str);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Removes all white spaces from a string.
|
||||
*
|
||||
* This function removes all white spaces, including spaces, tabs, newlines, carriage returns, form feeds,
|
||||
* and vertical tabs from the input string.
|
||||
*
|
||||
* @param str The input string to remove white spaces from.
|
||||
* @return The string with white spaces removed.
|
||||
*/
|
||||
std::string removeWhiteSpaces(const std::string& str);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Removes quotes from a string.
|
||||
*
|
||||
* This function removes single and double quotes from the beginning and end of the input string.
|
||||
*
|
||||
* @param str The input string to remove quotes from.
|
||||
* @return The string with quotes removed.
|
||||
*/
|
||||
void removeQuotes(std::string& str);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Replaces multiple consecutive slashes with a single slash in a string.
|
||||
*
|
||||
* This function replaces sequences of two or more consecutive slashes with a single slash in the input string.
|
||||
*
|
||||
* @param input The input string to process.
|
||||
* @return The string with multiple slashes replaced.
|
||||
*/
|
||||
//std::string replaceMultipleSlashes(const std::string& input);
|
||||
|
||||
|
||||
void resolveDirectoryTraversal(std::string& path);
|
||||
|
||||
/**
|
||||
* @brief Preprocesses a path string by replacing multiple slashes and adding "sdmc:" prefix.
|
||||
*
|
||||
* This function preprocesses a path string by removing multiple consecutive slashes,
|
||||
* adding the "sdmc:" prefix if not present, and modifying the input string in place.
|
||||
*
|
||||
* @param path The input path string to preprocess, passed by reference.
|
||||
*/
|
||||
void preprocessPath(std::string& path, const std::string& packagePath = "");
|
||||
|
||||
/**
|
||||
* @brief Preprocesses a URL string by adding "https://" prefix.
|
||||
*
|
||||
* This function preprocesses a URL string by adding the "https://" prefix if not already present.
|
||||
*
|
||||
* @param path The input URL string to preprocess, passed by reference and modified in-place.
|
||||
*/
|
||||
void preprocessUrl(std::string& path);
|
||||
|
||||
/**
|
||||
* @brief Drops the file extension from a filename.
|
||||
*
|
||||
* This function removes the file extension (characters after the last dot) from the input filename string.
|
||||
*
|
||||
* @param filename The input filename from which to drop the extension, passed by reference and modified in-place.
|
||||
*/
|
||||
void dropExtension(std::string& filename);
|
||||
|
||||
/**
|
||||
* @brief Checks if a string starts with a given prefix.
|
||||
*
|
||||
* This function checks if the input string starts with the specified prefix.
|
||||
*
|
||||
* @param str The input string to check.
|
||||
* @param prefix The prefix to check for.
|
||||
* @return True if the string starts with the prefix, false otherwise.
|
||||
*/
|
||||
bool startsWith(const std::string& str, const std::string& prefix);
|
||||
|
||||
|
||||
// Helper function to check if a string is a valid integer
|
||||
bool isValidNumber(const std::string& str);
|
||||
|
||||
// For properly handling placeholder replacements
|
||||
std::string returnOrNull(const std::string& value);
|
||||
|
||||
|
||||
// Function to slice a string from start to end index
|
||||
std::string sliceString(const std::string& str, size_t start, size_t end);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Converts a string to lowercase.
|
||||
*
|
||||
* This function takes a string as input and returns a lowercase version of that string.
|
||||
*
|
||||
* @param str The input string to convert to lowercase.
|
||||
* @return The lowercase version of the input string.
|
||||
*/
|
||||
|
||||
std::string stringToLowercase(const std::string& str);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Converts a string to uppercase.
|
||||
*
|
||||
* This function takes a string as input and returns an uppercase version of that string.
|
||||
*
|
||||
* @param str The input string to convert to uppercase.
|
||||
* @return The uppercase version of the input string.
|
||||
*/
|
||||
|
||||
std::string stringToUppercase(const std::string& str);
|
||||
|
||||
/**
|
||||
* @brief Formats a priority string to a desired width.
|
||||
*
|
||||
* This function takes a priority string and formats it to a specified desired width by padding with '0's if it's shorter
|
||||
* or truncating with '9's if it's longer.
|
||||
*
|
||||
* @param priority The input priority string to format.
|
||||
* @param desiredWidth The desired width of the formatted string (default is 4).
|
||||
* @return A formatted priority string.
|
||||
*/
|
||||
std::string formatPriorityString(const std::string& priority, int desiredWidth = 4);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Removes the part of the string after the first occurrence of '?' character.
|
||||
*
|
||||
* This function takes a string and removes the portion of the string that appears after
|
||||
* the first '?' character, if found. If no '?' character is present, the string remains unchanged.
|
||||
*
|
||||
* @param input The input string from which to remove the tag, passed by reference and modified in-place.
|
||||
*/
|
||||
void removeTag(std::string &input);
|
||||
|
||||
std::string getFirstLongEntry(const std::string& input, size_t minLength = 8);
|
||||
|
||||
|
||||
// This will take a string like "v1.3.5-abasdfasdfa" and output "1.3.5". string could also look like "test-1.3.5-1" or "v1.3.5" and we will only want "1.3.5"
|
||||
std::string cleanVersionLabel(const std::string& input);
|
||||
|
||||
|
||||
std::string extractTitle(const std::string& input);
|
||||
|
||||
|
||||
std::vector<std::string> splitString(const std::string& str, const std::string& delimiter);
|
||||
|
||||
|
||||
// Function to split a string by a delimiter and return a specific index
|
||||
std::string splitStringAtIndex(const std::string& str, const std::string& delimiter, size_t index);
|
||||
|
||||
|
||||
std::string customAlign(int number);
|
||||
|
||||
#if IS_LAUNCHER_DIRECTIVE
|
||||
std::string inputExists(const std::string& input);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,813 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: tsl_utils.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* 'tsl_utils.hpp' is a central utility header for the Ultrahand Overlay project,
|
||||
* containing a variety of functions and definitions related to system status,
|
||||
* input handling, and application-specific behavior on the Nintendo Switch.
|
||||
* This header provides essential utilities for interacting with the system,
|
||||
* managing key input, and enhancing overlay functionality.
|
||||
*
|
||||
* The utilities defined here are designed to operate independently, facilitating
|
||||
* robust system interaction capabilities required for custom overlays.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository:
|
||||
* GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay
|
||||
*
|
||||
* Note: This notice is integral to the project's documentation and must not be
|
||||
* altered or removed.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2023-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
#pragma once
|
||||
#ifndef TSL_UTILS_HPP
|
||||
#define TSL_UTILS_HPP
|
||||
|
||||
#if !USING_FSTREAM_DIRECTIVE // For not using fstream (needs implementing)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
#include <ultra.hpp>
|
||||
#include <switch.h>
|
||||
#include <arm_neon.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
//#include <math.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <cwctype>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
//#include <chrono>
|
||||
#include <list>
|
||||
#include <stack>
|
||||
#include <map>
|
||||
#include <barrier>
|
||||
|
||||
//#ifndef APPROXIMATE_cos
|
||||
//// Approximation for cos(x) using Taylor series around 0
|
||||
//#define APPROXIMATE_cos(x) (1 - (x) * (x) / 2 + (x) * (x) * (x) * (x) / 24) // valid for small x
|
||||
//#endif
|
||||
//
|
||||
//
|
||||
//#ifndef APPROXIMATE_ifloor
|
||||
//#define APPROXIMATE_ifloor(x) ((int)((x) >= 0 ? (x) : (x) - 1)) // truncate toward negative infinity
|
||||
//#define APPROXIMATE_iceil(x) ((int)((x) == (int)(x) ? (x) : ((x) > 0 ? (int)(x) + 1 : (int)(x)))) // truncate toward positive infinity
|
||||
//#endif
|
||||
//
|
||||
//#ifndef APPROXIMATE_sqrt
|
||||
//// Fast approximation for sqrt using Newton's method
|
||||
//#define APPROXIMATE_sqrt(x) ((x) <= 0 ? 0 : (x) / 2.0 * (3.0 - ((x) * (x) * 0.5))) // Approximation for x close to 1
|
||||
//#define APPROXIMATE_pow(x, y) ((y) == 0 ? 1 : ((y) == 1 ? (x) : APPROXIMATE_sqrt(x))) // limited to approximate sqrt if y=0.5
|
||||
//#endif
|
||||
//
|
||||
//#ifndef APPROXIMATE_fmod
|
||||
//#define APPROXIMATE_fmod(x, y) ((x) - ((int)((x) / (y)) * (y))) // equivalent to x - floor(x/y) * y
|
||||
//#endif
|
||||
//
|
||||
//#ifndef APPROXIMATE_cos
|
||||
//// Approximation for cos(x) using Taylor series around 0
|
||||
//#define APPROXIMATE_cos(x) (1 - (x) * (x) / 2 + (x) * (x) * (x) * (x) / 24) // valid for small x
|
||||
//#endif
|
||||
//
|
||||
//#ifndef APPROXIMATE_acos
|
||||
//#define APPROXIMATE_acos(x) (1.5708 - (x) - (x)*(x)*(x) / 6) // limited approximation for acos in range [-1, 1]
|
||||
//#endif
|
||||
//
|
||||
//#ifndef APPROXIMATE_fabs
|
||||
//#define APPROXIMATE_fabs(x) ((x) < 0 ? -(x) : (x))
|
||||
//#endif
|
||||
|
||||
struct OverlayCombo {
|
||||
std::string path; // full overlay path
|
||||
std::string launchArg; // empty = use per-overlay launch_args key, otherwise a “mode” arg
|
||||
};
|
||||
|
||||
struct SwapDepth {
|
||||
u32 value;
|
||||
explicit SwapDepth(u32 v) : value(v) {}
|
||||
};
|
||||
|
||||
namespace ult {
|
||||
// math funcs
|
||||
inline double cos(double x) {
|
||||
static constexpr double PI = 3.14159265358979323846;
|
||||
static constexpr double TWO_PI = 6.28318530717958647692;
|
||||
static constexpr double HALF_PI = 1.57079632679489661923;
|
||||
|
||||
// Fast normalization using multiply instead of divide when possible
|
||||
x = x - TWO_PI * static_cast<int>(x * 0.159154943091895); // 1/(2π)
|
||||
if (x < 0) x += TWO_PI;
|
||||
|
||||
// Use symmetry to reduce range
|
||||
int sign = 1;
|
||||
if (x > PI) {
|
||||
x -= PI;
|
||||
sign = -1;
|
||||
}
|
||||
if (x > HALF_PI) {
|
||||
x = PI - x;
|
||||
sign = -sign;
|
||||
}
|
||||
|
||||
// Horner's method for faster polynomial evaluation (fewer operations)
|
||||
// 5-term minimax polynomial for [0, π/2] - accurate to ~10^-8
|
||||
const double x2 = x * x;
|
||||
return sign * (1.0 + x2 * (-0.5 + x2 * (0.04166666666666666 + x2 * (-0.001388888888888889 + x2 * (0.0000248015873015873 - x2 * 0.0000002755731922398589)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern bool correctFrameSize; // for detecting the correct Overlay display size
|
||||
|
||||
extern u16 DefaultFramebufferWidth; ///< Width of the framebuffer
|
||||
extern u16 DefaultFramebufferHeight; ///< Height of the framebuffer
|
||||
|
||||
extern std::unordered_map<std::string, std::string> translationCache;
|
||||
|
||||
extern std::unordered_map<u64, OverlayCombo> g_entryCombos;
|
||||
extern std::atomic<bool> launchingOverlay;
|
||||
extern std::atomic<bool> settingsInitialized;
|
||||
extern std::atomic<bool> currentForeground;
|
||||
//extern std::mutex simulatedNextPageMutex;
|
||||
|
||||
//void loadOverlayKeyCombos();
|
||||
//std::string getOverlayForKeyCombo(u64 keys);
|
||||
|
||||
bool readFileContent(const std::string& filePath, std::string& content);
|
||||
void parseJsonContent(const std::string& content, std::unordered_map<std::string, std::string>& result);
|
||||
bool parseJsonToMap(const std::string& filePath, std::unordered_map<std::string, std::string>& result);
|
||||
|
||||
bool loadTranslationsFromJSON(const std::string& filePath);
|
||||
|
||||
extern u16 activeHeaderHeight;
|
||||
|
||||
bool consoleIsDocked();
|
||||
|
||||
std::string getBuildIdAsString();
|
||||
|
||||
std::string getTitleIdAsString();
|
||||
|
||||
extern std::string lastTitleID;
|
||||
extern std::atomic<bool> resetForegroundCheck;
|
||||
|
||||
|
||||
//extern bool isLauncher;
|
||||
extern std::atomic<bool> internalTouchReleased;
|
||||
extern u32 layerEdge;
|
||||
extern bool useRightAlignment;
|
||||
extern bool useSwipeToOpen;
|
||||
extern bool useLaunchCombos;
|
||||
extern bool useNotifications;
|
||||
extern bool useSoundEffects;
|
||||
extern bool useHapticFeedback;
|
||||
extern bool usePageSwap;
|
||||
extern std::atomic<bool> noClickableItems;
|
||||
|
||||
extern bool useDynamicLogo;
|
||||
extern bool useSelectionBG;
|
||||
extern bool useSelectionText;
|
||||
extern bool useSelectionValue;
|
||||
|
||||
|
||||
|
||||
// Define the duration boundaries (for smooth scrolling)
|
||||
//extern const std::chrono::milliseconds initialInterval; // Example initial interval
|
||||
//extern const std::chrono::milliseconds shortInterval; // Short interval after long hold
|
||||
//extern const std::chrono::milliseconds transitionPoint; // Point at which the shortest interval is reached
|
||||
|
||||
|
||||
|
||||
//constexpr std::chrono::milliseconds initialInterval = std::chrono::milliseconds(67); // Example initial interval
|
||||
//constexpr std::chrono::milliseconds shortInterval = std::chrono::milliseconds(10); // Short interval after long hold
|
||||
//constexpr std::chrono::milliseconds transitionPoint = std::chrono::milliseconds(2000); // Point at which the shortest interval is reached
|
||||
|
||||
// Function to interpolate between two durations
|
||||
//std::chrono::milliseconds interpolateDuration(std::chrono::milliseconds start, std::chrono::milliseconds end, float t);
|
||||
|
||||
#if IS_LAUNCHER_DIRECTIVE
|
||||
extern std::atomic<bool> overlayLaunchRequested;
|
||||
extern std::string requestedOverlayPath;
|
||||
extern std::string requestedOverlayArgs;
|
||||
extern std::mutex overlayLaunchMutex;
|
||||
#endif
|
||||
|
||||
|
||||
//#include <filesystem> // Comment out filesystem
|
||||
|
||||
// CUSTOM SECTION START
|
||||
//extern float backWidth, selectWidth, nextPageWidth;
|
||||
extern std::atomic<float> backWidth;
|
||||
extern std::atomic<float> selectWidth;
|
||||
extern std::atomic<float> nextPageWidth;
|
||||
extern std::atomic<bool> inMainMenu;
|
||||
extern std::atomic<bool> inHiddenMode;
|
||||
extern std::atomic<bool> inSettingsMenu;
|
||||
extern std::atomic<bool> inSubSettingsMenu;
|
||||
extern std::atomic<bool> inOverlaysPage;
|
||||
extern std::atomic<bool> inPackagesPage;
|
||||
|
||||
extern bool firstBoot; // for detecting first boot
|
||||
|
||||
//static std::unordered_map<std::string, std::string> hexSumCache;
|
||||
|
||||
// Define an atomic bool for interpreter completion
|
||||
extern std::atomic<bool> threadFailure;
|
||||
extern std::atomic<bool> runningInterpreter;
|
||||
extern std::atomic<bool> shakingProgress;
|
||||
|
||||
extern std::atomic<bool> isHidden;
|
||||
extern std::atomic<bool> externalAbortCommands;
|
||||
|
||||
//bool progressAnimation = false;
|
||||
extern bool disableTransparency;
|
||||
//bool useCustomWallpaper = false;
|
||||
//extern bool useMemoryExpansion;
|
||||
extern bool useOpaqueScreenshots;
|
||||
|
||||
extern std::atomic<bool> onTrackBar;
|
||||
extern std::atomic<bool> allowSlide;
|
||||
extern std::atomic<bool> unlockedSlide;
|
||||
|
||||
void atomicToggle(std::atomic<bool>& b);
|
||||
|
||||
/**
|
||||
* @brief Shutdown modes for the Ultrahand-Overlay project.
|
||||
*
|
||||
* These macros define the shutdown modes used in the Ultrahand-Overlay project:
|
||||
* - `SpsmShutdownMode_Normal`: Normal shutdown mode.
|
||||
* - `SpsmShutdownMode_Reboot`: Reboot mode.
|
||||
*/
|
||||
#define SpsmShutdownMode_Normal 0
|
||||
#define SpsmShutdownMode_Reboot 1
|
||||
|
||||
/**
|
||||
* @brief Key mapping macros for button keys.
|
||||
*
|
||||
* These macros define button keys for the Ultrahand-Overlay project to simplify key mappings.
|
||||
* For example, `KEY_A` represents the `HidNpadButton_A` key.
|
||||
*/
|
||||
#define KEY_A HidNpadButton_A
|
||||
#define KEY_B HidNpadButton_B
|
||||
#define KEY_X HidNpadButton_X
|
||||
#define KEY_Y HidNpadButton_Y
|
||||
#define KEY_L HidNpadButton_L
|
||||
#define KEY_R HidNpadButton_R
|
||||
#define KEY_ZL HidNpadButton_ZL
|
||||
#define KEY_ZR HidNpadButton_ZR
|
||||
#define KEY_PLUS HidNpadButton_Plus
|
||||
#define KEY_MINUS HidNpadButton_Minus
|
||||
#define KEY_DUP HidNpadButton_Up
|
||||
#define KEY_DDOWN HidNpadButton_Down
|
||||
#define KEY_DLEFT HidNpadButton_Left
|
||||
#define KEY_DRIGHT HidNpadButton_Right
|
||||
#define KEY_SL HidNpadButton_AnySL
|
||||
#define KEY_SR HidNpadButton_AnySR
|
||||
#define KEY_LSTICK HidNpadButton_StickL
|
||||
#define KEY_RSTICK HidNpadButton_StickR
|
||||
#define KEY_UP HidNpadButton_AnyUp
|
||||
#define KEY_DOWN HidNpadButton_AnyDown
|
||||
#define KEY_LEFT HidNpadButton_AnyLeft
|
||||
#define KEY_RIGHT HidNpadButton_AnyRight
|
||||
|
||||
#define SCRIPT_KEY HidNpadButton_Minus
|
||||
#define SYSTEM_SETTINGS_KEY HidNpadButton_Plus
|
||||
#define SETTINGS_KEY HidNpadButton_Y
|
||||
#define STAR_KEY HidNpadButton_X
|
||||
|
||||
|
||||
// Define a mask with all possible key flags
|
||||
#define ALL_KEYS_MASK (KEY_A | KEY_B | KEY_X | KEY_Y | KEY_DUP | KEY_DDOWN | KEY_DLEFT | KEY_DRIGHT | KEY_L | KEY_R | KEY_ZL | KEY_ZR | KEY_SL | KEY_SR | KEY_LSTICK | KEY_RSTICK | KEY_PLUS | KEY_MINUS)
|
||||
|
||||
|
||||
extern bool updateMenuCombos;
|
||||
|
||||
/**
|
||||
* @brief Ultrahand-Overlay Input Macros
|
||||
*
|
||||
* This block of code defines macros for handling input in the Ultrahand-Overlay project.
|
||||
* These macros simplify the mapping of input events to corresponding button keys and
|
||||
* provide aliases for touch and joystick positions.
|
||||
*
|
||||
* The macros included in this block are:
|
||||
*
|
||||
* - `touchPosition`: An alias for a constant `HidTouchState` pointer.
|
||||
* - `touchInput`: An alias for `&touchPos`, representing touch input.
|
||||
* - `JoystickPosition`: An alias for `HidAnalogStickState`, representing joystick input.
|
||||
*
|
||||
* These macros are utilized within the Ultrahand-Overlay project to manage and interpret
|
||||
* user input, including touch and joystick events.
|
||||
*/
|
||||
#define touchPosition const HidTouchState
|
||||
#define touchInput &touchPos
|
||||
#define JoystickPosition HidAnalogStickState
|
||||
|
||||
//void convertComboToUnicode(std::string& combo);
|
||||
|
||||
/**
|
||||
* @brief Combo key mapping
|
||||
*/
|
||||
struct KeyInfo {
|
||||
u64 key;
|
||||
const char* name;
|
||||
const char* glyph;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Combo key mappings
|
||||
*
|
||||
* Ordered as they should be displayed
|
||||
*/
|
||||
extern std::array<KeyInfo, 18> KEYS_INFO;
|
||||
|
||||
std::unordered_map<std::string, std::string> createButtonCharMap();
|
||||
|
||||
extern std::unordered_map<std::string, std::string> buttonCharMap;
|
||||
|
||||
|
||||
void convertComboToUnicode(std::string& combo);
|
||||
|
||||
|
||||
// English string definitions
|
||||
|
||||
extern const std::string whiteColor;
|
||||
extern const std::string blackColor;
|
||||
extern const std::string greyColor;
|
||||
|
||||
extern std::atomic<bool> languageWasChanged;
|
||||
|
||||
inline constexpr double _M_PI = 3.14159265358979323846; // For double precision
|
||||
inline constexpr double RAD_TO_DEG = 180.0f / _M_PI;
|
||||
|
||||
#if IS_LAUNCHER_DIRECTIVE
|
||||
extern std::string ENGLISH;
|
||||
extern std::string SPANISH;
|
||||
extern std::string FRENCH;
|
||||
extern std::string GERMAN;
|
||||
extern std::string JAPANESE;
|
||||
extern std::string KOREAN;
|
||||
extern std::string ITALIAN;
|
||||
extern std::string DUTCH;
|
||||
extern std::string PORTUGUESE;
|
||||
extern std::string RUSSIAN;
|
||||
extern std::string UKRAINIAN;
|
||||
extern std::string POLISH;
|
||||
extern std::string SIMPLIFIED_CHINESE;
|
||||
extern std::string TRADITIONAL_CHINESE;
|
||||
|
||||
extern std::string OVERLAYS; //defined in libTesla now
|
||||
extern std::string OVERLAYS_ABBR;
|
||||
extern std::string OVERLAY;
|
||||
extern std::string HIDDEN_OVERLAYS;
|
||||
extern std::string PACKAGES; //defined in libTesla now
|
||||
extern std::string PACKAGE;
|
||||
extern std::string HIDDEN_PACKAGES;
|
||||
extern std::string HIDDEN;
|
||||
extern std::string HIDE_OVERLAY;
|
||||
extern std::string HIDE_PACKAGE;
|
||||
extern std::string LAUNCH_ARGUMENTS;
|
||||
extern std::string FORCE_AMS110_SUPPORT;
|
||||
extern std::string QUICK_LAUNCH;
|
||||
extern std::string BOOT_COMMANDS;
|
||||
extern std::string EXIT_COMMANDS;
|
||||
extern std::string ERROR_LOGGING;
|
||||
extern std::string COMMANDS;
|
||||
extern std::string SETTINGS;
|
||||
extern std::string FAVORITE;
|
||||
extern std::string MAIN_SETTINGS;
|
||||
extern std::string UI_SETTINGS;
|
||||
|
||||
extern std::string WIDGET;
|
||||
extern std::string WIDGET_ITEMS;
|
||||
extern std::string WIDGET_SETTINGS;
|
||||
extern std::string CLOCK;
|
||||
extern std::string BATTERY;
|
||||
extern std::string SOC_TEMPERATURE;
|
||||
extern std::string PCB_TEMPERATURE;
|
||||
extern std::string BACKDROP;
|
||||
extern std::string DYNAMIC_COLORS;
|
||||
extern std::string CENTER_ALIGNMENT;
|
||||
extern std::string EXTENDED_BACKDROP;
|
||||
extern std::string MISCELLANEOUS;
|
||||
//extern std::string MENU_ITEMS;
|
||||
extern std::string MENU_SETTINGS;
|
||||
extern std::string USER_GUIDE;
|
||||
extern std::string SHOW_HIDDEN;
|
||||
extern std::string SHOW_DELETE;
|
||||
extern std::string SHOW_UNSUPPORTED;
|
||||
|
||||
extern std::string PAGE_SWAP;
|
||||
extern std::string RIGHT_SIDE_MODE;
|
||||
extern std::string OVERLAY_VERSIONS;
|
||||
extern std::string PACKAGE_VERSIONS;
|
||||
extern std::string CLEAN_VERSIONS;
|
||||
//extern std::string VERSION_LABELS;
|
||||
extern std::string KEY_COMBO;
|
||||
extern std::string MODE;
|
||||
extern std::string LAUNCH_MODES;
|
||||
extern std::string LANGUAGE;
|
||||
extern std::string OVERLAY_INFO;
|
||||
extern std::string SOFTWARE_UPDATE;
|
||||
extern std::string UPDATE_ULTRAHAND;
|
||||
extern std::string UPDATE_LANGUAGES;
|
||||
extern std::string SYSTEM;
|
||||
extern std::string DEVICE_INFO;
|
||||
extern std::string FIRMWARE;
|
||||
extern std::string BOOTLOADER;
|
||||
extern std::string HARDWARE;
|
||||
extern std::string MEMORY;
|
||||
extern std::string VENDOR;
|
||||
extern std::string MODEL;
|
||||
extern std::string STORAGE;
|
||||
//extern std::string NOTICE;
|
||||
//extern std::string UTILIZES;
|
||||
|
||||
extern std::string OVERLAY_MEMORY;
|
||||
extern std::string NOT_ENOUGH_MEMORY;
|
||||
extern std::string WALLPAPER_SUPPORT_DISABLED;
|
||||
extern std::string SOUND_SUPPORT_DISABLED;
|
||||
extern std::string WALLPAPER_SUPPORT_ENABLED;
|
||||
extern std::string SOUND_SUPPORT_ENABLED;
|
||||
extern std::string EXIT_OVERLAY_SYSTEM;
|
||||
|
||||
//extern std::string MEMORY_EXPANSION;
|
||||
//extern std::string REBOOT_REQUIRED;
|
||||
extern std::string LOCAL_IP;
|
||||
extern std::string WALLPAPER;
|
||||
extern std::string THEME;
|
||||
extern std::string DEFAULT;
|
||||
extern std::string ROOT_PACKAGE;
|
||||
extern std::string SORT_PRIORITY;
|
||||
extern std::string OPTIONS;
|
||||
extern std::string FAILED_TO_OPEN;
|
||||
|
||||
extern std::string LAUNCH_COMBOS;
|
||||
extern std::string NOTIFICATIONS;
|
||||
extern std::string SOUND_EFFECTS;
|
||||
extern std::string HAPTIC_FEEDBACK;
|
||||
extern std::string OPAQUE_SCREENSHOTS;
|
||||
|
||||
extern std::string PACKAGE_INFO;
|
||||
extern std::string _TITLE;
|
||||
extern std::string _VERSION;
|
||||
extern std::string _CREATOR;
|
||||
extern std::string _ABOUT;
|
||||
extern std::string _CREDITS;
|
||||
|
||||
extern std::string USERGUIDE_OFFSET;
|
||||
extern std::string SETTINGS_MENU;
|
||||
extern std::string SCRIPT_OVERLAY;
|
||||
extern std::string STAR_FAVORITE;
|
||||
extern std::string APP_SETTINGS;
|
||||
extern std::string ON_MAIN_MENU;
|
||||
extern std::string ON_A_COMMAND;
|
||||
extern std::string ON_OVERLAY_PACKAGE;
|
||||
extern std::string FEATURES;
|
||||
extern std::string SWIPE_TO_OPEN;
|
||||
|
||||
extern std::string THEME_SETTINGS;
|
||||
extern std::string DYNAMIC_LOGO;
|
||||
extern std::string SELECTION_BACKGROUND;
|
||||
extern std::string SELECTION_TEXT;
|
||||
extern std::string SELECTION_VALUE;
|
||||
extern std::string LIBULTRAHAND_TITLES;
|
||||
extern std::string LIBULTRAHAND_VERSIONS;
|
||||
extern std::string PACKAGE_TITLES;
|
||||
|
||||
extern std::string ULTRAHAND_HAS_STARTED;
|
||||
extern std::string NEW_UPDATE_IS_AVAILABLE;
|
||||
//extern std::string REBOOT_IS_REQUIRED;
|
||||
//extern std::string HOLD_A_TO_DELETE;
|
||||
|
||||
extern std::string DELETE_PACKAGE;
|
||||
extern std::string DELETE_OVERLAY;
|
||||
extern std::string SELECTION_IS_EMPTY;
|
||||
extern std::string FORCED_SUPPORT_WARNING;
|
||||
|
||||
extern std::string TASK_IS_COMPLETE;
|
||||
extern std::string TASK_HAS_FAILED;
|
||||
|
||||
//extern std::string PACKAGE_VERSIONS;
|
||||
//extern std::string PROGRESS_ANIMATION;
|
||||
|
||||
extern std::string REBOOT_TO;
|
||||
extern std::string REBOOT;
|
||||
extern std::string SHUTDOWN;
|
||||
extern std::string BOOT_ENTRY;
|
||||
#endif
|
||||
|
||||
extern std::string INCOMPATIBLE_WARNING;
|
||||
extern std::string SYSTEM_RAM;
|
||||
extern std::string FREE;
|
||||
|
||||
extern std::string DEFAULT_CHAR_WIDTH;
|
||||
extern std::string UNAVAILABLE_SELECTION;
|
||||
|
||||
extern std::string ON;
|
||||
extern std::string OFF;
|
||||
|
||||
extern std::string OK;
|
||||
extern std::string BACK;
|
||||
extern std::string HIDE;
|
||||
extern std::string CANCEL;
|
||||
|
||||
extern std::string GAP_1;
|
||||
extern std::string GAP_2;
|
||||
extern std::atomic<float> halfGap;
|
||||
|
||||
//extern std::string EMPTY;
|
||||
|
||||
#if USING_WIDGET_DIRECTIVE
|
||||
extern std::string SUNDAY;
|
||||
extern std::string MONDAY;
|
||||
extern std::string TUESDAY;
|
||||
extern std::string WEDNESDAY;
|
||||
extern std::string THURSDAY;
|
||||
extern std::string FRIDAY;
|
||||
extern std::string SATURDAY;
|
||||
|
||||
extern std::string JANUARY;
|
||||
extern std::string FEBRUARY;
|
||||
extern std::string MARCH;
|
||||
extern std::string APRIL;
|
||||
extern std::string MAY;
|
||||
extern std::string JUNE;
|
||||
extern std::string JULY;
|
||||
extern std::string AUGUST;
|
||||
extern std::string SEPTEMBER;
|
||||
extern std::string OCTOBER;
|
||||
extern std::string NOVEMBER;
|
||||
extern std::string DECEMBER;
|
||||
|
||||
extern std::string SUN;
|
||||
extern std::string MON;
|
||||
extern std::string TUE;
|
||||
extern std::string WED;
|
||||
extern std::string THU;
|
||||
extern std::string FRI;
|
||||
extern std::string SAT;
|
||||
|
||||
extern std::string JAN;
|
||||
extern std::string FEB;
|
||||
extern std::string MAR;
|
||||
extern std::string APR;
|
||||
extern std::string MAY_ABBR;
|
||||
extern std::string JUN;
|
||||
extern std::string JUL;
|
||||
extern std::string AUG;
|
||||
extern std::string SEP;
|
||||
extern std::string OCT;
|
||||
extern std::string NOV;
|
||||
extern std::string DEC;
|
||||
#endif
|
||||
|
||||
#if IS_LAUNCHER_DIRECTIVE
|
||||
// Constant string definitions (English)
|
||||
void reinitializeLangVars();
|
||||
#endif
|
||||
|
||||
|
||||
// Define the updateIfNotEmpty function
|
||||
void updateIfNotEmpty(std::string& constant, const char* jsonKey, const json_t* jsonData);
|
||||
|
||||
void parseLanguage(const std::string& langFile);
|
||||
|
||||
#if USING_WIDGET_DIRECTIVE
|
||||
void localizeTimeStr(char* timeStr);
|
||||
#endif
|
||||
|
||||
// Unified function to apply replacements
|
||||
void applyLangReplacements(std::string& text, bool isValue = false);
|
||||
|
||||
|
||||
|
||||
//// Map of character widths (pre-calibrated)
|
||||
//extern std::unordered_map<wchar_t, float> characterWidths;
|
||||
|
||||
//extern float defaultNumericCharWidth;
|
||||
|
||||
|
||||
|
||||
// Predefined hexMap
|
||||
//extern const std::array<int, 256> hexMap;
|
||||
inline constexpr std::array<int, 256> hexMap = [] {
|
||||
std::array<int, 256> map = {0};
|
||||
map['0'] = 0; map['1'] = 1; map['2'] = 2; map['3'] = 3; map['4'] = 4;
|
||||
map['5'] = 5; map['6'] = 6; map['7'] = 7; map['8'] = 8; map['9'] = 9;
|
||||
map['A'] = 10; map['B'] = 11; map['C'] = 12; map['D'] = 13; map['E'] = 14; map['F'] = 15;
|
||||
map['a'] = 10; map['b'] = 11; map['c'] = 12; map['d'] = 13; map['e'] = 14; map['f'] = 15;
|
||||
return map;
|
||||
}();
|
||||
|
||||
|
||||
// Prepare a map of default settings
|
||||
extern std::map<const std::string, std::string> defaultThemeSettingsMap;
|
||||
|
||||
bool isNumericCharacter(char c);
|
||||
|
||||
bool isValidHexColor(const std::string& hexColor);
|
||||
|
||||
|
||||
|
||||
//float calculateAmplitude(float x, float peakDurationFactor = 0.25f);
|
||||
|
||||
|
||||
extern std::atomic<bool> refreshWallpaperNow;
|
||||
extern std::atomic<bool> refreshWallpaper;
|
||||
extern std::vector<u8> wallpaperData;
|
||||
extern std::atomic<bool> inPlot;
|
||||
|
||||
extern std::mutex wallpaperMutex;
|
||||
extern std::condition_variable cv;
|
||||
|
||||
|
||||
|
||||
// Function to load the RGBA file into memory and modify wallpaperData directly
|
||||
void loadWallpaperFile(const std::string& filePath, s32 width = 448, s32 height = 720);
|
||||
void loadWallpaperFileWhenSafe();
|
||||
|
||||
void reloadWallpaper();
|
||||
|
||||
// Global variables for FPS calculation
|
||||
//extern double lastTimeCount;
|
||||
//extern int frameCount;
|
||||
//extern float fps;
|
||||
//extern double elapsedTime;
|
||||
|
||||
|
||||
extern std::atomic<bool> themeIsInitialized;
|
||||
|
||||
// Variables for touch commands
|
||||
extern std::atomic<bool> touchingBack;
|
||||
extern std::atomic<bool> touchingSelect;
|
||||
extern std::atomic<bool> touchingNextPage;
|
||||
extern std::atomic<bool> touchingMenu;
|
||||
extern std::atomic<bool> shortTouchAndRelease;
|
||||
extern std::atomic<bool> longTouchAndRelease;
|
||||
extern std::atomic<bool> simulatedBack;
|
||||
//extern bool simulatedBackComplete;
|
||||
extern std::atomic<bool> simulatedSelect;
|
||||
//extern bool simulatedSelectComplete;
|
||||
extern std::atomic<bool> simulatedNextPage;
|
||||
//extern std::atomic<bool> simulatedNextPageComplete;
|
||||
extern std::atomic<bool> simulatedMenu;
|
||||
//extern bool simulatedMenuComplete;
|
||||
extern std::atomic<bool> stillTouching;
|
||||
extern std::atomic<bool> interruptedTouch;
|
||||
extern std::atomic<bool> touchInBounds;
|
||||
|
||||
|
||||
#if USING_WIDGET_DIRECTIVE
|
||||
// Battery implementation
|
||||
extern bool powerInitialized;
|
||||
extern bool powerCacheInitialized;
|
||||
extern uint32_t powerCacheCharge;
|
||||
extern bool powerCacheIsCharging;
|
||||
extern PsmSession powerSession;
|
||||
|
||||
// Define variables to store previous battery charge and time
|
||||
//extern uint32_t prevBatteryCharge;
|
||||
//extern s64 timeOut;
|
||||
|
||||
|
||||
extern std::atomic<uint32_t> batteryCharge;
|
||||
extern std::atomic<bool> isCharging;
|
||||
|
||||
//constexpr std::chrono::seconds min_delay = std::chrono::seconds(3); // Minimum delay between checks
|
||||
|
||||
bool powerGetDetails(uint32_t *_batteryCharge, bool *_isCharging);
|
||||
|
||||
void powerInit(void);
|
||||
|
||||
void powerExit(void);
|
||||
#endif
|
||||
|
||||
// Temperature Implementation
|
||||
extern std::atomic<float> PCB_temperature;
|
||||
extern std::atomic<float> SOC_temperature;
|
||||
|
||||
/*
|
||||
I2cReadRegHandler was taken from Switch-OC-Suite source code made by KazushiMe
|
||||
Original repository link (Deleted, last checked 15.04.2023): https://github.com/KazushiMe/Switch-OC-Suite
|
||||
*/
|
||||
|
||||
Result I2cReadRegHandler(u8 reg, I2cDevice dev, u16 *out);
|
||||
|
||||
|
||||
#define TMP451_SOC_TEMP_REG 0x01 // Register for SOC temperature integer part
|
||||
#define TMP451_SOC_TMP_DEC_REG 0x10 // Register for SOC temperature decimal part
|
||||
#define TMP451_PCB_TEMP_REG 0x00 // Register for PCB temperature integer part
|
||||
#define TMP451_PCB_TMP_DEC_REG 0x15 // Register for PCB temperature decimal part
|
||||
|
||||
// Common helper function to read temperature (integer and fractional parts)
|
||||
Result ReadTemperature(float *temperature, u8 integerReg, u8 fractionalReg, bool integerOnly);
|
||||
|
||||
// Function to get the SOC temperature
|
||||
Result ReadSocTemperature(float *temperature, bool integerOnly = true);
|
||||
|
||||
// Function to get the PCB temperature
|
||||
Result ReadPcbTemperature(float *temperature, bool integerOnly = true);
|
||||
|
||||
|
||||
|
||||
// Time implementation
|
||||
|
||||
extern const std::string DEFAULT_DT_FORMAT;
|
||||
extern std::string datetimeFormat;
|
||||
|
||||
|
||||
// Widget settings
|
||||
//static std::string hideClock, hideBattery, hidePCBTemp, hideSOCTemp;
|
||||
extern bool hideClock, hideBattery, hidePCBTemp, hideSOCTemp, dynamicWidgetColors;
|
||||
extern bool hideWidgetBackdrop, centerWidgetAlignment, extendedWidgetBackdrop;
|
||||
|
||||
#if IS_LAUNCHER_DIRECTIVE
|
||||
void reinitializeWidgetVars();
|
||||
#endif
|
||||
|
||||
extern bool cleanVersionLabels, hideOverlayVersions, hidePackageVersions, useLibultrahandTitles, useLibultrahandVersions, usePackageTitles, usePackageVersions;
|
||||
|
||||
|
||||
|
||||
// nx-ovlloader settings
|
||||
enum class OverlayHeapSize : u64 {
|
||||
Size_4MB = 0x400000,
|
||||
Size_6MB = 0x600000,
|
||||
Size_8MB = 0x800000
|
||||
};
|
||||
|
||||
// Static cache
|
||||
static struct {
|
||||
bool initialized = false;
|
||||
OverlayHeapSize cachedSize = OverlayHeapSize::Size_6MB;
|
||||
u64 customSizeMB = 0; // NEW: store custom size in MB
|
||||
} heapSizeCache;
|
||||
|
||||
|
||||
// Helper function to convert MB to bytes
|
||||
extern u64 mbToBytes(u32 mb);
|
||||
|
||||
// Helper function to convert bytes to MB
|
||||
extern u32 bytesToMB(u64 bytes);
|
||||
|
||||
// Implementation
|
||||
OverlayHeapSize getCurrentHeapSize();
|
||||
|
||||
extern OverlayHeapSize currentHeapSize;
|
||||
|
||||
bool setOverlayHeapSize(OverlayHeapSize heapSize);
|
||||
|
||||
// Implementation
|
||||
bool requestOverlayExit();
|
||||
|
||||
extern const std::string loaderInfo;
|
||||
extern std::string loaderTitle;
|
||||
extern bool expandedMemory;
|
||||
extern bool furtherExpandedMemory;
|
||||
extern bool limitedMemory;
|
||||
|
||||
extern std::string versionLabel;
|
||||
|
||||
#if IS_LAUNCHER_DIRECTIVE
|
||||
void reinitializeVersionLabels();
|
||||
#endif
|
||||
|
||||
|
||||
// Number of renderer threads to use
|
||||
extern const unsigned numThreads;
|
||||
extern std::vector<std::thread> renderThreads;
|
||||
extern const s32 bmpChunkSize;
|
||||
extern std::atomic<s32> currentRow;
|
||||
|
||||
|
||||
|
||||
static std::barrier inPlotBarrier(numThreads, [](){
|
||||
inPlot.store(false, std::memory_order_release);
|
||||
});
|
||||
|
||||
|
||||
//extern std::atomic<unsigned int> barrierCounter;
|
||||
//extern std::mutex barrierMutex;
|
||||
//extern std::condition_variable barrierCV;
|
||||
//
|
||||
//extern void barrierWait();
|
||||
|
||||
|
||||
void initializeThemeVars();
|
||||
|
||||
void initializeUltrahandSettings();
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,49 +0,0 @@
|
||||
/********************************************************************************
|
||||
* File: ultra.hpp
|
||||
* Author: ppkantorski
|
||||
* Description:
|
||||
* 'ultra.hpp' serves as a central include header for the Ultrahand Overlay project,
|
||||
* bringing together a comprehensive suite of utility functions essential for the
|
||||
* development and operation of custom overlays on the Nintendo Switch. This header
|
||||
* provides consolidated access to functions facilitating debugging, string processing,
|
||||
* file management, JSON manipulation, and more, enhancing the modularity and
|
||||
* reusability of code within the project.
|
||||
*
|
||||
* These utilities are designed to operate independently, providing robust tools to
|
||||
* support complex overlay functionalities and interactions.
|
||||
*
|
||||
* For the latest updates and contributions, visit the project's GitHub repository:
|
||||
* GitHub Repository: https://github.com/ppkantorski/Ultrahand-Overlay
|
||||
*
|
||||
* Note: This notice is integral to the project's documentation and must not be
|
||||
* altered or removed.
|
||||
*
|
||||
* Licensed under both GPLv2 and CC-BY-4.0
|
||||
* Copyright (c) 2024-2025 ppkantorski
|
||||
********************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
|
||||
#ifndef ULTRA_HPP
|
||||
#define ULTRA_HPP
|
||||
|
||||
// Include all functional headers used in the libUltra library
|
||||
|
||||
#include "global_vars.hpp"
|
||||
#include "debug_funcs.hpp"
|
||||
#include "string_funcs.hpp"
|
||||
#include "get_funcs.hpp"
|
||||
#include "path_funcs.hpp"
|
||||
#include "list_funcs.hpp"
|
||||
#include "json_funcs.hpp"
|
||||
#include "ini_funcs.hpp"
|
||||
#include "hex_funcs.hpp"
|
||||
#include "download_funcs.hpp"
|
||||
#include "mod_funcs.hpp"
|
||||
#include "tsl_utils.hpp"
|
||||
#include "audio.hpp"
|
||||
#include "haptics.hpp"
|
||||
|
||||
#endif // ULTRA_HPP
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user