Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed fatal errors that broke the mod #2

Open
wants to merge 1 commit into
base: 1.8.9
Choose a base branch
from

Conversation

CAG2Mark
Copy link

There were two key errors in the original mod that made it not work.

  1. When iterating through the list of controllers, if there was one exception in the entire process, the entire for loop would exit. This means that if in the list of controllers, a faulty controller is before the desired controller, the desired controller would never be reached.
  2. The original code checked for float equality (namely, the mouse position to the double 0.0 exactly). Due to floating point errors, this is a very bad idea. The best solution is to compare a range of values (for example, -0.1 < x < 0.1).

I've fixed both these issues and can confirm the mod now works.

@CAG2Mark CAG2Mark changed the title Mod now works Fixed fatal errors that broke the mod May 23, 2021
@xCuri0
Copy link
Owner

xCuri0 commented May 24, 2021

thanks will check this

@xCuri0
Copy link
Owner

xCuri0 commented May 28, 2021

image
@CAG2Mark after testing this pr it seems like its accepting devices with no movement causing it not work

@CAG2Mark
Copy link
Author

image
@CAG2Mark after testing this pr it seems like its accepting devices with no movement causing it not work

Will have a look

@vichvich4444
Copy link

Bump

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants