diff options
| author | Teddy Wing | 2018-10-30 03:12:44 +0100 |
|---|---|---|
| committer | Teddy Wing | 2018-10-30 03:12:44 +0100 |
| commit | 330d3a0a70b2587e8e05dcddcc7c7991f12c825b (patch) | |
| tree | 662249bfc2cee1628abf8b9c2fde2d3bc80158be | |
| parent | 7e0b19d4d962087b8c9be85c4f6bcd217ced7b71 (diff) | |
| download | dome-key-map-330d3a0a70b2587e8e05dcddcc7c7991f12c825b.tar.bz2 | |
parser::map_group(): Use default `MapGroup` as a base
This means that if any of `<Up>`, `<Play>`, or `<Down>` are undefined in
the mappings file definition, they will be set to their default action
values (as set in `MapGroup::default()`).
To get rid of the default, map the button trigger to `<Nop>`.
Update a test that didn't map `<Up>` to give it the default mapping.
| -rw-r--r-- | src/parser.rs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/parser.rs b/src/parser.rs index 8314e0d..62eea12 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -640,13 +640,12 @@ where { definitions() .map(|definitions| { - let mut maps = HashMap::new(); - let mut modes = HashMap::new(); + let mut map_group = MapGroup::default(); for definition in definitions { match definition { Definition::Map(map) => { - maps.insert( + map_group.maps.insert( map.trigger, MapAction { action: map.action, @@ -655,7 +654,7 @@ where ); }, Definition::Mode(mode) => { - modes.insert( + map_group.modes.insert( mode.trigger, mode.maps, ); @@ -663,10 +662,7 @@ where } } - MapGroup { - maps: maps, - modes: modes, - } + map_group }) } @@ -1244,6 +1240,18 @@ cmd <play> /usr/bin/say hello let mut mode_maps: MapCollection = HashMap::new(); maps.insert( + vec![HeadphoneButton::Up], + MapAction { + action: Action::Map( + vec![KeyboardKeyWithModifiers::new( + KeyboardKey::NXKey(key_code::NX_KEYTYPE_SOUND_UP), + vec![], + )] + ), + kind: MapKind::Map, + }, + ); + maps.insert( vec![HeadphoneButton::Down], MapAction { action: Action::String("/bin/echo nothing".to_owned()), |
