Eye Tracking Support, Minecraft Without Hands

Add support for eye tracking hardware, eg the Tobii 5.
Add settings to toggle eye tracking in the settings menu.
Add settings to adjust the deadzone while looking at the crosshair.
Disable mouse raw input while eye tracking is in use, as these two modes are not compatible.
This commit is contained in:
Kabliz
2023-05-08 20:07:01 -07:00
parent 889a5d8d58
commit 60bd283c4c
7 changed files with 202 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
package eu.midnightdust.midnightcontrols.client.mixin;
import net.minecraft.client.util.InputUtil;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Final;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import java.lang.invoke.MethodHandle;
@Mixin(InputUtil.class)
public abstract class InputUtilMixin {
@Final
@Shadow
private static MethodHandle GLFW_RAW_MOUSE_MOTION_SUPPORTED_HANDLE;
/**
* @author kabliz
* @reason This method is static, and there is a terrible UX issue if raw input is turned on at the same time as
* eye tracking. Raw input only tracks literal mice and not other devices, leading to the game appearing to be
* unresponsive and the player not understanding why. This overwrite preserves the user's mouse preferences,
* while not interfering with eye tracking, and the two modes can be switched between during a play session.
*/
@Overwrite
public static boolean isRawMouseMotionSupported(){
if(MidnightControlsConfig.eyeTrackerAsMouse){
return false;
} else { //Paste original implementation from InputUtil below.
try {
return GLFW_RAW_MOUSE_MOTION_SUPPORTED_HANDLE != null &&
(boolean) GLFW_RAW_MOUSE_MOTION_SUPPORTED_HANDLE.invokeExact();
} catch (Throwable var1) {
throw new RuntimeException(var1);
}
}
}
}