You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

50 lines
1.5 KiB

  1. extern crate phf_codegen;
  2. use std::env;
  3. use std::fs::File;
  4. use std::io::{BufWriter, Write};
  5. use std::path::Path;
  6. fn main() {
  7. if cfg!(target_os = "windows") {
  8. println!("cargo:rustc-link-search=native=C:\\msys64\\mingw64\\lib");
  9. }
  10. let path = Path::new(&env::var("OUT_DIR").unwrap()).join("key_map_table.rs");
  11. let mut file = BufWriter::new(File::create(&path).unwrap());
  12. write!(&mut file, "static KEYVAL_MAP: phf::Map<&'static str, &'static str> = ").unwrap();
  13. phf_codegen::Map::new()
  14. .entry("F1", "\"F1\"")
  15. .entry("F2", "\"F2\"")
  16. .entry("F3", "\"F3\"")
  17. .entry("F4", "\"F4\"")
  18. .entry("F5", "\"F5\"")
  19. .entry("F6", "\"F6\"")
  20. .entry("F7", "\"F7\"")
  21. .entry("F8", "\"F8\"")
  22. .entry("F9", "\"F9\"")
  23. .entry("F10", "\"F10\"")
  24. .entry("F11", "\"F11\"")
  25. .entry("F12", "\"F12\"")
  26. .entry("Left", "\"Left\"")
  27. .entry("Right", "\"Right\"")
  28. .entry("Up", "\"Up\"")
  29. .entry("Down", "\"Down\"")
  30. .entry("Home", "\"Home\"")
  31. .entry("End", "\"End\"")
  32. .entry("BackSpace", "\"BS\"")
  33. .entry("Return", "\"CR\"")
  34. .entry("Escape", "\"Esc\"")
  35. .entry("Delete", "\"Del\"")
  36. .entry("Insert", "\"Insert\"")
  37. .entry("Page_Up", "\"PageUp\"")
  38. .entry("Page_Down", "\"PageDown\"")
  39. .entry("Enter", "\"CR\"")
  40. .entry("Tab", "\"Tab\"")
  41. .entry("ISO_Left_Tab", "\"Tab\"")
  42. .build(&mut file)
  43. .unwrap();
  44. write!(&mut file, ";\n").unwrap();
  45. }