MCPcopy Create free account
hub / github.com/TyberiusPrime/KeyToKey / handle_keys

Method handle_keys

src/lib.rs:147–186  ·  view source on GitHub ↗

handle an update to the event stream This returns OK(()) if all keys are handled by the handlers and an Err(()) otherwise. that way the down stream can decide what to do (tests: panic. Firmare/MatrixToStream -> drop unhandled events)

(&mut self)

Source from the content-addressed store, hash-verified

145 /// that way the down stream can decide what to do
146 /// (tests: panic. Firmare/MatrixToStream -> drop unhandled events)
147 pub fn handle_keys(&mut self) -> Result<(), ()> {
148 for (_e, status) in self.events.iter_mut() {
149 *status = EventStatus::Unhandled;
150 }
151 //skip the modifiers
152 for (ii, h) in self.handlers.iter_mut().enumerate() {
153 if self.output.state().modifiers_and_enabled_handlers[ii + KEYBOARD_STATE_RESERVED_BITS]
154 {
155 match h.process_keys(&mut self.events, &mut self.output) {
156 HandlerResult::NoOp => {}
157 HandlerResult::Disable => {
158 self.output
159 .state()
160 .disable_handler((ii + KEYBOARD_STATE_RESERVED_BITS) as HandlerID);
161 }
162 }
163 if self.output.state()._aborted() {
164 self.output.state()._clear_abort();
165 self.events.clear();
166 break; // no more handlers being done
167 }
168 }
169 }
170 // remove handled & timeout events.
171 self.events.drain_filter(|(event, status)| {
172 (EventStatus::Handled == *status)
173 || (match event {
174 Event::TimeOut(_) => true,
175 _ => false,
176 })
177 });
178 if self
179 .events
180 .iter()
181 .any(|(_e, status)| EventStatus::Unhandled == *status)
182 {
183 return Err(());
184 }
185 Ok(())
186 }
187 //throw away unhandled key events
188 pub fn clear_unhandled(&mut self) {
189 self.events

Callers 15

pcMethod · 0.80
rcMethod · 0.80
tcMethod · 0.80
pctMethod · 0.80
rctMethod · 0.80
test_toggle_handlerFunction · 0.80
test_dvorak_bracketsFunction · 0.80
test_oneshot_shiftFunction · 0.80
test_oneshot_interactionFunction · 0.80

Calls 6

stateMethod · 0.80
disable_handlerMethod · 0.80
_abortedMethod · 0.80
_clear_abortMethod · 0.80
clearMethod · 0.80
process_keysMethod · 0.45

Tested by 15

pcMethod · 0.64
rcMethod · 0.64
tcMethod · 0.64
pctMethod · 0.64
rctMethod · 0.64
test_toggle_handlerFunction · 0.64
test_dvorak_bracketsFunction · 0.64
test_oneshot_shiftFunction · 0.64
test_oneshot_interactionFunction · 0.64