From a6da79bf3d593a65843ddd0abb28c07ac044724f Mon Sep 17 00:00:00 2001 From: Orion Date: Mon, 24 Nov 2025 06:26:44 +0100 Subject: [PATCH] prevent the mode from changing during a click (#273) Fixes mouse buttons getting stuck if trigger is released in a different mode than the initial click. --- wlx-overlay-s/src/backend/input.rs | 71 ++++++++++++++++-------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/wlx-overlay-s/src/backend/input.rs b/wlx-overlay-s/src/backend/input.rs index ac7af03..404a5a8 100644 --- a/wlx-overlay-s/src/backend/input.rs +++ b/wlx-overlay-s/src/backend/input.rs @@ -72,42 +72,45 @@ impl InputState { hand.last_click = Instant::now(); } - if hand.now.click_modifier_right { - hand.interaction.mode = PointerMode::Right; - continue; - } - - if hand.now.click_modifier_middle { - hand.interaction.mode = PointerMode::Middle; - continue; - } - - let hmd_up = self.hmd.transform_vector3a(Vec3A::Y); - let dot = hmd_up.dot(hand.pose.transform_vector3a(Vec3A::X)) - * 2.0f32.mul_add(-(hand.idx as f32), 1.0); - - hand.interaction.mode = if dot < -0.85 { - PointerMode::Right - } else if dot > 0.7 { - PointerMode::Middle - } else { - PointerMode::Left - }; - - let middle_click_orientation = false; - let right_click_orientation = false; - match hand.interaction.mode { - PointerMode::Middle => { - if !middle_click_orientation { - hand.interaction.mode = PointerMode::Left; - } + // Prevent the mode from changing during a click + if !hand.before.click { + if hand.now.click_modifier_right { + hand.interaction.mode = PointerMode::Right; + continue; } - PointerMode::Right => { - if !right_click_orientation { - hand.interaction.mode = PointerMode::Left; - } + + if hand.now.click_modifier_middle { + hand.interaction.mode = PointerMode::Middle; + continue; + } + + let hmd_up = self.hmd.transform_vector3a(Vec3A::Y); + let dot = hmd_up.dot(hand.pose.transform_vector3a(Vec3A::X)) + * 2.0f32.mul_add(-(hand.idx as f32), 1.0); + + hand.interaction.mode = if dot < -0.85 { + PointerMode::Right + } else if dot > 0.7 { + PointerMode::Middle + } else { + PointerMode::Left + }; + + let middle_click_orientation = false; + let right_click_orientation = false; + match hand.interaction.mode { + PointerMode::Middle => { + if !middle_click_orientation { + hand.interaction.mode = PointerMode::Left; + } + } + PointerMode::Right => { + if !right_click_orientation { + hand.interaction.mode = PointerMode::Left; + } + } + _ => {} } - _ => {} } if hand.now.alt_click != hand.before.alt_click {