mirror of
https://github.com/CTCaer/hekate
synced 2024-11-16 00:49:27 +00:00
nyx: add option to use right joycon as mouse control
`jcforceright=1` in nyx.ini enables that feature. Useful for users with broken touch screen and broken left joycon rail.
This commit is contained in:
parent
af1ece903b
commit
c04d423f4b
5 changed files with 61 additions and 15 deletions
|
@ -172,6 +172,7 @@ If the main .ini is not found, it is created on the first hekate boot and only h
|
|||
| verification=1 | 0: Disable Backup/Restore verification, 1: Sparse (block based, fast and mostly reliable), 2: Full (sha256 based, slow and 100% reliable). |
|
||||
| umsemmcrw=0 | 1: eMMC/emuMMC UMS will be mounted as writable by default. |
|
||||
| jcdisable=0 | 1: Disables Joycon driver completely. |
|
||||
| jcforceright=0 | 1: Forces right joycon to be used as main mouse control. |
|
||||
| bpmpclock=1 | 0: Auto, 1: Faster, 2: Fast. Use 2 if Nyx hangs or some functions like UMS/Backup Verification fail. |
|
||||
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ void set_nyx_default_configuration()
|
|||
n_cfg.verification = 1;
|
||||
n_cfg.ums_emmc_rw = 0;
|
||||
n_cfg.jc_disable = 0;
|
||||
n_cfg.jc_force_right = 0;
|
||||
n_cfg.bpmp_clock = 0;
|
||||
}
|
||||
|
||||
|
@ -210,6 +211,9 @@ int create_nyx_config_entry(bool force_unmount)
|
|||
f_puts("\njcdisable=", &fp);
|
||||
itoa(n_cfg.jc_disable, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
f_puts("\njcforceright=", &fp);
|
||||
itoa(n_cfg.jc_force_right, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
f_puts("\nbpmpclock=", &fp);
|
||||
itoa(n_cfg.bpmp_clock, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
|
|
|
@ -48,6 +48,7 @@ typedef struct _nyx_config
|
|||
u32 verification;
|
||||
u32 ums_emmc_rw;
|
||||
u32 jc_disable;
|
||||
u32 jc_force_right;
|
||||
u32 bpmp_clock;
|
||||
} nyx_config;
|
||||
|
||||
|
|
|
@ -394,9 +394,23 @@ static bool _jc_virt_mouse_read(lv_indev_data_t *data)
|
|||
// Calibrate left stick.
|
||||
if (!jc_drv_ctx.centering_done)
|
||||
{
|
||||
if (jc_pad->conn_l
|
||||
&& jc_pad->lstick_x > 0x400 && jc_pad->lstick_y > 0x400
|
||||
&& jc_pad->lstick_x < 0xC00 && jc_pad->lstick_y < 0xC00)
|
||||
if (n_cfg.jc_force_right)
|
||||
{
|
||||
if (jc_pad->conn_r
|
||||
&& jc_pad->rstick_x > 0x400 && jc_pad->rstick_y > 0x400
|
||||
&& jc_pad->rstick_x < 0xC00 && jc_pad->rstick_y < 0xC00)
|
||||
{
|
||||
jc_drv_ctx.cx_max = jc_pad->rstick_x + 0x96;
|
||||
jc_drv_ctx.cx_min = jc_pad->rstick_x - 0x96;
|
||||
jc_drv_ctx.cy_max = jc_pad->rstick_y + 0x96;
|
||||
jc_drv_ctx.cy_min = jc_pad->rstick_y - 0x96;
|
||||
jc_drv_ctx.centering_done = true;
|
||||
jc_drv_ctx.cursor_timeout = 0;
|
||||
}
|
||||
}
|
||||
else if (jc_pad->conn_l
|
||||
&& jc_pad->lstick_x > 0x400 && jc_pad->lstick_y > 0x400
|
||||
&& jc_pad->lstick_x < 0xC00 && jc_pad->lstick_y < 0xC00)
|
||||
{
|
||||
jc_drv_ctx.cx_max = jc_pad->lstick_x + 0x96;
|
||||
jc_drv_ctx.cx_min = jc_pad->lstick_x - 0x96;
|
||||
|
@ -413,7 +427,12 @@ static bool _jc_virt_mouse_read(lv_indev_data_t *data)
|
|||
}
|
||||
|
||||
// Re-calibrate on disconnection.
|
||||
if (!jc_pad->conn_l)
|
||||
if (n_cfg.jc_force_right)
|
||||
{
|
||||
if (!jc_pad->conn_r)
|
||||
jc_drv_ctx.centering_done = 0;
|
||||
}
|
||||
else if (!jc_pad->conn_l)
|
||||
jc_drv_ctx.centering_done = 0;
|
||||
|
||||
// Set button presses.
|
||||
|
@ -466,19 +485,38 @@ static bool _jc_virt_mouse_read(lv_indev_data_t *data)
|
|||
}
|
||||
|
||||
// Calculate new cursor position.
|
||||
if (jc_pad->lstick_x <= jc_drv_ctx.cx_max && jc_pad->lstick_x >= jc_drv_ctx.cx_min)
|
||||
jc_drv_ctx.pos_x += 0;
|
||||
else if (jc_pad->lstick_x > jc_drv_ctx.cx_max)
|
||||
jc_drv_ctx.pos_x += ((jc_pad->lstick_x - jc_drv_ctx.cx_max) / 30);
|
||||
else
|
||||
jc_drv_ctx.pos_x -= ((jc_drv_ctx.cx_min - jc_pad->lstick_x) / 30);
|
||||
if (!n_cfg.jc_force_right)
|
||||
{
|
||||
if (jc_pad->lstick_x <= jc_drv_ctx.cx_max && jc_pad->lstick_x >= jc_drv_ctx.cx_min)
|
||||
jc_drv_ctx.pos_x += 0;
|
||||
else if (jc_pad->lstick_x > jc_drv_ctx.cx_max)
|
||||
jc_drv_ctx.pos_x += ((jc_pad->lstick_x - jc_drv_ctx.cx_max) / 30);
|
||||
else
|
||||
jc_drv_ctx.pos_x -= ((jc_drv_ctx.cx_min - jc_pad->lstick_x) / 30);
|
||||
|
||||
if (jc_pad->lstick_y <= jc_drv_ctx.cy_max && jc_pad->lstick_y >= jc_drv_ctx.cy_min)
|
||||
jc_drv_ctx.pos_y += 0;
|
||||
else if (jc_pad->lstick_y > jc_drv_ctx.cy_max)
|
||||
jc_drv_ctx.pos_y -= ((jc_pad->lstick_y - jc_drv_ctx.cy_max) / 30);
|
||||
if (jc_pad->lstick_y <= jc_drv_ctx.cy_max && jc_pad->lstick_y >= jc_drv_ctx.cy_min)
|
||||
jc_drv_ctx.pos_y += 0;
|
||||
else if (jc_pad->lstick_y > jc_drv_ctx.cy_max)
|
||||
jc_drv_ctx.pos_y -= ((jc_pad->lstick_y - jc_drv_ctx.cy_max) / 30);
|
||||
else
|
||||
jc_drv_ctx.pos_y += ((jc_drv_ctx.cy_min - jc_pad->lstick_y) / 30);
|
||||
}
|
||||
else
|
||||
jc_drv_ctx.pos_y += ((jc_drv_ctx.cy_min - jc_pad->lstick_y) / 30);
|
||||
{
|
||||
if (jc_pad->rstick_x <= jc_drv_ctx.cx_max && jc_pad->rstick_x >= jc_drv_ctx.cx_min)
|
||||
jc_drv_ctx.pos_x += 0;
|
||||
else if (jc_pad->rstick_x > jc_drv_ctx.cx_max)
|
||||
jc_drv_ctx.pos_x += ((jc_pad->rstick_x - jc_drv_ctx.cx_max) / 30);
|
||||
else
|
||||
jc_drv_ctx.pos_x -= ((jc_drv_ctx.cx_min - jc_pad->rstick_x) / 30);
|
||||
|
||||
if (jc_pad->rstick_y <= jc_drv_ctx.cy_max && jc_pad->rstick_y >= jc_drv_ctx.cy_min)
|
||||
jc_drv_ctx.pos_y += 0;
|
||||
else if (jc_pad->rstick_y > jc_drv_ctx.cy_max)
|
||||
jc_drv_ctx.pos_y -= ((jc_pad->rstick_y - jc_drv_ctx.cy_max) / 30);
|
||||
else
|
||||
jc_drv_ctx.pos_y += ((jc_drv_ctx.cy_min - jc_pad->rstick_y) / 30);
|
||||
}
|
||||
|
||||
// Ensure value inside screen limits.
|
||||
if (jc_drv_ctx.pos_x < 0)
|
||||
|
|
|
@ -271,6 +271,8 @@ skip_main_cfg_parse:
|
|||
n_cfg.ums_emmc_rw = atoi(kv->val) == 1;
|
||||
else if (!strcmp("jcdisable", kv->key))
|
||||
n_cfg.jc_disable = atoi(kv->val) == 1;
|
||||
else if (!strcmp("jcforceright", kv->key))
|
||||
n_cfg.jc_force_right = atoi(kv->val) == 1;
|
||||
else if (!strcmp("bpmpclock", kv->key))
|
||||
n_cfg.bpmp_clock = strtol(kv->val, NULL, 10);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue