Skip to content

Commit

Permalink
Handling case when scancode map doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
aQaTL committed Jan 13, 2019
1 parent 721952a commit 0bb9818
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kb_remapper"
version = "0.1.0"
version = "0.1.1"
edition = "2018"
authors = ["aQaTL <mmsoltys@outlook.com>"]

Expand Down
5 changes: 4 additions & 1 deletion src/keyboard/scancode_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ type KeyMapping = (Option<Key>, Option<Key>);
pub fn load_key_mappings() -> Result<Vec<KeyMapping>, Error> {
let hklm = RegKey::predef(winreg::enums::HKEY_LOCAL_MACHINE);
let keyboard_layout = hklm.open_subkey(r"SYSTEM\CurrentControlSet\Control\Keyboard Layout")?;
let scancode_map = keyboard_layout.get_raw_value("Scancode Map")?.bytes;
let scancode_map = match keyboard_layout.get_raw_value("Scancode Map") {
Ok(value) => value.bytes,
Err(_) => return Ok(vec![]),
};

let mut rdr = std::io::Cursor::new(scancode_map);
rdr.set_position(4 * 2); //Skips version and flag headers
Expand Down

0 comments on commit 0bb9818

Please sign in to comment.