Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
105.37k stars 10.23k forks source link

mouse and keyboard #4984

Open ozntyr opened 3 weeks ago

ozntyr commented 3 weeks ago

Environment

Describe the bug found this on a yt video and followed it. the screen mirroring works and I can hear the sounds but it doesn't register keyboard and mouse inputs. in the video it showed how to do it on wifi too and while trying that I found that it gives the following errors when I try to click anywhere

Microsoft Windows [Version 10.0.19045.4170]
(c) Microsoft Corporation. Tüm hakları saklıdır.

C:\Users\Ozntyr\Desktop\scrcpy-win64-v2.4>scrcpy
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
ERROR: Multiple (2) ADB devices:
ERROR:     -->   (usb)  UWKRCAS8G6HU6LH6                device  2311DRK48G
ERROR:     --> (tcpip)  192.168.1.162:5555              device  2311DRK48G
ERROR: Select a device via -s (--serial), -d (--select-usb) or -e (--select-tcpip)
ERROR: Server connection failed

C:\Users\Ozntyr\Desktop\scrcpy-win64-v2.4>scrcpy
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     --> (tcpip)  192.168.1.162:5555              device  2311DRK48G
C:\Users\Ozntyr\Desktop\scrcpy-win64-v2.4\scrcpy-server: 1 file pushed, 0 skipped. 35.0 MB/s (69007 bytes in 0.002s)
[server] INFO: Device: [Xiaomi] POCO 2311DRK48G (Android 14)
INFO: Renderer: direct3d
INFO: Texture: 1216x2712
[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.InputManager.injectInputEvent(InputManager.java:58)
        at com.genymobile.scrcpy.Device.injectEvent(Device.java:230)
        at com.genymobile.scrcpy.Device.injectEvent(Device.java:234)
        at com.genymobile.scrcpy.Controller.injectTouch(Controller.java:362)
        at com.genymobile.scrcpy.Controller.handleEvent(Controller.java:162)
        at com.genymobile.scrcpy.Controller.control(Controller.java:97)
        at com.genymobile.scrcpy.Controller.lambda$start$0$com-genymobile-scrcpy-Controller(Controller.java:105)
        at com.genymobile.scrcpy.Controller$$ExternalSyntheticLambda1.run(Unknown Source:4)
        at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.SecurityException: Injecting input events requires the caller (or the source of the instrumentation, if any) to have the INJECT_EVENTS permission.
        at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
        at android.os.Parcel.createException(Parcel.java:3041)
        at android.os.Parcel.readException(Parcel.java:3024)
        at android.os.Parcel.readException(Parcel.java:2966)
        at android.hardware.input.IInputManager$Stub$Proxy.injectInputEventToTarget(IInputManager.java:1590)
        at android.hardware.input.InputManagerGlobal.injectInputEvent(InputManagerGlobal.java:1217)
        at android.hardware.input.InputManagerGlobal.injectInputEvent(InputManagerGlobal.java:1227)
        ... 10 more
Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.input.InputManagerService.injectInputEventToTarget(InputManagerService.java:912)
        at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:752)
        at android.os.Binder.execTransactInternal(Binder.java:1346)
        at android.os.Binder.execTransact(Binder.java:1282)

[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.InputManager.injectInputEvent(InputManager.java:58)
        at com.genymobile.scrcpy.Device.injectEvent(Device.java:230)
        at com.genymobile.scrcpy.Device.injectEvent(Device.java:234)
        at com.genymobile.scrcpy.Controller.injectTouch(Controller.java:362)
        at com.genymobile.scrcpy.Controller.handleEvent(Controller.java:162)
        at com.genymobile.scrcpy.Controller.control(Controller.java:97)
        at com.genymobile.scrcpy.Controller.lambda$start$0$com-genymobile-scrcpy-Controller(Controller.java:105)
        at com.genymobile.scrcpy.Controller$$ExternalSyntheticLambda1.run(Unknown Source:4)
        at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.SecurityException: Injecting input events requires the caller (or the source of the instrumentation, if any) to have the INJECT_EVENTS permission.
        at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
        at android.os.Parcel.createException(Parcel.java:3041)
        at android.os.Parcel.readException(Parcel.java:3024)
        at android.os.Parcel.readException(Parcel.java:2966)
        at android.hardware.input.IInputManager$Stub$Proxy.injectInputEventToTarget(IInputManager.java:1590)
        at android.hardware.input.InputManagerGlobal.injectInputEvent(InputManagerGlobal.java:1217)
        at android.hardware.input.InputManagerGlobal.injectInputEvent(InputManagerGlobal.java:1227)
        ... 10 more
INFO: Texture: 2712x1216
INFO: Texture: 1216x2712
INFO: Texture: 2712x1216
INFO: Texture: 1216x2712
INFO: Texture: 2712x1216
INFO: Texture: 1216x2712
INFO: Texture: 2712x1216
rom1v commented 3 weeks ago

Caused by: java.lang.SecurityException: Injecting input events requires the caller (or the source of the instrumentation, if any) to have the INJECT_EVENTS permission.

Please read: https://github.com/Genymobile/scrcpy#prerequisites

ozntyr commented 3 weeks ago

oohhh you mean this: "On some devices, you also need to enable https://github.com/Genymobile/scrcpy/issues/70#issuecomment-373286323 USB debugging (Security Settings) (this is an item different from USB debugging) to control it using a keyboard and mouse. Rebooting the device is necessary once this option is set." ok I'll try that. thanks, also I just tried -M and -K and they work fine I just need to alt+tab to exit