Closed drmfinlay closed 3 years ago
@daanzu This might have fixed that weird bug (#182). If it didn't, then I can't see what else could be causing it. The input code is significantly more reliable now in any case.
I can say that this does fix a similar bug that occurs for me if I use my Dvorak keyboard layout and Dragonfly in 64-bit Python, which is what Kaldi requires.
@Versatilus Just FYI, this removes the soft keys code you added into sendinput.py
a little while ago. I have tested the SOFT_KEYS
set with the MapVirtualKey()
function and it returns 0 (meaning no scan code translation) for most of those keys. I assume the exceptions are due to layout/locale differences between us.
I'm happy to add it back in if this breaks something for you, but I'm pretty sure it will work fine.
This PR fixes a few bugs with the Windows keyboard input code and cleans it up a bit. The changes are as follows:
KeyboardInput
struct to only translate virtual keycodes to scan codes when necessary (in__init__
).MapVirtualKey
/MapVirtualKeyEx
function instead, which returns 0 for virtual keycodes that don't have corresponding scancodes.KeyboardInput
struct insendinput.py
now falls back on the virtual-key code if there is no equivalent scan code available. This is not done if the virtual keycode is 0 (forKEYEVENTF_UNICODE
mode).These changes fix bugs that occur with different keyboard layouts and should make this implementation more reliable.