Cygwin/X: Handle fake keypresses generated by speech recognizers
Apparently, fake keypresses generated by speech recognizers may not bother with a scan code, so look up what scan code corresponds to the virtual key code if this occurs. Patch by Paul Loewenstein <paul.loewenstein@gmail.com> Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
parent
0866322b57
commit
35901ece6a
|
@ -73,10 +73,31 @@ winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode)
|
||||||
{
|
{
|
||||||
int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
|
int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
|
||||||
int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
|
int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
|
||||||
int iParamScanCode = LOBYTE (HIWORD (lParam));
|
int iParam = HIWORD (lParam);
|
||||||
|
int iParamScanCode = LOBYTE (iParam);
|
||||||
|
|
||||||
|
/* WM_ key messages faked by Vista speech recognition (WSR) don't have a
|
||||||
|
* scan code.
|
||||||
|
*
|
||||||
|
* Vocola 3 (Rick Mohr's supplement to WSR) uses
|
||||||
|
* System.Windows.Forms.SendKeys.SendWait(), which appears always to give a
|
||||||
|
* scan code of 1
|
||||||
|
*/
|
||||||
|
if (iParamScanCode <= 1)
|
||||||
|
{
|
||||||
|
if (VK_PRIOR <= wParam && wParam <= VK_DOWN)
|
||||||
|
/* Trigger special case table to translate to extended
|
||||||
|
* keycode, otherwise if num_lock is on, we can get keypad
|
||||||
|
* numbers instead of navigation keys. */
|
||||||
|
iParam |= KF_EXTENDED;
|
||||||
|
else
|
||||||
|
iParamScanCode = MapVirtualKeyEx(wParam,
|
||||||
|
/*MAPVK_VK_TO_VSC*/0,
|
||||||
|
GetKeyboardLayout(0));
|
||||||
|
}
|
||||||
|
|
||||||
/* Branch on special extended, special non-extended, or normal key */
|
/* Branch on special extended, special non-extended, or normal key */
|
||||||
if ((HIWORD (lParam) & KF_EXTENDED) && iKeyFixupEx)
|
if ((iParam & KF_EXTENDED) && iKeyFixupEx)
|
||||||
*piScanCode = iKeyFixupEx;
|
*piScanCode = iKeyFixupEx;
|
||||||
else if (iKeyFixup)
|
else if (iKeyFixup)
|
||||||
*piScanCode = iKeyFixup;
|
*piScanCode = iKeyFixup;
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
|
|
||||||
#define WIN_KEYMAP_COLS 3
|
#define WIN_KEYMAP_COLS 3
|
||||||
|
|
||||||
|
/* Rows 160 through 165 correspond to software-generated codes, which
|
||||||
|
* may not be associated with the appropriate scan code.
|
||||||
|
*/
|
||||||
const int
|
const int
|
||||||
g_iKeyMap [] = {
|
g_iKeyMap [] = {
|
||||||
/* count Windows VK, ASCII, ASCII when extended VK */
|
/* count Windows VK, ASCII, ASCII when extended VK */
|
||||||
|
@ -208,12 +211,12 @@ g_iKeyMap [] = {
|
||||||
/* 157 */ 0, 0, 0,
|
/* 157 */ 0, 0, 0,
|
||||||
/* 158 */ 0, 0, 0,
|
/* 158 */ 0, 0, 0,
|
||||||
/* 159 */ 0, 0, 0,
|
/* 159 */ 0, 0, 0,
|
||||||
/* 160 */ 0, 0, 0,
|
/* 160 */ VK_LSHIFT, KEY_ShiftL, 0,
|
||||||
/* 161 */ 0, 0, 0,
|
/* 161 */ VK_RSHIFT, KEY_ShiftR, 0,
|
||||||
/* 162 */ 0, 0, 0,
|
/* 162 */ VK_LCONTROL, KEY_LCtrl, 0,
|
||||||
/* 163 */ 0, 0, 0,
|
/* 163 */ VK_RCONTROL, KEY_RCtrl, 0,
|
||||||
/* 164 */ 0, 0, 0,
|
/* 164 */ VK_LMENU, KEY_Alt, 0,
|
||||||
/* 165 */ 0, 0, 0,
|
/* 165 */ VK_RMENU, KEY_AltLang, 0,
|
||||||
/* 166 */ 0, 0, 0,
|
/* 166 */ 0, 0, 0,
|
||||||
/* 167 */ 0, 0, 0,
|
/* 167 */ 0, 0, 0,
|
||||||
/* 168 */ 0, 0, 0,
|
/* 168 */ 0, 0, 0,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user