Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

United States International Keyboard layout not working properly #547

Closed
timea-techgirl opened this issue May 22, 2019 · 19 comments
Closed

Comments

@timea-techgirl
Copy link

I use US International Keyboard layout and for example, typing, "I'm" doesn't work correctly.

@rom1v
Copy link
Collaborator

rom1v commented May 22, 2019

"I'm" doesn't work correctly.

What's the result?

For me, it's work correctly.

@timea-techgirl
Copy link
Author

timea-techgirl commented May 22, 2019

"I'm" doesn't work correctly.

What's the result?

For me, it's work correctly.

This is the result. Im' or I 'm
It works correctly on Vysor.
Using windows 10. English - US International keyboard.

I press the letter I and single inverted comma and m = Im'
OR press the letter I and single inverted comma and space and m = I 'm

Both work perfectly in international keyboard. I have never had this issue in any app.

@rom1v
Copy link
Collaborator

rom1v commented May 22, 2019

Just to find the cause, do you still have the issue if you type very slowly? I, wait 2 seconds, ', wait 2 seconds, m?

@timea-techgirl
Copy link
Author

Yes. I tried waiting more than 2 seconds. Still the same problem. My computer is very fast.

@rom1v
Copy link
Collaborator

rom1v commented May 22, 2019

What if you copy-paste I'm from the computer to scrcpy (instead of typing it)?

@timea-techgirl
Copy link
Author

It copies correctly.

@rom1v
Copy link
Collaborator

rom1v commented May 26, 2019

English - US International keyboard.

Is this your layout on Windows or Android?

I added some logs:

diff --git a/server/src/main/java/com/genymobile/scrcpy/EventController.java b/server/src/main/java/com/genymobile/scrcpy/EventController.java
index 341869f..7ce96c1 100644
--- a/server/src/main/java/com/genymobile/scrcpy/EventController.java
+++ b/server/src/main/java/com/genymobile/scrcpy/EventController.java
@@ -97,6 +97,7 @@ public class EventController {
             return false;
         }
         for (KeyEvent event : events) {
+            Ln.d(" --> keyCode=" + event.getKeyCode() + ", action=" + event.getAction() + ", metaState=0x" + Integer.toHexString(event.getMetaState()));
             if (!injectEvent(event)) {
                 return false;
             }
@@ -105,6 +106,7 @@ public class EventController {
     }
 
     private boolean injectText(String text) {
+        Ln.d("injectText(\"" + text.replaceAll("\"", "\\\"") + "\")");
         for (char c : text.toCharArray()) {
             if (!injectChar(c)) {
                 return false;
@@ -144,6 +146,7 @@ public class EventController {
     }
 
     private boolean injectKeyEvent(int action, int keyCode, int repeat, int metaState) {
+        Ln.d("injectKeyEvent(" + action + ", " + keyCode + ", " + repeat + ", 0x" + Integer.toHexString(metaState) + ")");
         long now = SystemClock.uptimeMillis();
         KeyEvent event = new KeyEvent(now, now, action, keyCode, repeat, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0,
                 InputDevice.SOURCE_KEYBOARD);
@@ -151,6 +154,7 @@ public class EventController {
     }
 
     private boolean injectKeycode(int keyCode) {
+        Ln.d("injectKeycode(" + keyCode + ")");
         return injectKeyEvent(KeyEvent.ACTION_DOWN, keyCode, 0, 0)
                 && injectKeyEvent(KeyEvent.ACTION_UP, keyCode, 0, 0);
     }

Here is a server built with these changes: scrcpy-server.jar
SHA-256: 29562c0558cac71675568c9cb6feb908d7ca377a95555b71d5d3c94a0b7afb90

Replace yours by this one. Then, in scrcpy, just press I, ' and m. It will print debug logs in your console. For me, it prints:

DEBUG: injectKeyEvent(0, 37, 0, 0x81)
DEBUG: injectKeyEvent(1, 37, 0, 0x0)
DEBUG: injectText("'")
DEBUG:  --> keyCode=75, action=0, metaState=0x0
DEBUG:  --> keyCode=75, action=1, metaState=0x0
DEBUG: injectKeyEvent(0, 41, 0, 0x0)
DEBUG: injectKeyEvent(1, 41, 0, 0x0)

What does it print for you?

@timea-techgirl
Copy link
Author

timea-techgirl commented May 26, 2019

I'm using US international in windows. I've been using it since I started using my computer.

DEBUG: injectKeyEvent(0, 37, 0, 0x41)
DEBUG: injectKeyEvent(1, 37, 0, 0x41)
DEBUG: injectKeyEvent(0, 41, 0, 0x0)
DEBUG: injectText("'")
DEBUG:  --> keyCode=75, action=0, metaState=0x0
DEBUG:  --> keyCode=75, action=1, metaState=0x0
DEBUG: injectKeyEvent(1, 41, 0, 0x0)

@rom1v
Copy link
Collaborator

rom1v commented May 26, 2019

Did you type slowly?

I will analyze this when I have some time. Thank you.

@timea-techgirl
Copy link
Author

Yes, I did. I tried multiple times. And got the same output.

@rom1v
Copy link
Collaborator

rom1v commented May 27, 2019

Sorry, could I ask you to test with this additional patch, to get the logs in the order we receive it on the client side, please?

diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c
index b777b77..d843810 100644
--- a/app/src/scrcpy.c
+++ b/app/src/scrcpy.c
@@ -147,10 +147,14 @@ handle_event(SDL_Event *event, bool control) {
             if (!control) {
                 break;
             }
+            LOGD("TEXTINPUT: [%s]\n", event->text.text);
             input_manager_process_text_input(&input_manager, &event->text);
             break;
         case SDL_KEYDOWN:
         case SDL_KEYUP:
+            LOGD("%s %x (%c)\n",
+                 event->type == SDL_KEYDOWN ? "KEYDOWN" : "KEYUP",
+                 (int) event->key.keysym.sym, (char) event->key.keysym.sym);
             // some key events do not interact with the device, so process the
             // event even if control is disabled
             input_manager_process_key(&input_manager, &event->key, control);

@timea-techgirl
Copy link
Author

I don't understand what I need to do with this code. Did you miss uploading "scrcpy-server.jar" with this patch?

Please feel free to ask me anything any number of times. :)

@rom1v
Copy link
Collaborator

rom1v commented May 28, 2019

Here is a compiled version: scrcpy.exe.
SHA-256: 6f87290178123ab0d3abbf5a62269507a7ab876eb5a6b781707cf553c5bacdd5

@timea-techgirl
Copy link
Author

scrcpy-server.jar: 1 file pushed. 1.7 MB/s (50495 bytes in 0.028s)
DEBUG: Starting stream thread
DEBUG: Starting controller thread
INFO: Created renderer: direct3d
INFO: Initial texture: 1080x1920
DEBUG: KEYDOWN 400000e1 (�)
DEBUG: KEYDOWN 69 (i)
DEBUG: TEXTINPUT: [I]
DEBUG: injectKeyEvent(0, 37, 0, 0x41)
DEBUG: KEYUP 69 (i)
DEBUG: injectKeyEvent(1, 37, 0, 0x41)
DEBUG: KEYUP 400000e1 (�)
DEBUG: KEYDOWN 27 (')
DEBUG: KEYUP 27 (')
DEBUG: KEYDOWN 6d (m)
DEBUG: TEXTINPUT: [']
DEBUG: TEXTINPUT: [m]
DEBUG: injectKeyEvent(0, 41, 0, 0x0)
DEBUG: injectText("'")
DEBUG:  --> keyCode=75, action=0, metaState=0x0
DEBUG:  --> keyCode=75, action=1, metaState=0x0
DEBUG: KEYUP 6d (m)
DEBUG: injectKeyEvent(1, 41, 0, 0x0)
scrcpy-server.jar: 1 file pushed. 1.7 MB/s (19734 bytes in 0.011s)
DEBUG: Starting stream thread
DEBUG: Starting controller thread
INFO: Created renderer: direct3d
INFO: Initial texture: 1080x1920
DEBUG: KEYDOWN 400000e1 (�)
DEBUG: KEYDOWN 400000e1 (�)
DEBUG: KEYDOWN 400000e1 (�)
DEBUG: KEYDOWN 400000e1 (�)
DEBUG: KEYDOWN 69 (i)
DEBUG: TEXTINPUT: [I]
DEBUG: KEYUP 69 (i)
DEBUG: KEYUP 400000e1 (�)
DEBUG: KEYDOWN 27 (')
DEBUG: KEYUP 27 (')
DEBUG: KEYDOWN 6d (m)
DEBUG: TEXTINPUT: [']
DEBUG: TEXTINPUT: [m]
DEBUG: KEYUP 6d (m)

@rom1v
Copy link
Collaborator

rom1v commented May 28, 2019

OK, thank you.

So when you press ', it waits for the next letter before generating the text input (which is weird, it means we cannot send ' (if we rely on text input) before you type m).

Maybe it triggers a SDL_TEXTEDITING event (https://wiki.libsdl.org/Tutorials/TextInput), but anyway, that will not solve the problem.

The result is messed up due to the workaround to fix bug #87: it sends letters as keys but other characters as text.

I wanted a "single mode" so that the user don't have to configure, but in the end there are several side-effects. I will probably add an option to select between "raw keys events", "text" (the behavior before v1.4) and "mixed" (the current behavior).

@timea-techgirl
Copy link
Author

Oh I see. Thanks for the explanation. :)

@rom1v
Copy link
Collaborator

rom1v commented Apr 11, 2020

Does it still happen?

What if you pass --prefer-text?

@timea-techgirl
Copy link
Author

It still happens.

It's fixed with this --prefer-text command.

@rom1v
Copy link
Collaborator

rom1v commented Apr 13, 2020

OK, thank you. 👍

This is "fixed" then (this is why --prefer-text had been implemented c916af0, because a single reasonable behavior could not work for all situations).

@rom1v rom1v closed this as completed Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants