├── manager ├── resources │ ├── .gitkeep │ └── fira │ │ └── FiraSans-Medium-rnx.ttf ├── README.md ├── lib │ └── borealis │ │ ├── .gitattributes │ │ ├── resources │ │ ├── .gitignore │ │ ├── icon │ │ │ └── borealis.jpg │ │ ├── inter │ │ │ └── Inter-Switch.ttf │ │ └── material │ │ │ └── MaterialIcons-Regular.ttf │ │ ├── library │ │ ├── lib │ │ │ ├── extern │ │ │ │ ├── libretro-common │ │ │ │ │ ├── .gitignore │ │ │ │ │ └── compat │ │ │ │ │ │ └── compat_strl.c │ │ │ │ └── nanovg │ │ │ │ │ └── LICENSE.txt │ │ │ ├── switch_wrapper.c │ │ │ ├── rectangle.cpp │ │ │ ├── material_icon.cpp │ │ │ ├── logger.cpp │ │ │ ├── task_manager.cpp │ │ │ ├── repeating_task.cpp │ │ │ └── header.cpp │ │ ├── borealis.mk │ │ ├── include │ │ │ ├── borealis │ │ │ │ ├── extern │ │ │ │ │ ├── nanovg │ │ │ │ │ │ └── LICENSE.txt │ │ │ │ │ └── libretro-common │ │ │ │ │ │ ├── retro_assert.h │ │ │ │ │ │ ├── retro_inline.h │ │ │ │ │ │ ├── boolean.h │ │ │ │ │ │ ├── compat │ │ │ │ │ │ └── strl.h │ │ │ │ │ │ ├── encodings │ │ │ │ │ │ └── utf.h │ │ │ │ │ │ └── features │ │ │ │ │ │ └── features_cpu.h │ │ │ │ ├── task_manager.hpp │ │ │ │ ├── material_icon.hpp │ │ │ │ ├── header.hpp │ │ │ │ ├── swkbd.hpp │ │ │ │ ├── frame_context.hpp │ │ │ │ ├── logger.hpp │ │ │ │ ├── rectangle.hpp │ │ │ │ ├── progress_spinner.hpp │ │ │ │ ├── layer_view.hpp │ │ │ │ ├── staged_applet_frame.hpp │ │ │ │ ├── tab_frame.hpp │ │ │ │ ├── crash_frame.hpp │ │ │ │ ├── hint.hpp │ │ │ │ ├── notification_manager.hpp │ │ │ │ ├── actions.hpp │ │ │ │ ├── progress_display.hpp │ │ │ │ ├── table.hpp │ │ │ │ ├── repeating_task.hpp │ │ │ │ ├── event.hpp │ │ │ │ ├── scroll_view.hpp │ │ │ │ ├── thumbnail_frame.hpp │ │ │ │ ├── image.hpp │ │ │ │ ├── sidebar.hpp │ │ │ │ ├── dropdown.hpp │ │ │ │ └── theme.hpp │ │ │ └── borealis.hpp │ │ └── meson.build │ │ ├── .gitignore │ │ ├── .gitrepo │ │ ├── .clang-format │ │ ├── meson.build │ │ ├── scripts │ │ └── format.sh │ │ ├── COPYING │ │ └── example │ │ ├── sample_installer_page.hpp │ │ └── sample_loading_page.hpp ├── icon.jpg ├── .gitignore ├── src │ ├── ipc │ │ ├── pc_shim │ │ │ ├── game.jpg │ │ │ ├── types.h │ │ │ ├── nacp.h │ │ │ ├── ns.h │ │ │ └── client.h │ │ ├── types.h │ │ ├── client.h │ │ └── ipc.h │ ├── about_tab.h │ ├── main_frame.h │ ├── cheat_sheet_tab.h │ ├── advanced_settings_tab.h │ ├── app_profile_frame.h │ ├── utils.h │ ├── logo.h │ ├── main_frame.cpp │ ├── app_profiles_tab.h │ ├── about_tab.cpp │ ├── cheat_sheet_tab.cpp │ └── logo.cpp └── meson.build ├── overlay ├── .gitignore ├── data │ └── logo_rgba.bin ├── lib │ └── tesla │ │ ├── .gitignore │ │ ├── .github │ │ └── FUNDING.yml │ │ ├── .gitrepo │ │ ├── .vscode │ │ ├── settings.json │ │ └── c_cpp_properties.json │ │ └── README.md ├── scripts │ └── make_logo.sh └── src │ ├── ipc.h │ ├── ui │ ├── style.h │ ├── gui │ │ ├── main_gui.h │ │ ├── base_gui.h │ │ ├── base_menu_gui.h │ │ ├── global_override_gui.h │ │ ├── fatal_gui.h │ │ ├── freq_choice_gui.h │ │ ├── app_profile_gui.h │ │ ├── base_gui.cpp │ │ ├── freq_choice_gui.cpp │ │ ├── main_gui.cpp │ │ └── fatal_gui.cpp │ ├── format.h │ └── elements │ │ └── base_frame.h │ └── main.cpp ├── sysmodule ├── .gitignore ├── lib │ ├── minIni │ │ ├── dev │ │ │ ├── testplain.ini │ │ │ ├── test.ini │ │ │ ├── minGlue-ffs.h │ │ │ ├── minGlue-stdio.h │ │ │ ├── minGlue-FatFs.h │ │ │ ├── minGlue.h │ │ │ ├── test2.cc │ │ │ ├── minGlue-mdd.h │ │ │ ├── minGlue-ccs.h │ │ │ └── minGlue-efsl.h │ │ ├── doc │ │ │ └── minIni.pdf │ │ ├── .gitignore │ │ ├── .gitrepo │ │ ├── NOTICE │ │ └── include │ │ │ └── minIni.h │ └── nxExt │ │ ├── .gitignore │ │ ├── include │ │ ├── nxExt.h │ │ └── nxExt │ │ │ ├── i2c.h │ │ │ ├── tmp451.h │ │ │ ├── max17050.h │ │ │ ├── t210.h │ │ │ ├── apm_ext.h │ │ │ ├── cpp │ │ │ └── lockable_mutex.h │ │ │ └── ipc_server.h │ │ └── src │ │ ├── i2c.c │ │ └── apm_ext.c └── src │ ├── process_management.h │ ├── errors.cpp │ ├── file_utils.h │ ├── errors.h │ ├── board.h │ ├── process_management.cpp │ ├── ipc_service.h │ └── clock_manager.h ├── .gitignore ├── .gitlab-ci.yml ├── LICENSE ├── config.ini.template └── common ├── include ├── sysclk │ ├── apm.h │ ├── errors.h │ ├── client │ │ ├── types.h │ │ └── ipc.h │ ├── clock_manager.h │ └── ipc.h └── sysclk.h └── src └── apm_profile_table.c /manager/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /manager/README.md: -------------------------------------------------------------------------------- 1 | # sys-clk-manager -------------------------------------------------------------------------------- /overlay/.gitignore: -------------------------------------------------------------------------------- 1 | /out 2 | /build 3 | -------------------------------------------------------------------------------- /sysmodule/.gitignore: -------------------------------------------------------------------------------- 1 | /out 2 | /build 3 | -------------------------------------------------------------------------------- /manager/lib/borealis/.gitattributes: -------------------------------------------------------------------------------- 1 | *.glsl text eol=lf 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | .DS_Store 3 | Thumbs.db 4 | desktop.ini 5 | .vscode -------------------------------------------------------------------------------- /manager/lib/borealis/resources/.gitignore: -------------------------------------------------------------------------------- 1 | Illegal-Font.ttf 2 | Wingdings.ttf 3 | -------------------------------------------------------------------------------- /manager/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retronx-team/sys-clk/HEAD/manager/icon.jpg -------------------------------------------------------------------------------- /sysmodule/lib/minIni/dev/testplain.ini: -------------------------------------------------------------------------------- 1 | String=noot # trailing commment 2 | #comment=3 3 | Val=1 4 | -------------------------------------------------------------------------------- /overlay/data/logo_rgba.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retronx-team/sys-clk/HEAD/overlay/data/logo_rgba.bin -------------------------------------------------------------------------------- /manager/lib/borealis/library/lib/extern/libretro-common/.gitignore: -------------------------------------------------------------------------------- 1 | *.dll 2 | *.exe 3 | *.c~ 4 | *.un~ 5 | *.o 6 | -------------------------------------------------------------------------------- /manager/.gitignore: -------------------------------------------------------------------------------- 1 | .*/ 2 | build/ 3 | build.nx/ 4 | *~ 5 | *.bak 6 | *.nro 7 | *.nacp 8 | *.elf 9 | .vscode 10 | -------------------------------------------------------------------------------- /manager/src/ipc/pc_shim/game.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retronx-team/sys-clk/HEAD/manager/src/ipc/pc_shim/game.jpg -------------------------------------------------------------------------------- /sysmodule/lib/minIni/doc/minIni.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retronx-team/sys-clk/HEAD/sysmodule/lib/minIni/doc/minIni.pdf -------------------------------------------------------------------------------- /manager/lib/borealis/.gitignore: -------------------------------------------------------------------------------- 1 | .*/ 2 | build/ 3 | build.nx/ 4 | *~ 5 | *.bak 6 | *.nro 7 | *.nacp 8 | *.elf 9 | .vscode 10 | builddir 11 | -------------------------------------------------------------------------------- /manager/resources/fira/FiraSans-Medium-rnx.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retronx-team/sys-clk/HEAD/manager/resources/fira/FiraSans-Medium-rnx.ttf -------------------------------------------------------------------------------- /manager/lib/borealis/resources/icon/borealis.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retronx-team/sys-clk/HEAD/manager/lib/borealis/resources/icon/borealis.jpg -------------------------------------------------------------------------------- /sysmodule/lib/minIni/dev/test.ini: -------------------------------------------------------------------------------- 1 | [First] 2 | String=noot # trailing commment 3 | Val=1 4 | 5 | [Second] 6 | Val = 2 7 | #comment=3 8 | String = mies 9 | -------------------------------------------------------------------------------- /manager/lib/borealis/resources/inter/Inter-Switch.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retronx-team/sys-clk/HEAD/manager/lib/borealis/resources/inter/Inter-Switch.ttf -------------------------------------------------------------------------------- /overlay/lib/tesla/.gitignore: -------------------------------------------------------------------------------- 1 | debug 2 | release 3 | lib 4 | *.bz2 5 | 6 | example/build/ 7 | 8 | *.elf 9 | 10 | *.nacp 11 | 12 | *.ovl 13 | -------------------------------------------------------------------------------- /sysmodule/lib/nxExt/.gitignore: -------------------------------------------------------------------------------- 1 | # Editor files 2 | *.swp 3 | *~ 4 | 5 | # Objects 6 | *.o 7 | *.a 8 | *.so 9 | 10 | # Lib 11 | lib 12 | release 13 | debug -------------------------------------------------------------------------------- /sysmodule/lib/minIni/.gitignore: -------------------------------------------------------------------------------- 1 | # Editor files 2 | *.swp 3 | *~ 4 | 5 | # Objects 6 | *.o 7 | *.a 8 | *.so 9 | 10 | # Lib 11 | lib 12 | release 13 | debug -------------------------------------------------------------------------------- /manager/lib/borealis/resources/material/MaterialIcons-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retronx-team/sys-clk/HEAD/manager/lib/borealis/resources/material/MaterialIcons-Regular.ttf -------------------------------------------------------------------------------- /overlay/lib/tesla/.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: werwolv 4 | custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KP7XRJAND9KWU&source=url 5 | github: WerWolv 6 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: $CI_SERVER_HOST:4567/libretro/infrastructure/libretro-build-libnx-devkitpro:latest 2 | 3 | variables: 4 | PACKAGE_FOLDER: "sys-clk" 5 | 6 | stages: 7 | - package 8 | 9 | nightly: 10 | stage: package 11 | script: 12 | - bash build.sh $PACKAGE_FOLDER 13 | artifacts: 14 | name: $PACKAGE_FOLDER 15 | expire_in: 24 hours 16 | paths: 17 | - $PACKAGE_FOLDER 18 | -------------------------------------------------------------------------------- /overlay/lib/tesla/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/WerWolv/libtesla 8 | branch = master 9 | commit = b32acbca64c78bf37bc456bd386cd6b7148842c8 10 | parent = dcd0d5d34dbc2d57b5caade31b92c45ca2c48450 11 | method = merge 12 | cmdver = 0.4.5 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------- 2 | "THE BEER-WARE LICENSE" (Revision 42): 3 | , , 4 | wrote this file. As long as you retain this notice you can do whatever you 5 | want with this stuff. If you meet any of us some day, and you think this 6 | stuff is worth it, you can buy us a beer in return. - The sys-clk authors 7 | -------------------------------------------------------------------------- 8 | -------------------------------------------------------------------------------- /sysmodule/lib/minIni/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/compuphase/minIni 8 | branch = master 9 | commit = 8ce144c3c287fa4e59f8ed4c405cd8b7e29f189b 10 | parent = f32c0b1bca87a6d7e55fb341f8db9ef33b13819f 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /manager/lib/borealis/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/natinusala/borealis 8 | branch = master 9 | commit = 2ec4957301f702635feac64111dcd212d2a37ec6 10 | parent = ec9981362c84ff6d44bb574f311f1d994dc80d9c 11 | method = rebase 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /manager/lib/borealis/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | AccessModifierOffset: -2 3 | AlignConsecutiveAssignments: 'true' 4 | BasedOnStyle: WebKit 5 | BreakBeforeBraces: Allman 6 | IncludeBlocks: Regroup 7 | IncludeCategories: 8 | - Regex: '^' 9 | Priority: 2 10 | - Regex: '^<.*\.h>' 11 | Priority: 1 12 | - Regex: '^<.*' 13 | Priority: 2 14 | - Regex: '.*' 15 | Priority: 3 16 | IndentCaseLabels: 'true' 17 | PointerAlignment: Left 18 | SortIncludes: 'true' 19 | Standard: Cpp11 20 | 21 | ... 22 | -------------------------------------------------------------------------------- /overlay/scripts/make_logo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | 6 | DEST="$CURRENT_DIR/../data/logo_rgba.bin" 7 | FONT="$CURRENT_DIR/../../manager/resources/fira/FiraSans-Medium-rnx.ttf" 8 | FONT_SIZE="30.5" 9 | TEXT="sys-clk" 10 | 11 | function render() { 12 | convert -background transparent -colorspace RGB -depth 8 -fill white -font "$1" -pointsize "$2" "label:$3" "$4" 13 | } 14 | 15 | render "$FONT" "$FONT_SIZE" "$TEXT" info: 16 | render "$FONT" "$FONT_SIZE" "$TEXT" "RGBA:$DEST" -------------------------------------------------------------------------------- /config.ini.template: -------------------------------------------------------------------------------- 1 | [values] 2 | ; Defines how often sys-clk log temperatures, in milliseconds (set 0 to disable) 3 | temp_log_interval_ms=0 4 | ; Defines how often sys-clk writes to the CSV, in milliseconds (set 0 to disable) 5 | csv_write_interval_ms=0 6 | 7 | ; Example #1: BOTW 8 | ; Overclock CPU when docked 9 | ; Overclock MEM to docked clocks when handheld 10 | ;[01007EF00011E000] 11 | ;docked_cpu=1224 12 | ;handheld_mem=1600 13 | 14 | ; Example #2: Picross 15 | ; Underclock to save battery 16 | ;[0100BA0003EEA000] 17 | ;handheld_cpu=816 18 | ;handheld_gpu=153 19 | ;handheld_mem=800 -------------------------------------------------------------------------------- /sysmodule/lib/minIni/NOTICE: -------------------------------------------------------------------------------- 1 | minIni is a programmer's library to read and write "INI" files in embedded 2 | systems. The library takes little resources and can be configured for various 3 | kinds of file I/O libraries. 4 | 5 | The method for portable INI file management in minIni is, in part based, on the 6 | article "Multiplatform .INI Files" by Joseph J. Graf in the March 1994 issue of 7 | Dr. Dobb's Journal. 8 | 9 | The C++ class in minIni.h was contributed by Steven Van Ingelgem. 10 | 11 | The option to compile minIni as a read-only library was contributed by Luca 12 | Bassanello. 13 | -------------------------------------------------------------------------------- /sysmodule/lib/minIni/include/minIni.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" 14 | { 15 | #endif 16 | 17 | #include "../dev/minIni.h" 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif -------------------------------------------------------------------------------- /manager/lib/borealis/meson.build: -------------------------------------------------------------------------------- 1 | project('borealis_example', ['c', 'cpp'], 2 | version: '1.0.0', 3 | default_options: [ 'buildtype=release', 'strip=true', 'b_ndebug=if-release', 'cpp_std=c++1z' ], 4 | ) 5 | 6 | subdir('library') 7 | 8 | example_files = files( 9 | 'example/main.cpp', 10 | 'example/sample_installer_page.cpp', 11 | 'example/sample_loading_page.cpp' 12 | ) 13 | 14 | borealis_example = executable( 15 | 'borealis_example', 16 | [ example_files, borealis_files ], 17 | dependencies : borealis_dependencies, 18 | install: true, 19 | include_directories: [ borealis_include, include_directories('example')], 20 | cpp_args: [ '-g', '-O2', '-DBOREALIS_RESOURCES="./resources/"' ] 21 | ) 22 | -------------------------------------------------------------------------------- /overlay/src/ipc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #if defined(__cplusplus) 14 | extern "C" 15 | { 16 | #endif 17 | 18 | #include 19 | #include 20 | 21 | #if defined(__cplusplus) 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/borealis.mk: -------------------------------------------------------------------------------- 1 | mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) 2 | current_dir := $(BOREALIS_PATH)/$(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) 3 | 4 | LIBS := -lglfw3 -lEGL -lglapi -ldrm_nouveau -lm $(LIBS) 5 | 6 | SOURCES := $(SOURCES) \ 7 | $(current_dir)/lib \ 8 | $(current_dir)/lib/extern/glad \ 9 | $(current_dir)/lib/extern/nanovg \ 10 | $(current_dir)/lib/extern/libretro-common/compat \ 11 | $(current_dir)/lib/extern/libretro-common/encodings \ 12 | $(current_dir)/lib/extern/libretro-common/features 13 | 14 | INCLUDES := $(INCLUDES) \ 15 | $(current_dir)/include \ 16 | $(current_dir)/include/borealis/extern/glad \ 17 | $(current_dir)/include/borealis/extern/nanovg \ 18 | $(current_dir)/include/borealis/extern/libretro-common 19 | -------------------------------------------------------------------------------- /manager/lib/borealis/scripts/format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$( dirname "${BASH_SOURCE[0]}" )/.." 4 | 5 | FIX="" 6 | COLOR="auto" 7 | 8 | for v in "$@"; do 9 | if [[ "$v" == "--no-ansi" ]] || [[ "$v" == "-n" ]]; then 10 | COLOR="never" 11 | fi 12 | if [[ "$v" == "--fix" ]] || [[ "$v" == "-f" ]]; then 13 | FIX="1" 14 | fi 15 | done 16 | 17 | function clang_format_run() { 18 | python ./scripts/run-clang-format.py -r \ 19 | --clang-format-executable="clang-format-8" \ 20 | --color="$COLOR" \ 21 | --exclude ./library/include/borealis/extern \ 22 | --exclude ./library/lib/extern \ 23 | ./library ./example 24 | } 25 | 26 | if [[ -z "$FIX" ]]; then 27 | clang_format_run 28 | else 29 | clang_format_run | patch -p1 -N -r - 30 | fi 31 | -------------------------------------------------------------------------------- /sysmodule/lib/nxExt/include/nxExt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "nxExt/apm_ext.h" 14 | #include "nxExt/i2c.h" 15 | #include "nxExt/t210.h" 16 | #include "nxExt/max17050.h" 17 | #include "nxExt/tmp451.h" 18 | #include "nxExt/ipc_server.h" 19 | #include "nxExt/cpp/lockable_mutex.h" 20 | -------------------------------------------------------------------------------- /sysmodule/lib/nxExt/include/nxExt/i2c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | #include 19 | 20 | Result i2csessionExtRegReceive(I2cSession* s, u8 in, void* out, u8 out_size); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /common/include/sysclk/apm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "board.h" 14 | 15 | typedef struct { 16 | uint32_t id; 17 | uint32_t cpu_hz; 18 | uint32_t gpu_hz; 19 | uint32_t mem_hz; 20 | } SysClkApmConfiguration; 21 | 22 | extern SysClkApmConfiguration sysclk_g_apm_configurations[]; 23 | -------------------------------------------------------------------------------- /sysmodule/lib/nxExt/include/nxExt/tmp451.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | #include 19 | 20 | Result tmp451Initialize(void); 21 | void tmp451Exit(void); 22 | s32 tmp451TempPcb(void); 23 | s32 tmp451TempSoc(void); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /common/include/sysclk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #include "sysclk/ipc.h" 18 | #include "sysclk/board.h" 19 | #include "sysclk/clock_manager.h" 20 | #include "sysclk/apm.h" 21 | #include "sysclk/config.h" 22 | #include "sysclk/errors.h" 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif -------------------------------------------------------------------------------- /sysmodule/lib/nxExt/include/nxExt/max17050.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | #include 19 | 20 | Result max17050Initialize(void); 21 | void max17050Exit(void); 22 | s32 max17050PowerNow(void); 23 | s32 max17050PowerAvg(void); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /common/include/sysclk/errors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #define SYSCLK_ERROR_MODULE 388 14 | #define SYSCLK_ERROR(desc) ((SYSCLK_ERROR_MODULE & 0x1FF) | (SysClkError_##desc & 0x1FFF)<<9) 15 | 16 | typedef enum 17 | { 18 | SysClkError_Generic = 0, 19 | SysClkError_ConfigNotLoaded = 1, 20 | SysClkError_ConfigSaveFailed = 2, 21 | } SysClkError; 22 | -------------------------------------------------------------------------------- /sysmodule/lib/nxExt/include/nxExt/t210.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | #include 19 | 20 | u32 t210ClkCpuFreq(void); 21 | u32 t210ClkMemFreq(void); 22 | u32 t210ClkGpuFreq(void); 23 | u32 t210EmcLoadAll(void); 24 | u32 t210EmcLoadCpu(void); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /overlay/src/ui/style.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #define TEXT_COLOR tsl::gfx::Renderer::a(0xFFFF) 16 | #define DESC_COLOR tsl::gfx::Renderer::a({ 0xC, 0xC, 0xC, 0xF }) 17 | #define VALUE_COLOR tsl::gfx::Renderer::a({ 0x5, 0xC, 0xA, 0xF }) 18 | #define SMALL_TEXT_SIZE 15 19 | #define LABEL_SPACING 7 20 | #define LABEL_FONT_SIZE 15 21 | -------------------------------------------------------------------------------- /overlay/src/ui/gui/main_gui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "base_menu_gui.h" 14 | 15 | class MainGui : public BaseMenuGui 16 | { 17 | protected: 18 | tsl::elm::ToggleListItem* enabledToggle; 19 | 20 | public: 21 | MainGui() {} 22 | ~MainGui() {} 23 | void listUI() override; 24 | void refresh() override; 25 | }; 26 | -------------------------------------------------------------------------------- /sysmodule/src/process_management.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | #include 13 | #include 14 | 15 | #define PROCESS_MANAGEMENT_QLAUNCH_TID 0x0100000000001000ULL 16 | 17 | class ProcessManagement 18 | { 19 | public: 20 | static void Initialize(); 21 | static void WaitForQLaunch(); 22 | static std::uint64_t GetCurrentApplicationId(); 23 | static void Exit(); 24 | }; 25 | -------------------------------------------------------------------------------- /manager/lib/borealis/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 fincs 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | -------------------------------------------------------------------------------- /common/include/sysclk/client/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #ifdef __SWITCH__ 14 | 15 | #include 16 | #include 17 | 18 | #else 19 | 20 | #define R_FAILED(res) ((res) != 0) 21 | #define R_SUCCEEDED(res) ((res) == 0) 22 | 23 | typedef std::uint32_t Result; 24 | typedef std::uint32_t u32; 25 | typedef std::int32_t s32; 26 | typedef std::uint64_t u64; 27 | typedef std::uint8_t u8; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/lib/extern/nanovg/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Mikko Mononen memon@inside.org 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | 19 | -------------------------------------------------------------------------------- /sysmodule/lib/nxExt/include/nxExt/apm_ext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | #include 19 | 20 | Result apmExtInitialize(void); 21 | void apmExtExit(void); 22 | 23 | Result apmExtGetPerformanceMode(u32* out_mode); 24 | Result apmExtSysRequestPerformanceMode(u32 mode); 25 | Result apmExtGetCurrentPerformanceConfiguration(u32* out_conf); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/extern/nanovg/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Mikko Mononen memon@inside.org 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | 19 | -------------------------------------------------------------------------------- /overlay/src/ui/gui/base_gui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #include "../style.h" 16 | 17 | class BaseGui : public tsl::Gui 18 | { 19 | public: 20 | BaseGui() {} 21 | ~BaseGui() {} 22 | virtual void preDraw(tsl::gfx::Renderer* renderer); 23 | void update() override; 24 | tsl::elm::Element* createUI() override; 25 | virtual tsl::elm::Element* baseUI() = 0; 26 | virtual void refresh() {} 27 | }; 28 | -------------------------------------------------------------------------------- /overlay/src/ui/format.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #define FREQ_DEFAULT_TEXT "Do not override" 16 | 17 | static inline std::string formatListFreqMHz(std::uint32_t mhz) 18 | { 19 | if(mhz == 0) 20 | { 21 | return FREQ_DEFAULT_TEXT; 22 | } 23 | 24 | char buf[10]; 25 | return std::string(buf, snprintf(buf, sizeof(buf), "%u MHz", mhz)); 26 | } 27 | 28 | static inline std::string formatListFreqHz(std::uint32_t hz) { return formatListFreqMHz(hz / 1000000); } 29 | -------------------------------------------------------------------------------- /manager/src/ipc/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | typedef char NsApplicationName[0x201]; 26 | typedef uint8_t NsApplicationIcon[0x20000]; 27 | -------------------------------------------------------------------------------- /sysmodule/lib/nxExt/src/i2c.c: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #include "nxExt/i2c.h" 12 | 13 | #define I2C_CMD_SND 0 14 | #define I2C_CMD_RCV 1 15 | 16 | Result i2csessionExtRegReceive(I2cSession* s, u8 in, void* out, u8 out_size) 17 | { 18 | u8 cmdlist[5] = { 19 | I2C_CMD_SND | (I2cTransactionOption_Start << 6), 20 | sizeof(in), 21 | in, 22 | 23 | I2C_CMD_RCV | (I2cTransactionOption_All << 6), 24 | out_size 25 | }; 26 | 27 | return i2csessionExecuteCommandList(s, out, out_size, cmdlist, sizeof(cmdlist)); 28 | } 29 | -------------------------------------------------------------------------------- /overlay/src/ui/gui/base_menu_gui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "../../ipc.h" 14 | #include "base_gui.h" 15 | 16 | class BaseMenuGui : public BaseGui 17 | { 18 | protected: 19 | SysClkContext* context; 20 | std::uint64_t lastContextUpdate; 21 | tsl::elm::List* listElement; 22 | 23 | public: 24 | BaseMenuGui(); 25 | ~BaseMenuGui(); 26 | void preDraw(tsl::gfx::Renderer* renderer) override; 27 | tsl::elm::Element* baseUI() override; 28 | void refresh() override; 29 | virtual void listUI() = 0; 30 | }; 31 | -------------------------------------------------------------------------------- /overlay/src/ui/elements/base_frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "../gui/base_gui.h" 15 | 16 | class BaseFrame : public tsl::elm::HeaderOverlayFrame 17 | { 18 | public: 19 | BaseFrame(BaseGui* gui) : tsl::elm::HeaderOverlayFrame(225) { 20 | this->gui = gui; 21 | } 22 | 23 | void draw(tsl::gfx::Renderer* renderer) override 24 | { 25 | tsl::elm::HeaderOverlayFrame::draw(renderer); 26 | this->gui->preDraw(renderer); 27 | } 28 | 29 | protected: 30 | BaseGui* gui; 31 | }; 32 | -------------------------------------------------------------------------------- /manager/src/about_tab.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019-2020 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | class AboutTab : public brls::List 26 | { 27 | public: 28 | AboutTab(); 29 | 30 | View* getDefaultFocus() override 31 | { 32 | return nullptr; 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /manager/src/ipc/client.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "ipc.h" 24 | 25 | #if defined(__SWITCH__) && defined(__cplusplus) 26 | extern "C" { 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | #if defined(__SWITCH__) && defined(__cplusplus) 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /overlay/src/ui/gui/global_override_gui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "../../ipc.h" 14 | #include "base_menu_gui.h" 15 | #include "freq_choice_gui.h" 16 | 17 | class GlobalOverrideGui : public BaseMenuGui 18 | { 19 | protected: 20 | tsl::elm::ListItem* listItems[SysClkModule_EnumMax]; 21 | std::uint32_t listHz[SysClkModule_EnumMax]; 22 | 23 | void openFreqChoiceGui(SysClkModule module); 24 | void addModuleListItem(SysClkModule module); 25 | 26 | public: 27 | GlobalOverrideGui(); 28 | ~GlobalOverrideGui() {} 29 | void listUI() override; 30 | void refresh() override; 31 | }; 32 | -------------------------------------------------------------------------------- /manager/src/main_frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include "refresh_task.h" 26 | 27 | class MainFrame : public brls::TabFrame 28 | { 29 | private: 30 | RefreshTask *refreshTask; 31 | 32 | public: 33 | MainFrame(); 34 | ~MainFrame(); 35 | }; 36 | -------------------------------------------------------------------------------- /overlay/src/ui/gui/fatal_gui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #include "base_gui.h" 16 | 17 | class FatalGui : public BaseGui 18 | { 19 | protected: 20 | std::string message; 21 | std::string info; 22 | 23 | public: 24 | FatalGui(const std::string message, const std::string info); 25 | ~FatalGui() {} 26 | tsl::elm::Element* baseUI() override; 27 | bool handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft, HidAnalogStickState joyStickPosRight); 28 | static void openWithResultCode(std::string tag, Result rc); 29 | }; 30 | -------------------------------------------------------------------------------- /manager/src/ipc/pc_shim/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #define R_FAILED(res) ((res) != 0) 26 | #define R_SUCCEEDED(res) ((res) == 0) 27 | 28 | typedef std::uint32_t Result; 29 | typedef std::uint32_t u32; 30 | typedef std::int32_t s32; 31 | typedef std::uint64_t u64; 32 | typedef std::uint8_t u8; 33 | -------------------------------------------------------------------------------- /manager/src/ipc/ipc.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "types.h" 24 | 25 | #ifdef __SWITCH__ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #else 38 | 39 | #include "pc_shim/nacp.h" 40 | #include "pc_shim/ns.h" 41 | #include "pc_shim/types.h" 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /sysmodule/src/errors.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #include "errors.h" 12 | #include 13 | #include 14 | 15 | void Errors::ThrowException(const char* format, ...) 16 | { 17 | va_list args; 18 | va_start(args, format); 19 | const char* msg = Errors::FormatMessage(format, args); 20 | va_end(args); 21 | 22 | throw std::runtime_error(msg); 23 | } 24 | 25 | const char* Errors::FormatMessage(const char* format, va_list args) 26 | { 27 | size_t len = vsnprintf(NULL, 0, format, args) * sizeof(char); 28 | char* buf = (char*)malloc(len + 1); 29 | if (buf == NULL) 30 | { 31 | return format; 32 | } 33 | 34 | vsnprintf(buf, len + 1, format, args); 35 | 36 | return buf; 37 | } 38 | -------------------------------------------------------------------------------- /manager/meson.build: -------------------------------------------------------------------------------- 1 | project('sys-clk-manager', ['c', 'cpp'], 2 | version: '1.0.0', 3 | default_options: [ 'buildtype=release', 'strip=true', 'b_ndebug=if-release', 'cpp_std=c++1z' ], 4 | ) 5 | 6 | add_global_arguments('-DAPP_TITLE="sys-clk manager"', language : 'cpp') 7 | 8 | subdir('lib/borealis/library') 9 | 10 | source_files = files( 11 | 'src/main.cpp', 12 | 'src/utils.cpp', 13 | 'src/refresh_task.cpp', 14 | 15 | 'src/main_frame.cpp', 16 | 'src/logo.cpp', 17 | 18 | 'src/status_tab.cpp', 19 | 'src/advanced_settings_tab.cpp', 20 | 'src/app_profiles_tab.cpp', 21 | 'src/app_profile_frame.cpp', 22 | 'src/cheat_sheet_tab.cpp', 23 | 'src/about_tab.cpp' 24 | ) 25 | 26 | ipc_files = files( 27 | 'src/ipc/pc_shim/client.cpp', 28 | 'src/ipc/pc_shim/ns.cpp' 29 | ) 30 | 31 | manager_include = include_directories( 32 | '../common/include' 33 | ) 34 | 35 | sys_clk_manager = executable( 36 | 'sys-clk-manager', 37 | [ source_files, borealis_files, ipc_files ], 38 | dependencies : borealis_dependencies, 39 | install: true, 40 | include_directories: [borealis_include, manager_include], 41 | cpp_args: [ '-g', '-O2', '-DBOREALIS_RESOURCES="./lib/borealis/resources/"', '-DAPP_RESOURCES="./resources/"'] 42 | ) 43 | -------------------------------------------------------------------------------- /manager/src/cheat_sheet_tab.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019-2020 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | class CheatSheetTab : public brls::List 26 | { 27 | public: 28 | CheatSheetTab(); 29 | 30 | void customSpacing(brls::View* current, brls::View* next, int* spacing) override; 31 | 32 | View* getDefaultFocus() override 33 | { 34 | return nullptr; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /overlay/src/ui/gui/freq_choice_gui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #include "base_menu_gui.h" 16 | 17 | using FreqChoiceListener = std::function; 18 | 19 | #define FREQ_DEFAULT_TEXT "Do not override" 20 | 21 | class FreqChoiceGui : public BaseMenuGui 22 | { 23 | protected: 24 | std::uint32_t selectedHz; 25 | std::uint32_t* hzList; 26 | std::uint32_t hzCount; 27 | FreqChoiceListener listener; 28 | tsl::elm::ListItem* createFreqListItem(std::uint32_t hz, bool selected); 29 | 30 | public: 31 | FreqChoiceGui(std::uint32_t selectedHz, std::uint32_t* hzList, std::uint32_t hzCount, FreqChoiceListener listener); 32 | ~FreqChoiceGui() {} 33 | void listUI() override; 34 | }; 35 | -------------------------------------------------------------------------------- /common/include/sysclk/clock_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "board.h" 15 | 16 | typedef struct 17 | { 18 | uint8_t enabled; 19 | uint64_t applicationId; 20 | SysClkProfile profile; 21 | uint32_t freqs[SysClkModule_EnumMax]; 22 | uint32_t realFreqs[SysClkModule_EnumMax]; 23 | uint32_t overrideFreqs[SysClkModule_EnumMax]; 24 | uint32_t temps[SysClkThermalSensor_EnumMax]; 25 | int32_t power[SysClkPowerSensor_EnumMax]; 26 | uint32_t ramLoad[SysClkRamLoad_EnumMax]; 27 | } SysClkContext; 28 | 29 | typedef struct 30 | { 31 | union { 32 | uint32_t mhz[SysClkProfile_EnumMax * SysClkModule_EnumMax]; 33 | uint32_t mhzMap[SysClkProfile_EnumMax][SysClkModule_EnumMax]; 34 | }; 35 | } SysClkTitleProfileList; 36 | 37 | #define SYSCLK_FREQ_LIST_MAX 32 38 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/task_manager.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | 25 | namespace brls 26 | { 27 | 28 | class TaskManager 29 | { 30 | private: 31 | std::vector repeatingTasks; 32 | 33 | void stopRepeatingTask(RepeatingTask* task); 34 | 35 | public: 36 | void frame(); 37 | 38 | void registerRepeatingTask(RepeatingTask* task); 39 | 40 | ~TaskManager(); 41 | }; 42 | 43 | } // namespace brls 44 | -------------------------------------------------------------------------------- /manager/src/advanced_settings_tab.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include "ipc/client.h" 26 | 27 | class AdvancedSettingsTab : public brls::List 28 | { 29 | public: 30 | AdvancedSettingsTab(); 31 | 32 | private: 33 | std::string getDescriptionForConfig(SysClkConfigValue config); 34 | 35 | bool isLoggingEnabled(); 36 | void setLoggingEnabled(bool value); 37 | 38 | SysClkConfigValueList configValues; 39 | }; 40 | -------------------------------------------------------------------------------- /manager/src/ipc/pc_shim/nacp.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "types.h" 24 | 25 | typedef struct 26 | { 27 | char name[0x200]; 28 | } NacpLanguageEntry; 29 | 30 | 31 | typedef struct 32 | { 33 | NacpLanguageEntry entry; 34 | } NacpStruct; 35 | 36 | static inline Result nacpGetLanguageEntry(NacpStruct* nacp, NacpLanguageEntry** langentry) 37 | { 38 | if(nacp && langentry) 39 | { 40 | *langentry = &nacp->entry; 41 | return 0; 42 | } 43 | return 0xBAD; 44 | } 45 | -------------------------------------------------------------------------------- /overlay/src/ui/gui/app_profile_gui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "../../ipc.h" 14 | #include "base_menu_gui.h" 15 | #include "freq_choice_gui.h" 16 | 17 | class AppProfileGui : public BaseMenuGui 18 | { 19 | protected: 20 | std::uint64_t applicationId; 21 | SysClkTitleProfileList* profileList; 22 | 23 | void openFreqChoiceGui(tsl::elm::ListItem* listItem, SysClkProfile profile, SysClkModule module); 24 | void addModuleListItem(SysClkProfile profile, SysClkModule module); 25 | void addProfileUI(SysClkProfile profile); 26 | 27 | public: 28 | AppProfileGui(std::uint64_t applicationId, SysClkTitleProfileList* profileList); 29 | ~AppProfileGui(); 30 | void listUI() override; 31 | static void changeTo(std::uint64_t applicationId); 32 | void update() override; 33 | }; 34 | -------------------------------------------------------------------------------- /sysmodule/lib/minIni/dev/minGlue-ffs.h: -------------------------------------------------------------------------------- 1 | /* Glue functions for the minIni library, based on the "FAT Filing System" 2 | * library by embedded-code.com 3 | * 4 | * By CompuPhase, 2008-2012 5 | * This "glue file" is in the public domain. It is distributed without 6 | * warranties or conditions of any kind, either express or implied. 7 | * 8 | * (The "FAT Filing System" library itself is copyright embedded-code.com, and 9 | * licensed at its own terms.) 10 | */ 11 | 12 | #define INI_BUFFERSIZE 256 /* maximum line length, maximum path length */ 13 | #include 14 | 15 | #define INI_FILETYPE FFS_FILE* 16 | #define ini_openread(filename,file) ((*(file) = ffs_fopen((filename),"r")) != NULL) 17 | #define ini_openwrite(filename,file) ((*(file) = ffs_fopen((filename),"w")) != NULL) 18 | #define ini_close(file) (ffs_fclose(*(file)) == 0) 19 | #define ini_read(buffer,size,file) (ffs_fgets((buffer),(size),*(file)) != NULL) 20 | #define ini_write(buffer,file) (ffs_fputs((buffer),*(file)) >= 0) 21 | #define ini_rename(source,dest) (ffs_rename((source), (dest)) == 0) 22 | #define ini_remove(filename) (ffs_remove(filename) == 0) 23 | 24 | #define INI_FILEPOS long 25 | #define ini_tell(file,pos) (ffs_fgetpos(*(file), (pos)) == 0) 26 | #define ini_seek(file,pos) (ffs_fsetpos(*(file), (pos)) == 0) 27 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/lib/switch_wrapper.c: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 WerWolv 5 | Copyright (C) 2019 p-sam 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | static int nxlink_sock = -1; 25 | 26 | void userAppInit() 27 | { 28 | romfsInit(); 29 | socketInitializeDefault(); 30 | nxlink_sock = nxlinkStdio(); 31 | plInitialize(PlServiceType_User); 32 | setsysInitialize(); 33 | } 34 | 35 | void userAppExit() 36 | { 37 | if (nxlink_sock != -1) 38 | close(nxlink_sock); 39 | socketExit(); 40 | romfsExit(); 41 | plExit(); 42 | setsysExit(); 43 | } 44 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/material_icon.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace brls 24 | { 25 | 26 | // A Material icon (from the Material font) 27 | class MaterialIcon : public View 28 | { 29 | private: 30 | std::string icon; 31 | unsigned middleX, middleY; 32 | 33 | public: 34 | MaterialIcon(std::string icon); 35 | 36 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 37 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 38 | }; 39 | 40 | } // namespace brls 41 | -------------------------------------------------------------------------------- /sysmodule/src/file_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #define FILE_CONFIG_DIR "/config/" TARGET 21 | #define FILE_FLAG_CHECK_INTERVAL_NS 5000000000ULL 22 | #define FILE_CONTEXT_CSV_PATH FILE_CONFIG_DIR "/context.csv" 23 | #define FILE_LOG_FLAG_PATH FILE_CONFIG_DIR "/log.flag" 24 | #define FILE_LOG_FILE_PATH FILE_CONFIG_DIR "/log.txt" 25 | 26 | class FileUtils 27 | { 28 | public: 29 | static void Exit(); 30 | static Result Initialize(); 31 | static bool IsInitialized(); 32 | static bool IsLogEnabled(); 33 | static void InitializeAsync(); 34 | static void LogLine(const char* format, ...); 35 | static void WriteContextToCsv(const SysClkContext* context); 36 | protected: 37 | static void RefreshFlags(bool force); 38 | }; 39 | -------------------------------------------------------------------------------- /manager/src/app_profile_frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include "app_profiles_tab.h" 28 | 29 | class AppProfileFrame : public brls::ThumbnailFrame 30 | { 31 | public: 32 | AppProfileFrame(Title* title); 33 | 34 | bool onCancel() override; 35 | 36 | private: 37 | Title* title; 38 | 39 | SysClkTitleProfileList profiles; 40 | 41 | bool hasProfileChanged(); 42 | 43 | void addFreqs(brls::List* list, SysClkProfile profile); 44 | 45 | void onProfileChanged(); 46 | }; 47 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/header.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | namespace brls 25 | { 26 | 27 | // A simple header with text, a rectangle on the left 28 | // and a separator 29 | class Header : public View 30 | { 31 | private: 32 | std::string label; 33 | std::string sublabel; 34 | bool separator; 35 | 36 | public: 37 | Header(std::string label, bool separator = true, std::string sublabel = ""); 38 | 39 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 40 | }; 41 | 42 | } // namespace brls 43 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/swkbd.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 WerWolv 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | 25 | namespace brls 26 | { 27 | 28 | class Swkbd 29 | { 30 | public: 31 | static bool openForText(std::function f, std::string headerText = "", std::string subText = "", int maxStringLength = 32, std::string initialText = ""); 32 | static bool openForNumber(std::function f, std::string headerText = "", std::string subText = "", int maxStringLength = 32, std::string initialText = "", std::string leftButton = "", std::string rightButton = ""); 33 | }; 34 | 35 | } // namespace brls 36 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/frame_context.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | namespace brls 28 | { 29 | 30 | class FontStash 31 | { 32 | public: 33 | int regular = 0; 34 | int korean = 0; 35 | 36 | int material = 0; 37 | int sharedSymbols = 0; 38 | }; 39 | 40 | class FrameContext 41 | { 42 | public: 43 | NVGcontext* vg = nullptr; 44 | float pixelRatio = 0.0; 45 | FontStash* fontStash = nullptr; 46 | ThemeValues* theme = nullptr; 47 | }; 48 | 49 | } // namespace brls 50 | -------------------------------------------------------------------------------- /sysmodule/lib/nxExt/include/nxExt/cpp/lockable_mutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #ifdef __cplusplus 14 | 15 | #include 16 | #include 17 | 18 | class LockableMutex 19 | { 20 | public: 21 | LockableMutex() 22 | { 23 | mutexInit(&this->m); 24 | } 25 | 26 | virtual ~LockableMutex() {} 27 | 28 | void Lock() 29 | { 30 | mutexLock(&this->m); 31 | } 32 | 33 | bool TryLock() 34 | { 35 | return mutexTryLock(&this->m); 36 | } 37 | 38 | void Unlock() 39 | { 40 | mutexUnlock(&this->m); 41 | } 42 | 43 | // snake_case aliases in order to implement Lockable 44 | 45 | void lock() 46 | { 47 | this->Lock(); 48 | } 49 | 50 | bool try_lock() 51 | { 52 | return this->TryLock(); 53 | } 54 | 55 | void unlock() 56 | { 57 | this->Unlock(); 58 | } 59 | 60 | private: 61 | Mutex m; 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/logger.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | #include 25 | 26 | namespace brls 27 | { 28 | 29 | enum class LogLevel 30 | { 31 | ERROR = 0, 32 | INFO, 33 | DEBUG 34 | }; 35 | 36 | class Logger 37 | { 38 | public: 39 | static void setLogLevel(LogLevel logLevel); 40 | 41 | static void error(const char* format, ...); 42 | static void info(const char* format, ...); 43 | static void debug(const char* format, ...); 44 | 45 | protected: 46 | static void log(LogLevel logLevel, const char* prefix, const char* color, const char* format, va_list ap); 47 | }; 48 | 49 | } // namespace brls 50 | -------------------------------------------------------------------------------- /manager/lib/borealis/example/sample_installer_page.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 Billy Laws 5 | Copyright (C) 2019 p-sam 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | class SampleInstallerPage : public brls::View 26 | { 27 | private: 28 | brls::Button* button; 29 | brls::Label* label; 30 | 31 | public: 32 | SampleInstallerPage(brls::StagedAppletFrame* frame, std::string label); 33 | ~SampleInstallerPage(); 34 | 35 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override; 36 | void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override; 37 | brls::View* getDefaultFocus() override; 38 | }; 39 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/rectangle.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | 25 | namespace brls 26 | { 27 | 28 | // A solid color rectangle 29 | class Rectangle : public View 30 | { 31 | protected: 32 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 33 | 34 | public: 35 | Rectangle(NVGcolor color); 36 | 37 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 38 | 39 | void setColor(NVGcolor color); 40 | 41 | ~Rectangle() {} 42 | 43 | private: 44 | NVGcolor color = nvgRGB(0, 0, 255); 45 | }; 46 | 47 | } // namespace brls 48 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/progress_spinner.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 Billy Laws 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | namespace brls 25 | { 26 | 27 | // A progress spinner 28 | class ProgressSpinner : public View 29 | { 30 | public: 31 | ProgressSpinner(); 32 | 33 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 34 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 35 | void willAppear(bool resetState = false) override; 36 | void willDisappear(bool resetState = false) override; 37 | 38 | private: 39 | float animationValue = 0.0f; 40 | 41 | void restartAnimation(); 42 | }; 43 | 44 | } // namespace brls 45 | -------------------------------------------------------------------------------- /common/src/apm_profile_table.c: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #include 12 | 13 | SysClkApmConfiguration sysclk_g_apm_configurations[] = { 14 | {0x00010000, 1020000000, 384000000, 1600000000}, 15 | {0x00010001, 1020000000, 768000000, 1600000000}, 16 | {0x00010002, 1224000000, 691200000, 1600000000}, 17 | {0x00020000, 1020000000, 230400000, 1600000000}, 18 | {0x00020001, 1020000000, 307200000, 1600000000}, 19 | {0x00020002, 1224000000, 230400000, 1600000000}, 20 | {0x00020003, 1020000000, 307200000, 1331200000}, 21 | {0x00020004, 1020000000, 384000000, 1331200000}, 22 | {0x00020005, 1020000000, 307200000, 1065600000}, 23 | {0x00020006, 1020000000, 384000000, 1065600000}, 24 | {0x92220007, 1020000000, 460800000, 1600000000}, 25 | {0x92220008, 1020000000, 460800000, 1331200000}, 26 | {0x92220009, 1785000000, 76800000, 1600000000}, 27 | {0x9222000A, 1785000000, 76800000, 1331200000}, 28 | {0x9222000B, 1020000000, 76800000, 1600000000}, 29 | {0x9222000C, 1020000000, 76800000, 1331200000}, 30 | {0, 0, 0, 0}, 31 | }; 32 | 33 | -------------------------------------------------------------------------------- /sysmodule/src/errors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | #define ERROR_THROW(format, ...) Errors::ThrowException(format "\n in %s:%u", ##__VA_ARGS__, __FILE__, __LINE__) 17 | #define ERROR_RESULT_THROW(rc, format, ...) ERROR_THROW(format "\n RC: [0x%x] %04d-%04d", ##__VA_ARGS__, rc, R_MODULE(rc), R_DESCRIPTION(rc)) 18 | #define ASSERT_RESULT_OK(rc, format, ...) \ 19 | if (R_FAILED(rc)) \ 20 | { \ 21 | ERROR_RESULT_THROW(rc, "ASSERT_RESULT_OK: " format, ##__VA_ARGS__); \ 22 | } 23 | #define ASSERT_ENUM_VALID(n, v) \ 24 | if(!SYSCLK_ENUM_VALID(n, v)) { \ 25 | ERROR_THROW("No such %s: %u", #n, v); \ 26 | } 27 | 28 | class Errors 29 | { 30 | public: 31 | static void ThrowException(const char* format, ...); 32 | 33 | protected: 34 | static const char* FormatMessage(const char* format, va_list args); 35 | }; 36 | -------------------------------------------------------------------------------- /common/include/sysclk/ipc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "board.h" 15 | #include "clock_manager.h" 16 | 17 | #define SYSCLK_IPC_API_VERSION 4 18 | #define SYSCLK_IPC_SERVICE_NAME "sys:clk" 19 | 20 | enum SysClkIpcCmd 21 | { 22 | SysClkIpcCmd_GetApiVersion = 0, 23 | SysClkIpcCmd_GetVersionString = 1, 24 | SysClkIpcCmd_GetCurrentContext = 2, 25 | SysClkIpcCmd_Exit = 3, 26 | SysClkIpcCmd_GetProfileCount = 4, 27 | SysClkIpcCmd_GetProfiles = 5, 28 | SysClkIpcCmd_SetProfiles = 6, 29 | SysClkIpcCmd_SetEnabled = 7, 30 | SysClkIpcCmd_SetOverride = 8, 31 | SysClkIpcCmd_GetConfigValues = 9, 32 | SysClkIpcCmd_SetConfigValues = 10, 33 | SysClkIpcCmd_GetFreqList = 11, 34 | }; 35 | 36 | 37 | typedef struct 38 | { 39 | uint64_t tid; 40 | SysClkTitleProfileList profiles; 41 | } SysClkIpc_SetProfiles_Args; 42 | 43 | typedef struct 44 | { 45 | SysClkModule module; 46 | uint32_t hz; 47 | } SysClkIpc_SetOverride_Args; 48 | 49 | typedef struct 50 | { 51 | SysClkModule module; 52 | uint32_t maxCount; 53 | } SysClkIpc_GetFreqList_Args; 54 | -------------------------------------------------------------------------------- /overlay/src/ui/gui/base_gui.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #include "base_gui.h" 12 | 13 | #include "../elements/base_frame.h" 14 | #include "logo_rgba_bin.h" 15 | 16 | #define LOGO_WIDTH 110 17 | #define LOGO_HEIGHT 39 18 | #define LOGO_X 18 19 | #define LOGO_Y 21 20 | 21 | #define LOGO_LABEL_X (LOGO_X + LOGO_WIDTH + 6) 22 | #define LOGO_LABEL_Y 50 23 | #define LOGO_LABEL_FONT_SIZE 28 24 | 25 | #define VERSION_X (LOGO_LABEL_X + 110) 26 | #define VERSION_Y LOGO_LABEL_Y 27 | #define VERSION_FONT_SIZE 15 28 | 29 | void BaseGui::preDraw(tsl::gfx::Renderer* renderer) 30 | { 31 | renderer->drawBitmap(LOGO_X, LOGO_Y, LOGO_WIDTH, LOGO_HEIGHT, logo_rgba_bin); 32 | renderer->drawString("overlay", false, LOGO_LABEL_X, LOGO_LABEL_Y, LOGO_LABEL_FONT_SIZE, TEXT_COLOR); 33 | renderer->drawString(TARGET_VERSION, false, VERSION_X, VERSION_Y, VERSION_FONT_SIZE, DESC_COLOR); 34 | } 35 | 36 | tsl::elm::Element* BaseGui::createUI() 37 | { 38 | BaseFrame* rootFrame = new BaseFrame(this); 39 | rootFrame->setContent(this->baseUI()); 40 | return rootFrame; 41 | } 42 | 43 | void BaseGui::update() 44 | { 45 | this->refresh(); 46 | } 47 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/meson.build: -------------------------------------------------------------------------------- 1 | dep_glfw3 = dependency('glfw3', version : '>=3.3') 2 | dep_glm = dependency('glm', version : '>=0.9.8') 3 | 4 | borealis_files = files( 5 | 'lib/extern/glad/glad.c', 6 | 'lib/extern/nanovg/nanovg.c', 7 | 8 | 'lib/extern/libretro-common/compat/compat_strl.c', 9 | 'lib/extern/libretro-common/features/features_cpu.c', 10 | 'lib/extern/libretro-common/encodings/encoding_utf.c', 11 | 12 | 'lib/application.cpp', 13 | 'lib/view.cpp', 14 | 'lib/applet_frame.cpp', 15 | 'lib/theme.cpp', 16 | 'lib/tab_frame.cpp', 17 | 'lib/rectangle.cpp', 18 | 'lib/box_layout.cpp', 19 | 'lib/sidebar.cpp', 20 | 'lib/animations.cpp', 21 | 'lib/style.cpp', 22 | 'lib/list.cpp', 23 | 'lib/label.cpp', 24 | 'lib/crash_frame.cpp', 25 | 'lib/button.cpp', 26 | 'lib/table.cpp', 27 | 'lib/dropdown.cpp', 28 | 'lib/logger.cpp', 29 | 'lib/staged_applet_frame.cpp', 30 | 'lib/progress_display.cpp', 31 | 'lib/progress_spinner.cpp', 32 | 'lib/image.cpp', 33 | 'lib/header.cpp', 34 | 'lib/popup_frame.cpp', 35 | 'lib/thumbnail_frame.cpp', 36 | 'lib/layer_view.cpp', 37 | 'lib/dialog.cpp', 38 | 'lib/material_icon.cpp', 39 | 'lib/hint.cpp', 40 | 'lib/scroll_view.cpp', 41 | 42 | 'lib/task_manager.cpp', 43 | 'lib/notification_manager.cpp', 44 | 45 | 'lib/repeating_task.cpp', 46 | 47 | 'lib/swkbd.cpp' 48 | ) 49 | 50 | borealis_include = include_directories('include', 'include/borealis/extern/glad', 'include/borealis/extern/nanovg', 'include/borealis/extern/libretro-common') 51 | 52 | borealis_dependencies = [ dep_glfw3, dep_glm ] 53 | -------------------------------------------------------------------------------- /manager/lib/borealis/example/sample_loading_page.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 Billy Laws 5 | Copyright (C) 2019 p-sam 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | class SampleLoadingPage : public brls::View 26 | { 27 | private: 28 | brls::StagedAppletFrame* frame; 29 | brls::ProgressDisplay* progressDisp; 30 | brls::Label* label; 31 | int progressValue = 0; 32 | 33 | public: 34 | SampleLoadingPage(brls::StagedAppletFrame* frame); 35 | ~SampleLoadingPage(); 36 | 37 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override; 38 | void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override; 39 | 40 | void willAppear(bool resetState = false) override; 41 | void willDisappear(bool resetState = false) override; 42 | }; 43 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/lib/rectangle.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | namespace brls 24 | { 25 | 26 | Rectangle::Rectangle(NVGcolor color) 27 | { 28 | this->setColor(color); 29 | } 30 | 31 | void Rectangle::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) 32 | { 33 | NVGcolor color = a(this->color); 34 | 35 | if (color.a == 0.0f) 36 | return; 37 | 38 | nvgFillColor(vg, color); 39 | 40 | nvgBeginPath(vg); 41 | nvgRect(vg, x, y, width, height); 42 | nvgFill(vg); 43 | } 44 | 45 | void Rectangle::setColor(NVGcolor color) 46 | { 47 | this->color = color; 48 | } 49 | 50 | void Rectangle::layout(NVGcontext* vg, Style* style, FontStash* stash) 51 | { 52 | // Nothing to do 53 | } 54 | 55 | } // namespace brls 56 | -------------------------------------------------------------------------------- /common/include/sysclk/client/ipc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "types.h" 14 | #include "../config.h" 15 | #include "../board.h" 16 | #include "../ipc.h" 17 | 18 | bool sysclkIpcRunning(); 19 | Result sysclkIpcInitialize(void); 20 | void sysclkIpcExit(void); 21 | 22 | Result sysclkIpcGetAPIVersion(u32* out_ver); 23 | Result sysclkIpcGetVersionString(char* out, size_t len); 24 | Result sysclkIpcGetCurrentContext(SysClkContext* out_context); 25 | Result sysclkIpcGetProfileCount(u64 tid, u8* out_count); 26 | Result sysclkIpcSetEnabled(bool enabled); 27 | Result sysclkIpcExitCmd(); 28 | Result sysclkIpcSetOverride(SysClkModule module, u32 hz); 29 | Result sysclkIpcGetProfiles(u64 tid, SysClkTitleProfileList* out_profiles); 30 | Result sysclkIpcSetProfiles(u64 tid, SysClkTitleProfileList* profiles); 31 | Result sysclkIpcGetConfigValues(SysClkConfigValueList* out_configValues); 32 | Result sysclkIpcSetConfigValues(SysClkConfigValueList* configValues); 33 | Result sysclkIpcGetFreqList(SysClkModule module, u32* list, u32 maxCount, u32* outCount); 34 | 35 | static inline Result sysclkIpcRemoveOverride(SysClkModule module) 36 | { 37 | return sysclkIpcSetOverride(module, 0); 38 | } 39 | -------------------------------------------------------------------------------- /manager/src/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include 26 | #include "ipc/ipc.h" 27 | 28 | #include 29 | 30 | #define APP_ASSET(p) APP_RESOURCES p 31 | 32 | extern uint32_t g_freq_table_hz[SysClkModule_EnumMax][SYSCLK_FREQ_LIST_MAX+1]; 33 | 34 | Result cacheFreqList(); 35 | std::string formatListItemTitle(const std::string str, size_t maxScore = 140); 36 | brls::SelectListItem* createFreqListItem(SysClkModule module, uint32_t selectedFreqInMHz, std::string defaultString = "Do not override"); 37 | 38 | std::string formatFreq(uint32_t freq); 39 | std::string formatTid(uint64_t tid); 40 | std::string formatProfile(SysClkProfile profile); 41 | std::string formatTemp(uint32_t temp); 42 | std::string formatPower(int32_t power); 43 | 44 | void errorResult(std::string tag, Result rc); 45 | -------------------------------------------------------------------------------- /overlay/lib/tesla/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "*.tcc": "cpp", 4 | "algorithm": "cpp", 5 | "array": "cpp", 6 | "atomic": "cpp", 7 | "bit": "cpp", 8 | "cctype": "cpp", 9 | "chrono": "cpp", 10 | "clocale": "cpp", 11 | "cmath": "cpp", 12 | "condition_variable": "cpp", 13 | "cstdarg": "cpp", 14 | "cstddef": "cpp", 15 | "cstdint": "cpp", 16 | "cstdio": "cpp", 17 | "cstdlib": "cpp", 18 | "cstring": "cpp", 19 | "ctime": "cpp", 20 | "cwchar": "cpp", 21 | "cwctype": "cpp", 22 | "deque": "cpp", 23 | "unordered_map": "cpp", 24 | "vector": "cpp", 25 | "exception": "cpp", 26 | "functional": "cpp", 27 | "iterator": "cpp", 28 | "memory": "cpp", 29 | "memory_resource": "cpp", 30 | "numeric": "cpp", 31 | "optional": "cpp", 32 | "random": "cpp", 33 | "ratio": "cpp", 34 | "string": "cpp", 35 | "string_view": "cpp", 36 | "system_error": "cpp", 37 | "tuple": "cpp", 38 | "type_traits": "cpp", 39 | "utility": "cpp", 40 | "fstream": "cpp", 41 | "initializer_list": "cpp", 42 | "iosfwd": "cpp", 43 | "istream": "cpp", 44 | "limits": "cpp", 45 | "mutex": "cpp", 46 | "new": "cpp", 47 | "ostream": "cpp", 48 | "sstream": "cpp", 49 | "stdexcept": "cpp", 50 | "streambuf": "cpp", 51 | "thread": "cpp", 52 | "cinttypes": "cpp", 53 | "typeinfo": "cpp", 54 | "map": "cpp", 55 | "stack": "cpp", 56 | "list": "cpp" 57 | } 58 | } -------------------------------------------------------------------------------- /sysmodule/lib/minIni/dev/minGlue-stdio.h: -------------------------------------------------------------------------------- 1 | /* Glue functions for the minIni library, based on the C/C++ stdio library 2 | * 3 | * Or better said: this file contains macros that maps the function interface 4 | * used by minIni to the standard C/C++ file I/O functions. 5 | * 6 | * By CompuPhase, 2008-2014 7 | * This "glue file" is in the public domain. It is distributed without 8 | * warranties or conditions of any kind, either express or implied. 9 | */ 10 | 11 | /* map required file I/O types and functions to the standard C library */ 12 | #include 13 | 14 | #define INI_FILETYPE FILE* 15 | #define ini_openread(filename,file) ((*(file) = fopen((filename),"rb")) != NULL) 16 | #define ini_openwrite(filename,file) ((*(file) = fopen((filename),"wb")) != NULL) 17 | #define ini_openrewrite(filename,file) ((*(file) = fopen((filename),"r+b")) != NULL) 18 | #define ini_close(file) (fclose(*(file)) == 0) 19 | #define ini_read(buffer,size,file) (fgets((buffer),(size),*(file)) != NULL) 20 | #define ini_write(buffer,file) (fputs((buffer),*(file)) >= 0) 21 | #define ini_rename(source,dest) (rename((source), (dest)) == 0) 22 | #define ini_remove(filename) (remove(filename) == 0) 23 | 24 | #define INI_FILEPOS long int 25 | #define ini_tell(file,pos) (*(pos) = ftell(*(file))) 26 | #define ini_seek(file,pos) (fseek(*(file), *(pos), SEEK_SET) == 0) 27 | 28 | /* for floating-point support, define additional types and functions */ 29 | #define INI_REAL float 30 | #define ini_ftoa(string,value) sprintf((string),"%f",(value)) 31 | #define ini_atof(string) (INI_REAL)strtod((string),NULL) 32 | -------------------------------------------------------------------------------- /overlay/lib/tesla/README.md: -------------------------------------------------------------------------------- 1 | # libtesla 2 | 3 |

4 | 5 |

6 | 7 | libtesla is the interface between the Tesla overlay loader and user-made Overlays. It handles all layer creation, UI creation, drawing and input management. 8 | 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. 9 | 10 | ## Screenshots 11 | 12 |
13 | 14 | 15 |
16 | 17 | `Overlays do NOT show up on Screenshots. These pictures were taken using a capture card` 18 | 19 | ## Example 20 | 21 | An example for how to use libtesla can be found here: https://github.com/WerWolv/libtesla/tree/master/example 22 | To create your own Overlay, please consider creating a new repository using the official Tesla overlay template: https://github.com/WerWolv/Tesla-Template 23 | 24 | **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. 25 | 26 | ## Credits 27 | 28 | - **switchbrew** for nx-hbloader which is used as basis for overlay loading 29 | - **kardch** for the amazing icon 30 | - **All the devs on AtlasNX, RetroNX and Switchbrew** for their feedback 31 | - **All overlay devs** for making something awesome out of this :) 32 | 33 | -------------------------------------------------------------------------------- /sysmodule/lib/nxExt/src/apm_ext.c: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #include "nxExt/apm_ext.h" 12 | 13 | #include 14 | 15 | static Service g_apmSrv; 16 | static Service g_apmSysSrv; 17 | static atomic_size_t g_refCnt; 18 | 19 | Result apmExtInitialize(void) 20 | { 21 | g_refCnt++; 22 | 23 | if (serviceIsActive(&g_apmSrv)) 24 | { 25 | return 0; 26 | } 27 | 28 | Result rc = 0; 29 | 30 | rc = smGetService(&g_apmSrv, "apm"); 31 | if(R_SUCCEEDED(rc)) 32 | { 33 | rc = smGetService(&g_apmSysSrv, "apm:sys"); 34 | } 35 | 36 | if (R_FAILED(rc)) 37 | { 38 | apmExtExit(); 39 | } 40 | 41 | return rc; 42 | } 43 | 44 | void apmExtExit(void) 45 | { 46 | if (--g_refCnt == 0) 47 | { 48 | serviceClose(&g_apmSrv); 49 | serviceClose(&g_apmSysSrv); 50 | } 51 | } 52 | 53 | Result apmExtGetPerformanceMode(u32* out_mode) 54 | { 55 | return serviceDispatchOut(&g_apmSrv, 1, *out_mode); 56 | } 57 | 58 | Result apmExtSysRequestPerformanceMode(u32 mode) 59 | { 60 | return serviceDispatchIn(&g_apmSysSrv, 0, mode); 61 | } 62 | 63 | Result apmExtGetCurrentPerformanceConfiguration(u32* out_conf) 64 | { 65 | return serviceDispatchOut(&g_apmSysSrv, 7, *out_conf); 66 | } 67 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/layer_view.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 WerWolv 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace brls 25 | { 26 | 27 | // A view containing multiple children views with the ability to freely switch between these layers 28 | class LayerView : public View 29 | { 30 | public: 31 | LayerView(); 32 | ~LayerView(); 33 | 34 | void addLayer(View* view); 35 | void changeLayer(int index, bool focus = false); 36 | int getLayerIndex(); 37 | 38 | View* getDefaultFocus() override; 39 | 40 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 41 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 42 | 43 | void willAppear(bool resetState = false) override; 44 | void willDisappear(bool resetState = false) override; 45 | 46 | private: 47 | std::vector layers; 48 | int selectedIndex = 0; 49 | }; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/lib/material_icon.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | namespace brls 22 | { 23 | 24 | MaterialIcon::MaterialIcon(std::string icon) 25 | : icon(icon) 26 | { 27 | } 28 | 29 | void MaterialIcon::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) 30 | { 31 | NVGcolor color = a(ctx->theme->textColor); 32 | 33 | nvgTextLineHeight(vg, 1.0f); 34 | nvgFillColor(vg, color); 35 | nvgFontSize(vg, height); 36 | nvgFontFaceId(vg, ctx->fontStash->material); 37 | nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE); 38 | nvgBeginPath(vg); 39 | nvgText(vg, this->middleX, this->middleY, this->icon.c_str(), nullptr); 40 | } 41 | 42 | void MaterialIcon::layout(NVGcontext* vg, Style* style, FontStash* stash) 43 | { 44 | this->middleX = this->getX() + this->getWidth() / 2; 45 | this->middleY = this->getY() + this->getHeight() / 2; 46 | } 47 | 48 | }; // namespace brls 49 | -------------------------------------------------------------------------------- /overlay/lib/tesla/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "DKP Aarch64 Windows", 5 | "includePath": [ 6 | "C:/devkitPro/devkitA64/aarch64-none-elf/include/**", 7 | "C:/devkitPro/devkitA64/lib/gcc/aarch64-none-elf/9.2.0/include/**", 8 | "C:/devkitPro/libnx/include/**", 9 | "C:/devkitPro/portlibs/switch/include/**", 10 | "${workspaceFolder}/include/**" 11 | ], 12 | "defines": [ 13 | "SWITCH", 14 | "VERSION=\"\"", 15 | "__SWITCH__", 16 | "__aarch64__" 17 | ], 18 | "compilerPath": "C:/devkitPro/devkitA64/bin/aarch64-none-elf-g++", 19 | "cStandard": "c11", 20 | "cppStandard": "c++17", 21 | "intelliSenseMode": "gcc-x64" 22 | }, 23 | { 24 | "name": "DKP Aarch64 Linux", 25 | "includePath": [ 26 | "/opt/devkitpro/devkitA64/aarch64-none-elf/include/**", 27 | "/opt/devkitpro/devkitA64/lib/gcc/aarch64-none-elf/9.2.0/include/**", 28 | "/opt/devkitpro/libnx/include/**", 29 | "/opt/devkitpro/portlibs/switch/include/**", 30 | "${workspaceFolder}/include/**" 31 | ], 32 | "defines": [ 33 | "SWITCH", 34 | "VERSION=\"\"", 35 | "__SWITCH__", 36 | "__aarch64__" 37 | ], 38 | "compilerPath": "/opt/devkitpro/devkitA64/bin/aarch64-none-elf-g++", 39 | "cStandard": "c11", 40 | "cppStandard": "c++17", 41 | "intelliSenseMode": "gcc-x64" 42 | } 43 | ], 44 | "version": 4 45 | } -------------------------------------------------------------------------------- /manager/src/logo.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019-2020 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include "utils.h" 26 | 27 | enum class LogoStyle 28 | { 29 | HEADER = 0, 30 | ABOUT 31 | }; 32 | 33 | #define LOGO_FONT_NAME "logo" 34 | #define LOGO_FONT_PATH APP_ASSET("fira/FiraSans-Medium-rnx.ttf") 35 | 36 | #define LOGO_HEADER_FONT_SIZE 45 37 | #define LOGO_HEADER_SPACING 12 38 | #define LOGO_ABOUT_FONT_SIZE 55 39 | #define LOGO_DESC_FONT_SIZE 28 40 | #define LOGO_OFFSET 2 41 | 42 | class Logo : public brls::View 43 | { 44 | protected: 45 | brls::Label* logoLabel = nullptr; 46 | brls::Label* descLabel = nullptr; 47 | void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash); 48 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override; 49 | public: 50 | Logo(LogoStyle style); 51 | virtual ~Logo(); 52 | }; 53 | -------------------------------------------------------------------------------- /sysmodule/lib/minIni/dev/minGlue-FatFs.h: -------------------------------------------------------------------------------- 1 | /* Glue functions for the minIni library, based on the FatFs and Petit-FatFs 2 | * libraries, see http://elm-chan.org/fsw/ff/00index_e.html 3 | * 4 | * By CompuPhase, 2008-2012 5 | * This "glue file" is in the public domain. It is distributed without 6 | * warranties or conditions of any kind, either express or implied. 7 | * 8 | * (The FatFs and Petit-FatFs libraries are copyright by ChaN and licensed at 9 | * its own terms.) 10 | */ 11 | 12 | #define INI_BUFFERSIZE 256 /* maximum line length, maximum path length */ 13 | 14 | /* You must set _USE_STRFUNC to 1 or 2 in the include file ff.h (or tff.h) 15 | * to enable the "string functions" fgets() and fputs(). 16 | */ 17 | #include "ff.h" /* include tff.h for Tiny-FatFs */ 18 | 19 | #define INI_FILETYPE FIL 20 | #define ini_openread(filename,file) (f_open((file), (filename), FA_READ+FA_OPEN_EXISTING) == FR_OK) 21 | #define ini_openwrite(filename,file) (f_open((file), (filename), FA_WRITE+FA_CREATE_ALWAYS) == FR_OK) 22 | #define ini_close(file) (f_close(file) == FR_OK) 23 | #define ini_read(buffer,size,file) f_gets((buffer), (size),(file)) 24 | #define ini_write(buffer,file) f_puts((buffer), (file)) 25 | #define ini_remove(filename) (f_unlink(filename) == FR_OK) 26 | 27 | #define INI_FILEPOS DWORD 28 | #define ini_tell(file,pos) (*(pos) = f_tell((file))) 29 | #define ini_seek(file,pos) (f_lseek((file), *(pos)) == FR_OK) 30 | 31 | static int ini_rename(TCHAR *source, const TCHAR *dest) 32 | { 33 | /* Function f_rename() does not allow drive letters in the destination file */ 34 | char *drive = strchr(dest, ':'); 35 | drive = (drive == NULL) ? dest : drive + 1; 36 | return (f_rename(source, drive) == FR_OK); 37 | } 38 | -------------------------------------------------------------------------------- /sysmodule/lib/minIni/dev/minGlue.h: -------------------------------------------------------------------------------- 1 | /* Glue functions for the minIni library, based on the C/C++ stdio library 2 | * 3 | * Or better said: this file contains macros that maps the function interface 4 | * used by minIni to the standard C/C++ file I/O functions. 5 | * 6 | * By CompuPhase, 2008-2014 7 | * This "glue file" is in the public domain. It is distributed without 8 | * warranties or conditions of any kind, either express or implied. 9 | */ 10 | 11 | /* map required file I/O types and functions to the standard C library */ 12 | #include 13 | 14 | #define INI_FILETYPE FILE* 15 | #define ini_openread(filename,file) ((*(file) = fopen((filename),"rb")) != NULL) 16 | #define ini_openwrite(filename,file) ((*(file) = fopen((filename),"wb")) != NULL) 17 | #define ini_openrewrite(filename,file) ((*(file) = fopen((filename),"r+b")) != NULL) 18 | #define ini_close(file) (fclose(*(file)) == 0) 19 | #define ini_read(buffer,size,file) (fgets((buffer),(size),*(file)) != NULL) 20 | #define ini_write(buffer,file) (fputs((buffer),*(file)) >= 0) 21 | #define ini_rename(source,dest) (rename((source), (dest)) == 0) 22 | #define ini_remove(filename) (remove(filename) == 0) 23 | 24 | #define INI_FILEPOS long int 25 | #define ini_tell(file,pos) (*(pos) = ftell(*(file))) 26 | #define ini_seek(file,pos) (fseek(*(file), *(pos), SEEK_SET) == 0) 27 | 28 | /* for floating-point support, define additional types and functions */ 29 | //#define INI_REAL float 30 | //#define ini_ftoa(string,value) sprintf((string),"%f",(value)) 31 | //#define ini_atof(string) (INI_REAL)strtod((string),NULL) 32 | 33 | #define INI_ANSIONLY 34 | #define INI_LINETERM "\n" 35 | #define PORTABLE_STRNICMP -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/staged_applet_frame.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 Billy Laws 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace brls 28 | { 29 | 30 | // An applet frame for implementing a stage based app with a progress display in top right 31 | class StagedAppletFrame : public AppletFrame 32 | { 33 | public: 34 | StagedAppletFrame(); 35 | ~StagedAppletFrame(); 36 | 37 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 38 | 39 | void addStage(View* view); 40 | void nextStage(); 41 | void previousStage(); 42 | 43 | unsigned getCurrentStage(); 44 | unsigned getStagesCount(); 45 | unsigned isLastStage(); 46 | 47 | private: 48 | size_t currentStage = 0; 49 | std::vector stageViews; 50 | 51 | void enterStage(int index, bool requestFocus); 52 | }; 53 | 54 | } // namespace brls 55 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/tab_frame.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019-2020 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace brls 28 | { 29 | 30 | // An applet frame containing a sidebar on the left with multiple tabs 31 | class TabFrame : public AppletFrame 32 | { 33 | public: 34 | TabFrame(); 35 | 36 | /** 37 | * Adds a tab with given label and view 38 | * All tabs and separators must be added 39 | * before the TabFrame is itself added to 40 | * the view hierarchy 41 | */ 42 | void addTab(std::string label, View* view); 43 | void addSeparator(); 44 | 45 | View* getDefaultFocus() override; 46 | 47 | virtual bool onCancel() override; 48 | 49 | ~TabFrame(); 50 | 51 | private: 52 | Sidebar* sidebar; 53 | BoxLayout* layout; 54 | View* rightPane = nullptr; 55 | 56 | void switchToView(View* view); 57 | }; 58 | 59 | } // namespace brls 60 | -------------------------------------------------------------------------------- /sysmodule/lib/nxExt/include/nxExt/ipc_server.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | #include 19 | 20 | #define IPC_SERVER_EXT_RESPONSE_MAX_DATA_SIZE (0x100 - 0x10 - sizeof(IpcServerRawHeader)) 21 | 22 | typedef struct 23 | { 24 | u64 magic; 25 | union 26 | { 27 | u64 cmdId; 28 | u64 result; 29 | }; 30 | } IpcServerRawHeader; 31 | 32 | typedef struct 33 | { 34 | SmServiceName srvName; 35 | Handle handles[MAX_WAIT_OBJECTS]; 36 | u32 max; 37 | u32 count; 38 | } IpcServer; 39 | 40 | typedef struct 41 | { 42 | u64 cmdId; 43 | void* ptr; 44 | size_t size; 45 | } IpcServerRequestData; 46 | 47 | typedef struct 48 | { 49 | HipcParsedRequest hipc; 50 | IpcServerRequestData data; 51 | } IpcServerRequest; 52 | 53 | typedef Result (*IpcServerRequestHandler)(void* userdata, const IpcServerRequest* r, u8* out_data, size_t* out_dataSize); 54 | 55 | Result ipcServerInit(IpcServer* server, const char* name, u32 max_sessions); 56 | Result ipcServerExit(IpcServer* server); 57 | Result ipcServerProcess(IpcServer* server, IpcServerRequestHandler handler, void* userdata); 58 | Result ipcServerParseCommand(const IpcServerRequest* r, size_t* out_datasize, void** out_data, u64* out_cmd); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | -------------------------------------------------------------------------------- /manager/src/main_frame.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019-2020 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #include "main_frame.h" 22 | 23 | #include "status_tab.h" 24 | #include "advanced_settings_tab.h" 25 | #include "app_profiles_tab.h" 26 | #include "cheat_sheet_tab.h" 27 | #include "about_tab.h" 28 | #include "logo.h" 29 | 30 | #include "ipc/client.h" 31 | 32 | MainFrame::MainFrame() : TabFrame() 33 | { 34 | // Start refresh task 35 | this->refreshTask = new RefreshTask(); 36 | this->refreshTask->start(); 37 | 38 | // Load UI 39 | this->setIcon(new Logo(LogoStyle::HEADER)); 40 | 41 | AppProfilesTab *tab = new AppProfilesTab(); 42 | 43 | this->addTab("Status", new StatusTab(this->refreshTask)); 44 | this->addTab("Application Profiles", tab); 45 | this->addTab("Advanced Settings", new AdvancedSettingsTab()); 46 | 47 | this->addSeparator(); 48 | 49 | this->addTab("Cheat Sheet", new CheatSheetTab()); 50 | this->addTab("About", new AboutTab()); 51 | } 52 | 53 | MainFrame::~MainFrame() 54 | { 55 | this->refreshTask->stop(); 56 | } 57 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/crash_frame.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019-2020 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace brls 28 | { 29 | 30 | // A screen similar to the "The software has closed" dialog 31 | // pressing OK will exit the app 32 | class CrashFrame : public View 33 | { 34 | private: 35 | Label* label; 36 | Button* button; 37 | Hint* hint; 38 | 39 | public: 40 | CrashFrame(std::string text); 41 | 42 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 43 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 44 | void onShowAnimationEnd() override; 45 | View* getDefaultFocus() override; 46 | 47 | bool isTranslucent() override 48 | { 49 | return true; // have it always translucent to disable fade out animation 50 | } 51 | 52 | ~CrashFrame(); 53 | }; 54 | 55 | } // namespace brls 56 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/extern/libretro-common/retro_assert.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2018 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_assert.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __RETRO_ASSERT_H 24 | #define __RETRO_ASSERT_H 25 | 26 | #include 27 | 28 | #ifdef RARCH_INTERNAL 29 | #include 30 | #define retro_assert(cond) do { \ 31 | if (!(cond)) { printf("Assertion failed at %s:%d.\n", __FILE__, __LINE__); abort(); } \ 32 | } while(0) 33 | #else 34 | #define retro_assert(cond) assert(cond) 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /sysmodule/src/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | #include 13 | #include 14 | #include 15 | 16 | class Board 17 | { 18 | public: 19 | static const char* GetProfileName(SysClkProfile profile, bool pretty); 20 | static const char* GetModuleName(SysClkModule module, bool pretty); 21 | static const char* GetThermalSensorName(SysClkThermalSensor sensor, bool pretty); 22 | static const char* GetPowerSensorName(SysClkPowerSensor sensor, bool pretty); 23 | static void Initialize(); 24 | static void Exit(); 25 | static void ResetToStock(); 26 | static SysClkProfile GetProfile(); 27 | static void SetHz(SysClkModule module, std::uint32_t hz); 28 | static std::uint32_t GetHz(SysClkModule module); 29 | static std::uint32_t GetRealHz(SysClkModule module); 30 | static void GetFreqList(SysClkModule module, std::uint32_t* outList, std::uint32_t maxCount, std::uint32_t* outCount); 31 | static std::uint32_t GetTemperatureMilli(SysClkThermalSensor sensor); 32 | static std::int32_t GetPowerMw(SysClkPowerSensor sensor); 33 | static std::uint32_t GetRamLoad(SysClkRamLoad load); 34 | static SysClkSocType GetSocType(); 35 | 36 | protected: 37 | static void FetchHardwareInfos(); 38 | static PcvModule GetPcvModule(SysClkModule sysclkModule); 39 | static PcvModuleId GetPcvModuleId(SysClkModule sysclkModule); 40 | }; 41 | -------------------------------------------------------------------------------- /manager/src/app_profiles_tab.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include "ipc/ipc.h" 26 | 27 | typedef struct 28 | { 29 | uint64_t tid; 30 | NsApplicationName name; 31 | NsApplicationIcon icon; 32 | uint8_t profileCount; 33 | 34 | brls::ListItem* listItem; 35 | } Title; 36 | 37 | class AppProfilesTab : public brls::List 38 | { 39 | private: 40 | bool showEmptyProfiles = true; 41 | 42 | std::vector titles; 43 | 44 | std::vector items; 45 | std::vector emptyProfilesItems; 46 | std::vector profilesItems; 47 | 48 | brls::Label *emptyListLabel; 49 | brls::ToggleListItem *filterListItem; 50 | 51 | void updateEmptyListLabel(bool animate = true); 52 | 53 | Title* editingTitle = nullptr; 54 | 55 | void refreshFilter(); 56 | 57 | public: 58 | AppProfilesTab(); 59 | ~AppProfilesTab(); 60 | 61 | void willAppear(bool resetState) override; 62 | }; 63 | -------------------------------------------------------------------------------- /sysmodule/src/process_management.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #include "process_management.h" 12 | #include "file_utils.h" 13 | #include "errors.h" 14 | 15 | void ProcessManagement::Initialize() 16 | { 17 | Result rc = 0; 18 | 19 | rc = pmdmntInitialize(); 20 | ASSERT_RESULT_OK(rc, "pmdmntInitialize"); 21 | 22 | rc = pminfoInitialize(); 23 | ASSERT_RESULT_OK(rc, "pminfoInitialize"); 24 | } 25 | 26 | void ProcessManagement::WaitForQLaunch() 27 | { 28 | Result rc = 0; 29 | std::uint64_t pid = 0; 30 | do 31 | { 32 | rc = pmdmntGetProcessId(&pid, PROCESS_MANAGEMENT_QLAUNCH_TID); 33 | svcSleepThread(500000000ULL); 34 | } while (R_FAILED(rc)); 35 | } 36 | 37 | std::uint64_t ProcessManagement::GetCurrentApplicationId() 38 | { 39 | Result rc = 0; 40 | std::uint64_t pid = 0; 41 | std::uint64_t tid = 0; 42 | rc = pmdmntGetApplicationProcessId(&pid); 43 | 44 | if (rc == 0x20f) 45 | { 46 | return PROCESS_MANAGEMENT_QLAUNCH_TID; 47 | } 48 | 49 | ASSERT_RESULT_OK(rc, "pmdmntGetApplicationProcessId"); 50 | 51 | rc = pminfoGetProgramId(&tid, pid); 52 | 53 | if (rc == 0x20f) 54 | { 55 | return PROCESS_MANAGEMENT_QLAUNCH_TID; 56 | } 57 | 58 | ASSERT_RESULT_OK(rc, "pminfoGetProgramId"); 59 | 60 | return tid; 61 | } 62 | 63 | void ProcessManagement::Exit() 64 | { 65 | pmdmntExit(); 66 | pminfoExit(); 67 | } 68 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/extern/libretro-common/retro_inline.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2018 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_inline.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_INLINE_H 24 | #define __LIBRETRO_SDK_INLINE_H 25 | 26 | #ifndef INLINE 27 | 28 | #if defined(_WIN32) || defined(__INTEL_COMPILER) 29 | #define INLINE __inline 30 | #elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L 31 | #define INLINE inline 32 | #elif defined(__GNUC__) 33 | #define INLINE __inline__ 34 | #else 35 | #define INLINE 36 | #endif 37 | 38 | #endif 39 | #endif 40 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/extern/libretro-common/boolean.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2018 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (boolean.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_BOOLEAN_H 24 | #define __LIBRETRO_SDK_BOOLEAN_H 25 | 26 | #ifndef __cplusplus 27 | 28 | #if defined(_MSC_VER) && _MSC_VER < 1800 && !defined(SN_TARGET_PS3) 29 | /* Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. */ 30 | #define bool unsigned char 31 | #define true 1 32 | #define false 0 33 | #else 34 | #include 35 | #endif 36 | 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /overlay/src/ui/gui/freq_choice_gui.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #include "freq_choice_gui.h" 12 | 13 | #include "../format.h" 14 | #include "fatal_gui.h" 15 | 16 | FreqChoiceGui::FreqChoiceGui(std::uint32_t selectedHz, std::uint32_t* hzList, std::uint32_t hzCount, FreqChoiceListener listener) 17 | { 18 | this->selectedHz = selectedHz; 19 | this->hzList = hzList; 20 | this->hzCount = hzCount; 21 | this->listener = listener; 22 | } 23 | 24 | tsl::elm::ListItem* FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool selected) 25 | { 26 | tsl::elm::ListItem* listItem = new tsl::elm::ListItem(formatListFreqHz(hz)); 27 | listItem->setValue(selected ? "\uE14B" : ""); 28 | 29 | listItem->setClickListener([this, hz](u64 keys) { 30 | if((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) 31 | { 32 | if(this->listener(hz)) 33 | { 34 | tsl::goBack(); 35 | } 36 | return true; 37 | } 38 | 39 | return false; 40 | }); 41 | 42 | return listItem; 43 | } 44 | 45 | void FreqChoiceGui::listUI() 46 | { 47 | this->listElement->addItem(this->createFreqListItem(0, this->selectedHz == 0)); 48 | for(std::uint32_t i = 0; i < this->hzCount; i++) { 49 | std::uint32_t hz = this->hzList[i]; 50 | this->listElement->addItem(this->createFreqListItem(hz, (hz / 1000000) == (this->selectedHz / 1000000))); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /sysmodule/src/ipc_service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include 16 | #include "clock_manager.h" 17 | 18 | class IpcService 19 | { 20 | public: 21 | IpcService(ClockManager* clockMgr); 22 | virtual ~IpcService(); 23 | void SetRunning(bool running); 24 | 25 | protected: 26 | static void ProcessThreadFunc(void* arg); 27 | static Result ServiceHandlerFunc(void* arg, const IpcServerRequest* r, std::uint8_t* out_data, size_t* out_dataSize); 28 | 29 | Result GetApiVersion(u32* out_version); 30 | Result GetVersionString(char* out_buf, size_t bufSize); 31 | Result GetCurrentContext(SysClkContext* out_ctx); 32 | Result Exit(); 33 | Result GetProfileCount(std::uint64_t* tid, std::uint8_t* out_count); 34 | Result GetProfiles(std::uint64_t* tid, SysClkTitleProfileList* out_profiles); 35 | Result SetProfiles(SysClkIpc_SetProfiles_Args* args); 36 | Result SetEnabled(std::uint8_t* enabled); 37 | Result SetOverride(SysClkIpc_SetOverride_Args* args); 38 | Result GetConfigValues(SysClkConfigValueList* out_configValues); 39 | Result SetConfigValues(SysClkConfigValueList* configValues); 40 | Result GetFreqList(SysClkIpc_GetFreqList_Args* args, std::uint32_t* out_list, std::size_t size, std::uint32_t* out_count); 41 | 42 | bool running; 43 | Thread thread; 44 | LockableMutex threadMutex; 45 | IpcServer server; 46 | ClockManager* clockMgr; 47 | }; 48 | -------------------------------------------------------------------------------- /sysmodule/src/clock_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | #include "config.h" 17 | #include "board.h" 18 | #include 19 | 20 | class ClockManager 21 | { 22 | public: 23 | ClockManager(); 24 | virtual ~ClockManager(); 25 | 26 | SysClkContext GetCurrentContext(); 27 | Config* GetConfig(); 28 | void SetRunning(bool running); 29 | bool Running(); 30 | void GetFreqList(SysClkModule module, std::uint32_t* list, std::uint32_t maxCount, std::uint32_t* outCount); 31 | void Tick(); 32 | void WaitForNextTick(); 33 | 34 | protected: 35 | bool IsAssignableHz(SysClkModule module, std::uint32_t hz); 36 | std::uint32_t GetMaxAllowedHz(SysClkModule module, SysClkProfile profile); 37 | std::uint32_t GetNearestHz(SysClkModule module, std::uint32_t inHz, std::uint32_t maxHz); 38 | bool ConfigIntervalTimeout(SysClkConfigValue intervalMsConfigValue, std::uint64_t ns, std::uint64_t* lastLogNs); 39 | void RefreshFreqTableRow(SysClkModule module); 40 | bool RefreshContext(); 41 | 42 | std::atomic_bool running; 43 | LockableMutex contextMutex; 44 | struct { 45 | std::uint32_t count; 46 | std::uint32_t list[SYSCLK_FREQ_LIST_MAX]; 47 | } freqTable[SysClkModule_EnumMax]; 48 | Config* config; 49 | SysClkContext* context; 50 | std::uint64_t lastTempLogNs; 51 | std::uint64_t lastFreqLogNs; 52 | std::uint64_t lastPowerLogNs; 53 | std::uint64_t lastCsvWriteNs; 54 | }; 55 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/hint.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2020 WerWolv 4 | Copyright (C) 2020 natinusala 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace brls 27 | { 28 | 29 | // Displays button hints for the currently focused view 30 | // Depending on the view's available actions 31 | // there can only be one Hint visible at any time 32 | class Hint : public BoxLayout 33 | { 34 | private: 35 | bool animate; 36 | 37 | GenericEvent::Subscription globalFocusEventSubscriptor; 38 | VoidEvent::Subscription globalHintsUpdateEventSubscriptor; 39 | 40 | static inline std::vector globalHintStack; 41 | 42 | static void pushHint(Hint* hint); 43 | static void popHint(Hint* hint); 44 | static void animateHints(); 45 | 46 | static std::string getKeyIcon(Key key); 47 | 48 | void rebuildHints(); 49 | 50 | public: 51 | Hint(bool animate = true); 52 | ~Hint(); 53 | 54 | void willAppear(bool resetState = false) override; 55 | void willDisappear(bool resetState = false) override; 56 | 57 | void setAnimate(bool animate) 58 | { 59 | this->animate = animate; 60 | } 61 | }; 62 | 63 | } // namespace brls 64 | -------------------------------------------------------------------------------- /manager/src/ipc/pc_shim/ns.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include "../types.h" 26 | #include "types.h" 27 | #include "nacp.h" 28 | 29 | typedef enum 30 | { 31 | NsApplicationControlSource_Storage = 1 32 | } NsApplicationControlSource; 33 | 34 | typedef struct 35 | { 36 | u64 application_id; 37 | } NsApplicationRecord; 38 | 39 | typedef struct 40 | { 41 | NacpStruct nacp; 42 | NsApplicationIcon icon; 43 | } NsApplicationControlData; 44 | 45 | Result nsInitialize(); 46 | Result nsListApplicationRecord(NsApplicationRecord* out_records, s32 size, s32 offset, s32* out_count); 47 | Result nsGetApplicationControlData(NsApplicationControlSource flag, u64 titleID, NsApplicationControlData* out_data, size_t size, u64* out_size); 48 | void nsExit(); 49 | 50 | class NsShimStore 51 | { 52 | public: 53 | NsShimStore(); 54 | void AddRecord(u64 titleID, std::string name, std::string iconPath); 55 | bool ListRecord(NsApplicationRecord* out_records, s32 size, s32 offset, s32* out_count); 56 | bool GetControlData(NsApplicationControlData* out_data, size_t size, u64 titleID, size_t* out_size); 57 | 58 | protected: 59 | std::map> store; 60 | }; 61 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/notification_manager.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #define BRLS_NOTIFICATIONS_MAX 8 26 | 27 | // TODO: check in HOS that the animation duration + notification timeout are correct 28 | 29 | namespace brls 30 | { 31 | 32 | class Notification : public View 33 | { 34 | public: 35 | Notification(std::string text); 36 | ~Notification(); 37 | 38 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 39 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 40 | 41 | menu_timer_t timeoutTimer; 42 | 43 | private: 44 | Label* label; 45 | }; 46 | 47 | class NotificationManager : public View 48 | { 49 | private: 50 | Notification* notifications[BRLS_NOTIFICATIONS_MAX]; 51 | 52 | void layoutNotification(size_t i); 53 | 54 | public: 55 | NotificationManager(); 56 | ~NotificationManager(); 57 | 58 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 59 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 60 | 61 | void notify(std::string text); 62 | }; 63 | 64 | }; // namespace brls 65 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/lib/logger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | namespace brls 26 | { 27 | 28 | static LogLevel g_logLevel = LogLevel::INFO; 29 | 30 | void Logger::setLogLevel(LogLevel newLogLevel) 31 | { 32 | g_logLevel = newLogLevel; 33 | } 34 | 35 | void Logger::log(LogLevel logLevel, const char* prefix, const char* color, const char* format, va_list ap) 36 | { 37 | if (g_logLevel < logLevel) 38 | return; 39 | 40 | printf("\033%s[%s]\033[0m ", color, prefix); 41 | vprintf(format, ap); 42 | printf("\n"); 43 | 44 | #ifdef __MINGW32__ 45 | fflush(0); 46 | #endif 47 | } 48 | 49 | void Logger::error(const char* format, ...) 50 | { 51 | va_list ap; 52 | va_start(ap, format); 53 | Logger::log(LogLevel::ERROR, "ERROR", "[0;31m", format, ap); 54 | va_end(ap); 55 | } 56 | 57 | void Logger::info(const char* format, ...) 58 | { 59 | va_list ap; 60 | va_start(ap, format); 61 | Logger::log(LogLevel::INFO, "INFO", "[0;34m", format, ap); 62 | va_end(ap); 63 | } 64 | 65 | void Logger::debug(const char* format, ...) 66 | { 67 | va_list ap; 68 | va_start(ap, format); 69 | Logger::log(LogLevel::DEBUG, "DEBUG", "[0;32m", format, ap); 70 | va_end(ap); 71 | } 72 | 73 | } // namespace brls 74 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/actions.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2020 WerWolv 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | #define GLFW_INCLUDE_NONE 25 | #include 26 | 27 | namespace brls 28 | { 29 | 30 | class View; 31 | 32 | typedef std::function ActionListener; 33 | 34 | // ZL and ZR do not exist here because GLFW doesn't know them 35 | enum class Key 36 | { 37 | A = GLFW_GAMEPAD_BUTTON_A, 38 | B = GLFW_GAMEPAD_BUTTON_B, 39 | X = GLFW_GAMEPAD_BUTTON_X, 40 | Y = GLFW_GAMEPAD_BUTTON_Y, 41 | LSTICK = GLFW_GAMEPAD_BUTTON_LEFT_THUMB, 42 | RSTICK = GLFW_GAMEPAD_BUTTON_RIGHT_THUMB, 43 | L = GLFW_GAMEPAD_BUTTON_LEFT_BUMPER, 44 | R = GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER, 45 | PLUS = GLFW_GAMEPAD_BUTTON_START, 46 | MINUS = GLFW_GAMEPAD_BUTTON_BACK, 47 | DLEFT = GLFW_GAMEPAD_BUTTON_DPAD_LEFT, 48 | DUP = GLFW_GAMEPAD_BUTTON_DPAD_UP, 49 | DRIGHT = GLFW_GAMEPAD_BUTTON_DPAD_RIGHT, 50 | DDOWN = GLFW_GAMEPAD_BUTTON_DPAD_DOWN, 51 | }; 52 | 53 | struct Action 54 | { 55 | Key key; 56 | 57 | std::string hintText; 58 | bool available; 59 | bool hidden; 60 | ActionListener actionListener; 61 | 62 | bool operator==(const Key other) 63 | { 64 | return this->key == other; 65 | } 66 | }; 67 | 68 | } // namespace brls 69 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #ifndef BOREALIS_RESOURCES 23 | #error BOREALIS_RESOURCES define missing 24 | #endif 25 | #define BOREALIS_ASSET(_str) BOREALIS_RESOURCES _str 26 | 27 | // Library 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/progress_display.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 Billy Laws 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace brls 27 | { 28 | 29 | // TODO: Add the "ProgressDisplayFlags_" prefix to the members 30 | enum ProgressDisplayFlags 31 | { 32 | SPINNER = 1u << 0, 33 | PERCENTAGE = 1u << 1 34 | }; 35 | 36 | inline constexpr ProgressDisplayFlags DEFAULT_PROGRESS_DISPLAY_FLAGS = (ProgressDisplayFlags)(ProgressDisplayFlags::SPINNER | ProgressDisplayFlags::PERCENTAGE); 37 | 38 | // A progress bar with an optional spinner and percentage text. 39 | class ProgressDisplay : public View 40 | { 41 | public: 42 | ProgressDisplay(ProgressDisplayFlags progressFlags = DEFAULT_PROGRESS_DISPLAY_FLAGS); 43 | ~ProgressDisplay(); 44 | 45 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 46 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 47 | void willAppear(bool resetState = false) override; 48 | void willDisappear(bool resetState = false) override; 49 | 50 | void setProgress(int current, int max); 51 | 52 | private: 53 | float progressPercentage = 0.0f; 54 | Label* label; 55 | ProgressSpinner* spinner; 56 | }; 57 | 58 | } // namespace brls 59 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/table.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace brls 27 | { 28 | 29 | // The type of a Table Row 30 | enum class TableRowType 31 | { 32 | HEADER = 0, 33 | BODY 34 | }; 35 | 36 | // A Table row 37 | class TableRow 38 | { 39 | private: 40 | TableRowType type; 41 | 42 | std::string label; 43 | std::string value; 44 | 45 | public: 46 | TableRow(TableRowType type, std::string label, std::string value = ""); 47 | 48 | std::string* getLabel(); 49 | std::string* getValue(); 50 | TableRowType getType(); 51 | 52 | void setValue(std::string value); 53 | }; 54 | 55 | // A simple, static two-columns table, as seen in 56 | // the Settings app (Internet connection details) 57 | // All rows must be added before adding the view 58 | // to a layout (it's static) 59 | class Table : public View 60 | { 61 | private: 62 | std::vector rows; 63 | 64 | public: 65 | ~Table(); 66 | 67 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 68 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 69 | 70 | TableRow* addRow(TableRowType type, std::string label, std::string value = ""); 71 | }; 72 | 73 | } // namespace brls 74 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/lib/task_manager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | namespace brls 25 | { 26 | 27 | void TaskManager::frame() 28 | { 29 | // Repeating tasks 30 | retro_time_t currentTime = cpu_features_get_time_usec() / 1000; 31 | for (auto i = this->repeatingTasks.begin(); i != this->repeatingTasks.end(); i++) 32 | { 33 | RepeatingTask* task = *i; 34 | 35 | // Stop the task if needed 36 | if (task->isStopRequested()) 37 | { 38 | this->stopRepeatingTask(task); 39 | this->repeatingTasks.erase(i--); 40 | } 41 | // Fire it 42 | else if (task->isRunning() && currentTime - task->getLastRun() > task->getInterval()) 43 | { 44 | task->run(currentTime); 45 | } 46 | } 47 | } 48 | 49 | void TaskManager::registerRepeatingTask(RepeatingTask* task) 50 | { 51 | this->repeatingTasks.push_back(task); 52 | } 53 | 54 | void TaskManager::stopRepeatingTask(RepeatingTask* task) 55 | { 56 | task->onStop(); 57 | delete task; 58 | } 59 | 60 | TaskManager::~TaskManager() 61 | { 62 | // Stop all repeating tasks 63 | for (RepeatingTask* task : this->repeatingTasks) 64 | this->stopRepeatingTask(task); 65 | 66 | this->repeatingTasks.clear(); 67 | } 68 | 69 | } // namespace brls 70 | -------------------------------------------------------------------------------- /sysmodule/lib/minIni/dev/test2.cc: -------------------------------------------------------------------------------- 1 | /* 2 | gcc -o minIni.o -c minIni.c 3 | g++ -o test2.o -c test2.cc 4 | g++ -o test2 test2.o minIni.o 5 | ./test2 6 | */ 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | using namespace std ; 13 | 14 | #include "minIni.h" 15 | 16 | int main(void) 17 | { 18 | minIni ini("test.ini"); 19 | string s; 20 | 21 | /* string reading */ 22 | s = ini.gets( "first", "string" , "aap" ); 23 | assert(s == "noot"); 24 | s = ini.gets( "second", "string" , "aap" ); 25 | assert(s == "mies"); 26 | s = ini.gets( "first", "dummy" , "aap" ); 27 | assert(s == "aap"); 28 | cout << "1. String reading tests passed" << endl ; 29 | 30 | 31 | /* value reading */ 32 | long n; 33 | n = ini.getl("first", "val", -1 ); 34 | assert(n==1); 35 | n = ini.getl("second", "val", -1); 36 | assert(n==2); 37 | n = ini.getl("first", "dummy", -1); 38 | assert(n==-1); 39 | cout << "2. Value reading tests passed" << endl ; 40 | 41 | 42 | /* string writing */ 43 | bool b; 44 | b = ini.put("first", "alt", "flagged as \"correct\""); 45 | assert(b); 46 | s = ini.gets("first", "alt", "aap"); 47 | assert(s=="flagged as \"correct\""); 48 | 49 | b = ini.put("second", "alt", "correct"); 50 | assert(b); 51 | s = ini.gets("second", "alt", "aap"); 52 | assert(s=="correct"); 53 | 54 | b = ini.put("third", "alt", "correct"); 55 | assert(b); 56 | s = ini.gets("third", "alt", "aap" ); 57 | assert(s=="correct"); 58 | cout << "3. String writing tests passed" << endl; 59 | 60 | /* section/key enumeration */ 61 | cout << "4. section/key enumeration; file contents follows" << endl; 62 | string section; 63 | for (int is = 0; section = ini.getsection(is), section.length() > 0; is++) { 64 | cout << " [" << section.c_str() << "]" << endl; 65 | for (int ik = 0; s = ini.getkey(section, ik), s.length() > 0; ik++) { 66 | cout << "\t" << s.c_str() << endl; 67 | } 68 | } 69 | 70 | /* string deletion */ 71 | b = ini.del("first", "alt"); 72 | assert(b); 73 | b = ini.del("second", "alt"); 74 | assert(b); 75 | b = ini.del("third"); 76 | assert(b); 77 | cout << "5. string deletion passed " << endl; 78 | 79 | return 0; 80 | } 81 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/lib/repeating_task.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | namespace brls 24 | { 25 | 26 | RepeatingTask::RepeatingTask(retro_time_t interval) 27 | : interval(interval) 28 | { 29 | Application::getTaskManager()->registerRepeatingTask(this); 30 | } 31 | 32 | void RepeatingTask::run(retro_time_t currentTime) 33 | { 34 | this->lastRun = currentTime; 35 | } 36 | 37 | void RepeatingTask::start() 38 | { 39 | this->onStart(); 40 | this->running = true; 41 | } 42 | 43 | void RepeatingTask::pause() 44 | { 45 | this->running = false; 46 | } 47 | 48 | void RepeatingTask::stop() 49 | { 50 | this->pause(); 51 | this->stopRequested = true; 52 | } 53 | 54 | void RepeatingTask::fireNow() 55 | { 56 | if (!this->isRunning()) 57 | return; 58 | 59 | retro_time_t currentTime = cpu_features_get_time_usec() / 1000; 60 | this->run(currentTime); 61 | } 62 | 63 | retro_time_t RepeatingTask::getInterval() 64 | { 65 | return this->interval; 66 | } 67 | 68 | retro_time_t RepeatingTask::getLastRun() 69 | { 70 | return this->lastRun; 71 | } 72 | 73 | bool RepeatingTask::isRunning() 74 | { 75 | return this->running; 76 | } 77 | 78 | bool RepeatingTask::isStopRequested() 79 | { 80 | return this->stopRequested; 81 | } 82 | 83 | RepeatingTask::~RepeatingTask() 84 | { 85 | // Nothing to do here, only the Task Manager is supposed to free tasks 86 | } 87 | 88 | } // namespace brls 89 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/repeating_task.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | namespace brls 25 | { 26 | 27 | // A task that is repeated at a given interval 28 | // by the UI thread 29 | class RepeatingTask 30 | { 31 | private: 32 | retro_time_t interval; 33 | 34 | retro_time_t lastRun = 0; 35 | 36 | bool running = false; 37 | bool stopRequested = false; 38 | 39 | public: 40 | RepeatingTask(retro_time_t interval); 41 | virtual ~RepeatingTask(); 42 | 43 | /** 44 | * Actual code to run by the task 45 | * Must call RepeatingTask::run() ! 46 | */ 47 | virtual void run(retro_time_t currentTime); 48 | 49 | /** 50 | * Fired when the task starts 51 | */ 52 | virtual void onStart() {}; 53 | 54 | /** 55 | * Fired when the task stops 56 | */ 57 | virtual void onStop() {}; 58 | 59 | /** 60 | * Starts the task 61 | */ 62 | void start(); 63 | 64 | /** 65 | * Fires the task immediately and delays the 66 | * next run 67 | */ 68 | void fireNow(); 69 | 70 | /** 71 | * Pauses the task without deleting it 72 | */ 73 | void pause(); 74 | 75 | /** 76 | * Stops and deletes the task 77 | */ 78 | void stop(); 79 | 80 | retro_time_t getInterval(); 81 | retro_time_t getLastRun(); 82 | 83 | bool isRunning(); 84 | bool isStopRequested(); 85 | }; 86 | 87 | } // namespace brls 88 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/event.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2020 natinusala 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace brls 26 | { 27 | 28 | // Simple observer pattern implementation 29 | // 30 | // Usage: 31 | // 1. typedef your event type 32 | // 2. create as many events as you want using that type 33 | // 3. call subscribe on the events with your observers 34 | // 4. call fire when you want to fire the events 35 | // it wil return true if at least one subscriber exists 36 | // for that event 37 | template 38 | class Event 39 | { 40 | public: 41 | typedef std::function Callback; 42 | typedef std::list CallbacksList; 43 | typedef typename CallbacksList::iterator Subscription; 44 | 45 | Subscription subscribe(Callback cb); 46 | void unsubscribe(Subscription subscription); 47 | bool fire(Ts... args); 48 | 49 | private: 50 | CallbacksList callbacks; 51 | }; 52 | 53 | template 54 | typename Event::Subscription Event::subscribe(Event::Callback cb) 55 | { 56 | this->callbacks.push_back(cb); 57 | return --this->callbacks.end(); 58 | } 59 | 60 | template 61 | void Event::unsubscribe(Event::Subscription subscription) 62 | { 63 | this->callbacks.erase(subscription); 64 | } 65 | 66 | template 67 | bool Event::fire(Ts... args) 68 | { 69 | for (Callback cb : this->callbacks) 70 | cb(args...); 71 | 72 | return !this->callbacks.empty(); 73 | } 74 | 75 | }; // namespace brls 76 | -------------------------------------------------------------------------------- /overlay/src/ui/gui/main_gui.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #include "main_gui.h" 12 | 13 | #include "fatal_gui.h" 14 | #include "app_profile_gui.h" 15 | #include "global_override_gui.h" 16 | 17 | void MainGui::listUI() 18 | { 19 | this->enabledToggle = new tsl::elm::ToggleListItem("Enable", false); 20 | enabledToggle->setStateChangedListener([this](bool state) { 21 | Result rc = sysclkIpcSetEnabled(state); 22 | if(R_FAILED(rc)) 23 | { 24 | FatalGui::openWithResultCode("sysclkIpcSetEnabled", rc); 25 | } 26 | 27 | this->lastContextUpdate = armGetSystemTick(); 28 | this->context->enabled = state; 29 | }); 30 | this->listElement->addItem(this->enabledToggle); 31 | 32 | tsl::elm::ListItem* appProfileItem = new tsl::elm::ListItem("Edit app profile"); 33 | appProfileItem->setClickListener([this](u64 keys) { 34 | if((keys & HidNpadButton_A) == HidNpadButton_A && this->context) 35 | { 36 | AppProfileGui::changeTo(this->context->applicationId); 37 | return true; 38 | } 39 | 40 | return false; 41 | }); 42 | this->listElement->addItem(appProfileItem); 43 | 44 | this->listElement->addItem(new tsl::elm::CategoryHeader("Advanced")); 45 | 46 | tsl::elm::ListItem* globalOverrideItem = new tsl::elm::ListItem("Temporary overrides"); 47 | globalOverrideItem->setClickListener([this](u64 keys) { 48 | if((keys & HidNpadButton_A) == HidNpadButton_A) 49 | { 50 | tsl::changeTo(); 51 | return true; 52 | } 53 | 54 | return false; 55 | }); 56 | this->listElement->addItem(globalOverrideItem); 57 | } 58 | 59 | void MainGui::refresh() 60 | { 61 | BaseMenuGui::refresh(); 62 | 63 | if(this->context) 64 | { 65 | this->enabledToggle->setState(this->context->enabled); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /manager/src/about_tab.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019-2020 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #include "about_tab.h" 22 | 23 | #include "logo.h" 24 | #include "ipc/ipc.h" 25 | #include "ipc/client.h" 26 | 27 | #include 28 | 29 | AboutTab::AboutTab() 30 | { 31 | this->addView(new Logo(LogoStyle::ABOUT)); 32 | 33 | // Subtitle 34 | brls::Label *subTitle = new brls::Label( 35 | brls::LabelStyle::REGULAR, 36 | "Nintendo Switch overclocking / underclocking system module and frontend app by the RetroNX Team", 37 | true 38 | ); 39 | subTitle->setHorizontalAlign(NVG_ALIGN_CENTER); 40 | this->addView(subTitle); 41 | 42 | // Copyright 43 | brls::Label *copyright = new brls::Label( 44 | brls::LabelStyle::DESCRIPTION, 45 | "System module licensed under the Beerware license\n" \ 46 | "Frontend app licensed under GPL-3.0\n" \ 47 | "\u00A9 2019 - 2020 natinusala, p-sam, m4xw", 48 | true 49 | ); 50 | copyright->setHorizontalAlign(NVG_ALIGN_CENTER); 51 | this->addView(copyright); 52 | 53 | // Links 54 | this->addView(new brls::Header("Links and Resources")); 55 | brls::Label *links = new brls::Label( 56 | brls::LabelStyle::SMALL, 57 | "\uE016 User guide and code source can be found on our GitHub repository\n" \ 58 | "\uE016 The sys-clk manager is powered by Borealis, an hardware accelerated UI library\n" \ 59 | "\uE016 Join the RetroNX Discord server for support, to request features or just hang out!", 60 | true 61 | ); 62 | this->addView(links); 63 | } 64 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/scroll_view.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2020 natinusala 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | namespace brls 22 | { 23 | 24 | // TODO: horizontal scrolling, either in ScrollView or in a separate class (like Android has) 25 | 26 | // A view that automatically scrolls vertically 27 | // when one of its children gains focus 28 | class ScrollView : public View 29 | { 30 | private: 31 | View* contentView = nullptr; 32 | 33 | bool ready = false; // has layout been called at least once? 34 | 35 | unsigned middleY = 0; // y + height/2 36 | unsigned bottomY = 0; // y + height 37 | 38 | float scrollY = 0.0f; // from 0.0f to 1.0f, in % of content view height 39 | 40 | bool updateScrollingOnNextLayout = false; 41 | bool updateScrollingOnNextFrame = false; 42 | 43 | unsigned getYCenter(View* view); 44 | 45 | void prebakeScrolling(); 46 | bool updateScrolling(bool animated); 47 | void startScrolling(bool animated, float newScroll); 48 | void scrollAnimationTick(); 49 | 50 | public: 51 | ~ScrollView(); 52 | 53 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 54 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 55 | void willAppear(bool resetState = false) override; 56 | void willDisappear(bool resetState = false) override; 57 | View* getDefaultFocus() override; 58 | void onChildFocusGained(View* child) override; 59 | void onWindowSizeChanged() override; 60 | 61 | void setContentView(View* view); 62 | View* getContentView(); 63 | }; 64 | 65 | } // namespace brls 66 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/extern/libretro-common/compat/strl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2018 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (strl.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_COMPAT_STRL_H 24 | #define __LIBRETRO_SDK_COMPAT_STRL_H 25 | 26 | #include 27 | #include 28 | 29 | #if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H) 30 | #include "../../../config.h" 31 | #endif 32 | 33 | #include 34 | 35 | RETRO_BEGIN_DECLS 36 | 37 | #ifdef __MACH__ 38 | #ifndef HAVE_STRL 39 | #define HAVE_STRL 40 | #endif 41 | #endif 42 | 43 | #ifndef HAVE_STRL 44 | /* Avoid possible naming collisions during link since 45 | * we prefer to use the actual name. */ 46 | #define strlcpy(dst, src, size) strlcpy_retro__(dst, src, size) 47 | 48 | #define strlcat(dst, src, size) strlcat_retro__(dst, src, size) 49 | 50 | size_t strlcpy(char *dest, const char *source, size_t size); 51 | size_t strlcat(char *dest, const char *source, size_t size); 52 | 53 | #endif 54 | 55 | char *strldup(const char *s, size_t n); 56 | 57 | RETRO_END_DECLS 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /overlay/src/ui/gui/fatal_gui.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #include "fatal_gui.h" 12 | 13 | FatalGui::FatalGui(const std::string message, const std::string info) 14 | { 15 | this->message = message; 16 | this->info = info; 17 | } 18 | 19 | void FatalGui::openWithResultCode(std::string tag, Result rc) 20 | { 21 | char rcStr[32]; 22 | std::string info = tag; 23 | info.append(rcStr, snprintf(rcStr, sizeof(rcStr), "\n\n[0x%x] %04d-%04d", rc, R_MODULE(rc), R_DESCRIPTION(rc))); 24 | 25 | tsl::changeTo( 26 | "Could not connect to sys-clk.\n\n" 27 | "\n" 28 | "Please make sure everything is\n\n" 29 | "correctly installed and enabled.", 30 | info 31 | ); 32 | } 33 | 34 | tsl::elm::Element* FatalGui::baseUI() 35 | { 36 | tsl::elm::CustomDrawer* drawer = new tsl::elm::CustomDrawer([this](tsl::gfx::Renderer* renderer, u16 x, u16 y, u16 w, u16 h) { 37 | renderer->drawString("\uE150", false, 40, 210, 40, TEXT_COLOR); 38 | renderer->drawString("Fatal error", false, 100, 210, 30, TEXT_COLOR); 39 | 40 | std::uint32_t txtY = 255; 41 | if(!this->message.empty()) 42 | { 43 | txtY += renderer->drawString(this->message.c_str(), false, 40, txtY, 23, TEXT_COLOR).second; 44 | txtY += 55; 45 | } 46 | 47 | if(!this->info.empty()) 48 | { 49 | renderer->drawString(this->info.c_str(), false, 40, txtY, 18, DESC_COLOR); 50 | } 51 | }); 52 | 53 | return drawer; 54 | } 55 | 56 | bool FatalGui::handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft, HidAnalogStickState joyStickPosRight) 57 | { 58 | if((keysDown & HidNpadButton_A) == HidNpadButton_A || (keysDown & HidNpadButton_B) == HidNpadButton_B) 59 | { 60 | while(tsl::Overlay::get()->getCurrentGui() != nullptr) { 61 | tsl::goBack(); 62 | } 63 | return true; 64 | } 65 | 66 | return false; 67 | } 68 | -------------------------------------------------------------------------------- /sysmodule/lib/minIni/dev/minGlue-mdd.h: -------------------------------------------------------------------------------- 1 | /* minIni glue functions for Microchip's "Memory Disk Drive" file system 2 | * library, as presented in Microchip application note AN1045. 3 | * 4 | * By CompuPhase, 2011-2014 5 | * This "glue file" is in the public domain. It is distributed without 6 | * warranties or conditions of any kind, either express or implied. 7 | * 8 | * (The "Microchip Memory Disk Drive File System" is copyright (c) Microchip 9 | * Technology Incorporated, and licensed at its own terms.) 10 | */ 11 | 12 | #define INI_BUFFERSIZE 256 /* maximum line length, maximum path length */ 13 | 14 | #include "MDD File System\fsio.h" 15 | #include 16 | 17 | #define INI_FILETYPE FSFILE* 18 | #define ini_openread(filename,file) ((*(file) = FSfopen((filename),FS_READ)) != NULL) 19 | #define ini_openwrite(filename,file) ((*(file) = FSfopen((filename),FS_WRITE)) != NULL) 20 | #define ini_openrewrite(filename,file) ((*(file) = fopen((filename),FS_READPLUS)) != NULL) 21 | #define ini_close(file) (FSfclose(*(file)) == 0) 22 | #define ini_write(buffer,file) (FSfwrite((buffer), 1, strlen(buffer), (*file)) > 0) 23 | #define ini_remove(filename) (FSremove((filename)) == 0) 24 | 25 | #define INI_FILEPOS long int 26 | #define ini_tell(file,pos) (*(pos) = FSftell(*(file))) 27 | #define ini_seek(file,pos) (FSfseek(*(file), *(pos), SEEK_SET) == 0) 28 | 29 | /* Since the Memory Disk Drive file system library reads only blocks of files, 30 | * the function to read a text line does so by "over-reading" a block of the 31 | * of the maximum size and truncating it behind the end-of-line. 32 | */ 33 | static int ini_read(char *buffer, int size, INI_FILETYPE *file) 34 | { 35 | size_t numread = size; 36 | char *eol; 37 | 38 | if ((numread = FSfread(buffer, 1, size, *file)) == 0) 39 | return 0; /* at EOF */ 40 | if ((eol = strchr(buffer, '\n')) == NULL) 41 | eol = strchr(buffer, '\r'); 42 | if (eol != NULL) { 43 | /* terminate the buffer */ 44 | *++eol = '\0'; 45 | /* "unread" the data that was read too much */ 46 | FSfseek(*file, - (int)(numread - (size_t)(eol - buffer)), SEEK_CUR); 47 | } /* if */ 48 | return 1; 49 | } 50 | 51 | #ifndef INI_READONLY 52 | static int ini_rename(const char *source, const char *dest) 53 | { 54 | FSFILE* ftmp = FSfopen((source), FS_READ); 55 | FSrename((dest), ftmp); 56 | return FSfclose(ftmp) == 0; 57 | } 58 | #endif 59 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/lib/extern/libretro-common/compat/compat_strl.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2018 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (compat_strl.c). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | /* Implementation of strlcpy()/strlcat() based on OpenBSD. */ 29 | 30 | #ifndef __MACH__ 31 | 32 | size_t strlcpy(char *dest, const char *source, size_t size) 33 | { 34 | size_t src_size = 0; 35 | size_t n = size; 36 | 37 | if (n) 38 | while (--n && (*dest++ = *source++)) src_size++; 39 | 40 | if (!n) 41 | { 42 | if (size) *dest = '\0'; 43 | while (*source++) src_size++; 44 | } 45 | 46 | return src_size; 47 | } 48 | 49 | size_t strlcat(char *dest, const char *source, size_t size) 50 | { 51 | size_t len = strlen(dest); 52 | 53 | dest += len; 54 | 55 | if (len > size) 56 | size = 0; 57 | else 58 | size -= len; 59 | 60 | return len + strlcpy(dest, source, size); 61 | } 62 | #endif 63 | 64 | char *strldup(const char *s, size_t n) 65 | { 66 | char *dst = (char*)malloc(sizeof(char) * (n + 1)); 67 | strlcpy(dst, s, n); 68 | return dst; 69 | } 70 | -------------------------------------------------------------------------------- /manager/src/cheat_sheet_tab.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019-2020 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #include "cheat_sheet_tab.h" 22 | 23 | #include 24 | 25 | CheatSheetTab::CheatSheetTab() 26 | { 27 | // CPU 28 | this->addView(new brls::Header("CPU Clocks")); 29 | brls::Table *cpuTable = new brls::Table(); 30 | 31 | cpuTable->addRow(brls::TableRowType::BODY, "Maximum", "1785 MHz"); 32 | cpuTable->addRow(brls::TableRowType::BODY, "Official Docked and Handheld", "1020 MHz"); 33 | 34 | this->addView(cpuTable); 35 | 36 | // GPU 37 | this->addView(new brls::Header("GPU Clocks")); 38 | brls::Table *gpuTable = new brls::Table(); 39 | 40 | gpuTable->addRow(brls::TableRowType::BODY, "Maximum", "921 MHz"); 41 | gpuTable->addRow(brls::TableRowType::BODY, "Official Docked", "768 MHz"); 42 | gpuTable->addRow(brls::TableRowType::BODY, "Maximum Mariko Handheld", "614 MHz"); 43 | gpuTable->addRow(brls::TableRowType::BODY, "Maximum Erista Handheld", "460 MHz"); 44 | gpuTable->addRow(brls::TableRowType::BODY, "Official Handheld", "384 MHz"); 45 | 46 | this->addView(gpuTable); 47 | 48 | // MEM 49 | this->addView(new brls::Header("MEM Clocks")); 50 | brls::Table *memTable = new brls::Table(); 51 | 52 | memTable->addRow(brls::TableRowType::BODY, "Maximum, Official Docked", "1600 MHz"); 53 | memTable->addRow(brls::TableRowType::BODY, "Official Handheld", "1331 MHz"); 54 | 55 | this->addView(memTable); 56 | } 57 | 58 | void CheatSheetTab::customSpacing(brls::View* current, brls::View* next, int* spacing) 59 | { 60 | if (dynamic_cast(current)) 61 | *spacing = 0; 62 | else 63 | List::customSpacing(current, next, spacing); 64 | } 65 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/thumbnail_frame.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace brls 27 | { 28 | 29 | // The sidebar used in ThumbnailFrame 30 | class ThumbnailSidebar : public View 31 | { 32 | private: 33 | Image* image = nullptr; 34 | Button* button = nullptr; 35 | 36 | Label* title = nullptr; 37 | Label* subTitle = nullptr; 38 | 39 | public: 40 | ThumbnailSidebar(); 41 | ~ThumbnailSidebar(); 42 | 43 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 44 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 45 | View* getDefaultFocus() override; 46 | 47 | void setThumbnail(std::string imagePath); 48 | void setThumbnail(unsigned char* buffer, size_t bufferSize); 49 | 50 | void setTitle(std::string title); 51 | void setSubtitle(std::string subTitle); 52 | 53 | Button* getButton(); 54 | }; 55 | 56 | // An applet frame with a sidebar on the right, containing a thumbnail 57 | // and a button (similar to the Wi-Fi settings in HOS) 58 | class ThumbnailFrame : public AppletFrame 59 | { 60 | private: 61 | ThumbnailSidebar* sidebar = nullptr; 62 | BoxLayout* boxLayout = nullptr; 63 | 64 | View* thumbnailContentView = nullptr; 65 | 66 | public: 67 | ThumbnailFrame(); 68 | ~ThumbnailFrame(); 69 | 70 | void setContentView(View* view) override; 71 | 72 | protected: 73 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 74 | 75 | ThumbnailSidebar* getSidebar(); 76 | }; 77 | 78 | } // namespace brls 79 | -------------------------------------------------------------------------------- /overlay/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * , , 5 | * wrote this file. As long as you retain this notice you can do whatever you 6 | * want with this stuff. If you meet any of us some day, and you think this 7 | * stuff is worth it, you can buy us a beer in return. - The sys-clk authors 8 | * -------------------------------------------------------------------------- 9 | */ 10 | 11 | #define TESLA_INIT_IMPL 12 | #include 13 | 14 | #include "ui/gui/fatal_gui.h" 15 | #include "ui/gui/main_gui.h" 16 | 17 | class AppOverlay : public tsl::Overlay 18 | { 19 | public: 20 | AppOverlay() {} 21 | ~AppOverlay() {} 22 | 23 | virtual void exitServices() override { 24 | sysclkIpcExit(); 25 | } 26 | 27 | virtual std::unique_ptr loadInitialGui() override 28 | { 29 | uint32_t apiVersion; 30 | smInitialize(); 31 | 32 | tsl::hlp::ScopeGuard smGuard([] { smExit(); }); 33 | 34 | if(!sysclkIpcRunning()) 35 | { 36 | return initially( 37 | "sys-clk is not running.\n\n" 38 | "\n" 39 | "Please make sure it is correctly\n\n" 40 | "installed and enabled.", 41 | "" 42 | ); 43 | } 44 | 45 | if(R_FAILED(sysclkIpcInitialize()) || R_FAILED(sysclkIpcGetAPIVersion(&apiVersion))) 46 | { 47 | return initially( 48 | "Could not connect to sys-clk.\n\n" 49 | "\n" 50 | "Please make sure it is correctly\n\n" 51 | "installed and enabled.", 52 | "" 53 | ); 54 | } 55 | 56 | if(SYSCLK_IPC_API_VERSION != apiVersion) 57 | { 58 | return initially( 59 | "Overlay not compatible with\n\n" 60 | "the running sys-clk version.\n\n" 61 | "\n" 62 | "Please make sure everything is\n\n" 63 | "installed and up to date.", 64 | "" 65 | ); 66 | } 67 | 68 | return initially(); 69 | } 70 | }; 71 | 72 | int main(int argc, char **argv) 73 | { 74 | return tsl::loop(argc, argv); 75 | } 76 | -------------------------------------------------------------------------------- /sysmodule/lib/minIni/dev/minGlue-ccs.h: -------------------------------------------------------------------------------- 1 | /* minIni glue functions for FAT library by CCS, Inc. (as provided with their 2 | * PIC MCU compiler) 3 | * 4 | * By CompuPhase, 2011-2012 5 | * This "glue file" is in the public domain. It is distributed without 6 | * warranties or conditions of any kind, either express or implied. 7 | * 8 | * (The FAT library is copyright (c) 2007 Custom Computer Services, and 9 | * licensed at its own terms.) 10 | */ 11 | 12 | #define INI_BUFFERSIZE 256 /* maximum line length, maximum path length */ 13 | 14 | #ifndef FAT_PIC_C 15 | #error FAT library must be included before this module 16 | #endif 17 | #define const /* keyword not supported by CCS */ 18 | 19 | #define INI_FILETYPE FILE 20 | #define ini_openread(filename,file) (fatopen((filename), "r", (file)) == GOODEC) 21 | #define ini_openwrite(filename,file) (fatopen((filename), "w", (file)) == GOODEC) 22 | #define ini_close(file) (fatclose((file)) == 0) 23 | #define ini_read(buffer,size,file) (fatgets((buffer), (size), (file)) != NULL) 24 | #define ini_write(buffer,file) (fatputs((buffer), (file)) == GOODEC) 25 | #define ini_remove(filename) (rm_file((filename)) == 0) 26 | 27 | #define INI_FILEPOS fatpos_t 28 | #define ini_tell(file,pos) (fatgetpos((file), (pos)) == 0) 29 | #define ini_seek(file,pos) (fatsetpos((file), (pos)) == 0) 30 | 31 | #ifndef INI_READONLY 32 | /* CCS FAT library lacks a rename function, so instead we copy the file to the 33 | * new name and delete the old file 34 | */ 35 | static int ini_rename(char *source, char *dest) 36 | { 37 | FILE fr, fw; 38 | int n; 39 | 40 | if (fatopen(source, "r", &fr) != GOODEC) 41 | return 0; 42 | if (rm_file(dest) != 0) 43 | return 0; 44 | if (fatopen(dest, "w", &fw) != GOODEC) 45 | return 0; 46 | 47 | /* With some "insider knowledge", we can save some memory: the "source" 48 | * parameter holds a filename that was built from the "dest" parameter. It 49 | * was built in a local buffer with the size INI_BUFFERSIZE. We can reuse 50 | * this buffer for copying the file. 51 | */ 52 | while (n=fatread(source, 1, INI_BUFFERSIZE, &fr)) 53 | fatwrite(source, 1, n, &fw); 54 | 55 | fatclose(&fr); 56 | fatclose(&fw); 57 | 58 | /* Now we need to delete the source file. However, we have garbled the buffer 59 | * that held the filename of the source. So we need to build it again. 60 | */ 61 | ini_tempname(source, dest, INI_BUFFERSIZE); 62 | return rm_file(source) == 0; 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/image.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 WerWolv 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | 25 | namespace brls 26 | { 27 | 28 | enum class ImageScaleType 29 | { 30 | NO_RESIZE = 0, // Nothing is resized 31 | FIT, // The image is shrinked to fit the view boundaries 32 | CROP, // The image is not resized but is cropped if bigger than the view 33 | SCALE, // The image is stretched to match the view boundaries 34 | VIEW_RESIZE // The view is resized to match the image 35 | }; 36 | 37 | // An image 38 | class Image : public View 39 | { 40 | public: 41 | Image(std::string imagePath); 42 | Image(unsigned char* buffer, size_t bufferSize); 43 | ~Image(); 44 | 45 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 46 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 47 | 48 | void setImage(unsigned char* buffer, size_t bufferSize); 49 | void setImage(std::string imagePath); 50 | 51 | void setScaleType(ImageScaleType imageScaleType); 52 | void setOpacity(float opacity); 53 | 54 | void setCornerRadius(float radius) 55 | { 56 | this->cornerRadius = radius; 57 | } 58 | 59 | private: 60 | std::string imagePath; 61 | unsigned char* imageBuffer = nullptr; 62 | size_t imageBufferSize = 0; 63 | 64 | int texture = -1; 65 | NVGpaint imgPaint; 66 | 67 | ImageScaleType imageScaleType = ImageScaleType::FIT; 68 | 69 | float cornerRadius = 0; 70 | 71 | int imageX = 0, imageY = 0; 72 | int imageWidth = 0, imageHeight = 0; 73 | int origViewWidth = 0, origViewHeight = 0; 74 | 75 | void reloadTexture(); 76 | }; 77 | 78 | } // namespace brls 79 | -------------------------------------------------------------------------------- /manager/src/ipc/pc_shim/client.h: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include 26 | #include "../client.h" 27 | 28 | class SysClkShimServer 29 | { 30 | public: 31 | SysClkShimServer(); 32 | void SetContextApplicationId(u64 tid); 33 | void SetContextHz(SysClkModule module, u32 hz); 34 | void SetContextRealHz(SysClkModule module, u32 hz); 35 | void SetContextTemp(SysClkThermalSensor sensor, u32 temp); 36 | void SetContextProfile(SysClkProfile profile); 37 | void SetContextEnabled(bool enabled); 38 | void SetContextOverride(SysClkModule module, u32 hz); 39 | void CopyContext(SysClkContext* out_context); 40 | void SetProfile(uint64_t applicationId, SysClkModule module, SysClkProfile profile, u32 mhz); 41 | u32 GetProfileMHz(uint64_t applicationId, SysClkModule module, SysClkProfile profile); 42 | void GetProfiles(u64 applicationId, SysClkTitleProfileList* out_profiles); 43 | void SetProfiles(u64 applicationId, SysClkTitleProfileList* profiles); 44 | u8 CountProfiles(u64 applicationId); 45 | u64 GetConfigValue(SysClkConfigValue kval); 46 | void SetConfigValue(SysClkConfigValue kval, u64 val); 47 | void GetConfigValues(SysClkConfigValueList* out_configValues); 48 | void SetConfigValues(SysClkConfigValueList* configValues); 49 | void AddFreq(SysClkModule module, u32 hz); 50 | void GetFreqList(SysClkModule module, u32* list, u32 maxCount, u32* outCount); 51 | 52 | protected: 53 | SysClkContext context; 54 | std::vector freqs[SysClkModule_EnumMax]; 55 | std::map, u32> store; 56 | u64 configValues[SysClkConfigValue_EnumMax]; 57 | }; 58 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/extern/libretro-common/encodings/utf.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2018 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (utf.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef _LIBRETRO_ENCODINGS_UTF_H 24 | #define _LIBRETRO_ENCODINGS_UTF_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | 33 | RETRO_BEGIN_DECLS 34 | 35 | enum CodePage 36 | { 37 | CODEPAGE_LOCAL = 0, /* CP_ACP */ 38 | CODEPAGE_UTF8 = 65001 /* CP_UTF8 */ 39 | }; 40 | 41 | size_t utf8_conv_utf32(uint32_t *out, size_t out_chars, 42 | const char *in, size_t in_size); 43 | 44 | bool utf16_conv_utf8(uint8_t *out, size_t *out_chars, 45 | const uint16_t *in, size_t in_size); 46 | 47 | size_t utf8len(const char *string); 48 | 49 | size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars); 50 | 51 | const char *utf8skip(const char *str, size_t chars); 52 | 53 | uint32_t utf8_walk(const char **string); 54 | 55 | bool utf16_to_char_string(const uint16_t *in, char *s, size_t len); 56 | 57 | char* utf8_to_local_string_alloc(const char *str); 58 | 59 | char* local_to_utf8_string_alloc(const char *str); 60 | 61 | wchar_t* utf8_to_utf16_string_alloc(const char *str); 62 | 63 | char* utf16_to_utf8_string_alloc(const wchar_t *str); 64 | 65 | RETRO_END_DECLS 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /sysmodule/lib/minIni/dev/minGlue-efsl.h: -------------------------------------------------------------------------------- 1 | /* Glue functions for the minIni library, based on the EFS Library, see 2 | * http://www.efsl.be/ 3 | * 4 | * By CompuPhase, 2008-2012 5 | * This "glue file" is in the public domain. It is distributed without 6 | * warranties or conditions of any kind, either express or implied. 7 | * 8 | * (EFSL is copyright 2005-2006 Lennart Ysboodt and Michael De Nil, and 9 | * licensed under the GPL with an exception clause for static linking.) 10 | */ 11 | 12 | #define INI_BUFFERSIZE 256 /* maximum line length, maximum path length */ 13 | #define INI_LINETERM "\r\n" /* set line termination explicitly */ 14 | 15 | #include "efs.h" 16 | extern EmbeddedFileSystem g_efs; 17 | 18 | #define INI_FILETYPE EmbeddedFile 19 | #define ini_openread(filename,file) (file_fopen((file), &g_efs.myFs, (char*)(filename), 'r') == 0) 20 | #define ini_openwrite(filename,file) (file_fopen((file), &g_efs.myFs, (char*)(filename), 'w') == 0) 21 | #define ini_close(file) file_fclose(file) 22 | #define ini_read(buffer,size,file) (file_read((file), (size), (buffer)) > 0) 23 | #define ini_write(buffer,file) (file_write((file), strlen(buffer), (char*)(buffer)) > 0) 24 | #define ini_remove(filename) rmfile(&g_efs.myFs, (char*)(filename)) 25 | 26 | #define INI_FILEPOS euint32 27 | #define ini_tell(file,pos) (*(pos) = (file)->FilePtr)) 28 | #define ini_seek(file,pos) file_setpos((file), (*pos)) 29 | 30 | #if ! defined INI_READONLY 31 | /* EFSL lacks a rename function, so instead we copy the file to the new name 32 | * and delete the old file 33 | */ 34 | static int ini_rename(char *source, const char *dest) 35 | { 36 | EmbeddedFile fr, fw; 37 | int n; 38 | 39 | if (file_fopen(&fr, &g_efs.myFs, source, 'r') != 0) 40 | return 0; 41 | if (rmfile(&g_efs.myFs, (char*)dest) != 0) 42 | return 0; 43 | if (file_fopen(&fw, &g_efs.myFs, (char*)dest, 'w') != 0) 44 | return 0; 45 | 46 | /* With some "insider knowledge", we can save some memory: the "source" 47 | * parameter holds a filename that was built from the "dest" parameter. It 48 | * was built in buffer and this buffer has the size INI_BUFFERSIZE. We can 49 | * reuse this buffer for copying the file. 50 | */ 51 | while (n=file_read(&fr, INI_BUFFERSIZE, source)) 52 | file_write(&fw, n, source); 53 | 54 | file_fclose(&fr); 55 | file_fclose(&fw); 56 | 57 | /* Now we need to delete the source file. However, we have garbled the buffer 58 | * that held the filename of the source. So we need to build it again. 59 | */ 60 | ini_tempname(source, dest, INI_BUFFERSIZE); 61 | return rmfile(&g_efs.myFs, source) == 0; 62 | } 63 | #endif 64 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/extern/libretro-common/features/features_cpu.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2018 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (features_cpu.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef _LIBRETRO_SDK_CPU_INFO_H 24 | #define _LIBRETRO_SDK_CPU_INFO_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | 32 | RETRO_BEGIN_DECLS 33 | 34 | /** 35 | * cpu_features_get_perf_counter: 36 | * 37 | * Gets performance counter. 38 | * 39 | * Returns: performance counter. 40 | **/ 41 | retro_perf_tick_t cpu_features_get_perf_counter(void); 42 | 43 | /** 44 | * cpu_features_get_time_usec: 45 | * 46 | * Gets time in microseconds, from an undefined epoch. 47 | * The epoch may change between computers or across reboots. 48 | * 49 | * Returns: time in microseconds 50 | **/ 51 | retro_time_t cpu_features_get_time_usec(void); 52 | 53 | /** 54 | * cpu_features_get: 55 | * 56 | * Gets CPU features. 57 | * 58 | * Returns: bitmask of all CPU features available. 59 | **/ 60 | uint64_t cpu_features_get(void); 61 | 62 | /** 63 | * cpu_features_get_core_amount: 64 | * 65 | * Gets the amount of available CPU cores. 66 | * 67 | * Returns: amount of CPU cores available. 68 | **/ 69 | unsigned cpu_features_get_core_amount(void); 70 | 71 | void cpu_features_get_model_name(char *name, int len); 72 | 73 | RETRO_END_DECLS 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/sidebar.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace brls 27 | { 28 | 29 | // A sidebar with multiple tabs 30 | class SidebarSeparator : public View 31 | { 32 | public: 33 | SidebarSeparator(); 34 | 35 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 36 | }; 37 | 38 | class Sidebar; 39 | 40 | // TODO: Use a Label view with integrated ticker for label and sublabel 41 | // TODO: Have the label always tick when active 42 | class SidebarItem : public View 43 | { 44 | private: 45 | std::string label; 46 | bool active = false; 47 | 48 | Sidebar* sidebar = nullptr; 49 | View* associatedView = nullptr; 50 | 51 | public: 52 | SidebarItem(std::string label, Sidebar* sidebar); 53 | 54 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 55 | 56 | View* getDefaultFocus() override 57 | { 58 | return this; 59 | } 60 | 61 | virtual bool onClick(); 62 | 63 | void setActive(bool active); 64 | bool isActive(); 65 | 66 | void onFocusGained() override; 67 | 68 | void setAssociatedView(View* view); 69 | View* getAssociatedView(); 70 | 71 | ~SidebarItem(); 72 | }; 73 | 74 | // TODO: Add a style with icons, make it collapsible? 75 | class Sidebar : public BoxLayout 76 | { 77 | private: 78 | SidebarItem* currentActive = nullptr; 79 | 80 | public: 81 | Sidebar(); 82 | 83 | SidebarItem* addItem(std::string label, View* view); 84 | void addSeparator(); 85 | 86 | void setActive(SidebarItem* item); 87 | 88 | View* getDefaultFocus() override; 89 | void onChildFocusGained(View* child) override; 90 | 91 | size_t lastFocus = 0; 92 | }; 93 | 94 | } // namespace brls 95 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/lib/header.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | namespace brls 24 | { 25 | 26 | Header::Header(std::string label, bool separator, std::string sublabel) 27 | : label(label) 28 | , sublabel(sublabel) 29 | , separator(separator) 30 | { 31 | Style* style = Application::getStyle(); 32 | this->setHeight(style->Header.height); 33 | } 34 | 35 | void Header::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) 36 | { 37 | unsigned padding = style->Header.padding; 38 | 39 | // Rectangle 40 | nvgBeginPath(vg); 41 | nvgFillColor(vg, a(ctx->theme->headerRectangleColor)); 42 | nvgRect(vg, x, y + padding, style->Header.rectangleWidth, height - padding * 2); 43 | nvgFill(vg); 44 | 45 | // Label 46 | nvgBeginPath(vg); 47 | nvgFontFaceId(vg, ctx->fontStash->regular); 48 | nvgFontSize(vg, style->Header.fontSize); 49 | nvgFillColor(vg, a(ctx->theme->textColor)); 50 | nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE); 51 | nvgText(vg, x + style->Header.rectangleWidth + padding, y + height / 2, this->label.c_str(), nullptr); 52 | 53 | // Sublabel 54 | if (this->sublabel != "") 55 | { 56 | nvgBeginPath(vg); 57 | nvgFontFaceId(vg, ctx->fontStash->regular); 58 | nvgFontSize(vg, style->Header.fontSize); 59 | nvgFillColor(vg, a(ctx->theme->descriptionColor)); 60 | nvgTextAlign(vg, NVG_ALIGN_RIGHT | NVG_ALIGN_MIDDLE); 61 | nvgText(vg, x + width - style->Header.rectangleWidth - padding, y + height / 2, this->sublabel.c_str(), nullptr); 62 | } 63 | 64 | // Separator 65 | if (this->separator) 66 | { 67 | nvgBeginPath(vg); 68 | nvgFillColor(vg, a(ctx->theme->listItemSeparatorColor)); 69 | nvgRect(vg, x, y + height, width, 1); 70 | nvgFill(vg); 71 | } 72 | } 73 | 74 | } // namespace brls 75 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/dropdown.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019-2020 natinusala 4 | Copyright (C) 2019-2020 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace brls 28 | { 29 | 30 | // Fired when the user has selected a value 31 | // 32 | // Parameter is either the selected value index 33 | // or -1 if the user cancelled 34 | // 35 | // Assume that the Dropdown is deleted 36 | // as soon as this function is called 37 | typedef Event ValueSelectedEvent; 38 | 39 | // Allows the user to select between multiple 40 | // values 41 | // Use Dropdown::open() 42 | class Dropdown : public View 43 | { 44 | private: 45 | Dropdown(std::string title, std::vector values, ValueSelectedEvent::Callback cb, size_t selected = 0); 46 | 47 | std::string title; 48 | 49 | int valuesCount; 50 | 51 | ValueSelectedEvent valueEvent; 52 | 53 | List* list; 54 | Hint* hint; 55 | 56 | float topOffset; // for slide in animation 57 | 58 | protected: 59 | unsigned getShowAnimationDuration(ViewAnimation animation) override; 60 | 61 | public: 62 | ~Dropdown(); 63 | 64 | void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override; 65 | void layout(NVGcontext* vg, Style* style, FontStash* stash) override; 66 | View* getDefaultFocus() override; 67 | virtual bool onCancel(); 68 | void show(std::function cb, bool animate = true, ViewAnimation animation = ViewAnimation::FADE) override; 69 | void willAppear(bool resetState = false) override; 70 | void willDisappear(bool resetState = false) override; 71 | 72 | static void open(std::string title, std::vector values, ValueSelectedEvent::Callback cb, int selected = -1); 73 | 74 | bool isTranslucent() override 75 | { 76 | return true || View::isTranslucent(); 77 | } 78 | }; 79 | 80 | } // namespace brls 81 | -------------------------------------------------------------------------------- /manager/lib/borealis/library/include/borealis/theme.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Borealis, a Nintendo Switch UI Library 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019 p-sam 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | namespace brls 25 | { 26 | 27 | // Theme variants 28 | // (used in Application) 29 | // 30 | // Not an enum class because it's used 31 | // as an array index in Theme 32 | enum ThemeVariant 33 | { 34 | ThemeVariant_LIGHT = 0, 35 | ThemeVariant_DARK, 36 | ThemeVariant_NUMBER_OF_VARIANTS 37 | }; 38 | 39 | typedef struct 40 | { 41 | float backgroundColor[3]; // gl color 42 | NVGcolor backgroundColorRGB; 43 | 44 | NVGcolor textColor; 45 | NVGcolor descriptionColor; 46 | 47 | NVGcolor notificationTextColor; 48 | NVGcolor backdropColor; 49 | 50 | NVGcolor separatorColor; 51 | 52 | NVGcolor sidebarColor; 53 | NVGcolor activeTabColor; 54 | NVGcolor sidebarSeparatorColor; 55 | 56 | NVGcolor highlightBackgroundColor; 57 | NVGcolor highlightColor1; 58 | NVGcolor highlightColor2; 59 | 60 | NVGcolor listItemSeparatorColor; 61 | NVGcolor listItemValueColor; 62 | NVGcolor listItemFaintValueColor; 63 | 64 | NVGcolor tableEvenBackgroundColor; 65 | NVGcolor tableBodyTextColor; 66 | 67 | NVGcolor dropdownBackgroundColor; 68 | 69 | NVGcolor nextStageBulletColor; 70 | 71 | NVGcolor spinnerBarColor; 72 | 73 | NVGcolor headerRectangleColor; 74 | 75 | NVGcolor buttonPlainEnabledBackgroundColor; 76 | NVGcolor buttonPlainDisabledBackgroundColor; 77 | NVGcolor buttonPlainEnabledTextColor; 78 | NVGcolor buttonPlainDisabledTextColor; 79 | 80 | NVGcolor dialogColor; 81 | NVGcolor dialogBackdrop; 82 | NVGcolor dialogButtonColor; 83 | NVGcolor dialogButtonSeparatorColor; 84 | } ThemeValues; 85 | 86 | // A theme contains colors for all variants 87 | class Theme 88 | { 89 | public: 90 | ThemeValues colors[ThemeVariant_NUMBER_OF_VARIANTS]; 91 | 92 | // As close to HOS as possible 93 | static Theme horizon(); 94 | }; 95 | 96 | } // namespace brls 97 | -------------------------------------------------------------------------------- /manager/src/logo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | sys-clk manager, a sys-clk frontend homebrew 3 | Copyright (C) 2019 natinusala 4 | Copyright (C) 2019-2020 p-sam 5 | Copyright (C) 2019 m4xw 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #include "logo.h" 22 | 23 | Logo::Logo(LogoStyle style) { 24 | this->logoLabel = new brls::Label(brls::LabelStyle::LIST_ITEM, "sys-clk", style == LogoStyle::ABOUT); 25 | this->logoLabel->setParent(this); 26 | 27 | int logoFont = brls::Application::findFont(LOGO_FONT_NAME); 28 | if (logoFont >= 0) 29 | { 30 | this->logoLabel->setFont(logoFont); 31 | } 32 | 33 | if (style == LogoStyle::ABOUT) 34 | { 35 | this->logoLabel->setFontSize(LOGO_ABOUT_FONT_SIZE); 36 | this->logoLabel->setHorizontalAlign(NVG_ALIGN_CENTER); 37 | } 38 | 39 | if (style == LogoStyle::HEADER) 40 | { 41 | this->logoLabel->setFontSize(LOGO_HEADER_FONT_SIZE); 42 | this->descLabel = new brls::Label(brls::LabelStyle::LIST_ITEM, "manager"); 43 | this->descLabel->setParent(this); 44 | this->descLabel->setFontSize(LOGO_DESC_FONT_SIZE); 45 | } 46 | 47 | } 48 | 49 | Logo::~Logo() { 50 | delete this->logoLabel; 51 | 52 | if (this->descLabel) 53 | delete this->descLabel; 54 | } 55 | 56 | void Logo::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) 57 | { 58 | this->logoLabel->frame(ctx); 59 | 60 | if (this->descLabel) 61 | this->descLabel->frame(ctx); 62 | } 63 | 64 | void Logo::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) 65 | { 66 | this->logoLabel->setBoundaries(this->x, this->y + LOGO_OFFSET, this->width, this->height); 67 | this->logoLabel->layout(vg, style, stash); 68 | this->height = this->logoLabel->getHeight(); 69 | 70 | if (this->descLabel) 71 | { 72 | this->descLabel->layout(vg, style, stash); 73 | this->descLabel->setBoundaries(this->x + LOGO_HEADER_SPACING + this->logoLabel->getWidth(), this->y + style->AppletFrame.titleOffset - 1, this->descLabel->getWidth(), height); 74 | } 75 | } 76 | --------------------------------------------------------------------------------