I noticed a couple of interface issues with Keycode::from_scancode that render it an insufficient interface over SDL_GetKeyFromScancode:
First, modstate uses the sys struct SDL_Keymod. This requires translations when trying to account for modifier keys in events, which use the keyboard::Mod struct. That said, the second issue renders that a bit moot: when key_event is true, it will only return Some for defined Keycode values. When providing a modstate with key_event set to false, the function is meant to be able to return both upper and lowercase letters, for example.
To replicate the original function, Keycode may need to be closer to SDL_Keycode, being a tuple struct with u32 instead of an enum.
I noticed a couple of interface issues with
Keycode::from_scancodethat render it an insufficient interface overSDL_GetKeyFromScancode:First,
modstateuses thesysstructSDL_Keymod. This requires translations when trying to account for modifier keys in events, which use thekeyboard::Modstruct. That said, the second issue renders that a bit moot: whenkey_eventistrue, it will only returnSomefor definedKeycodevalues. When providing amodstatewithkey_eventset tofalse, the function is meant to be able to return both upper and lowercase letters, for example.To replicate the original function,
Keycodemay need to be closer toSDL_Keycode, being a tuple struct withu32instead of anenum.