mirror of
https://github.com/Team-Neptune/DeepSea-Toolbox.git
synced 2024-11-23 04:19:42 +00:00
Adapt to Atmosphere 0.10.0 and libnx 3.0.0 (#19)
* Adapt to libnx-master and atmosphere 0.10.0 ayaya * Fix path for atmosphere config * add findOrCreate functions to simpleIniParser * Create atmosphere ini file and fill it as necessary * Accept inputs from any controller * Sort source files into folders * Update source/Utils/threads.cpp * Create flags folder for each sysmodule Co-Authored-By: WerWolv <werwolv98@gmail.com> * Rename folders to snake_case * Messed up the folders somehow * Remove /ini folder and use SimpleIniParser submodule instead * Build custom libs dependencies * Change SimpleIniParser path * Change SimpleIniParser URL Co-authored-by: WerWolv <werwolv98@gmail.com>
This commit is contained in:
parent
80e60c0c06
commit
f3741ff8bd
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "SimpleIniParser"]
|
||||
path = SimpleIniParser
|
||||
url = https://github.com/AtlasNX/SimpleIniParser
|
23
Makefile
23
Makefile
@ -38,14 +38,15 @@ APP_TITLE := Kosmos Toolbox
|
||||
APP_AUTHOR := WerWolv
|
||||
APP_VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}
|
||||
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
OUTDIR := out
|
||||
TARGET := KosmosToolbox
|
||||
OUTDIR := out
|
||||
BUILD := build
|
||||
SOURCES := source source/ini
|
||||
SOURCES := source source/gui source/utils
|
||||
DATA := data
|
||||
INCLUDES := include include/ini
|
||||
INCLUDES := include include/gui include/utils
|
||||
EXEFS_SRC := exefs_src
|
||||
#ROMFS := romfs
|
||||
CUSTOM_LIBS := SimpleIniParser
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
@ -62,13 +63,15 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fexceptions -std=gnu++17
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lnx `freetype-config --libs`
|
||||
LIBS := -lnx `freetype-config --libs` \
|
||||
$(foreach lib,$(CUSTOM_LIBS),-l$(lib))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(PORTLIBS) $(LIBNX)
|
||||
LIBDIRS := $(PORTLIBS) $(LIBNX) \
|
||||
$(foreach dir,$(CUSTOM_LIBS),$(TOPDIR)/$(dir))
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
@ -147,12 +150,15 @@ ifneq ($(ROMFS),)
|
||||
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
.PHONY: $(CUSTOM_LIBS) $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
$(CUSTOM_LIBS):
|
||||
@$(MAKE) -C $@
|
||||
|
||||
$(BUILD): $(CUSTOM_LIBS)
|
||||
@[ -d $@ ] || mkdir -p $@ $(BUILD) $(OUTDIR)
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
@ -160,6 +166,7 @@ $(BUILD):
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTDIR) $(TARGET).pfs0 $(TARGET).nso $(TARGET).nro $(TARGET).nacp $(TARGET).elf
|
||||
@for lib in $(CUSTOM_LIBS); do $(MAKE) -C $$lib clean; done
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
1
SimpleIniParser
Submodule
1
SimpleIniParser
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 6d02959136931fc1bdb1f3a8dcc864dcbd1e019e
|
@ -80,7 +80,7 @@ private:
|
||||
FT_Library m_fontLibrary;
|
||||
FT_Face m_fontFaces[FONT_FACES_MAX];
|
||||
FT_Face m_fontLastUsedFace;
|
||||
size_t m_fontFacesTotal;
|
||||
s32 m_fontFacesTotal;
|
||||
|
||||
std::unordered_map<size_t, std::pair<u16, u16>> m_stringDimensions;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "utils.hpp"
|
||||
#include "ini/simple_ini_parser.hpp"
|
||||
#include "SimpleIniParser.hpp"
|
||||
|
||||
|
||||
class GuiHIDMitm : public Gui {
|
@ -1,36 +0,0 @@
|
||||
// SimpleIniParser
|
||||
// Copyright (C) 2019 Steven Mattera
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "ini_section.hpp"
|
||||
|
||||
namespace simpleIniParser {
|
||||
class Ini {
|
||||
public:
|
||||
std::vector<IniSection *> sections;
|
||||
|
||||
~Ini();
|
||||
std::string build();
|
||||
IniSection * findSection(std::string name);
|
||||
bool writeToFile(std::string path);
|
||||
static Ini * parseFile(std::string path);
|
||||
};
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
// SimpleIniParser
|
||||
// Copyright (C) 2019 Steven Mattera
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace simpleIniParser {
|
||||
class IniOption {
|
||||
public:
|
||||
std::string key;
|
||||
std::string value;
|
||||
|
||||
IniOption(std::string name, std::string val);
|
||||
std::string build();
|
||||
static IniOption * parse(std::string line);
|
||||
};
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
// SimpleIniParser
|
||||
// Copyright (C) 2019 Steven Mattera
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ini_option.hpp"
|
||||
|
||||
namespace simpleIniParser {
|
||||
typedef enum {
|
||||
SECTION,
|
||||
SEMICOLON_COMMENT,
|
||||
HASHTAG_COMMENT,
|
||||
HEKATE_CAPTION,
|
||||
BLANK_LINE
|
||||
} IniSectionType;
|
||||
|
||||
class IniSection {
|
||||
public:
|
||||
IniSectionType type;
|
||||
std::string value;
|
||||
std::vector<IniOption *> options;
|
||||
|
||||
IniSection(IniSectionType type, std::string value);
|
||||
~IniSection();
|
||||
IniOption * findFirstOption(std::string key);
|
||||
std::string build();
|
||||
static IniSection * parse(std::string line);
|
||||
};
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
//
|
||||
// SimpleIniParser
|
||||
// Copyright (C) 2019 Steven Mattera
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
|
||||
#include "simpleIniParser/ini.hpp"
|
||||
#include "simpleIniParser/ini_section.hpp"
|
||||
#include "simpleIniParser/ini_section.hpp"
|
@ -1,43 +0,0 @@
|
||||
// Source: https://stackoverflow.com/questions/216823
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <locale>
|
||||
|
||||
// trim from start (in place)
|
||||
static inline void ltrim(std::string &s) {
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {
|
||||
return !std::isspace(ch);
|
||||
}));
|
||||
}
|
||||
|
||||
// trim from end (in place)
|
||||
static inline void rtrim(std::string &s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {
|
||||
return !std::isspace(ch);
|
||||
}).base(), s.end());
|
||||
}
|
||||
|
||||
// trim from both ends (in place)
|
||||
static inline void trim(std::string &s) {
|
||||
ltrim(s);
|
||||
rtrim(s);
|
||||
}
|
||||
|
||||
// trim from start (copying)
|
||||
static inline std::string ltrim_copy(std::string s) {
|
||||
ltrim(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
// trim from end (copying)
|
||||
static inline std::string rtrim_copy(std::string s) {
|
||||
rtrim(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
// trim from both ends (copying)
|
||||
static inline std::string trim_copy(std::string s) {
|
||||
trim(s);
|
||||
return s;
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define LOADER_INI "sdmc:/atmosphere/loader.ini"
|
||||
#define LOADER_INI "sdmc:/atmosphere/config/override_config.ini"
|
||||
#define HEKATE_INI "sdmc:/bootloader/hekate_ipl.ini"
|
||||
#define INI_PATH "sdmc:/bootloader/ini/"
|
||||
#define HID_MITM_INI "sdmc:/config/hid_mitm/config.ini"
|
@ -5,7 +5,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
Button::Button(u16 x, u16 y, u16 w, u16 h, std::function<void(Gui*, u16, u16, bool*)> drawAction, std::function<void(u32, bool*)> inputAction, std::vector<s32> adjacentButton, bool activatable, std::function<bool()> usableCondition)
|
||||
: m_x(x), m_y(y), m_w(w), m_h(h), m_drawAction(drawAction), m_inputAction(inputAction), m_usableCondition(usableCondition) , m_adjacentButton(adjacentButton), m_activatable(activatable){
|
||||
: m_x(x), m_y(y), m_w(w), m_h(h), m_drawAction(drawAction), m_inputAction(inputAction), m_usableCondition(usableCondition), m_activatable(activatable), m_adjacentButton(adjacentButton){
|
||||
Button::g_buttons.push_back(this);
|
||||
|
||||
m_isActivated = false;
|
@ -88,7 +88,7 @@ bool Gui::fontInit() {
|
||||
|
||||
if (R_FAILED(plGetSharedFont(0, fonts, FONT_FACES_MAX, &m_fontFacesTotal))) return false;
|
||||
|
||||
for (u32 i = 0; i < m_fontFacesTotal; i++) {
|
||||
for (s32 i = 0; i < m_fontFacesTotal; i++) {
|
||||
ret = FT_New_Memory_Face(m_fontLibrary, (FT_Byte*)fonts[i].address, fonts[i].size, 0, &m_fontFaces[i]);
|
||||
|
||||
m_fontFacesRet[i] = ret;
|
||||
@ -99,7 +99,7 @@ bool Gui::fontInit() {
|
||||
}
|
||||
|
||||
void Gui::fontExit() {
|
||||
for (u32 i = 0; i < m_fontFacesTotal; i++)
|
||||
for (s32 i = 0; i < m_fontFacesTotal; i++)
|
||||
if (m_fontFacesRet[i] == 0) FT_Done_Face(m_fontFaces[i]);
|
||||
|
||||
if (m_fontLibret == 0) FT_Done_FreeType(m_fontLibrary);
|
||||
@ -118,7 +118,7 @@ bool Gui::setFontType(u32 font) {
|
||||
default: return false;
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < m_fontFacesTotal; i++) {
|
||||
for (s32 i = 0; i < m_fontFacesTotal; i++) {
|
||||
ret = FT_Set_Char_Size(m_fontFaces[i], 0, scale * 64, 300, 300);
|
||||
|
||||
if (ret) return false;
|
||||
@ -136,7 +136,7 @@ inline bool Gui::fontLoadGlyph(glyph_t* glyph, u32 font, u32 codepoint) {
|
||||
|
||||
if (m_fontFacesTotal == 0) return false;
|
||||
|
||||
for (u32 i = 0; i < m_fontFacesTotal; i++) {
|
||||
for (s32 i = 0; i < m_fontFacesTotal; i++) {
|
||||
face = m_fontFaces[i];
|
||||
m_fontLastUsedFace = face;
|
||||
glyphIndex = FT_Get_Char_Index(face, codepoint);
|
@ -6,7 +6,7 @@
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <utility>
|
||||
#include "ini/simple_ini_parser.hpp"
|
||||
#include "SimpleIniParser.hpp"
|
||||
|
||||
#include "list_selector.hpp"
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "utils.hpp"
|
||||
#include "ini/simple_ini_parser.hpp"
|
||||
#include "SimpleIniParser.hpp"
|
||||
|
||||
#include "list_selector.hpp"
|
||||
|
||||
@ -19,8 +19,12 @@ static std::vector<std::string> autobootNames;
|
||||
static u16 currAutoBootEntryIndex;
|
||||
|
||||
GuiMain::GuiMain() : Gui() {
|
||||
simpleIniParser::Ini *ini = simpleIniParser::Ini::parseFile(LOADER_INI);
|
||||
keyCharsToKey(ini->findSection("hbl_config")->findFirstOption("override_key")->value, &m_overrideKeyCombo, &m_overrideByDefault);
|
||||
{
|
||||
// Get the override keys, if any exist
|
||||
simpleIniParser::Ini *ini = simpleIniParser::Ini::parseOrCreateFile(LOADER_INI);
|
||||
keyCharsToKey(ini->findOrCreateSection("hbl_config", true, simpleIniParser::IniSectionType::Section)->findOrCreateFirstOption("override_key", "!R")->value, &m_overrideKeyCombo, &m_overrideByDefault);
|
||||
delete ini;
|
||||
}
|
||||
|
||||
m_autoBootConfigs.push_back({ "Disable autoboot", 0, false });
|
||||
m_currAutoBootConfig = getBootConfigs(m_autoBootConfigs, currAutoBootEntryIndex);
|
||||
@ -34,9 +38,10 @@ GuiMain::GuiMain() : Gui() {
|
||||
if(*isActivated) {
|
||||
if(!(kdown & (kdown - 1)) && (kdown <= KEY_DDOWN || kdown >= KEY_SL) && kdown != KEY_TOUCH) {
|
||||
m_overrideKeyCombo = kdown;
|
||||
simpleIniParser::Ini *ini = simpleIniParser::Ini::parseFile(LOADER_INI);
|
||||
auto ini_override_key = ini->findSection("hbl_config")->findFirstOption("override_key");
|
||||
ini_override_key->value = GuiMain::keyToKeyChars(m_overrideKeyCombo, m_overrideByDefault);
|
||||
//Find or create a loader ini file with set override_key values, and write the result to the file.
|
||||
simpleIniParser::Ini *ini = simpleIniParser::Ini::parseOrCreateFile(LOADER_INI);
|
||||
auto keyValue = GuiMain::keyToKeyChars(m_overrideKeyCombo, m_overrideByDefault);
|
||||
ini->findOrCreateSection("hbl_config", true, simpleIniParser::IniSectionType::Section)->findOrCreateFirstOption("override_key", "")->value = keyValue;
|
||||
|
||||
ini->writeToFile(LOADER_INI);
|
||||
*isActivated = false;
|
||||
@ -54,9 +59,10 @@ GuiMain::GuiMain() : Gui() {
|
||||
}, [&](u32 kdown, bool *isActivated){
|
||||
if (kdown & KEY_A) {
|
||||
m_overrideByDefault = !m_overrideByDefault;
|
||||
simpleIniParser::Ini *ini = simpleIniParser::Ini::parseFile(LOADER_INI);
|
||||
auto ini_override_key = ini->findSection("hbl_config")->findFirstOption("override_key");
|
||||
ini_override_key->value = GuiMain::keyToKeyChars(m_overrideKeyCombo, m_overrideByDefault);
|
||||
//Find or create a loader ini file with set override_key values, and write the result to the file.
|
||||
simpleIniParser::Ini *ini = simpleIniParser::Ini::parseOrCreateFile(LOADER_INI);
|
||||
auto keyValue = GuiMain::keyToKeyChars(m_overrideKeyCombo, m_overrideByDefault);
|
||||
ini->findOrCreateSection("hbl_config", true, simpleIniParser::IniSectionType::Section)->findOrCreateFirstOption("override_key", "")->value = keyValue;
|
||||
|
||||
ini->writeToFile(LOADER_INI);
|
||||
delete ini;
|
@ -48,14 +48,14 @@ GuiSysmodule::GuiSysmodule() : Gui() {
|
||||
for (auto sysmodule : configJson["sysmodules"]) {
|
||||
try {
|
||||
std::stringstream path;
|
||||
path << "/atmosphere/titles/" << sysmodule["tid"].get<std::string>() << "/exefs.nsp";
|
||||
path << "/atmosphere/contents/" << sysmodule["tid"].get<std::string>() << "/exefs.nsp";
|
||||
|
||||
if (access(path.str().c_str(), F_OK) == -1) continue;
|
||||
|
||||
this->m_sysmodules.insert(std::make_pair(sysmodule["tid"].get<std::string>(), (sysModule_t){ sysmodule["name"].get<std::string>(), sysmodule["tid"].get<std::string>(), sysmodule["requires_reboot"].get<bool>() }));
|
||||
|
||||
u64 sysmodulePid = 0;
|
||||
pmdmntGetTitlePid(&sysmodulePid, std::stoul(sysmodule["tid"].get<std::string>(), nullptr, 16));
|
||||
pmdmntGetProcessId(&sysmodulePid, std::stoul(sysmodule["tid"].get<std::string>(), nullptr, 16));
|
||||
|
||||
if (sysmodulePid > 0)
|
||||
this->m_runningSysmodules.insert(sysmodule["tid"].get<std::string>());
|
||||
@ -70,7 +70,7 @@ GuiSysmodule::GuiSysmodule() : Gui() {
|
||||
s32 sysmoduleCnt = this->m_sysmodules.size();
|
||||
|
||||
for (auto &sysmodule : this->m_sysmodules) {
|
||||
FILE *exefs = fopen(std::string("/atmosphere/titles/" + sysmodule.second.titleID + "/exefs.nsp").c_str(), "r");
|
||||
FILE *exefs = fopen(std::string("/atmosphere/contents/" + sysmodule.second.titleID + "/exefs.nsp").c_str(), "r");
|
||||
|
||||
if (exefs == nullptr)
|
||||
continue;
|
||||
@ -112,14 +112,14 @@ GuiSysmodule::GuiSysmodule() : Gui() {
|
||||
if (kdown & KEY_A) {
|
||||
u64 pid;
|
||||
u64 tid = std::stol(sysmodule.first.c_str(), nullptr, 16);
|
||||
|
||||
mkdir(std::string("/atmosphere/contents/" + sysmodule.second.titleID + "/flags").c_str(), 777);
|
||||
std::stringstream path;
|
||||
path << "/atmosphere/titles/" << sysmodule.first << "/flags/boot2.flag";
|
||||
path << "/atmosphere/contents/" << sysmodule.first << "/flags/boot2.flag";
|
||||
|
||||
|
||||
if (this->m_runningSysmodules.find(sysmodule.first) != this->m_runningSysmodules.end()) {
|
||||
if (!sysmodule.second.requiresReboot) {
|
||||
pmshellTerminateProcessByTitleId(tid);
|
||||
pmshellTerminateProgram(tid);
|
||||
} else {
|
||||
(new MessageBox("This sysmodule requires a reboot to fully work. \n Please restart your console in order use it.", MessageBox::OKAY))->show();
|
||||
}
|
||||
@ -132,7 +132,11 @@ GuiSysmodule::GuiSysmodule() : Gui() {
|
||||
FILE *fptr = fopen(path.str().c_str(), "wb+");
|
||||
if (fptr != nullptr) fclose(fptr);
|
||||
} else {
|
||||
if (R_SUCCEEDED(pmshellLaunchProcess(0, tid, FsStorageId_None, &pid))) {
|
||||
NcmProgramLocation programLocation{
|
||||
.program_id = tid,
|
||||
.storageID = NcmStorageId_None,
|
||||
};
|
||||
if (R_SUCCEEDED(pmshellLaunchProgram(0, &programLocation, &pid))) {
|
||||
FILE *fptr = fopen(path.str().c_str(), "wb+");
|
||||
if (fptr != nullptr) fclose(fptr);
|
||||
}
|
||||
@ -140,7 +144,7 @@ GuiSysmodule::GuiSysmodule() : Gui() {
|
||||
}
|
||||
|
||||
pid = 0;
|
||||
pmdmntGetTitlePid(&pid, tid);
|
||||
pmdmntGetProcessId(&pid, tid);
|
||||
|
||||
if (!sysmodule.second.requiresReboot) {
|
||||
if (pid != 0)
|
@ -8,36 +8,7 @@ static bool hidExtraPaused = false;
|
||||
|
||||
Result hidExtraReloadConfig()
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct
|
||||
{
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} * raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 65000;
|
||||
|
||||
Result rc = serviceIpcDispatch(&hid_service);
|
||||
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct
|
||||
{
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
||||
Result rc = serviceDispatch(&hid_service, 65000);
|
||||
hidExtraPaused = false;
|
||||
svcSleepThread(1e9L/50); // Need to wait for hid to be polled again
|
||||
|
||||
@ -51,36 +22,7 @@ Result hidExtraPause()
|
||||
if(hidExtraPaused)
|
||||
return 0;
|
||||
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct
|
||||
{
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} * raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 65001;
|
||||
|
||||
Result rc = serviceIpcDispatch(&hid_service);
|
||||
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct
|
||||
{
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
||||
Result rc = serviceDispatch(&hid_service, 65001);
|
||||
svcSleepThread(1e9L/50); // Need to wait for hid to be polled again
|
||||
|
||||
hidExtraPaused = true;
|
||||
|
@ -1,96 +0,0 @@
|
||||
// SimpleIniParser
|
||||
// Copyright (C) 2019 Steven Mattera
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "ini/simpleIniParser/ini.hpp"
|
||||
#include "ini/simpleIniParser/ini_option.hpp"
|
||||
#include "trim.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace simpleIniParser {
|
||||
Ini::~Ini() {
|
||||
for (IniSection * section : sections) {
|
||||
if (section != nullptr) {
|
||||
delete section;
|
||||
section = nullptr;
|
||||
}
|
||||
}
|
||||
sections.clear();
|
||||
}
|
||||
|
||||
string Ini::build() {
|
||||
string result;
|
||||
|
||||
for (IniSection * section : sections) {
|
||||
result += section->build() + "\n";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
IniSection * Ini::findSection(string name) {
|
||||
auto it = find_if(sections.begin(), sections.end(), [&name](const IniSection * obj) { return obj->value == name; });
|
||||
if (it == sections.end())
|
||||
return nullptr;
|
||||
|
||||
return (*it);
|
||||
}
|
||||
|
||||
bool Ini::writeToFile(string path) {
|
||||
ofstream file(path);
|
||||
if (!file.is_open())
|
||||
return false;
|
||||
|
||||
file << build();
|
||||
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Ini * Ini::parseFile(string path) {
|
||||
ifstream file(path);
|
||||
if (!file.is_open())
|
||||
return nullptr;
|
||||
|
||||
Ini * ini = new Ini();
|
||||
string line;
|
||||
while (getline(file, line)) {
|
||||
trim(line);
|
||||
|
||||
if (line.size() == 0)
|
||||
continue;
|
||||
|
||||
IniSection * section = IniSection::parse(line);
|
||||
if (section != nullptr) {
|
||||
ini->sections.push_back(section);
|
||||
}
|
||||
else if (ini->sections.size() != 0 && ini->sections.back()->type == SECTION) {
|
||||
IniOption * option = IniOption::parse(line);
|
||||
|
||||
if (option != nullptr)
|
||||
ini->sections.back()->options.push_back(option);
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
return ini;
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
// SimpleIniParser
|
||||
// Copyright (C) 2019 Steven Mattera
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#include "ini/simpleIniParser/ini_option.hpp"
|
||||
#include "trim.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace simpleIniParser {
|
||||
IniOption::IniOption(string name, string val) {
|
||||
key = name;
|
||||
value = val;
|
||||
}
|
||||
|
||||
string IniOption::build() {
|
||||
return key + '=' + value;
|
||||
}
|
||||
|
||||
IniOption * IniOption::parse(string line) {
|
||||
size_t pos = line.find('=');
|
||||
if (pos != string::npos && pos > 0) {
|
||||
return new IniOption(rtrim_copy(line.substr(0, pos)), ltrim_copy(line.substr(pos + 1)));
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
// SimpleIniParser
|
||||
// Copyright (C) 2019 Steven Mattera
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#include "ini/simpleIniParser/ini_section.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace simpleIniParser {
|
||||
IniSection::IniSection(IniSectionType t, string v) {
|
||||
type = t;
|
||||
value = v;
|
||||
}
|
||||
|
||||
IniSection::~IniSection() {
|
||||
for (IniOption * option : options) {
|
||||
if (option != nullptr) {
|
||||
delete option;
|
||||
option = nullptr;
|
||||
}
|
||||
}
|
||||
options.clear();
|
||||
}
|
||||
|
||||
IniOption * IniSection::findFirstOption(string key) {
|
||||
auto it = find_if(options.begin(), options.end(), [&key](const IniOption * obj) { return obj->key == key; });
|
||||
if (it == options.end())
|
||||
return nullptr;
|
||||
|
||||
return (*it);
|
||||
}
|
||||
|
||||
string IniSection::build() {
|
||||
if (type == HEKATE_CAPTION)
|
||||
return "{" + value + "}\n";
|
||||
|
||||
if (type == SEMICOLON_COMMENT)
|
||||
return ";" + value + "\n";
|
||||
|
||||
if (type == HASHTAG_COMMENT)
|
||||
return "#" + value + "\n";
|
||||
|
||||
if (type == BLANK_LINE)
|
||||
return "\n";
|
||||
|
||||
string result = "[" + value + "]\n";
|
||||
|
||||
for (IniOption * option : options) {
|
||||
result += option->build() + "\n";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
IniSection * IniSection::parse(string line) {
|
||||
if (line.at(0) == '{' && line.at(line.size() - 1) == '}') {
|
||||
return new IniSection(HEKATE_CAPTION, line.substr(1, line.size() - 2));
|
||||
} else if (line.at(0) == ';') {
|
||||
return new IniSection(SEMICOLON_COMMENT, line.substr(1, line.size() - 1));
|
||||
} else if (line.at(0) == '#') {
|
||||
return new IniSection(HASHTAG_COMMENT, line.substr(1, line.size() - 1));
|
||||
} else if (line.at(0) == '[' && line.at(line.size() - 1) == ']') {
|
||||
return new IniSection(SECTION, line.substr(1, line.size() - 2));
|
||||
} else if (line.size() == 0) {
|
||||
return new IniSection(BLANK_LINE, "");
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
@ -69,7 +69,10 @@ int main(int argc, char **argv){
|
||||
|
||||
while(appletMainLoop()) {
|
||||
hidScanInput();
|
||||
kdown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
kdown = 0;
|
||||
for (u8 controller = 0; controller < 10; controller++) {
|
||||
kdown |= hidKeysDown(static_cast<HidControllerID>(controller));
|
||||
}
|
||||
|
||||
if (Gui::g_nextGui != GUI_INVALID) {
|
||||
mutexLock(&mutexCurrGui);
|
||||
|
@ -11,42 +11,21 @@ void pmdmntExit_mod() {
|
||||
}
|
||||
|
||||
Result pmdmntGetCurrentLimitInfo(u64 *cur_val, u64 *lim_val, u32 category, u32 resource) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u32 category;
|
||||
u32 resource;
|
||||
} *raw;
|
||||
} in = {category, resource};
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 65001;
|
||||
raw->category = category;
|
||||
raw->resource = resource;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_pmdmntSrv);
|
||||
struct {
|
||||
u64 cur_val;
|
||||
u64 lim_val;
|
||||
} out;
|
||||
|
||||
Result rc = serviceDispatchInOut(&g_pmdmntSrv, 65001, in, out);
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u64 cur_val;
|
||||
u64 lim_val;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
*cur_val = resp->cur_val;
|
||||
*lim_val = resp->lim_val;
|
||||
}
|
||||
*cur_val = out.cur_val;
|
||||
*lim_val = out.lim_val;
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
@ -8,7 +8,7 @@ Result Threads::create(ThreadFunc func) {
|
||||
Thread thread;
|
||||
|
||||
Result res;
|
||||
if (R_FAILED( res = threadCreate(&thread, func, nullptr, 0x2000, 0x2B, -2)))
|
||||
if (R_FAILED( res = threadCreate(&thread, func, nullptr, nullptr, 0x2000, 0x2B, -2)))
|
||||
return res;
|
||||
|
||||
if (R_FAILED( res = threadStart(&thread)))
|
@ -1,5 +1,5 @@
|
||||
#include "utils.hpp"
|
||||
#include "ini/simple_ini_parser.hpp"
|
||||
#include "SimpleIniParser.hpp"
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <algorithm>
|
||||
@ -18,7 +18,7 @@ BootEntry getBootConfigs(std::vector<BootEntry> &out_bootEntries, u16 &currAutoB
|
||||
currEntry = out_bootEntries.back();
|
||||
|
||||
for (auto const& it : hekateIni->sections) {
|
||||
if(std::string(it->value) == "config" || it->type != simpleIniParser::SECTION) continue;
|
||||
if(std::string(it->value) == "config" || it->type != simpleIniParser::IniSectionType::Section) continue;
|
||||
out_bootEntries.push_back({ it->value, ++id, false });
|
||||
|
||||
if(!currAutoboot_list && id == currAutoboot) {
|
||||
@ -49,7 +49,7 @@ BootEntry getBootConfigs(std::vector<BootEntry> &out_bootEntries, u16 &currAutoB
|
||||
hekateIni = simpleIniParser::Ini::parseFile(file);
|
||||
|
||||
for (auto const& it : hekateIni->sections) {
|
||||
if (it->type != simpleIniParser::SECTION) continue;
|
||||
if (it->type != simpleIniParser::IniSectionType::Section) continue;
|
||||
out_bootEntries.push_back({ it->value, ++id, true });
|
||||
|
||||
if(currAutoboot_list && id == currAutoboot) {
|
Loading…
Reference in New Issue
Block a user