1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-11-24 18:42:05 +00:00

Updater JC color swapper to latest libnx

This commit is contained in:
flb 2020-12-28 14:27:24 +01:00
parent 7d1710c68d
commit dd19949328
3 changed files with 24 additions and 21 deletions

View file

@ -45,7 +45,7 @@ DATA := data
INCLUDES := include lib/zipper/include
APP_TITLE := All-in-One Switch Updater
APP_AUTHOR := HamletDuFromage
APP_VERSION := 1.3.1
APP_VERSION := 1.3.2
TARGET := $(notdir $(CURDIR))-v$(APP_VERSION)
ROMFS := resources

View file

@ -1,6 +1,7 @@
#pragma once
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <filesystem>
@ -10,6 +11,7 @@
#include <switch.h>
#include "constants.hpp"
#include "progress_event.hpp"
#include "utils.hpp"
#include "json.hpp"
int hexToBGR(std::string hex);

View file

@ -28,9 +28,9 @@ int setColor(std::vector<int> colors){
Result pads, ljc, rjc;
int res = 0;
s32 nbEntries;
u64 UniquePadIds[2] = {};
HidsysUniquePadId UniquePadIds[2] = {};
pads = hidsysGetUniquePadsFromNpad(CONTROLLER_HANDHELD, UniquePadIds, 2,&nbEntries);
pads = hidsysGetUniquePadsFromNpad(HidNpadIdType_Handheld, UniquePadIds, 2,&nbEntries);
if(R_SUCCEEDED(pads)){
ljc = hiddbgUpdateControllerColor(colors[0], colors[1], UniquePadIds[0]);
if (R_FAILED(ljc)) res +=1;
@ -44,10 +44,11 @@ int setColor(std::vector<int> colors){
}
int backupToJSON(json &profiles, const char* path){
HidControllerColors colors;
hidGetControllerColors(CONTROLLER_P1_AUTO, &colors);
HidNpadControllerColor color_left;
HidNpadControllerColor color_right;
Result res = hidGetNpadControllerColorSplit(HidNpadIdType_Handheld, &color_left, &color_right);
std::vector<int> oldBackups;
if (colors.splitSet) {
if (R_SUCCEEDED(res)) {
int i = 0;
for (const auto& x : profiles.items()){
if(x.value()["name"] == "_backup") {
@ -60,10 +61,10 @@ int backupToJSON(json &profiles, const char* path){
}
json newBackup = json::object({
{"name", "_backup"},
{"L_JC", BGRToHex(colors.leftColorBody)},
{"L_BTN", BGRToHex(colors.leftColorButtons)},
{"R_JC", BGRToHex(colors.rightColorBody)},
{"R_BTN", BGRToHex(colors.rightColorButtons)}
{"L_JC", BGRToHex(color_left.main)},
{"L_BTN", BGRToHex(color_left.sub)},
{"R_JC", BGRToHex(color_right.main)},
{"R_BTN", BGRToHex(color_right.sub)}
});
profiles.push_back(newBackup);
writeJSONToFile(profiles, path);
@ -76,16 +77,16 @@ int backupToJSON(json &profiles, const char* path){
json backupProfile(){
json newBackup;
HidControllerColors colors;
hidGetControllerColors(CONTROLLER_P1_AUTO, &colors);
//if(0){
if (colors.splitSet) {
HidNpadControllerColor color_left;
HidNpadControllerColor color_right;
Result res = hidGetNpadControllerColorSplit(HidNpadIdType_Handheld, &color_left, &color_right);
if (R_SUCCEEDED(res)) {
newBackup = json::object({
{"name", "_backup"},
{"L_JC", BGRToHex(colors.leftColorBody)},
{"L_BTN", BGRToHex(colors.leftColorButtons)},
{"R_JC", BGRToHex(colors.rightColorBody)},
{"R_BTN", BGRToHex(colors.rightColorButtons)}
{"L_JC", BGRToHex(color_left.main)},
{"L_BTN", BGRToHex(color_left.sub)},
{"R_JC", BGRToHex(color_right.main)},
{"R_BTN", BGRToHex(color_right.sub)}
});
}
return newBackup;
@ -153,9 +154,9 @@ void changeJCColor(std::vector<int> values){
hidsysInitialize();
ProgressEvent::instance().reset();
ProgressEvent::instance().setStep(1);
int res = -1;
while(res !=0){
res = setColor(values);
int res = setColor(values);
if(res != 0){
showDialogBox("Could not change the Joy-Cons color. Make sure they're docked and try again.\nError :" + std::to_string(res), "Ok");
}
hiddbgExit();
hidsysExit();