From aae7331d57ae58c9d60b8c6fb5b65eb672d79172 Mon Sep 17 00:00:00 2001 From: Jacques Gagnon Date: Sat, 14 Sep 2024 01:22:26 +0000 Subject: [PATCH] [ADAPTER] Fix issues in wired PS module --- main/adapter/wired/ps.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/main/adapter/wired/ps.c b/main/adapter/wired/ps.c index 0e27dfef..454ee145 100644 --- a/main/adapter/wired/ps.c +++ b/main/adapter/wired/ps.c @@ -220,7 +220,7 @@ void ps_meta_init(struct wired_ctrl *ctrl_data) { ctrl_data[i].desc = ps_kb_desc; goto exit_axes_loop; case DEV_MOUSE: - if (i >= PS_JOYSTICK_AXES_CNT) { + if (j >= PS_JOYSTICK_AXES_CNT) { goto exit_axes_loop; } ctrl_data[i].mask = ps_mouse_mask; @@ -280,13 +280,15 @@ static void ps_ctrl_from_generic(struct wired_ctrl *ctrl_data, struct wired_data map_tmp.axes[ps_axes_idx[i]] = (uint8_t)(ctrl_data->axes[i].value + ctrl_data->axes[i].meta->neutral); } - if (i >= PS_JOYSTICK_AXES_CNT && map_tmp.axes[ps_axes_idx[i]]) { - map_tmp.buttons &= ~ps_btns_mask[btn_id];; - wired_data->cnt_mask[btn_id] = ctrl_data->btns[0].cnt_mask[btn_id]; - } - else { - map_tmp.buttons |= ps_btns_mask[btn_id]; - wired_data->cnt_mask[btn_id] = 0; + if (i >= PS_JOYSTICK_AXES_CNT) { + if (map_tmp.axes[ps_axes_idx[i]]) { + map_tmp.buttons &= ~ps_btns_mask[btn_id];; + wired_data->cnt_mask[btn_id] = ctrl_data->btns[0].cnt_mask[btn_id]; + } + else { + map_tmp.buttons |= ps_btns_mask[btn_id]; + wired_data->cnt_mask[btn_id] = 0; + } } } wired_data->cnt_mask[btn_id] = ctrl_data->axes[i].cnt_mask;