(
&mut self,
app: &mut S,
index: usize,
side: JoyConSide,
serial: String,
device_key: String,
)
| 687 | let _ = tx.send(DeviceCommand::SetPlayerLamp { pattern: indicator }); |
| 688 | } |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | fn sync_player_binding_lamps<S: JoyConSink>(&mut self, app: &mut S) { |
| 693 | let mut desired = [None; MAX_PERSISTENT_JOYCON_SLOTS]; |
| 694 | app.for_each_player_binding(&mut |player_idx, binding| { |
| 695 | let Some(indicator) = PlayerIndicatorSlot::from_player_number(player_idx + 1) |
| 696 | else { |
| 697 | return; |
| 698 | }; |
| 699 | let pattern = indicator.to_lamp_pattern(); |
| 700 | match binding { |
| 701 | PlayerBinding::JoyConSingle { index } => { |
| 702 | if let Some(slot) = desired.get_mut(index) { |
| 703 | *slot = Some(pattern); |
| 704 | } else if self.last_player_lamp.get(&index).copied() != Some(pattern) { |
| 705 | self.apply_indicator(index, pattern); |
| 706 | } |
| 707 | } |
| 708 | PlayerBinding::JoyConPair { left, right } => { |
| 709 | for index in [left, right] { |
| 710 | if let Some(slot) = desired.get_mut(index) { |
| 711 | *slot = Some(pattern); |
| 712 | } else if self.last_player_lamp.get(&index).copied() != Some(pattern) { |
| 713 | self.apply_indicator(index, pattern); |
| 714 | } |
| 715 | } |
| 716 | } |
| 717 | _ => {} |
| 718 | } |
| 719 | }); |
| 720 | for (index, pattern) in desired.into_iter().enumerate() { |
| 721 | let Some(pattern) = pattern else { |
| 722 | continue; |
| 723 | }; |
| 724 | if self.last_player_lamp.get(&index).copied() == Some(pattern) { |
| 725 | continue; |
| 726 | } |
| 727 | self.apply_indicator(index, pattern); |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | fn start_calibration<S: JoyConSink>(&mut self, app: &mut S, index: usize) { |
| 732 | if let Some((_, controller)) = self |
| 733 | .connected |
| 734 | .iter_mut() |
| 735 | .find(|((idx, _), _)| *idx == index) |
| 736 | { |
| 737 | controller.status = CalibrationStatus::Calibrating; |
| 738 | controller.session = Some(CalibrationSession::new()); |
| 739 | app.set_joycon_calibration_in_progress(index, true); |
| 740 | app.set_joycon_calibrated(index, false); |
| 741 | app.set_joycon_calibration_bias(index, 0.0, 0.0, 0.0); |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | fn on_connected<S: JoyConSink>( |
| 746 | &mut self, |
no test coverage detected