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

Closing and opening laptop lid while scrcpy has focus produces errors #572

Closed
myself248 opened this issue Jun 1, 2019 · 4 comments
Closed

Comments

@myself248
Copy link

I have my laptop set to remain running when I close the lid to carry it around. It does, however, turn off the screen and turn it back on when I open it again. After doing so, I see this message in the console:

The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list https://discourse.libsdl.org/ X11 KeyCode 151 (143), X11 KeySym 0x1008FF2B (XF86WakeUp).

This tends to cause really weird behavior in the Android app that happens to be foreground at the moment. Simple workaround is to make sure scrcpy doesn't have focus when folding the lappy...

@rom1v
Copy link
Collaborator

rom1v commented Jun 1, 2019

I have my laptop set to remain running when I close the lid to carry it around. It does, however, turn off the screen and turn it back on when I open it again.

I cannot reproduce on my laptop :(

This tends to cause really weird behavior in the Android app that happens to be foreground at the moment.

This is very weird, because only specific keycodes are converted and forwarded:

scrcpy/app/src/convert.c

Lines 76 to 77 in 5d473ef

static bool
convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod) {

Could you apply the changes I posted in #547 (comment) to get more logs about events, please?

@rom1v
Copy link
Collaborator

rom1v commented Jun 11, 2019

@myself248 Did you find some time to test with more logs?

@myself248
Copy link
Author

No, I've got the new server being pushed to the phone, but I haven't sat down to figure out how to apply the patch to the client. New to all this, sorry.

The weird behavior in the Android app may have been a coincidence, I can't reproduce it reliably and the app in question is pretty crashy anyway.

@rom1v
Copy link
Collaborator

rom1v commented Jun 12, 2019

I haven't sat down to figure out how to apply the patch to the client.

At the root of the project, execute patch -p1. It will wait for input. Paste the content of the patch:

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

Then press Ctrl+D twice.

@rom1v rom1v closed this as completed Apr 11, 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