Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/main/java/com/kuri0/rawinput/RawInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,26 @@ public void run() {
try {
Controller[] controllers;
controllers = createDefaultEnvironment().getControllers();
for (int i = 0; i < controllers.length; i++) {
if (controllers[i].getType() == Controller.Type.MOUSE) {
controllers[i].poll();
if (((Mouse)controllers[i]).getX().getPollData() != 0.0 || ((Mouse)controllers[i]).getY().getPollData() != 0.0) {
mouse = (Mouse)controllers[i];
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Found mouse"));
for (Controller controller : controllers) {
try {
if (controller.getType() == Controller.Type.MOUSE) {
controller.poll();
float px = ((Mouse) controller).getX().getPollData();
float py = ((Mouse) controller).getY().getPollData();
float eps = 0.1f;

// check if mouse is moving
if ((-eps < px && px < eps) || (-eps < py && py < eps)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line is causing the problem @xCuri0 is referring to. ((-eps < px && px < eps) || (-eps < py && py < eps)) will return true if either px or py is almost zero. This will cause it to detect a not-moving mouse. Rather, the line should be:

if (px < -eps || px > eps || py < -eps || py > eps)

That will only trigger the condition if the mouse is actively moving rather than the other way around.

mouse = (Mouse) controller;
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Found mouse"));
}
}
}
}
}
catch (Exception e) {
// skip to next
e.printStackTrace();
}
}
} catch (ReflectiveOperationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down