dictation-toolbox / dragonfly

Speech recognition framework allowing powerful Python-based scripting and extension of Dragon NaturallySpeaking (DNS), Windows Speech Recognition (WSR), Kaldi and CMU Pocket Sphinx
GNU Lesser General Public License v3.0
383 stars 75 forks source link

Having numlock on changes keypresses in dragonfly2 `0.32.0` #350

Closed LexiconCode closed 3 years ago

LexiconCode commented 3 years ago

Having numlock on Key("del") emulates . instead of the delete key in dragonfly2 0.32.0. The same issue is not present in 0.31.2

Other keys are affected but I'll need to research.

drmfinlay commented 3 years ago

Thank you for opening this issue. I'm fairly certain I know what is causing the problem and will fix it in the next patch version.

drmfinlay commented 3 years ago

Thank you very much for noting this issue wasn't present in 0.31.2, @LexiconCode! I see now that the issue is related to use of the KEYEVENTF_EXTENDEDKEY flag, which Microsoft appears to be documenting somewhat incorrectly.

This flag is mentioned here, for instance, where the "scan code was preceded by a prefix byte having the value 0xE0 (224)". However, the scan codes for certain keys (e.g. the Up arrow key) do not have the prefix byte when retrieved via MapVirtualKeyExW(). This would be because this is an older use of the flag preceding the introduction of 0xE0 and 0xE1 prefix bytes in Windows Vista. For that older use, whether using scancodes or virtual-key codes, the keys require this flag for our use case. Quite confusing!

Anyway, I'll fix the problem in PR #352 by restoring the hard-coded list of extended keys of the older type.

LexiconCode commented 3 years ago

I think confusing is an understatement. Yuck.

drmfinlay commented 3 years ago

For sure. The documentation just needs to be clearer, really. A sentence or two in all relevant Remarks sections would be enough. 🤷