mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
fix keyboard repeat; accidentally eliminated it during power optimizations
This commit is contained in:
parent
24d1bed9f8
commit
cf747f2844
1 changed files with 20 additions and 2 deletions
|
|
@ -365,6 +365,9 @@ mod implementation {
|
||||||
pub(crate) fn set_chord_interval(&mut self, delay: u32) {
|
pub(crate) fn set_chord_interval(&mut self, delay: u32) {
|
||||||
self.chord_interval = delay;
|
self.chord_interval = delay;
|
||||||
}
|
}
|
||||||
|
pub(crate) fn get_repeat_check_interval(&self) -> u32 {
|
||||||
|
self.rate
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn update(&mut self) -> KeyRawStates {
|
pub(crate) fn update(&mut self) -> KeyRawStates {
|
||||||
// EV_PENDING_KEYPRESSED effectively does an XOR of the previous keyboard state
|
// EV_PENDING_KEYPRESSED effectively does an XOR of the previous keyboard state
|
||||||
|
|
@ -718,6 +721,9 @@ mod implementation {
|
||||||
|
|
||||||
ks
|
ks
|
||||||
}
|
}
|
||||||
|
pub fn is_repeating_key(&self) -> bool {
|
||||||
|
self.repeating_key.is_some()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -799,8 +805,11 @@ fn xmain() -> ! {
|
||||||
let mut kbd = Keyboard::new(kbd_sid);
|
let mut kbd = Keyboard::new(kbd_sid);
|
||||||
|
|
||||||
// register a suspend/resume listener
|
// register a suspend/resume listener
|
||||||
let sr_cid = xous::connect(kbd_sid).expect("couldn't create suspend callback connection");
|
let self_cid = xous::connect(kbd_sid).expect("couldn't create suspend callback connection");
|
||||||
let mut susres = susres::Susres::new(&xns, Opcode::SuspendResume as u32, sr_cid).expect("couldn't create suspend/resume object");
|
let mut susres = susres::Susres::new(&xns, Opcode::SuspendResume as u32, self_cid).expect("couldn't create suspend/resume object");
|
||||||
|
|
||||||
|
// start a thread that can ping the keyboard loop when a key is held down
|
||||||
|
let ticktimer = ticktimer_server::Ticktimer::new().unwrap();
|
||||||
|
|
||||||
let mut listener_conn: Option<CID> = None;
|
let mut listener_conn: Option<CID> = None;
|
||||||
let mut listener_op: Option<usize> = None;
|
let mut listener_op: Option<usize> = None;
|
||||||
|
|
@ -899,6 +908,15 @@ fn xmain() -> ! {
|
||||||
)
|
)
|
||||||
).expect("couldn't send key codes to listener");
|
).expect("couldn't send key codes to listener");
|
||||||
}
|
}
|
||||||
|
// as long as we have a keydown, keep pinging the loop at a high rate. this consumes more power, but keydowns are relatively rare.
|
||||||
|
if kbd.is_repeating_key() {
|
||||||
|
log::info!("keydowns hold");
|
||||||
|
// fire a second call to check if we should transition to a repeating state
|
||||||
|
ticktimer.sleep_ms(kbd.get_repeat_check_interval() as _).unwrap();
|
||||||
|
xous::send_message(self_cid,
|
||||||
|
xous::Message::new_scalar(Opcode::HandlerTrigger.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
|
).unwrap();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
None => {log::error!("couldn't convert opcode"); break}
|
None => {log::error!("couldn't convert opcode"); break}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue