https://github.com/pentamassiv/input_event_codes_hashmap
Hashmaps to look up the u32 value for a given input event code
https://github.com/pentamassiv/input_event_codes_hashmap
Last synced: 2 months ago
JSON representation
Hashmaps to look up the u32 value for a given input event code
- Host: GitHub
- URL: https://github.com/pentamassiv/input_event_codes_hashmap
- Owner: pentamassiv
- Created: 2020-09-05T21:10:12.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-13T21:48:34.000Z (over 4 years ago)
- Last Synced: 2024-10-16T15:31:02.528Z (8 months ago)
- Language: Rust
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://crates.io/crates/input_event_codes_hashmap)
[](https://deps.rs/repo/github/grelltrier/input_event_codes_hashmap)
# input_event_codes_hashmap
This crate provides HashMaps to look up the u32 value for a given input event code. The lazy-static crate is used so they are only created, if you used them.
The codes are taken from input-event-codes.h.## Usage
There are the HashMaps ABS, BTN, EV, INPUT_PROP, KEY, LED, MSC, REL, REP, SND, SW and SYN. The prefix tells you which HashMap to use.
If you are looking for KEY_T, you want to search in the KEY HashMap for "T". No need to repeat the prefix. There is an example on how to find the u32 value for KEY_T.
It's as easy as:
```Rust
use input_event_codes_hashmap::KEY;fn main() {
let keycode_name = "T";
if let Some(keycode_value) = KEY.get(keycode_name) {
println!("The u32 value for {} is {}", keycode_name, keycode_value);
} else {
println!("The u32 value could not be found");
}
}
```
You can run the example by entering the following command:
```bash
cargo run --example example
```## Contributing
PRs are always welcome! If I made a mistake please tell me as well :)