mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-02 06:08:53 +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 axis = msg.getGameControllerAxis();
|
||||
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.");
|
||||
break;
|
||||
}
|
||||
gameControllers.get(id).setAxis(axis, value);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ControlMessage.TYPE_INJECT_GAME_CONTROLLER_BUTTON:
|
||||
|
@ -194,11 +198,14 @@ public class Controller {
|
|||
int id = msg.getGameControllerId();
|
||||
int button = msg.getGameControllerButton();
|
||||
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.");
|
||||
break;
|
||||
}
|
||||
gameControllers.get(id).setButton(button, state);
|
||||
}
|
||||
break;
|
||||
case ControlMessage.TYPE_INJECT_GAME_CONTROLLER_DEVICE:
|
||||
|
@ -212,12 +219,15 @@ public class Controller {
|
|||
break;
|
||||
|
||||
case GameController.DEVICE_REMOVED:
|
||||
if (!gameControllers.contains(id)) {
|
||||
GameController controller = gameControllers.get(id);
|
||||
|
||||
if (controller != null) {
|
||||
controller.close();
|
||||
gameControllers.delete(id);
|
||||
} else {
|
||||
Ln.w("Non-existant game controller removed.");
|
||||
break;
|
||||
}
|
||||
gameControllers.get(id).close();
|
||||
gameControllers.delete(id);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -4,14 +4,12 @@ import android.graphics.Rect;
|
|||
import android.media.MediaCodecInfo;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue