CyberVillain wrote:hm ok. will have to look into it, that code looks a bit strange.
basically what you do is
if deltax > 0.5 then substract it with closest integer of deltax
Yes there are two things to consider here that need to change in your code:
1) Resetting pitch when only yaw moved (and vice versa)
Imagine you are moving the sensor from left to right but also slightly downward. If the sensor refresh rate is fast enough and the movement slow the vertical movement will be ignored since you are zeroing this everytime you adjust the yaw.
I.e.
1st Cycle
yaw = 1.2
pitch = -0.4
2nd cycle
yaw = 0.9
pitch = -0.35
3rd cycle
yaw= 1.3
pitch = 0.49
In this situation you would "lose" the pitch movement since you are resetting it in your code however it should have moved 1 pixel down.
2) You need to keep the remainder delta to the next cycle. Imagine the following situation:
100 cycles of yaw = 0.6
then
100 cycles of yaw = -1
What would actually happen here is that you would move your sensor the equivalent of 60 pixels to the right. You would then move it the equivalent of 100 pixels to the left. However the mouse would have moved the the exact same amount of pixels on both directions, again leading to "lost" movement. You can see this is clearly not right.
Whereas by keeping the remainder it works like this:
1st cycle
0.6 (mouse moves 1 pixel right)
remainder = 0.6 - 1 (Integer Value) = -0.4
2nd cycle
0.6 + -0.4 = 0.2 (mouse does not move)
0.2 - 0 (integer value) = 0.2
3rd cycle
0.6 = 0.2 = 0.8 (mouse moves 1 pixel)
You actually dont need to check if it is > 0.5 as this will round down (like in the 2nd cycle) whereby no change is made to the delta.
Therefore the only change to your code to solve both problems is
Code: Select all
deltaXOut = deltaXOut - (int)deltaXOut;
deltaYOut = deltaYOut - (int)deltaYOut;
on line 110 of FreePIE.Core.Plugins/MousePlugin.cs
instead of
deltaXOut = 0;
deltaYOut = 0;
I appreciate this is hard to test if you don't have the right hardware. I believe the reason I experience it with the YEI is because the refresh rate is very high and the change in delta is very precise.
However having played with this for quite a few hours I can assure you my method has been tested correct.