Fixed unicode key down and up messages.

This commit is contained in:
Armin Novak 2019-02-07 15:58:55 +01:00
parent 295ac3daa4
commit 281dd22061
6 changed files with 11 additions and 19 deletions

View 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

View 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) {

View 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;
}

View 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);

View 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;

View 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)