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/ffi.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/ffi.rs')
| -rw-r--r-- | src/ffi.rs | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -50,13 +50,13 @@ pub extern "C" fn dome_key_state_free(ptr: *mut State) { pub extern "C" fn dome_key_state_load_map_group(ptr: *mut State) { match xdg::BaseDirectories::with_prefix("dome-key") { Ok(xdg_dirs) => { + let state = unsafe { + assert!(!ptr.is_null()); + &mut *ptr + }; + match xdg_dirs.find_config_file("mappings.dkmap") { Some(mapping_file) => { - let state = unsafe { - assert!(!ptr.is_null()); - &mut *ptr - }; - let dkmap = fs::read_to_string(mapping_file) .expect("Failed to read 'mappings.dkmap'"); @@ -67,10 +67,13 @@ pub extern "C" fn dome_key_state_load_map_group(ptr: *mut State) { state.map_group = Some(map_group); }, None => { + state.map_group = Some(MapGroup::default()); + match xdg_dirs.get_config_home().to_str() { Some(config_home) => { error!( - "No mapping file found at '{}{}'", + "No mapping file found at '{}{}'. + Using default mappings.", config_home, "mappings.dkmap" ) |
