From 991a307191fce512baac167a903bd925cd5a957b Mon Sep 17 00:00:00 2001 From: nirenjan Date: Wed, 1 Apr 2026 20:41:38 -0700 Subject: [PATCH] fix: Handle shortcut execution in x52d_mouse_report_event Prior to this change, there is a potential bug where if the left and right mouse buttons and/or wheel are reported in the same HID report, the first one to have a change would block any subsequent items. This is due to the shortcut execution of the `||` operator. By switching the order in which we evaluate the operands, we can ensure that the report_* functions are always called. --- daemon/x52d_mouse_handler.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/x52d_mouse_handler.c b/daemon/x52d_mouse_handler.c index 6ca4151..96d01eb 100644 --- a/daemon/x52d_mouse_handler.c +++ b/daemon/x52d_mouse_handler.c @@ -215,9 +215,9 @@ void x52d_mouse_report_event(libx52io_report *report) } state_changed = false; - state_changed = state_changed || (0 == report_button_change(VKM_MOUSE_BTN_LEFT, LIBX52IO_BTN_MOUSE_PRIMARY)); - state_changed = state_changed || (0 == report_button_change(VKM_MOUSE_BTN_RIGHT, LIBX52IO_BTN_MOUSE_SECONDARY)); - state_changed = state_changed || (0 == report_wheel()); + state_changed = (0 == report_button_change(VKM_MOUSE_BTN_LEFT, LIBX52IO_BTN_MOUSE_PRIMARY)) || state_changed; + state_changed = (0 == report_button_change(VKM_MOUSE_BTN_RIGHT, LIBX52IO_BTN_MOUSE_SECONDARY)) || state_changed; + state_changed = (0 == report_wheel()) || state_changed; if (state_changed) { report_sync();