1use std::collections::HashSet;
2use std::hash::Hash;
3
4use repose_core::input::PhysicalKey;
5use repose_core::runtime::Scheduler;
6
7pub fn apply_scheduler_levels<C>(
8 staged_held: &mut HashSet<C>,
9 lmb_held: &mut bool,
10 rmb_held: &mut bool,
11 window_focused: &mut bool,
12 sched: &Scheduler,
13 code_for: impl Fn(PhysicalKey) -> Option<C>,
14 keys_for: impl Fn(&C) -> Option<&'static [PhysicalKey]>,
15) where
16 C: Eq + Hash + Clone,
17{
18 if !sched.window_focused {
19 staged_held.clear();
20 *lmb_held = false;
21 *rmb_held = false;
22 *window_focused = false;
23 return;
24 }
25 *window_focused = true;
26 repame_input::reconcile_held(staged_held, &sched.held_keys, code_for, keys_for);
27 if !sched.mouse_primary {
28 *lmb_held = false;
29 }
30 if !sched.mouse_secondary {
31 *rmb_held = false;
32 }
33}