auto reformat main.rs

This commit is contained in:
Travis Burtrum 2017-09-19 01:46:36 -04:00
parent 8f320174a1
commit 8b7ab9d036
1 changed files with 383 additions and 387 deletions

View File

@ -17,7 +17,7 @@ use std::collections::HashMap;
use std::process::{exit, Command};
use std::fs::File;
use std::io::{Read};
use std::io::Read;
use std::{env, mem};
use std::os::unix::io::AsRawFd;
@ -41,7 +41,6 @@ impl Config {
}
fn main() {
let key_map_config = parse_cfg("keymap.toml").expect("provided config cannot be found/parsed");
//println!("key_map_config: {:?}", key_map_config);
@ -86,7 +85,6 @@ fn main() {
} else {
device.write_event(event).expect("could not write event?");
}
}
}
@ -277,7 +275,6 @@ impl KeyMaps {
continue;
}
let v = v.split(",").map(|k| {
let ret: Box<KeyMapper> = if k.contains(HALF_KEY_SEPARATOR) {
let keys: Vec<&str> = k.split(HALF_KEY_SEPARATOR).collect();
if keys.len() != 2 {
@ -333,7 +330,8 @@ impl KeyMaps {
keymaps: keymaps,
keymap_index_keys: keymap_index_keys,
switch_layout_keys: config.switch_layout_keys.iter().map(|k| parse_key(key_map, k) as usize).collect(),
key_state: [false; KEY_MAX], // todo: detect key state? at least CAPSLOCK...
key_state: [false; KEY_MAX],
// todo: detect key state? at least CAPSLOCK...
revert_default_key: parse_key(key_map, &config.revert_default_key),
revert_keymap_index: config.revert_keymap_index,
chosen_keymap_index: config.default_keymap_index,
@ -388,7 +386,8 @@ impl KeyMaps {
const KEY_MAX: usize = 249;
struct KeyMap {
keymap: Vec<Box<KeyMapper>>,//[Box<KeyMapper>; KEY_MAX],
keymap: Vec<Box<KeyMapper>>,
//[Box<KeyMapper>; KEY_MAX],
}
impl KeyMap {
@ -649,7 +648,6 @@ impl KeyMap {
("WWAN", KEY_WWAN),
("RFKILL", KEY_RFKILL),
("MICMUTE", KEY_MICMUTE),
// below manual shortcuts
("PSCR", KEY_SYSRQ),
("SLCK", KEY_SCROLLLOCK),
@ -668,27 +666,22 @@ impl KeyMap {
("COMM", KEY_COMMA),
("DOT", KEY_DOT),
("SLSH", KEY_SLASH),
("CAPS", KEY_CAPSLOCK),
("LSFT", KEY_LEFTSHIFT),
("RSFT", KEY_RIGHTSHIFT),
("SPC", KEY_SPACE),
("APP", KEY_COMPOSE),
("LCTL", KEY_LEFTCTRL),
("RCTL", KEY_RIGHTCTRL),
("LALT", KEY_LEFTALT),
("RALT", KEY_RIGHTALT),
("LGUI", KEY_LEFTMETA),
("RGUI", KEY_RIGHTMETA),
("INS", KEY_INSERT),
("PGUP", KEY_PAGEUP),
("PGDN", KEY_PAGEDOWN),
("DEL", KEY_DELETE),
("RGHT", KEY_RIGHT),
("NLCK", KEY_NUMLOCK),
("PSLS", KEY_KPSLASH),
("PAST", KEY_KPASTERISK),
@ -706,7 +699,6 @@ impl KeyMap {
("P0", KEY_KP0),
("PDOT", KEY_KPDOT),
("PENT", KEY_KPENTER),
].iter().cloned().map(|(m, v)| (m, v as *const c_int)).collect()
}
@ -760,6 +752,7 @@ impl KeyMapper for u16 {
const NOOP: Noop = Noop {};
// nightly I hear... const BOX_NOOP : Box<KeyMapper> = Box::new(NOOP);
struct Noop {}
impl KeyMapper for Noop {
fn send_event(&mut self, key_state: &mut [bool], mut event: input_event, device: &Device) {
device.write_event(event).expect("could not write event?");
@ -767,9 +760,12 @@ impl KeyMapper for Noop {
}
struct HalfInvertedKey {
code: u16, // code this is describing
invert_shift: bool, // true to invert shift for this code
capslock_nomodify: bool, // true means capslock does not normally modify this, but you would like it to
code: u16,
// code this is describing
invert_shift: bool,
// true to invert shift for this code
capslock_nomodify: bool,
// true means capslock does not normally modify this, but you would like it to
}
impl HalfInvertedKey {