Open Cloudperry opened 1 year ago
This is mostly a note to myself, but libfix's division implementation seems to be the most complex operation with most potential for overflow bugs. Other math operations do more or less the same thing as fixedptc.h (when FIXMATH_NO_ROUND and FIXMATH_NO_OVERFLOW are used).
I think then sticking to fixedptc makes the most sense, when it did the job well without any issues.
This is a port of the current float based acceleration code to fixed point math using libfixmath.
This version has feature parity with the current float based version of leetmouse (but default parameters are displayed in a very messy format as in #29). This version is completely stable (doesn't crash the kernel) unlike the one I posted in #14. The acceleration code is probably correct and it works most of the time, but there is one big problem in libfixmath.
About once every 2 minutes some math operation overflows and it causes the cursor to jump all over the place. I have looked into this a bit and there seems to be no consistency in which line of code the overflow happens. It could happen in the acceleration code itself or rate calculation or anywhere really. I verified that when the overflow happened the operands were numbers that shouldn't overflow. However its a bit hard to debug as attempts to print fixed point numbers have a decent chance of crashing the kernel. I included some example code of printing numbers as a comment in the acceleration code.
I have tried FIXMATH_NO_OVERFLOW to see if the overflow checks themself were buggy, but that doesn't help at all. FIXMATH_NO_ROUNDING changes nothing as well.
If you really want to test a fixed point version of Leetmouse I would suggest testing #28 (only if you don't need to change parameters often as it doesn't support changing them at runtime). I have used it for 2 weeks now and it seems to fix the issues mentioned in #14.