mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 19:31:12 +00:00
Added safeui option to Nyx and ofw as launch option to be selected en launch menu and konami code
This commit is contained in:
parent
3250b2e32a
commit
63d9f35a78
8 changed files with 158 additions and 3 deletions
|
@ -28,6 +28,32 @@
|
|||
|
||||
#define JC_BTNS_ALL (JC_BTNS_PREV_NEXT | JC_BTNS_ENTER | JC_BTNS_DIRECTION_PAD | JC_BTNS_ESC)
|
||||
|
||||
// Joy-Con buttons mask
|
||||
#define JC_BTNS_Y 0x000001
|
||||
#define JC_BTNS_X 0x000002
|
||||
#define JC_BTNS_B 0x000004
|
||||
#define JC_BTNS_A 0x000008
|
||||
#define JC_BTNS_SR_R 0x000010
|
||||
#define JC_BTNS_SL_R 0x000020
|
||||
#define JC_BTNS_R 0x000040
|
||||
#define JC_BTNS_ZR 0x000080
|
||||
#define JC_BTNS_MINUS 0x000100
|
||||
#define JC_BTNS_PLUS 0x000200
|
||||
#define JC_BTNS_R3 0x000400
|
||||
#define JC_BTNS_L3 0x000800
|
||||
#define JC_BTNS_HOME 0x001000
|
||||
#define JC_BTNS_CAPTURE 0x002000
|
||||
#define JC_BTNS_PAD 0x004000
|
||||
#define JC_BTNS_WIRED 0x008000
|
||||
#define JC_BTNS_DOWN 0x010000
|
||||
#define JC_BTNS_UP 0x020000
|
||||
#define JC_BTNS_RIGHT 0x040000
|
||||
#define JC_BTNS_LEFT 0x080000
|
||||
#define JC_BTNS_SR_L 0x100000
|
||||
#define JC_BTNS_SL_L 0x200000
|
||||
#define JC_BTNS_L 0x400000
|
||||
#define JC_BTNS_ZL 0x800000
|
||||
|
||||
typedef struct _jc_bt_conn_t
|
||||
{
|
||||
u8 type;
|
||||
|
|
|
@ -27,6 +27,7 @@ OBJS = $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
|||
start.o exception_handlers.o \
|
||||
nyx.o heap.o \
|
||||
gfx.o \
|
||||
konami.o \
|
||||
gui.o gui_info.o gui_tools.o gui_options.o gui_emmc_tools.o gui_emummc_tools.o gui_tools_partition_manager.o \
|
||||
fe_emummc_tools.o fe_emmc_tools.o \
|
||||
)
|
||||
|
|
|
@ -60,6 +60,7 @@ void set_nyx_default_configuration()
|
|||
n_cfg.jc_disable = 0;
|
||||
n_cfg.jc_force_right = 0;
|
||||
n_cfg.bpmp_clock = 0;
|
||||
n_cfg.safeui = 0;
|
||||
}
|
||||
|
||||
int create_config_entry()
|
||||
|
@ -242,6 +243,10 @@ int create_nyx_config_entry(bool force_unmount)
|
|||
itoa(n_cfg.bpmp_clock, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
|
||||
f_puts("\nsafeui=", &fp);
|
||||
itoa(n_cfg.safeui, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
|
||||
f_puts("\n", &fp);
|
||||
|
||||
f_close(&fp);
|
||||
|
|
|
@ -54,6 +54,7 @@ typedef struct _nyx_config
|
|||
u32 jc_disable;
|
||||
u32 jc_force_right;
|
||||
u32 bpmp_clock;
|
||||
u32 safeui;
|
||||
} nyx_config;
|
||||
|
||||
void set_default_configuration();
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "../config.h"
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include "konami.h"
|
||||
|
||||
extern hekate_config h_cfg;
|
||||
extern nyx_config n_cfg;
|
||||
|
@ -615,6 +616,8 @@ static bool _jc_virt_mouse_read(lv_indev_data_t *data)
|
|||
close_btn = NULL;
|
||||
}
|
||||
|
||||
check_konami_code(jc_pad);
|
||||
|
||||
return false; // No buffering so no more data read.
|
||||
}
|
||||
|
||||
|
@ -779,6 +782,35 @@ lv_res_t mbox_action(lv_obj_t *btns, const char *txt)
|
|||
return LV_RES_INV;
|
||||
}
|
||||
|
||||
lv_res_t mbox_konami_action(lv_obj_t *btns, const char *txt)
|
||||
{
|
||||
lv_obj_t *mbox = lv_mbox_get_from_btn(btns);
|
||||
|
||||
// Do here some konami code related stuff
|
||||
// put safeui to false and homescreen to 0
|
||||
n_cfg.safeui = 0;
|
||||
n_cfg.home_screen = 0;
|
||||
|
||||
//store nyx config
|
||||
int res = !create_nyx_config_entry(true);
|
||||
|
||||
if(res){
|
||||
lv_obj_t *dark_bg = lv_obj_get_parent(mbox);
|
||||
lv_obj_del(dark_bg); // Deletes children also (mbox).
|
||||
reload_nyx();
|
||||
return LV_RES_INV;
|
||||
}else {
|
||||
static const char * mbox_btn_map[] = {"\251", "\222OK!", "\251", ""};
|
||||
mbox = lv_mbox_create(lv_scr_act(), NULL);
|
||||
lv_mbox_set_recolor_text(mbox, true);
|
||||
lv_mbox_set_text(mbox, "#FF8000 Nyx Configuration#\n\n#FFDD00 Failed to save the configuration#\n#FFDD00 to sd card!#");
|
||||
lv_mbox_add_btns(mbox, mbox_btn_map, NULL);
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_top(mbox, true);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
}
|
||||
|
||||
bool nyx_emmc_check_battery_enough()
|
||||
{
|
||||
if (fuse_read_hw_state() == FUSE_NX_HW_STATE_DEV)
|
||||
|
@ -1508,7 +1540,10 @@ static lv_obj_t *create_window_launch(const char *win_title)
|
|||
|
||||
lv_win_set_style(win, LV_WIN_STYLE_BG, &win_bg_style);
|
||||
|
||||
close_btn = lv_win_add_btn(win, NULL, SYMBOL_CLOSE" Close", _win_launch_close_action);
|
||||
if(!n_cfg.safeui)
|
||||
close_btn = lv_win_add_btn(win, NULL, SYMBOL_CLOSE" Close", _win_launch_close_action);
|
||||
else
|
||||
close_btn = NULL;
|
||||
|
||||
return win;
|
||||
}
|
||||
|
@ -1522,6 +1557,12 @@ static lv_res_t _launch_action(lv_obj_t *btn)
|
|||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t _launch_ofw_action(lv_obj_t *btn)
|
||||
{
|
||||
power_set_state(REBOOT_BYPASS_FUSES);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t logs_onoff_toggle(lv_obj_t *btn)
|
||||
{
|
||||
launch_logs_enable = !launch_logs_enable;
|
||||
|
@ -1639,7 +1680,8 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
|
|||
else
|
||||
win = create_window_launch(SYMBOL_GPS" More Configurations");
|
||||
|
||||
lv_win_add_btn(win, NULL, SYMBOL_LIST" Logs #D0D0D0 OFF#", logs_onoff_toggle);
|
||||
if(!n_cfg.safeui)
|
||||
lv_win_add_btn(win, NULL, SYMBOL_LIST" Logs #D0D0D0 OFF#", logs_onoff_toggle);
|
||||
launch_logs_enable = false;
|
||||
|
||||
lv_cont_set_fit(lv_page_get_scrl(lv_win_get_content(win)), false, false);
|
||||
|
@ -1733,6 +1775,7 @@ ini_parsing:
|
|||
|
||||
icon_path = NULL;
|
||||
bool payload = false;
|
||||
bool ofw = false;
|
||||
bool img_colorize = false;
|
||||
bool img_noborder = false;
|
||||
lv_img_dsc_t *bmp = NULL;
|
||||
|
@ -1745,6 +1788,9 @@ ini_parsing:
|
|||
icon_path = kv->val;
|
||||
else if (!strcmp("payload", kv->key))
|
||||
payload = true;
|
||||
else if (!strcmp("ofw", kv->key))
|
||||
if (kv->val[0] == '1')
|
||||
ofw = true;
|
||||
}
|
||||
|
||||
// If icon not found, check res folder for section_name.bmp.
|
||||
|
@ -1863,7 +1909,9 @@ ini_parsing:
|
|||
ext->idx = entry_idx;
|
||||
|
||||
// Set action.
|
||||
if (!more_cfg)
|
||||
if(ofw)
|
||||
lv_btn_set_action(btns, LV_BTN_ACTION_CLICK, _launch_ofw_action);
|
||||
else if (!more_cfg)
|
||||
lv_btn_set_action(btns, LV_BTN_ACTION_CLICK, _launch_action);
|
||||
else
|
||||
lv_btn_set_action(btns, LV_BTN_ACTION_CLICK, _launch_more_cfg_action);
|
||||
|
@ -2276,6 +2324,24 @@ void first_time_bpmp_clock(void *param)
|
|||
create_nyx_config_entry(false);
|
||||
}
|
||||
|
||||
static void _show_mbox_konami(){
|
||||
|
||||
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_style(dark_bg, &mbox_darken);
|
||||
lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES);
|
||||
|
||||
static const char * mbox_btn_map[] = { "\251", "\222OK", "\251", "" };
|
||||
lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL);
|
||||
lv_mbox_set_recolor_text(mbox, true);
|
||||
lv_obj_set_width(mbox, LV_HOR_RES * 5 / 9);
|
||||
|
||||
lv_mbox_set_text(mbox, "#FF8000 Konami Code#\n\n#96FF00 You found a secret!#");
|
||||
lv_mbox_add_btns(mbox, mbox_btn_map, mbox_konami_action);
|
||||
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_top(mbox, true);
|
||||
}
|
||||
|
||||
static void _nyx_main_menu(lv_theme_t * th)
|
||||
{
|
||||
static lv_style_t no_padding;
|
||||
|
@ -2446,6 +2512,9 @@ void nyx_load_and_run()
|
|||
// Create main menu
|
||||
_nyx_main_menu(th);
|
||||
|
||||
// Register konami code handler
|
||||
register_konami_code_handler(_show_mbox_konami);
|
||||
|
||||
jc_drv_ctx.cursor = lv_img_create(lv_scr_act(), NULL);
|
||||
lv_img_set_src(jc_drv_ctx.cursor, &touch_cursor);
|
||||
lv_obj_set_opa_scale(jc_drv_ctx.cursor, LV_OPA_TRANSP);
|
||||
|
|
41
nyx/nyx_gui/frontend/konami.c
Normal file
41
nyx/nyx_gui/frontend/konami.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include "konami.h"
|
||||
|
||||
// pointer to function
|
||||
static void (*konami_code_handler)(void) = NULL;
|
||||
|
||||
void check_konami_code(jc_gamepad_rpt_t *jc_pad){
|
||||
|
||||
static u32 konami_code[] = {
|
||||
JC_BTNS_UP,
|
||||
JC_BTNS_UP,
|
||||
JC_BTNS_DOWN,
|
||||
JC_BTNS_DOWN,
|
||||
JC_BTNS_LEFT,
|
||||
JC_BTNS_RIGHT,
|
||||
JC_BTNS_LEFT,
|
||||
JC_BTNS_RIGHT,
|
||||
JC_BTNS_B,
|
||||
JC_BTNS_A
|
||||
};
|
||||
|
||||
static u8 konami_code_idx = 0;
|
||||
|
||||
u32 key_pressed = (jc_pad->buttons & konami_code[konami_code_idx]);
|
||||
if (key_pressed && (key_pressed == konami_code[konami_code_idx] || key_pressed == konami_code[(konami_code_idx = 0)]))
|
||||
{
|
||||
konami_code_idx++;
|
||||
if (konami_code_idx == 10)
|
||||
{
|
||||
konami_code_idx = 0;
|
||||
if (konami_code_handler)
|
||||
{
|
||||
(*konami_code_handler)();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void register_konami_code_handler(// pointer to function
|
||||
void (*handler)(void)) {
|
||||
konami_code_handler = handler;
|
||||
}
|
10
nyx/nyx_gui/frontend/konami.h
Normal file
10
nyx/nyx_gui/frontend/konami.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef _KONAMI_H_
|
||||
#define _KONAMI_H_
|
||||
|
||||
#include <bdk.h>
|
||||
|
||||
void check_konami_code(jc_gamepad_rpt_t *jc_pad);
|
||||
void register_konami_code_handler(// pointer to function
|
||||
void (*handler)(void));
|
||||
|
||||
#endif /* _KONAMI_H_ */
|
|
@ -286,6 +286,8 @@ skip_main_cfg_parse:
|
|||
n_cfg.jc_force_right = atoi(kv->val) == 1;
|
||||
else if (!strcmp("bpmpclock", kv->key))
|
||||
n_cfg.bpmp_clock = atoi(kv->val);
|
||||
else if (!strcmp("safeui", kv->key))
|
||||
n_cfg.safeui = atoi(kv->val) == 1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue