forked from Clones/Controlify
print driver flag
This commit is contained in:
@ -9,7 +9,6 @@ import dev.isxander.controlify.driver.*;
|
|||||||
import dev.isxander.controlify.rumble.RumbleManager;
|
import dev.isxander.controlify.rumble.RumbleManager;
|
||||||
import dev.isxander.controlify.rumble.RumbleSource;
|
import dev.isxander.controlify.rumble.RumbleSource;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import org.lwjgl.glfw.GLFWGamepadState;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -33,6 +32,7 @@ public class GamepadController extends AbstractController<GamepadState, GamepadC
|
|||||||
|
|
||||||
this.drivers = GamepadDrivers.forController(joystickId, hidInfo.hidDevice());
|
this.drivers = GamepadDrivers.forController(joystickId, hidInfo.hidDevice());
|
||||||
this.uniqueDrivers = drivers.getUniqueDrivers();
|
this.uniqueDrivers = drivers.getUniqueDrivers();
|
||||||
|
this.drivers.printDrivers();
|
||||||
|
|
||||||
this.rumbleManager = new RumbleManager(this);
|
this.rumbleManager = new RumbleManager(this);
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ public class DebugProperties {
|
|||||||
public static final boolean PRINT_JOY_STATE = boolProp("controlify.debug.print_joy_state", false, false);
|
public static final boolean PRINT_JOY_STATE = boolProp("controlify.debug.print_joy_state", false, false);
|
||||||
/* Print gyro data if supported */
|
/* Print gyro data if supported */
|
||||||
public static final boolean PRINT_GYRO = boolProp("controlify.debug.print_gyro", false, false);
|
public static final boolean PRINT_GYRO = boolProp("controlify.debug.print_gyro", false, false);
|
||||||
|
/* Print what drivers are being used */
|
||||||
|
public static final boolean PRINT_DRIVER = boolProp("controlify.debug.print_driver", false, true);
|
||||||
|
|
||||||
public static void printProperties() {
|
public static void printProperties() {
|
||||||
if (properties.stream().noneMatch(DebugProperty::enabled))
|
if (properties.stream().noneMatch(DebugProperty::enabled))
|
||||||
|
@ -6,6 +6,8 @@ public interface BasicGamepadInputDriver extends Driver {
|
|||||||
|
|
||||||
BasicGamepadState getBasicGamepadState();
|
BasicGamepadState getBasicGamepadState();
|
||||||
|
|
||||||
|
String getBasicGamepadDetails();
|
||||||
|
|
||||||
record BasicGamepadState(GamepadState.AxesState axes, GamepadState.ButtonState buttons) {
|
record BasicGamepadState(GamepadState.AxesState axes, GamepadState.ButtonState buttons) {
|
||||||
public static final BasicGamepadState EMPTY = new BasicGamepadState(GamepadState.AxesState.EMPTY, GamepadState.ButtonState.EMPTY);
|
public static final BasicGamepadState EMPTY = new BasicGamepadState(GamepadState.AxesState.EMPTY, GamepadState.ButtonState.EMPTY);
|
||||||
}
|
}
|
||||||
@ -19,5 +21,10 @@ public interface BasicGamepadInputDriver extends Driver {
|
|||||||
public BasicGamepadState getBasicGamepadState() {
|
public BasicGamepadState getBasicGamepadState() {
|
||||||
return BasicGamepadState.EMPTY;
|
return BasicGamepadState.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBasicGamepadDetails() {
|
||||||
|
return "Unsupported";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -51,4 +51,9 @@ public class GLFWGamepadDriver implements BasicGamepadInputDriver {
|
|||||||
public BasicGamepadState getBasicGamepadState() {
|
public BasicGamepadState getBasicGamepadState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBasicGamepadDetails() {
|
||||||
|
return "GLFW Gamepad";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package dev.isxander.controlify.driver;
|
package dev.isxander.controlify.driver;
|
||||||
|
|
||||||
|
import dev.isxander.controlify.Controlify;
|
||||||
import dev.isxander.controlify.controller.sdl2.SDL2NativesManager;
|
import dev.isxander.controlify.controller.sdl2.SDL2NativesManager;
|
||||||
|
import dev.isxander.controlify.debug.DebugProperties;
|
||||||
import org.hid4java.HidDevice;
|
import org.hid4java.HidDevice;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -12,6 +14,16 @@ public record GamepadDrivers(BasicGamepadInputDriver basicGamepadInputDriver, Gy
|
|||||||
return drivers;
|
return drivers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void printDrivers() {
|
||||||
|
if (DebugProperties.PRINT_DRIVER) {
|
||||||
|
Controlify.LOGGER.info("Drivers in use: Basic Input = {}, Gyro = {}, Rumble = {}",
|
||||||
|
basicGamepadInputDriver.getBasicGamepadDetails(),
|
||||||
|
gyroDriver.getGyroDetails(),
|
||||||
|
rumbleDriver.getRumbleDetails()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static GamepadDrivers forController(int jid, Optional<HidDevice> hid) {
|
public static GamepadDrivers forController(int jid, Optional<HidDevice> hid) {
|
||||||
BasicGamepadInputDriver basicGamepadInputDriver = new GLFWGamepadDriver(jid);
|
BasicGamepadInputDriver basicGamepadInputDriver = new GLFWGamepadDriver(jid);
|
||||||
GyroDriver gyroDriver = GyroDriver.UNSUPPORTED;
|
GyroDriver gyroDriver = GyroDriver.UNSUPPORTED;
|
||||||
|
@ -7,6 +7,8 @@ public interface GyroDriver extends Driver {
|
|||||||
|
|
||||||
boolean isGyroSupported();
|
boolean isGyroSupported();
|
||||||
|
|
||||||
|
String getGyroDetails();
|
||||||
|
|
||||||
GyroDriver UNSUPPORTED = new GyroDriver() {
|
GyroDriver UNSUPPORTED = new GyroDriver() {
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
@ -21,5 +23,10 @@ public interface GyroDriver extends Driver {
|
|||||||
public boolean isGyroSupported() {
|
public boolean isGyroSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGyroDetails() {
|
||||||
|
return "Unsupported";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ public interface RumbleDriver extends Driver {
|
|||||||
|
|
||||||
boolean isRumbleSupported();
|
boolean isRumbleSupported();
|
||||||
|
|
||||||
|
String getRumbleDetails();
|
||||||
|
|
||||||
RumbleDriver UNSUPPORTED = new RumbleDriver() {
|
RumbleDriver UNSUPPORTED = new RumbleDriver() {
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
@ -19,5 +21,10 @@ public interface RumbleDriver extends Driver {
|
|||||||
public boolean isRumbleSupported() {
|
public boolean isRumbleSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRumbleDetails() {
|
||||||
|
return "Unsupported";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -56,4 +56,14 @@ public class SDL2GamepadDriver implements GyroDriver, RumbleDriver {
|
|||||||
public void close() {
|
public void close() {
|
||||||
SDL.SDL_GameControllerClose(ptrGamepad);
|
SDL.SDL_GameControllerClose(ptrGamepad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGyroDetails() {
|
||||||
|
return "SDL2 supported=%s".formatted(isGyroSupported);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRumbleDetails() {
|
||||||
|
return "SDL2 supported=%s".formatted(isRumbleSupported);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,16 @@ public class SteamDeckDriver implements GyroDriver, BasicGamepadInputDriver {
|
|||||||
hidDevice.close();
|
hidDevice.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBasicGamepadDetails() {
|
||||||
|
return "SteamDeck HIDAPI";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGyroDetails() {
|
||||||
|
return "SteamDeck HIDAPI";
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/kmicki/SteamDeckGyroDSU/blob/574745406011cc2433fc6f179446ecc836180aa4/inc/sdgyrodsu/sdhidframe.h
|
// https://github.com/kmicki/SteamDeckGyroDSU/blob/574745406011cc2433fc6f179446ecc836180aa4/inc/sdgyrodsu/sdhidframe.h
|
||||||
private record Frame(
|
private record Frame(
|
||||||
int header,
|
int header,
|
||||||
|
Reference in New Issue
Block a user