mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-02 22:29:25 +00:00
Fix checkstyle errors unrelated to naming scheme
This commit is contained in:
parent
54cdd8222f
commit
b5e450ce0c
3 changed files with 35 additions and 35 deletions
|
@ -151,7 +151,7 @@ public final class CleanUp {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void unlinkNativeLibs() {
|
private static void unlinkNativeLibs() {
|
||||||
for (String lib : Server.NATIVE_LIBRARIES){
|
for (String lib : Server.NATIVE_LIBRARIES) {
|
||||||
try {
|
try {
|
||||||
new File(Server.SERVER_DIR + "/" + lib).delete();
|
new File(Server.SERVER_DIR + "/" + lib).delete();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -152,8 +152,7 @@ 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))
|
if (!gameControllers.contains(id)) {
|
||||||
{
|
|
||||||
Ln.w("Received data for non-existant controller.");
|
Ln.w("Received data for non-existant controller.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -165,8 +164,7 @@ 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))
|
if (!gameControllers.contains(id)) {
|
||||||
{
|
|
||||||
Ln.w("Received data for non-existant controller.");
|
Ln.w("Received data for non-existant controller.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -182,16 +180,18 @@ public class Controller {
|
||||||
case GameController.DEVICE_ADDED:
|
case GameController.DEVICE_ADDED:
|
||||||
gameControllers.append(id, new GameController());
|
gameControllers.append(id, new GameController());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GameController.DEVICE_REMOVED:
|
case GameController.DEVICE_REMOVED:
|
||||||
if (!gameControllers.contains(id))
|
if (!gameControllers.contains(id)) {
|
||||||
{
|
|
||||||
Ln.w("Non-existant game controller removed.");
|
Ln.w("Non-existant game controller removed.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gameControllers.get(id).close();
|
gameControllers.get(id).close();
|
||||||
gameControllers.delete(id);
|
gameControllers.delete(id);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Ln.w("Unknown game controller event received.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,25 +1,26 @@
|
||||||
package com.genymobile.scrcpy;
|
package com.genymobile.scrcpy;
|
||||||
|
|
||||||
|
import com.sun.jna.Library;
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.Platform;
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.Structure;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.sun.jna.Library;
|
|
||||||
import com.sun.jna.Platform;
|
|
||||||
import com.sun.jna.Native;
|
|
||||||
import com.sun.jna.Structure;
|
|
||||||
import com.sun.jna.Pointer;
|
|
||||||
|
|
||||||
public final class GameController {
|
public final class GameController {
|
||||||
public static final int DEVICE_ADDED = 0;
|
public static final int DEVICE_ADDED = 0;
|
||||||
public static final int DEVICE_REMOVED = 1;
|
public static final int DEVICE_REMOVED = 1;
|
||||||
|
|
||||||
private static int UINPUT_MAX_NAME_SIZE = 80;
|
private static final int UINPUT_MAX_NAME_SIZE = 80;
|
||||||
|
|
||||||
public static class input_id extends Structure {
|
public static class input_id extends Structure {
|
||||||
public short bustype = 0;
|
public short bustype = 0;
|
||||||
public short vendor = 0;
|
public short vendor = 0;
|
||||||
public short product = 0;
|
public short product = 0;
|
||||||
public short version = 0;
|
public short version = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getFieldOrder() {
|
protected List<String> getFieldOrder() {
|
||||||
return Arrays.asList("bustype", "vendor", "product", "version");
|
return Arrays.asList("bustype", "vendor", "product", "version");
|
||||||
|
@ -54,10 +55,9 @@ public final class GameController {
|
||||||
public static class uinput_abs_setup extends Structure {
|
public static class uinput_abs_setup extends Structure {
|
||||||
public short code;
|
public short code;
|
||||||
public input_absinfo absinfo;
|
public input_absinfo absinfo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getFieldOrder()
|
protected List<String> getFieldOrder() {
|
||||||
{
|
|
||||||
return Arrays.asList("code", "absinfo");
|
return Arrays.asList("code", "absinfo");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -87,19 +87,19 @@ public final class GameController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int _IOC_NONE = 0;
|
private static final int _IOC_NONE = 0;
|
||||||
private static int _IOC_WRITE = 1;
|
private static final int _IOC_WRITE = 1;
|
||||||
|
|
||||||
private static int _IOC_DIRSHIFT = 30;
|
private static final int _IOC_DIRSHIFT = 30;
|
||||||
private static int _IOC_TYPESHIFT = 8;
|
private static final int _IOC_TYPESHIFT = 8;
|
||||||
private static int _IOC_NRSHIFT = 0;
|
private static final int _IOC_NRSHIFT = 0;
|
||||||
private static int _IOC_SIZESHIFT = 16;
|
private static final int _IOC_SIZESHIFT = 16;
|
||||||
|
|
||||||
private static int _IOC(int dir, int type, int nr, int size) {
|
private static int _IOC(int dir, int type, int nr, int size) {
|
||||||
return (dir << _IOC_DIRSHIFT) |
|
return (dir << _IOC_DIRSHIFT)
|
||||||
(type << _IOC_TYPESHIFT) |
|
| (type << _IOC_TYPESHIFT)
|
||||||
(nr << _IOC_NRSHIFT) |
|
| (nr << _IOC_NRSHIFT)
|
||||||
(size << _IOC_SIZESHIFT);
|
| (size << _IOC_SIZESHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int _IO(int type, int nr, int size) {
|
private static int _IO(int type, int nr, int size) {
|
||||||
|
@ -114,7 +114,7 @@ public final class GameController {
|
||||||
private static final int O_NONBLOCK = 04000;
|
private static final int O_NONBLOCK = 04000;
|
||||||
|
|
||||||
private static final int BUS_USB = 0x03;
|
private static final int BUS_USB = 0x03;
|
||||||
|
|
||||||
private static final int UINPUT_IOCTL_BASE = 'U';
|
private static final int UINPUT_IOCTL_BASE = 'U';
|
||||||
|
|
||||||
private static final int UI_SET_EVBIT = _IOW(UINPUT_IOCTL_BASE, 100, 4);
|
private static final int UI_SET_EVBIT = _IOW(UINPUT_IOCTL_BASE, 100, 4);
|
||||||
|
@ -200,7 +200,7 @@ public final class GameController {
|
||||||
private int fd;
|
private int fd;
|
||||||
|
|
||||||
public interface LibC extends Library {
|
public interface LibC extends Library {
|
||||||
LibC fn = (LibC)Native.load("c", LibC.class);
|
LibC fn = (LibC) Native.load("c", LibC.class);
|
||||||
|
|
||||||
int open(String pathname, int flags);
|
int open(String pathname, int flags);
|
||||||
int ioctl(int fd, long request, Object... args);
|
int ioctl(int fd, long request, Object... args);
|
||||||
|
@ -208,7 +208,7 @@ public final class GameController {
|
||||||
int close(int fd);
|
int close(int fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void load_native_libraries() {
|
public static void load_native_libraries() {
|
||||||
GameController.LibC.fn.write(1, null, 0);
|
GameController.LibC.fn.write(1, null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ public final class GameController {
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
throw new RuntimeException("Couldn't open uinput device.");
|
throw new RuntimeException("Couldn't open uinput device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
LibC.fn.ioctl(fd, UI_SET_EVBIT, EV_KEY);
|
LibC.fn.ioctl(fd, UI_SET_EVBIT, EV_KEY);
|
||||||
add_key(XBOX_BTN_A);
|
add_key(XBOX_BTN_A);
|
||||||
add_key(XBOX_BTN_B);
|
add_key(XBOX_BTN_B);
|
||||||
|
@ -230,7 +230,7 @@ public final class GameController {
|
||||||
add_key(XBOX_BTN_GUIDE);
|
add_key(XBOX_BTN_GUIDE);
|
||||||
add_key(XBOX_BTN_LS);
|
add_key(XBOX_BTN_LS);
|
||||||
add_key(XBOX_BTN_RS);
|
add_key(XBOX_BTN_RS);
|
||||||
|
|
||||||
LibC.fn.ioctl(fd, UI_SET_EVBIT, EV_ABS);
|
LibC.fn.ioctl(fd, UI_SET_EVBIT, EV_ABS);
|
||||||
add_abs(XBOX_ABS_LSX, -32768, 32767, 16, 128);
|
add_abs(XBOX_ABS_LSX, -32768, 32767, 16, 128);
|
||||||
add_abs(XBOX_ABS_LSY, -32768, 32767, 16, 128);
|
add_abs(XBOX_ABS_LSY, -32768, 32767, 16, 128);
|
||||||
|
@ -254,7 +254,7 @@ public final class GameController {
|
||||||
close();
|
close();
|
||||||
throw new RuntimeException("Couldn't setup uinput device.");
|
throw new RuntimeException("Couldn't setup uinput device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LibC.fn.ioctl(fd, UI_DEV_CREATE) == -1) {
|
if (LibC.fn.ioctl(fd, UI_DEV_CREATE) == -1) {
|
||||||
close();
|
close();
|
||||||
throw new RuntimeException("Couldn't create uinput device.");
|
throw new RuntimeException("Couldn't create uinput device.");
|
||||||
|
@ -414,7 +414,7 @@ public final class GameController {
|
||||||
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
|
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
|
||||||
emit(fd, EV_ABS, XBOX_ABS_DPADX, state != 0 ? 1 : 0);
|
emit(fd, EV_ABS, XBOX_ABS_DPADX, state != 0 ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
emit(fd, EV_KEY, translateButton(button), state);
|
emit(fd, EV_KEY, translateButton(button), state);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue