mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 03:11:16 +00:00
joycon: Skip first 4 packets for calibration
This commit is contained in:
parent
4e0c70a402
commit
80dd0f1580
1 changed files with 11 additions and 0 deletions
|
@ -386,6 +386,8 @@ static bool _fts_touch_read(lv_indev_data_t *data)
|
|||
|
||||
static bool _jc_virt_mouse_read(lv_indev_data_t *data)
|
||||
{
|
||||
static u32 calib_timer = 0;
|
||||
|
||||
// Poll Joy-Con.
|
||||
jc_gamepad_rpt_t *jc_pad = joycon_poll();
|
||||
|
||||
|
@ -407,6 +409,12 @@ static bool _jc_virt_mouse_read(lv_indev_data_t *data)
|
|||
// Calibrate left stick.
|
||||
if (!jc_drv_ctx.centering_done)
|
||||
{
|
||||
if (!calib_timer)
|
||||
calib_timer = get_tmr_ms() + LV_INDEV_READ_PERIOD * 4;
|
||||
|
||||
if (calib_timer > get_tmr_ms())
|
||||
return false;
|
||||
|
||||
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)
|
||||
|
@ -427,7 +435,10 @@ static bool _jc_virt_mouse_read(lv_indev_data_t *data)
|
|||
|
||||
// Re-calibrate on disconnection.
|
||||
if (!jc_pad->conn_l)
|
||||
{
|
||||
calib_timer = 0;
|
||||
jc_drv_ctx.centering_done = 0;
|
||||
}
|
||||
|
||||
// Set button presses.
|
||||
if (jc_pad->a || jc_pad->zl || jc_pad->zr)
|
||||
|
|
Loading…
Reference in a new issue