MCPcopy Create free account
hub / github.com/PerroEngine/Perro / set_key_state

Method set_key_state

perro_source/api_modules/perro_input_api/src/state.rs:50–65  ·  view source on GitHub ↗
(&mut self, key: KeyCode, is_down: bool)

Source from the content-addressed store, hash-verified

48 /// Apply a key transition and update one-frame pressed/released edges.
49 #[inline]
50 pub fn set_key_state(&mut self, key: KeyCode, is_down: bool) {
51 let idx = key.as_index();
52 let word = idx / 64;
53 let bit = 1_u64 << (idx % 64);
54 let was_down = self.down[word] & bit != 0;
55
56 if is_down {
57 if !was_down {
58 self.down[word] |= bit;
59 self.pressed[word] |= bit;
60 }
61 } else if was_down {
62 self.down[word] &= !bit;
63 self.released[word] |= bit;
64 }
65 }
66
67 // ---- Query ----
68

Calls 1

as_indexMethod · 0.45