Ecore_Win32 : Fix the key release values for non keystroke keys (Windows XP)
authorcaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 29 Nov 2011 23:06:01 +0000 (23:06 +0000)
committercaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 29 Nov 2011 23:06:01 +0000 (23:06 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@65695 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
src/lib/ecore_win32/ecore_win32.c
src/lib/ecore_win32/ecore_win32_event.c

index 963c64b..4f3f4c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
         * Discard left Ctrl when AltGr is pressed (Windows XP)
        * Fix the string value for the Delete key (Windows XP)
+       * Fix the key release values for non keystroke keys (Windows XP)
index ba61493..b571d74 100644 (file)
@@ -132,7 +132,7 @@ _ecore_win32_window_procedure(HWND   window,
              * we check if the next message
              * - is a WM_KEYUP or WM_SYSKEYUP
              * - has the same timestamp than the Ctrl one
-             * - is the key press of the right Alt key
+             * - is the key release of the right Alt key
              */
             res = PeekMessage(&next_msg, data->window,
                               WM_KEYUP, WM_SYSKEYUP,
index 159d3f9..c12562d 100644 (file)
@@ -650,6 +650,7 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
                                  char        **keycompose,
                                  unsigned int *modifiers)
 {
+  WCHAR buf[3];
   char delete_string[2] = { 0x7f, 0 };
   char *kn = NULL;
   char *ks = NULL;
@@ -1115,8 +1116,32 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
        kc = "";
        break;
      default:
-       /* other non keystroke characters */
-       return 0;
+       {
+          /* other non keystroke characters */
+          BYTE kbd_state[256];
+          int res;
+
+          if (is_down)
+            return 0;
+
+          if (!GetKeyboardState(kbd_state))
+            return 0;
+
+           res = ToUnicode(msg->window_param,
+                           MapVirtualKey(msg->window_param, 2),
+                           kbd_state, buf, 3, 0);
+           if (res == 1)
+             {
+               /* FIXME: might be troublesome for non european languages */
+               /* in that case, UNICODE should be used, I guess */
+               buf[1] = '\0';
+               kn = (char *)buf;
+               ks = (char *)buf;
+               kc = (char *)buf;
+               break;
+             }
+           return 0;
+         }
      }
 
    *keyname = strdup(kn);