diff --git a/source/hid/hid.c b/source/hid/hid.c index d2dd5ab..f995366 100644 --- a/source/hid/hid.c +++ b/source/hid/hid.c @@ -3,6 +3,7 @@ #include "../utils/btn.h" #include "../gfx/gfx.h" #include "../utils/types.h" +#include "../tegraexplorer/utils/utils.h" static Inputs inputs = {0}; u16 LbaseX = 0, LbaseY = 0, RbaseX = 0, RbaseY = 0; @@ -15,6 +16,10 @@ Inputs *hidRead(){ jc_gamepad_rpt_t *controller = joycon_poll(); static bool errPrint = false; + if (controller->cap) + utils_takeScreenshot(); + + u8 btn = btn_read(); inputs.volp = (btn & BTN_VOL_UP) ? 1 : 0; inputs.volm = (btn & BTN_VOL_DOWN) ? 1 : 0; diff --git a/source/tegraexplorer/fs/filemenu.c b/source/tegraexplorer/fs/filemenu.c index bbd3310..6394441 100644 --- a/source/tegraexplorer/fs/filemenu.c +++ b/source/tegraexplorer/fs/filemenu.c @@ -25,7 +25,7 @@ int delfile(const char *path, const char *filename){ gfx_clearscreen(); SWAPCOLOR(COLOR_ORANGE); gfx_printf("Are you sure you want to delete:\n%s\n\nPress B to cancel\n", filename); - if (gfx_makewaitmenu("Press A to delete", 3)){ + if (gfx_makewaitmenu("Press A to delete", 2)){ f_unlink(path); fsreader_readfolder(currentpath); return 0; diff --git a/source/tegraexplorer/fs/foldermenu.c b/source/tegraexplorer/fs/foldermenu.c index a726dd0..8bc4123 100644 --- a/source/tegraexplorer/fs/foldermenu.c +++ b/source/tegraexplorer/fs/foldermenu.c @@ -79,7 +79,7 @@ int foldermenu(){ break; case DIR_DELETEFOLDER: gfx_clearscreen(); - if (gfx_defaultWaitMenu("Do you want to delete this folder?\nThe entire folder, with all subcontents will be deleted!!!", 4)){ + if (gfx_defaultWaitMenu("Do you want to delete this folder?\nThe entire folder, with all subcontents will be deleted!", 2)){ gfx_clearscreen(); gfx_printf("\nDeleting folder, please wait...\n"); diff --git a/source/tegraexplorer/utils/utils.c b/source/tegraexplorer/utils/utils.c index fc3d95c..55a6407 100644 --- a/source/tegraexplorer/utils/utils.c +++ b/source/tegraexplorer/utils/utils.c @@ -6,12 +6,15 @@ #include "../../mem/heap.h" #include "../gfx/gfxutils.h" #include "../../hid/hid.h" -/* #include "../../utils/util.h" #include "../../utils/sprintf.h" #include "../../libs/fatfs/ff.h" #include "../fs/fsutils.h" -*/ +#include "../../mem/minerva.h" +#include "../../storage/nx_sd.h" +#include "../../gfx/di.h" + +extern bool sd_mounted; int utils_mmcMenu(){ if (emu_cfg.enabled) @@ -26,18 +29,66 @@ void utils_copystring(const char *in, char **out){ strcpy(*out, in); } -/* + void utils_takeScreenshot(){ + static u32 timer = 0; + + if (!minerva_cfg || !sd_mounted) + return; + + if (timer + 3 < get_tmr_s()) + timer = get_tmr_s(); + else + return; + char *name, *path; char basepath[] = "sd:/tegraexplorer/screenshots"; - name = malloc(35); - sprintf(name, "Screenshot_%d", get_tmr_s()); + name = malloc(40); + sprintf(name, "Screenshot_%08X.bmp", get_tmr_us()); f_mkdir("sd:/tegraexplorer"); f_mkdir(basepath); path = fsutil_getnextloc(basepath, name); + free(name); + + const u32 file_size = 0x384000 + 0x36; + u8 *bitmap = malloc(file_size); + u32 *fb = malloc(0x384000); + u32 *fb_ptr = gfx_ctxt.fb; + + for (int x = 1279; x >= 0; x--) + { + for (int y = 719; y >= 0; y--) + fb[y * 1280 + x] = *fb_ptr++; + } + + memcpy(bitmap + 0x36, fb, 0x384000); + bmp_t *bmp = (bmp_t *)bitmap; + + bmp->magic = 0x4D42; + bmp->size = file_size; + bmp->rsvd = 0; + bmp->data_off = 0x36; + bmp->hdr_size = 40; + bmp->width = 1280; + bmp->height = 720; + bmp->planes = 1; + bmp->pxl_bits = 32; + bmp->comp = 0; + bmp->img_size = 0x384000; + bmp->res_h = 2834; + bmp->res_v = 2834; + bmp->rsvd2 = 0; + + sd_save_to_file(bitmap, file_size, path); + free(bitmap); + free(fb); + + display_backlight_brightness(255, 1000); + msleep(100); + display_backlight_brightness(100, 1000); } -*/ + char *utils_InputText(char *start, int maxLen){ if (!hidConnected()) diff --git a/source/tegraexplorer/utils/utils.h b/source/tegraexplorer/utils/utils.h index c080f3b..ff74177 100644 --- a/source/tegraexplorer/utils/utils.h +++ b/source/tegraexplorer/utils/utils.h @@ -1,5 +1,26 @@ #pragma once +#include "../../utils/types.h" + +typedef struct _bmp_t +{ + u16 magic; + u32 size; + u32 rsvd; + u32 data_off; + u32 hdr_size; + u32 width; + u32 height; + u16 planes; + u16 pxl_bits; + u32 comp; + u32 img_size; + u32 res_h; + u32 res_v; + u64 rsvd2; +} __attribute__((packed)) bmp_t; + int utils_mmcMenu(); void utils_copystring(const char *in, char **out); -char *utils_InputText(char *start, int maxLen); \ No newline at end of file +char *utils_InputText(char *start, int maxLen); +void utils_takeScreenshot(); \ No newline at end of file