Ajust some gfx functions for joycon compatibility
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "../../utils/sprintf.h"
|
||||
#include "../script/parser.h"
|
||||
#include "../emmc/emmcoperations.h"
|
||||
#include "../../hid/hid.h"
|
||||
|
||||
extern char *currentpath;
|
||||
extern char *clipboard;
|
||||
@@ -36,23 +37,25 @@ int delfile(const char *path, const char *filename){
|
||||
|
||||
void viewbytes(char *path){
|
||||
FIL in;
|
||||
u8 print[2048];
|
||||
u8 print[1024];
|
||||
u32 size;
|
||||
QWORD offset = 0;
|
||||
int res;
|
||||
Inputs *input = hidRead();
|
||||
|
||||
while (input->buttons & (KEY_POW | KEY_B));
|
||||
|
||||
gfx_clearscreen();
|
||||
|
||||
if ((res = f_open(&in, path, FA_READ | FA_OPEN_EXISTING))){
|
||||
gfx_errDisplay("viewbytes", res, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
while (btn_read() & BTN_POWER);
|
||||
|
||||
while (1){
|
||||
f_lseek(&in, offset * 16);
|
||||
|
||||
if ((res = f_read(&in, &print, 2048 * sizeof(u8), &size))){
|
||||
if ((res = f_read(&in, &print, 1024 * sizeof(u8), &size))){
|
||||
gfx_errDisplay("viewbytes", res, 2);
|
||||
return;
|
||||
}
|
||||
@@ -60,16 +63,16 @@ void viewbytes(char *path){
|
||||
gfx_con_setpos(0, 31);
|
||||
gfx_hexdump(offset * 16, print, size * sizeof(u8));
|
||||
|
||||
res = btn_read();
|
||||
input = hidRead();
|
||||
|
||||
if (!res)
|
||||
res = btn_wait();
|
||||
if (!(input->buttons))
|
||||
input = hidWait();
|
||||
|
||||
if (res & BTN_VOL_DOWN && 2048 * sizeof(u8) == size)
|
||||
if (input->Ldown && 1024 * sizeof(u8) == size)
|
||||
offset++;
|
||||
if (res & BTN_VOL_UP && offset > 0)
|
||||
if (input->Lup && offset > 0)
|
||||
offset--;
|
||||
if (res & BTN_POWER)
|
||||
if (input->buttons & (KEY_POW | KEY_B))
|
||||
break;
|
||||
}
|
||||
f_close(&in);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "../../utils/util.h"
|
||||
#include "../../mem/heap.h"
|
||||
#include "../common/common.h"
|
||||
#include "../../hid/hid.h"
|
||||
|
||||
int printerrors = true;
|
||||
|
||||
@@ -22,12 +23,12 @@ void gfx_clearscreen(){
|
||||
gfx_boxGrey(0, 703, 1279, 719, 0xFF);
|
||||
gfx_boxGrey(0, 0, 1279, 15, 0xFF);
|
||||
gfx_con_setpos(0, 0);
|
||||
gfx_printf("Tegraexplorer v1.5.2 | Battery: %3d%%", battery >> 8);
|
||||
gfx_printf("Tegraexplorer v1.5.2 | Battery: %3d%%\n", battery >> 8);
|
||||
|
||||
RESETCOLOR;
|
||||
}
|
||||
|
||||
int gfx_message(u32 color, const char* message, ...){
|
||||
u32 gfx_message(u32 color, const char* message, ...){
|
||||
va_list ap;
|
||||
va_start(ap, message);
|
||||
|
||||
@@ -37,10 +38,10 @@ int gfx_message(u32 color, const char* message, ...){
|
||||
gfx_vprintf(message, ap);
|
||||
|
||||
va_end(ap);
|
||||
return btn_wait();
|
||||
return hidWait()->buttons;
|
||||
}
|
||||
|
||||
int gfx_errDisplay(char *src_func, int err, int loc){
|
||||
u32 gfx_errDisplay(char *src_func, int err, int loc){
|
||||
if (!printerrors)
|
||||
return 0;
|
||||
|
||||
@@ -61,27 +62,24 @@ int gfx_errDisplay(char *src_func, int err, int loc){
|
||||
|
||||
RESETCOLOR;
|
||||
|
||||
while (btn_read() != 0);
|
||||
|
||||
return btn_wait();
|
||||
return hidWait()->buttons;
|
||||
}
|
||||
|
||||
int gfx_makewaitmenu(char *hiddenmessage, int timer){
|
||||
int res;
|
||||
u32 start = get_tmr_s();
|
||||
|
||||
while (btn_read() != 0);
|
||||
Inputs *input = NULL;
|
||||
|
||||
while(1){
|
||||
res = btn_read();
|
||||
input = hidRead();
|
||||
|
||||
if (res & BTN_VOL_DOWN || res & BTN_VOL_UP)
|
||||
if (input->buttons & (KEY_VOLM | KEY_VOLP | KEY_B))
|
||||
return 0;
|
||||
|
||||
if (start + timer > get_tmr_s())
|
||||
gfx_printf("\r<Wait %d seconds> ", timer + start - get_tmr_s());
|
||||
|
||||
else if (res & BTN_POWER)
|
||||
else if (input->a)
|
||||
return 1;
|
||||
|
||||
else
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#define RESETCOLOR gfx_printf("%k%K", COLOR_WHITE, COLOR_DEFAULT)
|
||||
|
||||
void gfx_clearscreen();
|
||||
int gfx_message(u32 color, const char* message, ...);
|
||||
int gfx_errDisplay(char *src_func, int err, int loc);
|
||||
u32 gfx_message(u32 color, const char* message, ...);
|
||||
u32 gfx_errDisplay(char *src_func, int err, int loc);
|
||||
int gfx_makewaitmenu(char *hiddenmessage, int timer);
|
||||
void gfx_printlength(int size, char *toprint);
|
||||
void gfx_printandclear(char *in, int length, int endX);
|
||||
|
||||
@@ -153,7 +153,7 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
|
||||
gfx_printf("Type: %s", (entries[currentpos].property & ISDIR) ? "Dir " : "File");
|
||||
}
|
||||
else
|
||||
gfx_boxGrey(800, 223, 1279, 271, 0x1B);
|
||||
gfx_boxGrey(800, 144, 1279, 190, 0x1B);
|
||||
|
||||
gfx_con_setpos(0, 703);
|
||||
SWAPCOLOR(COLOR_DEFAULT);
|
||||
|
||||
@@ -37,8 +37,8 @@ void MainMenu_SDCard(){
|
||||
|
||||
void MainMenu_EMMC(){
|
||||
gfx_clearscreen();
|
||||
gfx_printf("You're about to enter EMMC\nModifying anything here\n can result in a BRICK!\n\nPlease only continue\n if you know what you're doing\n\nPress Vol+/- to return\n");
|
||||
if (gfx_makewaitmenu("Press Power to enter", 4)){
|
||||
gfx_printf("You're about to enter EMMC\nModifying anything here\n can result in a BRICK!\n\nPlease only continue\n if you know what you're doing\n\nPress B to return\n");
|
||||
if (gfx_makewaitmenu("Press A to enter", 4)){
|
||||
/*
|
||||
connect_mmc(SYSMMC);
|
||||
|
||||
@@ -92,8 +92,8 @@ void MainMenu_SDFormat(){
|
||||
|
||||
if (res > 0){
|
||||
gfx_clearscreen();
|
||||
gfx_printf("Are you sure you want to format your sd?\nThis will delete everything on your SD card\nThis action is irreversible!\n\nPress Vol+/- to cancel\n");
|
||||
if(gfx_makewaitmenu("Press Power to continue", 10)){
|
||||
gfx_printf("Are you sure you want to format your sd?\nThis will delete everything on your SD card\nThis action is irreversible!\n\nPress B to cancel\n");
|
||||
if(gfx_makewaitmenu("Press A to continue", 10)){
|
||||
if (format(res)){
|
||||
sd_unmount();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user