Closed dieKatze88 closed 4 years ago
Hello, I am new to contributing to open-source projects.
While looking through the code, I found that message here https://github.com/Genymobile/scrcpy/blob/521f2fe994019065e938aa1a54b56b4f10a4ac4a/app/src/main.c#L103 followed by this code https://github.com/Genymobile/scrcpy/blob/521f2fe994019065e938aa1a54b56b4f10a4ac4a/app/src/main.c#L104
From experimenting on a simple C application, getchar() requires pressing ENTER/RETURN key to continue the program. If you want any key press to continue the program, I found getch() provides that functionality. Requires importing conio.h header file.
https://www.geeksforgeeks.org/getch-function-in-c-with-examples/
The fun thing about this issue is there's actually two ways to fix it.
Either the above suggestion to change how a character is read from the console, or changing the language of the message, to be specific to pressing Return.
I'm not going to pretend to know which one is better for this error, because this isn't my project. I just spotted an issue in a program I found useful. If it were me, I would fix the code so it accepted any key, but scrcpy is probably more of a development tool to most users, where as I am a filthy casual using it to play Fire Emblem Heroes faster because I don't write android apps anymore. Seeing the errors might be more worth it to those users, so changing the language of the message might be more appropriate for this application. I honestly don't know and I'm not 100% up to the pulse of how this application is usually used.
This message is just a workaround to pause in case of error on Windows, so that the console does not immediately close before having time to read the errors (140b1ef6a5f2de489f99c6f7f63dc2a49bc404f6).
In practice, we don't care if we can quit with any key or just Enter. Since stdin
is line-buffered, getchar()
will return after a new line (by pressing Enter).
Since getch()
is not standard, I'd prefer changing the text (even if the message is printed only on Windows).
The only other suggestion I could have is ditching the pause entirely on Windows, because this is always an option.
scrcpy-omgineedthat.cmd
scrcpy.exe pause
Changing the text may be best since in this scenario, just want to give user control when program dismisses.
Just wanted to provide a solution in case wanted to stick with the "Press any key to continue".
Fixed by #1783.
If you want your program to run after clicking any key to contitue to execute set of instructions then use getch in your windows system. First include conio.h
header file and then call getch();
function.
Reference: https://scholarsoul.com/getch-in-c/
Hi Rom I'm facing a problem in scrcpy I have redmi10 pro , and when I run the scrcpy it works for just 2 seconds and disconnected abruptly Have tried many time but facing same Here's what I get Microsoft Windows [Version 10.0.22000.613] (c) Microsoft Corporation. All rights reserved.
C:\Users\muhammad suhail\Downloads\adb\platform-tools_r33.0.1-windows\platform-tools>scrcpy.exe scrcpy 1.24 https://github.com/Genymobile/scrcpy C:\Users\muhammad suhail\Downloads\adb\platform-tools_r33.... file pushed, 0 skipped. 40.0 MB/s (41159 bytes in 0.001s) [server] INFO: Device: Xiaomi M2101K6P (Android 12) INFO: Renderer: direct3d INFO: Initial texture: 1080x2400 [server] ERROR: Encoding error: java.lang.IllegalStateException: null WARN: Device disconnected [server] ERROR: Exception on thread Thread[main,5,main] java.lang.IllegalStateException at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method) at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:3535) at com.genymobile.scrcpy.ScreenEncoder.encode(ScreenEncoder.java:152) at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:102) at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:74) at com.genymobile.scrcpy.Server.scrcpy(Server.java:101) at com.genymobile.scrcpy.Server.main(Server.java:335) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:363)
C:\Users\muhammad suhail\Downloads\adb\platform-tools_r33.0.1-windows\platform-tools>C:\Users\muhammad suhail\Downloads\adb\platform-tools_r33.0.1-windows\platform-toolsC:\Users\muhammad suhail\Downloads\adb\platform-tools_r33.0.1-windows\platform-tools
[server] ERROR: Encoding error: java.lang.IllegalStateException: null WARN: Device disconnected [server] ERROR: Exception on thread Thread[main,5,main]
Environment
Describe the bug If you are using the console version, any time it says "Press any key to continue..." The console only accepts return to dismiss.
D:\scrcopy>scrcpy.exe -Sw INFO: scrcpy 1.16 https://github.com/Genymobile/scrcpy adb: error: failed to get feature set: no devices/emulators found ERROR: "adb push" returned with value 1 Press any key to continue...
Pressing any other key other than Return does not have the intended result of dismissing the program.