Fixed panic on windows when tabbing into WindowsSandbox (Fixes #363)#421
Fixed panic on windows when tabbing into WindowsSandbox (Fixes #363)#421CryZe merged 3 commits intoLiveSplit:masterfrom Splamy:master
Conversation
|
Wow, thank you for doing this. Are you sure it makes sense to map this as a "valid key" rather than "ignoring" it? The Windows documentation states that only values from 1 to 254 are valid. It's also not part of their enum: https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes Also I'm not sure if I like the additional dependency. I recently wanted to remove dependencies that do very little for us, and these dependencies certainly would fall under that same category. |
|
Sure, I can understand that. I just edited my top post to add my note but that probably didn't reach you in time :P |
|
Yeah I'd prefer that tbh. |
|
Alright I canged it. |
So I took matters into my own hands and fixed the crash I reported in #363 :P
According to this SO post windows may send 0xFF as virtual key code is some edgecases or when a key isn't mapped to a VK.
And apparently switching focus into the windows sandbox is one of them.
Anyway, adding
Unmapped = 0xFF,is sufficient to fix the crash because rust apparently didn't like the transmute to a nonexistant enum value.But for good measure I also added
num-traits/num-deriveto safely map numbers back to enum values. I don't think this shouldn't have any significant negative runtime impact, though I haven't tested it. If you don't like the change I can also remove it entirely.An alternative fix without additional libraries or the extra enum field would be to just check if
key_code <= 0xFE, but it kinda feels wrong since windows being windows might still send undeclared vk values...