nyx: Allow disabling of Joycon

Setting `jcdisable=1` in nyx.ini disables the usage of Joycon completely.

This also disables the BT pairing data dumping tool.
This commit is contained in:
CTCaer 2020-10-20 10:21:48 +03:00
parent 2f5b52223c
commit dae7be8ec4
7 changed files with 29 additions and 7 deletions

View file

@ -68,7 +68,8 @@ You can find a template [Here](./res/hekate_ipl_template.ini)
| timeoff=100 | Sets time offset in HEX. Must be in HOS epoch format | | timeoff=100 | Sets time offset in HEX. Must be in HOS epoch format |
| homescreen=0 | Sets home screen. 0: Home menu, 1: All configs (merges Launch and More configs), 2: Launch, 3: More Configs. | | homescreen=0 | Sets home screen. 0: Home menu, 1: All configs (merges Launch and More configs), 2: Launch, 3: More Configs. |
| verification=1 | 0: Disable Backup/Restore verification, 1: Sparse (block based, fast and mostly reliable), 2: Full (sha256 based, slow and 100% reliable). | | verification=1 | 0: Disable Backup/Restore verification, 1: Sparse (block based, fast and mostly reliable), 2: Full (sha256 based, slow and 100% reliable). |
| umsemmcrw=1 | 1: eMMC/emuMMC UMS will be mounted as writable by default. | | umsemmcrw=0 | 1: eMMC/emuMMC UMS will be mounted as writable by default. |
| jcdisable=0 | 1: Disables Joycon driver completely. |
### Boot entry key/value combinations: ### Boot entry key/value combinations:

View file

@ -523,6 +523,9 @@ jc_gamepad_rpt_t *jc_get_bt_pairing_info(bool *is_l_hos, bool *is_r_hos)
u8 retries; u8 retries;
jc_bt_conn_t *bt_conn; jc_bt_conn_t *bt_conn;
if (!jc_init_done)
return NULL;
bt_conn = &jc_gamepad.bt_conn_l; bt_conn = &jc_gamepad.bt_conn_l;
memset(bt_conn->host_mac, 0, 6); memset(bt_conn->host_mac, 0, 6);
memset(bt_conn->ltk, 0, 16); memset(bt_conn->ltk, 0, 16);

View file

@ -60,6 +60,7 @@ void set_nyx_default_configuration()
n_cfg.home_screen = 0; n_cfg.home_screen = 0;
n_cfg.verification = 1; n_cfg.verification = 1;
n_cfg.ums_emmc_rw = 0; n_cfg.ums_emmc_rw = 0;
n_cfg.jc_disable = 0;
} }
int create_config_entry() int create_config_entry()
@ -198,6 +199,9 @@ int create_nyx_config_entry()
f_puts("\numsemmcrw=", &fp); f_puts("\numsemmcrw=", &fp);
itoa(n_cfg.ums_emmc_rw, lbuf, 10); itoa(n_cfg.ums_emmc_rw, lbuf, 10);
f_puts(lbuf, &fp); f_puts(lbuf, &fp);
f_puts("\njcdisable=", &fp);
itoa(n_cfg.jc_disable, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\n", &fp); f_puts("\n", &fp);
f_close(&fp); f_close(&fp);

View file

@ -48,6 +48,7 @@ typedef struct _nyx_config
u32 home_screen; u32 home_screen;
u32 verification; u32 verification;
u32 ums_emmc_rw; u32 ums_emmc_rw;
u32 jc_disable;
} nyx_config; } nyx_config;
void set_default_configuration(); void set_default_configuration();

View file

@ -2234,8 +2234,11 @@ void nyx_load_and_run()
lv_disp_drv_register(&disp_drv); lv_disp_drv_register(&disp_drv);
// Initialize Joy-Con. // Initialize Joy-Con.
lv_task_t *task_jc_init_hw = lv_task_create(jc_init_hw, LV_TASK_ONESHOT, LV_TASK_PRIO_LOWEST, NULL); if (!n_cfg.jc_disable)
lv_task_once(task_jc_init_hw); {
lv_task_t *task_jc_init_hw = lv_task_create(jc_init_hw, LV_TASK_ONESHOT, LV_TASK_PRIO_LOWEST, NULL);
lv_task_once(task_jc_init_hw);
}
lv_indev_drv_t indev_drv_jc; lv_indev_drv_t indev_drv_jc;
lv_indev_drv_init(&indev_drv_jc); lv_indev_drv_init(&indev_drv_jc);
indev_drv_jc.type = LV_INDEV_TYPE_POINTER; indev_drv_jc.type = LV_INDEV_TYPE_POINTER;

View file

@ -740,10 +740,20 @@ void first_time_clock_edit(void *param)
static lv_res_t _joycon_info_dump_action(lv_obj_t * btn) static lv_res_t _joycon_info_dump_action(lv_obj_t * btn)
{ {
FIL fp; FIL fp;
int error;
bool is_l_hos = false; bool is_l_hos = false;
bool is_r_hos = false; bool is_r_hos = false;
jc_gamepad_rpt_t *jc_pad = jc_get_bt_pairing_info(&is_l_hos, &is_r_hos); jc_gamepad_rpt_t *jc_pad = jc_get_bt_pairing_info(&is_l_hos, &is_r_hos);
char *data = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(0x1000);
if (!jc_pad)
{
error = 255;
goto disabled;
}
// Count valid joycon. // Count valid joycon.
u32 joycon_found = jc_pad->bt_conn_l.type ? 1 : 0; u32 joycon_found = jc_pad->bt_conn_l.type ? 1 : 0;
if (jc_pad->bt_conn_r.type) if (jc_pad->bt_conn_r.type)
@ -753,10 +763,7 @@ static lv_res_t _joycon_info_dump_action(lv_obj_t * btn)
jc_pad->bt_conn_l.type = is_l_hos ? jc_pad->bt_conn_l.type : 0; jc_pad->bt_conn_l.type = is_l_hos ? jc_pad->bt_conn_l.type : 0;
jc_pad->bt_conn_r.type = is_r_hos ? jc_pad->bt_conn_r.type : 0; jc_pad->bt_conn_r.type = is_r_hos ? jc_pad->bt_conn_r.type : 0;
int error = !sd_mount(); error = !sd_mount();
char *data = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(0x1000);
if (!error) if (!error)
{ {
@ -798,6 +805,7 @@ static lv_res_t _joycon_info_dump_action(lv_obj_t * btn)
sd_unmount(); sd_unmount();
} }
disabled:;
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL); lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_style(dark_bg, &mbox_darken); lv_obj_set_style(dark_bg, &mbox_darken);
lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES); lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES);

View file

@ -270,6 +270,8 @@ void load_saved_configuration()
n_cfg.verification = atoi(kv->val); n_cfg.verification = atoi(kv->val);
else if (!strcmp("umsemmcrw", kv->key)) else if (!strcmp("umsemmcrw", kv->key))
n_cfg.ums_emmc_rw = atoi(kv->val) == 1; n_cfg.ums_emmc_rw = atoi(kv->val) == 1;
else if (!strcmp("jcdisable", kv->key))
n_cfg.jc_disable = atoi(kv->val) == 1;
} }
break; break;