From 7add4b6b13c94a08b26ad58d7dcf8b12c4e7c6e2 Mon Sep 17 00:00:00 2001 From: "Such Meme, Many Skill" Date: Sat, 2 May 2020 20:53:13 +0200 Subject: [PATCH] Misc fixes, mostly related to no-joycon controls --- source/hid/hid.c | 5 +++++ source/hid/hid.h | 3 ++- source/main.c | 2 +- source/tegraexplorer/fs/filemenu.c | 3 ++- source/tegraexplorer/fs/foldermenu.c | 13 ++++++++----- source/tegraexplorer/script/functions.c | 4 ++-- source/tegraexplorer/utils/utils.c | 3 +++ 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/source/hid/hid.c b/source/hid/hid.c index 563db97..19104cf 100644 --- a/source/hid/hid.c +++ b/source/hid/hid.c @@ -98,4 +98,9 @@ Inputs *hidWait(){ while (!(in->buttons)) hidRead(); return in; +} + +bool hidConnected(){ + jc_gamepad_rpt_t *controller = joycon_poll(); + return (controller->conn_l && controller->conn_r) ? 1 : 0; } \ No newline at end of file diff --git a/source/hid/hid.h b/source/hid/hid.h index 179bb1b..8c28315 100644 --- a/source/hid/hid.h +++ b/source/hid/hid.h @@ -51,4 +51,5 @@ typedef struct _inputs { void hidInit(); Inputs *hidRead(); Inputs *hidWait(); -Inputs *hidWaitMask(u32 mask); \ No newline at end of file +Inputs *hidWaitMask(u32 mask); +bool hidConnected(); \ No newline at end of file diff --git a/source/main.c b/source/main.c index 5c353ca..f3a293b 100644 --- a/source/main.c +++ b/source/main.c @@ -451,7 +451,7 @@ static void _show_errors(){ } RESETCOLOR; - gfx_printf("\n\nPress any key to continue..."); + gfx_printf("\n\nPress vol+/- or power to continue"); *excp_enabled = 0; btn_wait(); diff --git a/source/tegraexplorer/fs/filemenu.c b/source/tegraexplorer/fs/filemenu.c index 198b7c9..fa85ef5 100644 --- a/source/tegraexplorer/fs/filemenu.c +++ b/source/tegraexplorer/fs/filemenu.c @@ -147,6 +147,7 @@ int filemenu(menu_entry file){ (attribs.fattrib & AM_ARC) ? 'A' : '-'); } + SETBIT(fs_menu_file[6].property, ISHIDE, !hidConnected()); SETBIT(fs_menu_file[8].property, ISHIDE, !(strstr(file.name, ".bin") != NULL && file.property & ISKB) && strstr(file.name, ".rom") == NULL); SETBIT(fs_menu_file[9].property, ISHIDE, strstr(file.name, ".te") == NULL); SETBIT(fs_menu_file[11].property, ISHIDE, strstr(file.name, ".bis") == NULL); @@ -166,7 +167,7 @@ int filemenu(menu_entry file){ char *name, *curPath; gfx_clearscreen(); gfx_printf("Renaming %s...\n\n", file.name); - name = utils_InputText(file.name, 32); + name = utils_InputText(file.name, 39); if (name == NULL) break; diff --git a/source/tegraexplorer/fs/foldermenu.c b/source/tegraexplorer/fs/foldermenu.c index 45a53c6..a726dd0 100644 --- a/source/tegraexplorer/fs/foldermenu.c +++ b/source/tegraexplorer/fs/foldermenu.c @@ -10,6 +10,7 @@ #include "fsutils.h" #include "../../utils/sprintf.h" #include "../utils/utils.h" +#include "../../hid/hid.h" extern char *currentpath; extern char *clipboard; @@ -39,7 +40,7 @@ void copyfolder(char *in, char *out){ } int foldermenu(){ - int res; + int res, hidConn; char *name; FILINFO attribs; @@ -48,11 +49,13 @@ int foldermenu(){ fs_menu_folder[0].name = malloc(16); - res = strlen(currentpath); + hidConn = hidConnected(); + res = strlen(currentpath); SETBIT(fs_menu_folder[3].property, ISHIDE, (*(currentpath + res - 1) == '/')); SETBIT(fs_menu_folder[4].property, ISHIDE, (*(currentpath + res - 1) == '/')); - SETBIT(fs_menu_folder[5].property, ISHIDE, (*(currentpath + res - 1) == '/')); + SETBIT(fs_menu_folder[5].property, ISHIDE, (*(currentpath + res - 1) == '/') || !hidConn); + SETBIT(fs_menu_folder[6].property, ISHIDE, !hidConn); if (f_stat(currentpath, &attribs)) SETBIT(fs_menu_folder[0].property, ISHIDE, 1); @@ -93,7 +96,7 @@ int foldermenu(){ gfx_clearscreen(); gfx_printf("Renaming %s...\n\n", dirName); - name = utils_InputText(dirName, 32); + name = utils_InputText(dirName, 39); if (name == NULL) break; @@ -115,7 +118,7 @@ int foldermenu(){ case DIR_CREATE:; gfx_clearscreen(); gfx_printf("Give a name for your new folder\n\n"); - name = utils_InputText("New Folder", 32); + name = utils_InputText("New Folder", 39); if (name == NULL) break; diff --git a/source/tegraexplorer/script/functions.c b/source/tegraexplorer/script/functions.c index 6be7308..07b0fd3 100644 --- a/source/tegraexplorer/script/functions.c +++ b/source/tegraexplorer/script/functions.c @@ -459,10 +459,10 @@ int part_setPrintPos(){ if (parseIntInput(argv[1], &right)) return -1; - if (left > 42) + if (left > 78) return -1; - if (right > 78) + if (right > 42) return -1; gfx_con_setpos(left * 16, right * 16); diff --git a/source/tegraexplorer/utils/utils.c b/source/tegraexplorer/utils/utils.c index fc88a73..fc3d95c 100644 --- a/source/tegraexplorer/utils/utils.c +++ b/source/tegraexplorer/utils/utils.c @@ -40,6 +40,9 @@ void utils_takeScreenshot(){ */ char *utils_InputText(char *start, int maxLen){ + if (!hidConnected()) + return NULL; + int offset = -1, currentPos = 0, len; char temp; Inputs *input = hidRead();