The XWin server uses primarily hardware scan codes for interpreting the
windows WM_KEYDOWN and WM_SYSKEYDOWN messages. Unfortunately, Vista
speech recognition (WSR) doesn't bother to fill in the scancode field in
the lParam entry. Neither does SendKeys.SendWait(), which is what
Vocola 3, a recently released supplement to WSR, uses to send input to
applications.
To work around these Microsoft bugs, I modified winkeybd.c as follows:
void
winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode)
{
int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
int iParamScanCode = LOBYTE (HIWORD (lParam));
to
void
winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode)
{
HKL dwhkl = GetKeyboardLayout(0);
int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
int iParamScanCode = MapVirtualKeyEx (wParam,
/*MAPVK_VK_TO_VSC*/0, dwhkl);
so that the scan code is regenerated from the keycode.
An initial test appears to work. However, it is not clear to me whether
I have introduced some subtle bugs. For example, its correctness depends
on extended codes having the same scan code as the non-extended
equivalent on all keyboard layouts.
Can someone tell me if I've broken anything? Or suggest a more robust
fix? It would be nice to be able to release it rather than having a
privately distributed modification solely for Vista speech recognition.
Paul
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ: http://x.cygwin.com/docs/faq/