Josh DuBois : wineandroid: Implement GetKeyNameText.
Alexandre Julliard
julliard at winehq.org
Fri Jun 9 12:43:58 CDT 2017
Module: wine
Branch: master
Commit: 86534e0dd55d972b35ccecf2e9a2b3f53059d3a6
URL: http://source.winehq.org/git/wine.git/?a=commit;h=86534e0dd55d972b35ccecf2e9a2b3f53059d3a6
Author: Josh DuBois <duboisj at codeweavers.com>
Date: Fri Jun 9 09:19:42 2017 +0200
wineandroid: Implement GetKeyNameText.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wineandroid.drv/keyboard.c | 172 ++++++++++++++++++++++++++++++
dlls/wineandroid.drv/wineandroid.drv.spec | 1 +
2 files changed, 173 insertions(+)
diff --git a/dlls/wineandroid.drv/keyboard.c b/dlls/wineandroid.drv/keyboard.c
index b3ac76f..9afb73a 100644
--- a/dlls/wineandroid.drv/keyboard.c
+++ b/dlls/wineandroid.drv/keyboard.c
@@ -522,6 +522,118 @@ static const WORD vkey_to_scancode[] =
0, /* 0xff undefined */
};
+static const struct
+{
+ DWORD vkey;
+ const char *name;
+} vkey_names[] = {
+ { VK_ADD, "Num +" },
+ { VK_BACK, "Backspace" },
+ { VK_CAPITAL, "Caps Lock" },
+ { VK_CONTROL, "Ctrl" },
+ { VK_DECIMAL, "Num Del" },
+ { VK_DELETE | 0x100, "Delete" },
+ { VK_DIVIDE | 0x100, "Num /" },
+ { VK_DOWN | 0x100, "Down" },
+ { VK_END | 0x100, "End" },
+ { VK_ESCAPE, "Esc" },
+ { VK_F1, "F1" },
+ { VK_F2, "F2" },
+ { VK_F3, "F3" },
+ { VK_F4, "F4" },
+ { VK_F5, "F5" },
+ { VK_F6, "F6" },
+ { VK_F7, "F7" },
+ { VK_F8, "F8" },
+ { VK_F9, "F9" },
+ { VK_F10, "F10" },
+ { VK_F11, "F11" },
+ { VK_F12, "F12" },
+ { VK_F13, "F13" },
+ { VK_F14, "F14" },
+ { VK_F15, "F15" },
+ { VK_F16, "F16" },
+ { VK_F17, "F17" },
+ { VK_F18, "F18" },
+ { VK_F19, "F19" },
+ { VK_F20, "F20" },
+ { VK_F21, "F21" },
+ { VK_F22, "F22" },
+ { VK_F23, "F23" },
+ { VK_F24, "F24" },
+ { VK_HELP | 0x100, "Help" },
+ { VK_HOME | 0x100, "Home" },
+ { VK_INSERT | 0x100, "Insert" },
+ { VK_LCONTROL, "Ctrl" },
+ { VK_LEFT | 0x100, "Left" },
+ { VK_LMENU, "Alt" },
+ { VK_LSHIFT, "Shift" },
+ { VK_LWIN | 0x100, "Win" },
+ { VK_MENU, "Alt" },
+ { VK_MULTIPLY, "Num *" },
+ { VK_NEXT | 0x100, "Page Down" },
+ { VK_NUMLOCK | 0x100, "Num Lock" },
+ { VK_NUMPAD0, "Num 0" },
+ { VK_NUMPAD1, "Num 1" },
+ { VK_NUMPAD2, "Num 2" },
+ { VK_NUMPAD3, "Num 3" },
+ { VK_NUMPAD4, "Num 4" },
+ { VK_NUMPAD5, "Num 5" },
+ { VK_NUMPAD6, "Num 6" },
+ { VK_NUMPAD7, "Num 7" },
+ { VK_NUMPAD8, "Num 8" },
+ { VK_NUMPAD9, "Num 9" },
+ { VK_OEM_CLEAR, "Num Clear" },
+ { VK_OEM_NEC_EQUAL | 0x100, "Num =" },
+ { VK_PRIOR | 0x100, "Page Up" },
+ { VK_RCONTROL | 0x100, "Right Ctrl" },
+ { VK_RETURN, "Return" },
+ { VK_RETURN | 0x100, "Num Enter" },
+ { VK_RIGHT | 0x100, "Right" },
+ { VK_RMENU | 0x100, "Right Alt" },
+ { VK_RSHIFT, "Right Shift" },
+ { VK_RWIN | 0x100, "Right Win" },
+ { VK_SEPARATOR, "Num ," },
+ { VK_SHIFT, "Shift" },
+ { VK_SPACE, "Space" },
+ { VK_SUBTRACT, "Num -" },
+ { VK_TAB, "Tab" },
+ { VK_UP | 0x100, "Up" },
+ { VK_VOLUME_DOWN | 0x100, "Volume Down" },
+ { VK_VOLUME_MUTE | 0x100, "Mute" },
+ { VK_VOLUME_UP | 0x100, "Volume Up" },
+ { VK_OEM_MINUS, "-" },
+ { VK_OEM_PLUS, "=" },
+ { VK_OEM_1, ";" },
+ { VK_OEM_2, "/" },
+ { VK_OEM_3, "`" },
+ { VK_OEM_4, "[" },
+ { VK_OEM_5, "\\" },
+ { VK_OEM_6, "]" },
+ { VK_OEM_7, "'" },
+ { VK_OEM_COMMA, "," },
+ { VK_OEM_PERIOD, "." },
+};
+
+static UINT scancode_to_vkey( UINT scan )
+{
+ UINT j;
+
+ for (j = 0; j < sizeof(vkey_to_scancode)/sizeof(vkey_to_scancode[0]); j++)
+ if (vkey_to_scancode[j] == scan)
+ return j;
+ return 0;
+}
+
+static const char* vkey_to_name( UINT vkey )
+{
+ UINT j;
+
+ for (j = 0; j < sizeof(vkey_names)/sizeof(vkey_names[0]); j++)
+ if (vkey_names[j].vkey == vkey)
+ return vkey_names[j].name;
+ return NULL;
+}
/***********************************************************************
* keyboard_event
@@ -649,3 +761,63 @@ INT CDECL ANDROID_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state,
TRACE( "returning %d / %s\n", strlenW( buffer ), debugstr_wn(buf, strlenW( buffer )));
return strlenW( buffer );
}
+
+
+/***********************************************************************
+ * ANDROID_GetKeyNameText
+ */
+INT CDECL ANDROID_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
+{
+ int scancode, vkey, len;
+ const char *name;
+ char key[2];
+
+ scancode = (lparam >> 16) & 0x1FF;
+ vkey = scancode_to_vkey( scancode );
+
+ if (lparam & (1 << 25))
+ {
+ /* Caller doesn't care about distinctions between left and
+ right keys. */
+ switch (vkey)
+ {
+ case VK_LSHIFT:
+ case VK_RSHIFT:
+ vkey = VK_SHIFT; break;
+ case VK_LCONTROL:
+ case VK_RCONTROL:
+ vkey = VK_CONTROL; break;
+ case VK_LMENU:
+ case VK_RMENU:
+ vkey = VK_MENU; break;
+ }
+ }
+
+ if (scancode & 0x100) vkey |= 0x100;
+
+ if ((vkey >= 0x30 && vkey <= 0x39) || (vkey >= 0x41 && vkey <= 0x5a))
+ {
+ key[0] = vkey;
+ if (vkey >= 0x41)
+ key[0] += 0x20;
+ key[1] = 0;
+ name = key;
+ }
+ else
+ {
+ name = vkey_to_name( vkey );
+ }
+
+ len = MultiByteToWideChar( CP_UTF8, 0, name, -1, buffer, size );
+ if (len) len--;
+
+ if (!len)
+ {
+ static const WCHAR format[] = {'K','e','y',' ','0','x','%','0','2','x',0};
+ snprintfW( buffer, size, format, vkey );
+ len = strlenW( buffer );
+ }
+
+ TRACE( "lparam 0x%08x -> %s\n", lparam, debugstr_w( buffer ));
+ return len;
+}
diff --git a/dlls/wineandroid.drv/wineandroid.drv.spec b/dlls/wineandroid.drv/wineandroid.drv.spec
index 1a74624..4e7815a 100644
--- a/dlls/wineandroid.drv/wineandroid.drv.spec
+++ b/dlls/wineandroid.drv/wineandroid.drv.spec
@@ -4,6 +4,7 @@
# USER driver
+@ cdecl GetKeyNameText(long ptr long) ANDROID_GetKeyNameText
@ cdecl ToUnicodeEx(long long ptr ptr long long long) ANDROID_ToUnicodeEx
@ cdecl EnumDisplayMonitors(long ptr ptr long) ANDROID_EnumDisplayMonitors
@ cdecl GetMonitorInfo(long ptr) ANDROID_GetMonitorInfo
More information about the wine-cvs
mailing list