james612 / android-vnc-viewer

Automatically exported from code.google.com/p/android-vnc-viewer
0 stars 0 forks source link

Not an issue: How are the trackball/touch motion events handled #140

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Can someone help me understand this code:

In trackballMouse/touchEvent handlers:

    dx = dx * dx * dx;
    dy = dy * dy * dy;

and 
        int dx = (int) (evt.getX() * 6.01);
    int dy = (int) (evt.getY() * 6.01);

Why is the 6.01 and cube funtions used here?

Thanks!

Original issue reported on code.google.com by puneet.y...@gmail.com on 23 Jun 2010 at 6:45

GoogleCodeExporter commented 8 years ago
These numbers are to scale the motion events that are delivered to the 
onTrackballEvent methods by the Android system (at least with G1 and Nexus One, 
which are the trackball-equipped models I have).  They basically come in a few 
sizes: 

0.16666, 0.33333, 1

Where 1 comes from a very fast scroll.

The multiply by 6 just changes the scale so the smallest increment represents 1 
pixel.

The cubing (actually it is 1/2 cubing now) is a dumb way to do mouse 
acceleration-- so a very fast mouse spin goes much farther than a small scroll, 
instead of linearly farther, which makes the mouse way too slow.

The mouse acceleration could probably be tweaked so it acts more naturally if I 
added a timer for how long it was continuously scrolling to the same quadrant-- 
it's not bad (for me, at least) the way it is now.

Hope this clears things up.

Original comment by googlec...@antlersoft.com on 1 Jul 2010 at 7:03