mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-02 14:19:05 +00:00
Avoid calls unavailable on API level 21
This commit is contained in:
parent
c2b8b6fb37
commit
fe88111187
2 changed files with 22 additions and 14 deletions
|
@ -182,11 +182,15 @@ public class Controller {
|
||||||
int id = msg.getGameControllerId();
|
int id = msg.getGameControllerId();
|
||||||
int axis = msg.getGameControllerAxis();
|
int axis = msg.getGameControllerAxis();
|
||||||
int value = msg.getGameControllerAxisValue();
|
int value = msg.getGameControllerAxisValue();
|
||||||
if (!gameControllers.contains(id)) {
|
|
||||||
|
GameController controller = gameControllers.get(id);
|
||||||
|
|
||||||
|
if (controller != null) {
|
||||||
|
controller.setAxis(axis, value);
|
||||||
|
} else {
|
||||||
Ln.w("Received data for non-existant controller.");
|
Ln.w("Received data for non-existant controller.");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
gameControllers.get(id).setAxis(axis, value);
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ControlMessage.TYPE_INJECT_GAME_CONTROLLER_BUTTON:
|
case ControlMessage.TYPE_INJECT_GAME_CONTROLLER_BUTTON:
|
||||||
|
@ -194,11 +198,14 @@ public class Controller {
|
||||||
int id = msg.getGameControllerId();
|
int id = msg.getGameControllerId();
|
||||||
int button = msg.getGameControllerButton();
|
int button = msg.getGameControllerButton();
|
||||||
int state = msg.getGameControllerButtonState();
|
int state = msg.getGameControllerButtonState();
|
||||||
if (!gameControllers.contains(id)) {
|
|
||||||
|
GameController controller = gameControllers.get(id);
|
||||||
|
|
||||||
|
if (controller != null) {
|
||||||
|
controller.setButton(button, state);
|
||||||
|
} else {
|
||||||
Ln.w("Received data for non-existant controller.");
|
Ln.w("Received data for non-existant controller.");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
gameControllers.get(id).setButton(button, state);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ControlMessage.TYPE_INJECT_GAME_CONTROLLER_DEVICE:
|
case ControlMessage.TYPE_INJECT_GAME_CONTROLLER_DEVICE:
|
||||||
|
@ -212,12 +219,15 @@ public class Controller {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GameController.DEVICE_REMOVED:
|
case GameController.DEVICE_REMOVED:
|
||||||
if (!gameControllers.contains(id)) {
|
GameController controller = gameControllers.get(id);
|
||||||
Ln.w("Non-existant game controller removed.");
|
|
||||||
break;
|
if (controller != null) {
|
||||||
}
|
controller.close();
|
||||||
gameControllers.get(id).close();
|
|
||||||
gameControllers.delete(id);
|
gameControllers.delete(id);
|
||||||
|
} else {
|
||||||
|
Ln.w("Non-existant game controller removed.");
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -4,14 +4,12 @@ import android.graphics.Rect;
|
||||||
import android.media.MediaCodecInfo;
|
import android.media.MediaCodecInfo;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.channels.FileChannel;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue