There's a potential divide by zero. I could see that causing jerky mouse at low movement rates since the counter will tend towards zero the slower it's moved, so more chances for an exception or whatever that MCU does in that case.
This should be split into 2 blocks, otherwise if both axis change direction at the same time the Y axis won't get reversed correctly until the next USB report, causing the Y axis to move wrong/jerky for a short while.
(copied from email source)
There's a potential divide by zero. I could see that causing jerky mouse at low movement rates since the counter will tend towards zero the slower it's moved, so more chances for an exception or whatever that MCU does in that case.
Change line 519: from: timerTopValue = ((10000 / timerTopValue) / 64) - 1;
to: if (timerTopValue > 0) timerTopValue = ((10000 / timerTopValue) / 64) - 1; else timerTopValue = 155;
Also found another minor bug where it detects a change in direction starting in line 380
if (MouseReport.X > 0 && mouseDirectionX == 0) { mouseDistanceX = 0; mouseDirectionX = 1; } else if (MouseReport.X < 0 && mouseDirectionX == 1) { mouseDistanceX = 0; mouseDirectionX = 0; } else if (MouseReport.Y > 0 && mouseDirectionY == 0) { mouseDistanceY = 0; mouseDirectionY = 1; } else if (MouseReport.Y < 0 && mouseDirectionY == 1) { mouseDistanceY = 0; mouseDirectionY = 0; }
This should be split into 2 blocks, otherwise if both axis change direction at the same time the Y axis won't get reversed correctly until the next USB report, causing the Y axis to move wrong/jerky for a short while.
if (MouseReport.X > 0 && mouseDirectionX == 0) { mouseDistanceX = 0; mouseDirectionX = 1; } else if (MouseReport.X < 0 && mouseDirectionX == 1) { mouseDistanceX = 0; mouseDirectionX = 0; }
if (MouseReport.Y > 0 && mouseDirectionY == 0) { mouseDistanceY = 0; mouseDirectionY = 1; } else if (MouseReport.Y < 0 && mouseDirectionY == 1) { mouseDistanceY = 0; mouseDirectionY = 0; }