Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
6cac0c32a2 | |||
2d84737f41 | |||
fa5b2a29e9 | |||
0c94887075 | |||
88543cb545 | |||
aaf3869a54 |
@ -1,6 +1,7 @@
|
||||
#include "adb_device.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
sc_adb_device_destroy(struct sc_adb_device *device) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
#ifndef SC_COMMON_H
|
||||
#define SC_COMMON_H
|
||||
|
||||
#include "config.h"
|
||||
#include "compat.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef COMPAT_H
|
||||
#define COMPAT_H
|
||||
#ifndef SC_COMPAT_H
|
||||
#define SC_COMPAT_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef CONTROLMSG_H
|
||||
#define CONTROLMSG_H
|
||||
#ifndef SC_CONTROLMSG_H
|
||||
#define SC_CONTROLMSG_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef CONTROLLER_H
|
||||
#define CONTROLLER_H
|
||||
#ifndef SC_CONTROLLER_H
|
||||
#define SC_CONTROLLER_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef DEVICEMSG_H
|
||||
#define DEVICEMSG_H
|
||||
#ifndef SC_DEVICEMSG_H
|
||||
#define SC_DEVICEMSG_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef FPSCOUNTER_H
|
||||
#define FPSCOUNTER_H
|
||||
#ifndef SC_FPSCOUNTER_H
|
||||
#define SC_FPSCOUNTER_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef ICON_H
|
||||
#define ICON_H
|
||||
#ifndef SC_ICON_H
|
||||
#define SC_ICON_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef INPUTMANAGER_H
|
||||
#define INPUTMANAGER_H
|
||||
#ifndef SC_INPUTMANAGER_H
|
||||
#define SC_INPUTMANAGER_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
@ -28,7 +28,7 @@ sc_opengl_init(struct sc_opengl *gl) {
|
||||
sizeof(OPENGL_ES_PREFIX) - 1);
|
||||
if (gl->is_opengles) {
|
||||
/* skip the prefix */
|
||||
version += sizeof(PREFIX) - 1;
|
||||
version += sizeof(OPENGL_ES_PREFIX) - 1;
|
||||
}
|
||||
|
||||
int r = sscanf(version, "%d.%d", &gl->version_major, &gl->version_minor);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef RECEIVER_H
|
||||
#define RECEIVER_H
|
||||
#ifndef SC_RECEIVER_H
|
||||
#define SC_RECEIVER_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// generic circular buffer (bounded queue) implementation
|
||||
#ifndef CBUF_H
|
||||
#define CBUF_H
|
||||
#ifndef SC_CBUF_H
|
||||
#define SC_CBUF_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef NET_H
|
||||
#define NET_H
|
||||
#ifndef SC_NET_H
|
||||
#define SC_NET_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
2
run
2
run
@ -20,6 +20,6 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRCPY_ICON_PATH="data/icon.png" \
|
||||
SCRCPY_ICON_PATH="app/data/icon.png" \
|
||||
SCRCPY_SERVER_PATH="$BUILDDIR/server/scrcpy-server" \
|
||||
"$BUILDDIR/app/scrcpy" "$@"
|
||||
|
@ -14,24 +14,18 @@ public final class InputManager {
|
||||
public static final int INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT = 1;
|
||||
public static final int INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH = 2;
|
||||
|
||||
private final IInterface manager;
|
||||
private final android.hardware.input.InputManager manager;
|
||||
private Method injectInputEventMethod;
|
||||
private boolean alternativeInjectInputEventMethod;
|
||||
|
||||
private static Method setDisplayIdMethod;
|
||||
|
||||
public InputManager(IInterface manager) {
|
||||
public InputManager(android.hardware.input.InputManager manager) {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
private Method getInjectInputEventMethod() throws NoSuchMethodException {
|
||||
if (injectInputEventMethod == null) {
|
||||
try {
|
||||
injectInputEventMethod = manager.getClass().getMethod("injectInputEvent", InputEvent.class, int.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
injectInputEventMethod = manager.getClass().getMethod("injectInputEvent", InputEvent.class, int.class, int.class);
|
||||
alternativeInjectInputEventMethod = true;
|
||||
}
|
||||
injectInputEventMethod = manager.getClass().getMethod("injectInputEvent", InputEvent.class, int.class);
|
||||
}
|
||||
return injectInputEventMethod;
|
||||
}
|
||||
@ -39,10 +33,6 @@ public final class InputManager {
|
||||
public boolean injectInputEvent(InputEvent inputEvent, int mode) {
|
||||
try {
|
||||
Method method = getInjectInputEventMethod();
|
||||
if (alternativeInjectInputEventMethod) {
|
||||
// See <https://github.com/Genymobile/scrcpy/issues/2250>
|
||||
return (boolean) method.invoke(manager, inputEvent, mode, 0);
|
||||
}
|
||||
return (boolean) method.invoke(manager, inputEvent, mode);
|
||||
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
||||
Ln.e("Could not invoke method", e);
|
||||
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@SuppressLint("PrivateApi,DiscouragedPrivateApi")
|
||||
@ -56,7 +57,13 @@ public final class ServiceManager {
|
||||
|
||||
public InputManager getInputManager() {
|
||||
if (inputManager == null) {
|
||||
inputManager = new InputManager(getService("input", "android.hardware.input.IInputManager"));
|
||||
try {
|
||||
Method getInstanceMethod = android.hardware.input.InputManager.class.getDeclaredMethod("getInstance");
|
||||
android.hardware.input.InputManager im = (android.hardware.input.InputManager) getInstanceMethod.invoke(null);
|
||||
inputManager = new InputManager(im);
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
return inputManager;
|
||||
}
|
||||
|
Reference in New Issue
Block a user