diff options
| author | Teddy Wing | 2018-10-30 00:15:38 +0100 |
|---|---|---|
| committer | Teddy Wing | 2018-10-30 03:07:07 +0100 |
| commit | 7e0b19d4d962087b8c9be85c4f6bcd217ced7b71 (patch) | |
| tree | add06c7266ad340da7454a70d86da05ce5fd472b /src/parser.rs | |
| parent | ce022122b89c2e9bee28963d37b54de0101ac4d1 (diff) | |
| download | dome-key-map-7e0b19d4d962087b8c9be85c4f6bcd217ced7b71.tar.bz2 | |
If no 'mappings.dkmap' file is found, use default mappings
If a mappings file is found but is empty, no mappings will be set. Hmm,
that sounds wrong. We still want to keep the defaults even if only some
button triggers are mapped. Making buttons do nothing is what `<Nop>` is
for, not this behaviour. Darn.
Diffstat (limited to 'src/parser.rs')
| -rw-r--r-- | src/parser.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/parser.rs b/src/parser.rs index fe56fca..8314e0d 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -203,6 +203,58 @@ impl MapGroup { } } +/// Default headphone button mappings: +/// +/// * Up → Volume up +/// * Middle → Play +/// * Down → Volume down +impl Default for MapGroup { + fn default() -> Self { + let mut default_maps: MapCollection = HashMap::new(); + default_maps.insert( + vec![HeadphoneButton::Up], + MapAction { + action: Action::Map( + vec![KeyboardKeyWithModifiers::new( + KeyboardKey::NXKey(key_code::NX_KEYTYPE_SOUND_UP), + vec![], + )] + ), + kind: MapKind::Map, + }, + ); + default_maps.insert( + vec![HeadphoneButton::Play], + MapAction { + action: Action::Map( + vec![KeyboardKeyWithModifiers::new( + KeyboardKey::NXKey(key_code::NX_KEYTYPE_PLAY), + vec![], + )] + ), + kind: MapKind::Map, + }, + ); + default_maps.insert( + vec![HeadphoneButton::Down], + MapAction { + action: Action::Map( + vec![KeyboardKeyWithModifiers::new( + KeyboardKey::NXKey(key_code::NX_KEYTYPE_SOUND_DOWN), + vec![], + )] + ), + kind: MapKind::Map, + }, + ); + + MapGroup { + maps: default_maps, + modes: HashMap::new(), + } + } +} + fn string_case_insensitive<I>( s: &'static str |
