fix(objects/input): disable_controller still lets hands exist

This commit is contained in:
Nova
2023-09-24 11:44:16 -04:00
parent 167c3d1cbf
commit bf248e192f
2 changed files with 10 additions and 6 deletions

View File

@@ -251,8 +251,8 @@ fn main() {
mouse_pointer.update(sk);
}
if let Some((left_hand, right_hand)) = &mut hands {
left_hand.update(sk);
right_hand.update(sk);
left_hand.update(!cli_args.disable_controller, sk);
right_hand.update(!cli_args.disable_controller, sk);
}
if let Some((left_controller, right_controller)) = &mut controllers {
left_controller.update(sk);

View File

@@ -54,12 +54,16 @@ impl SkHand {
})
}
#[instrument(level = "debug", name = "Update Hand Input Method", skip_all)]
pub fn update(&mut self, sk: &impl StereoKitMultiThread) {
pub fn update(&mut self, controller_enabled: bool, sk: &impl StereoKitMultiThread) {
let sk_hand = sk.input_hand(self.handed);
if let InputType::Hand(hand) = &mut *self.input.specialization.lock() {
let controller = sk.input_controller(self.handed);
*self.input.enabled.lock() = !controller.tracked.contains(ButtonState::ACTIVE)
&& sk_hand.tracked_state.contains(ButtonState::ACTIVE);
let controller_active = controller_enabled
&& sk
.input_controller(self.handed)
.tracked
.contains(ButtonState::ACTIVE);
*self.input.enabled.lock() =
!controller_active && sk_hand.tracked_state.contains(ButtonState::ACTIVE);
sk.input_hand_visible(self.handed, *self.input.enabled.lock());
if *self.input.enabled.lock() {
hand.base.thumb.tip = convert_joint(sk_hand.fingers[0][4]);