Fixed unicode key down and up messages.
authorArmin Novak <armin.novak@thincast.com>
Thu, 7 Feb 2019 14:58:55 +0000 (15:58 +0100)
committerArmin Novak <armin.novak@thincast.com>
Fri, 5 Apr 2019 07:14:35 +0000 (09:14 +0200)
client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/SessionActivity.java
client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java
client/Android/android_event.c
client/Android/android_event.h
client/Android/android_freerdp.c
libfreerdp/core/input.c

index 81cb993..c148c71 100644 (file)
@@ -726,7 +726,8 @@ public class SessionActivity extends AppCompatActivity implements
 
     @Override
     public void processUnicodeKey(int unicodeKey) {
-        LibFreeRDP.sendUnicodeKeyEvent(session.getInstance(), unicodeKey);
+        LibFreeRDP.sendUnicodeKeyEvent(session.getInstance(), unicodeKey, true);
+        LibFreeRDP.sendUnicodeKeyEvent(session.getInstance(), unicodeKey, false);
     }
 
     @Override
index d01e8db..686b5c2 100644 (file)
@@ -82,7 +82,7 @@ public class LibFreeRDP {
 
     private static native boolean freerdp_send_key_event(long inst, int keycode, boolean down);
 
-    private static native boolean freerdp_send_unicodekey_event(long inst, int keycode);
+    private static native boolean freerdp_send_unicodekey_event(long inst, int keycode, boolean down);
 
     private static native boolean freerdp_send_clipboard_data(long inst, String data);
 
@@ -357,8 +357,8 @@ public class LibFreeRDP {
         return freerdp_send_key_event(inst, keycode, down);
     }
 
-    public static boolean sendUnicodeKeyEvent(long inst, int keycode) {
-        return freerdp_send_unicodekey_event(inst, keycode);
+    public static boolean sendUnicodeKeyEvent(long inst, int keycode, boolean down) {
+        return freerdp_send_unicodekey_event(inst, keycode, down);
     }
 
     public static boolean sendClipboardData(long inst, String data) {
index de04157..7b764ac 100644 (file)
@@ -195,7 +195,7 @@ static void android_event_key_free(ANDROID_EVENT_KEY* event)
        free(event);
 }
 
-ANDROID_EVENT_KEY* android_event_unicodekey_new(UINT16 key)
+ANDROID_EVENT_KEY* android_event_unicodekey_new(UINT16 flags, UINT16 key)
 {
        ANDROID_EVENT_KEY* event;
        event = (ANDROID_EVENT_KEY*) calloc(1, sizeof(ANDROID_EVENT_KEY));
@@ -204,6 +204,7 @@ ANDROID_EVENT_KEY* android_event_unicodekey_new(UINT16 key)
                return NULL;
 
        event->type = EVENT_TYPE_KEY_UNICODE;
+       event->flags = flags;
        event->scancode = key;
        return event;
 }
index 584d672..1110a87 100644 (file)
@@ -67,7 +67,7 @@ FREERDP_LOCAL BOOL android_check_handle(freerdp* inst);
 
 FREERDP_LOCAL ANDROID_EVENT_KEY* android_event_key_new(int flags,
         UINT16 scancode);
-FREERDP_LOCAL ANDROID_EVENT_KEY* android_event_unicodekey_new(UINT16 key);
+FREERDP_LOCAL ANDROID_EVENT_KEY* android_event_unicodekey_new(UINT16 flags, UINT16 key);
 FREERDP_LOCAL ANDROID_EVENT_CURSOR* android_event_cursor_new(UINT16 flags,
         UINT16 x, UINT16 y);
 FREERDP_LOCAL ANDROID_EVENT* android_event_disconnect_new(void);
index f4a70e7..00d4489 100644 (file)
@@ -975,11 +975,12 @@ static jboolean JNICALL jni_freerdp_send_key_event(
 }
 
 static jboolean JNICALL jni_freerdp_send_unicodekey_event(
-    JNIEnv* env, jclass cls, jlong instance, jint keycode)
+    JNIEnv* env, jclass cls, jlong instance, jint keycode, jboolean down)
 {
        ANDROID_EVENT* event;
        freerdp* inst = (freerdp*)instance;
-       event = (ANDROID_EVENT*) android_event_unicodekey_new(keycode);
+       UINT16 flags = (down == JNI_TRUE) ? 0 : KBD_FLAGS_RELEASE;
+       event = (ANDROID_EVENT*) android_event_unicodekey_new(flags, keycode);
 
        if (!event)
                return JNI_FALSE;
index e199ae9..216817d 100644 (file)
@@ -130,7 +130,6 @@ static void input_write_unicode_keyboard_event(wStream* s, UINT16 flags, UINT16
 static BOOL input_send_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
 {
        wStream* s;
-       UINT16 keyboardFlags = 0;
        rdpRdp* rdp;
 
        if (!input || !input->context)
@@ -143,16 +142,6 @@ static BOOL input_send_unicode_keyboard_event(rdpInput* input, UINT16 flags, UIN
        }
 
        rdp = input->context->rdp;
-       /*
-        * According to the specification, the slow path Unicode Keyboard Event
-        * (TS_UNICODE_KEYBOARD_EVENT) contains KBD_FLAGS_RELEASE flag when key
-        * is released, but contains no flags when it is pressed.
-        * This is different from the slow path Keyboard Event
-        * (TS_KEYBOARD_EVENT) which does contain KBD_FLAGS_DOWN flag when the
-        * key is pressed.
-        * There is no KBD_FLAGS_EXTENDED flag in TS_UNICODE_KEYBOARD_EVENT.
-        */
-       keyboardFlags |= (flags & KBD_FLAGS_RELEASE) ? KBD_FLAGS_RELEASE : 0;
        s = rdp_client_input_pdu_init(rdp, INPUT_EVENT_UNICODE);
 
        if (!s)