Skip to content

Commit

Permalink
fix(DBus): add support for translating keyboard input to dbus input
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Mar 13, 2024
1 parent 2d57b96 commit 9c5d005
Showing 1 changed file with 163 additions and 3 deletions.
166 changes: 163 additions & 3 deletions src/input/event/dbus.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::input::capability::{Capability, Gamepad, GamepadAxis, GamepadButton};
use crate::input::capability::{Capability, Gamepad, GamepadAxis, GamepadButton, Keyboard};

use super::native::{InputValue, NativeEvent};

Expand Down Expand Up @@ -178,8 +178,168 @@ fn actions_from_capability(capability: Capability) -> Vec<Action> {
_ => vec![Action::None],
},
Capability::Mouse(_) => vec![Action::None],
// TODO: Handle keyboard translation
Capability::Keyboard(_) => vec![Action::None],
Capability::Keyboard(key) => match key {
Keyboard::KeyEsc => vec![Action::Back],
Keyboard::Key1 => vec![Action::None],
Keyboard::Key2 => vec![Action::None],
Keyboard::Key3 => vec![Action::None],
Keyboard::Key4 => vec![Action::None],
Keyboard::Key5 => vec![Action::None],
Keyboard::Key6 => vec![Action::None],
Keyboard::Key7 => vec![Action::None],
Keyboard::Key8 => vec![Action::None],
Keyboard::Key9 => vec![Action::None],
Keyboard::Key0 => vec![Action::None],
Keyboard::KeyMinus => vec![Action::None],
Keyboard::KeyEqual => vec![Action::None],
Keyboard::KeyBackspace => vec![Action::Back],
Keyboard::KeyTab => vec![Action::None],
Keyboard::KeyQ => vec![Action::None],
Keyboard::KeyW => vec![Action::None],
Keyboard::KeyE => vec![Action::None],
Keyboard::KeyR => vec![Action::None],
Keyboard::KeyT => vec![Action::None],
Keyboard::KeyY => vec![Action::None],
Keyboard::KeyU => vec![Action::None],
Keyboard::KeyI => vec![Action::None],
Keyboard::KeyO => vec![Action::None],
Keyboard::KeyP => vec![Action::None],
Keyboard::KeyLeftBrace => vec![Action::None],
Keyboard::KeyRightBrace => vec![Action::None],
Keyboard::KeyEnter => vec![Action::Accept],
Keyboard::KeyLeftCtrl => vec![Action::None],
Keyboard::KeyA => vec![Action::None],
Keyboard::KeyS => vec![Action::None],
Keyboard::KeyD => vec![Action::None],
Keyboard::KeyF => vec![Action::None],
Keyboard::KeyG => vec![Action::None],
Keyboard::KeyH => vec![Action::None],
Keyboard::KeyJ => vec![Action::None],
Keyboard::KeyK => vec![Action::None],
Keyboard::KeyL => vec![Action::None],
Keyboard::KeySemicolon => vec![Action::None],
Keyboard::KeyApostrophe => vec![Action::None],
Keyboard::KeyGrave => vec![Action::None],
Keyboard::KeyLeftShift => vec![Action::None],
Keyboard::KeyBackslash => vec![Action::None],
Keyboard::KeyZ => vec![Action::None],
Keyboard::KeyX => vec![Action::None],
Keyboard::KeyC => vec![Action::None],
Keyboard::KeyV => vec![Action::None],
Keyboard::KeyB => vec![Action::None],
Keyboard::KeyN => vec![Action::None],
Keyboard::KeyM => vec![Action::None],
Keyboard::KeyComma => vec![Action::None],
Keyboard::KeyDot => vec![Action::None],
Keyboard::KeySlash => vec![Action::None],
Keyboard::KeyRightShift => vec![Action::None],
Keyboard::KeyKpAsterisk => vec![Action::None],
Keyboard::KeyLeftAlt => vec![Action::None],
Keyboard::KeySpace => vec![Action::None],
Keyboard::KeyCapslock => vec![Action::None],
Keyboard::KeyF1 => vec![Action::None],
Keyboard::KeyF2 => vec![Action::None],
Keyboard::KeyF3 => vec![Action::None],
Keyboard::KeyF4 => vec![Action::None],
Keyboard::KeyF5 => vec![Action::None],
Keyboard::KeyF6 => vec![Action::None],
Keyboard::KeyF7 => vec![Action::None],
Keyboard::KeyF8 => vec![Action::None],
Keyboard::KeyF9 => vec![Action::None],
Keyboard::KeyF10 => vec![Action::None],
Keyboard::KeyNumlock => vec![Action::None],
Keyboard::KeyScrollLock => vec![Action::None],
Keyboard::KeyKp7 => vec![Action::None],
Keyboard::KeyKp8 => vec![Action::None],
Keyboard::KeyKp9 => vec![Action::None],
Keyboard::KeyKpMinus => vec![Action::None],
Keyboard::KeyKp4 => vec![Action::None],
Keyboard::KeyKp5 => vec![Action::None],
Keyboard::KeyKp6 => vec![Action::None],
Keyboard::KeyKpPlus => vec![Action::None],
Keyboard::KeyKp1 => vec![Action::None],
Keyboard::KeyKp2 => vec![Action::None],
Keyboard::KeyKp3 => vec![Action::None],
Keyboard::KeyKp0 => vec![Action::None],
Keyboard::KeyKpDot => vec![Action::None],
Keyboard::KeyZenkakuhankaku => vec![Action::None],
Keyboard::Key102nd => vec![Action::None],
Keyboard::KeyF11 => vec![Action::None],
Keyboard::KeyF12 => vec![Action::None],
Keyboard::KeyRo => vec![Action::None],
Keyboard::KeyKatakana => vec![Action::None],
Keyboard::KeyHiragana => vec![Action::None],
Keyboard::KeyHenkan => vec![Action::None],
Keyboard::KeyKatakanaHiragana => vec![Action::None],
Keyboard::KeyMuhenkan => vec![Action::None],
Keyboard::KeyKpJpComma => vec![Action::None],
Keyboard::KeyKpEnter => vec![Action::None],
Keyboard::KeyRightCtrl => vec![Action::None],
Keyboard::KeyKpSlash => vec![Action::None],
Keyboard::KeySysrq => vec![Action::None],
Keyboard::KeyRightAlt => vec![Action::None],
Keyboard::KeyHome => vec![Action::None],
Keyboard::KeyUp => vec![Action::Up],
Keyboard::KeyPageUp => vec![Action::None],
Keyboard::KeyLeft => vec![Action::Left],
Keyboard::KeyRight => vec![Action::Right],
Keyboard::KeyEnd => vec![Action::None],
Keyboard::KeyDown => vec![Action::Down],
Keyboard::KeyPageDown => vec![Action::None],
Keyboard::KeyInsert => vec![Action::None],
Keyboard::KeyDelete => vec![Action::None],
Keyboard::KeyMute => vec![Action::None],
Keyboard::KeyVolumeDown => vec![Action::None],
Keyboard::KeyVolumeUp => vec![Action::None],
Keyboard::KeyPower => vec![Action::None],
Keyboard::KeyKpEqual => vec![Action::None],
Keyboard::KeyPause => vec![Action::None],
Keyboard::KeyKpComma => vec![Action::None],
Keyboard::KeyHanja => vec![Action::None],
Keyboard::KeyYen => vec![Action::None],
Keyboard::KeyLeftMeta => vec![Action::Guide],
Keyboard::KeyRightMeta => vec![Action::Guide],
Keyboard::KeyCompose => vec![Action::None],
Keyboard::KeyStop => vec![Action::None],
Keyboard::KeyAgain => vec![Action::None],
Keyboard::KeyProps => vec![Action::None],
Keyboard::KeyUndo => vec![Action::None],
Keyboard::KeyFront => vec![Action::None],
Keyboard::KeyCopy => vec![Action::None],
Keyboard::KeyOpen => vec![Action::None],
Keyboard::KeyPaste => vec![Action::None],
Keyboard::KeyFind => vec![Action::None],
Keyboard::KeyCut => vec![Action::None],
Keyboard::KeyHelp => vec![Action::None],
Keyboard::KeyCalc => vec![Action::None],
Keyboard::KeySleep => vec![Action::None],
Keyboard::KeyWww => vec![Action::None],
Keyboard::KeyBack => vec![Action::None],
Keyboard::KeyForward => vec![Action::None],
Keyboard::KeyEjectCD => vec![Action::None],
Keyboard::KeyNextSong => vec![Action::None],
Keyboard::KeyPlayPause => vec![Action::None],
Keyboard::KeyPreviousSong => vec![Action::None],
Keyboard::KeyStopCD => vec![Action::None],
Keyboard::KeyRefresh => vec![Action::None],
Keyboard::KeyEdit => vec![Action::None],
Keyboard::KeyScrollUp => vec![Action::None],
Keyboard::KeyScrollDown => vec![Action::None],
Keyboard::KeyKpLeftParen => vec![Action::None],
Keyboard::KeyKpRightParen => vec![Action::None],
Keyboard::KeyF13 => vec![Action::None],
Keyboard::KeyF14 => vec![Action::None],
Keyboard::KeyF15 => vec![Action::None],
Keyboard::KeyF16 => vec![Action::None],
Keyboard::KeyF17 => vec![Action::None],
Keyboard::KeyF18 => vec![Action::None],
Keyboard::KeyF19 => vec![Action::None],
Keyboard::KeyF20 => vec![Action::None],
Keyboard::KeyF21 => vec![Action::None],
Keyboard::KeyF22 => vec![Action::None],
Keyboard::KeyF23 => vec![Action::None],
Keyboard::KeyF24 => vec![Action::None],
},
}
}

Expand Down

0 comments on commit 9c5d005

Please sign in to comment.