core: button: add supported keys querying to keyboard trait
This commit is contained in:
parent
d3a17813c0
commit
adf71ed2c8
2 changed files with 10 additions and 0 deletions
|
|
@ -107,6 +107,8 @@ struct Press {
|
|||
const PRESSES_MAX: usize = 64;
|
||||
|
||||
pub trait Keyboard {
|
||||
fn key_supported(&self, sym: Keysym) -> bool;
|
||||
|
||||
fn press(&mut self, sym: Keysym);
|
||||
fn release(&mut self, sym: Keysym);
|
||||
fn change_layout(&mut self, layout: &Layout);
|
||||
|
|
|
|||
|
|
@ -89,6 +89,14 @@ impl VirtualKeyboard {
|
|||
}
|
||||
|
||||
impl Keyboard for VirtualKeyboard {
|
||||
fn key_supported(&self, sym: Keysym) -> bool
|
||||
{
|
||||
match sym.name() {
|
||||
Some(n) => n.starts_with("XK_"),
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn press(&mut self, sym: Keysym)
|
||||
{
|
||||
if sym == Keysym::NoSymbol || sym == Keysym::XF86_Fn {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue