winput icon indicating copy to clipboard operation
winput copied to clipboard

Issue 10: support for safe conversion of `u8` into `Vk`

Open kzagar opened this issue 1 year ago • 0 comments

Two functions are added to Vk: is_valid, that determines wheter a given u8 value is safe to convert to Vk enum, and from_u8_safe that converts an u8 to an Option<Vk>.

For efficient implementation, a lazily-initialized static array is used (using lazy_static), with bools corresponding to whether a given u8 value (index in the array) is a valid Virtual Key. strum crate's EnumIter derive is used to allow iteration over an enum.

kzagar avatar Jan 30 '24 20:01 kzagar