From b1deb15c4b365da40f6910828492394cea07cf00 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Mon, 3 Jan 2011 16:22:35 -0800 Subject: Another attempt to reduce jitter by limiting max call per second diff --git a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java index 785c11d..4c5039c 100644 --- a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java +++ b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java @@ -53,6 +53,7 @@ public class SoftKeysService extends Service { private View mDraggingViewObj; private int mDraggingOrigX, mDraggingOrigY; private int mDraggingViewX, mDraggingViewY; + private boolean mPendingDragEvent; private boolean mDidDrag; private int mNumDrags; private OrientationEventListener mOrientation; @@ -178,11 +179,16 @@ public class SoftKeysService extends Service { mDraggingView = true; mDidDrag = true; + // note: input smoother has no effect on the nook, something else is + // causing the jitters, I'm guessing we need to lock something when + // we update the params mInputSmoother.addPoint( (int)me.getRawX(), (int)me.getRawY() ); mInputSmoother.updateOutliers(); - //view.removeCallbacks( mUpdateDrag ); - view.post( mUpdateDrag ); + if( ! mPendingDragEvent ) { + mPendingDragEvent = true; + view.postDelayed( mUpdateDrag, 50 ); + } return( false ); } } @@ -238,10 +244,14 @@ public class SoftKeysService extends Service { finaly = mScreenHeight + mOffScreenMax - height; } + d( "Final xy: " + finalx + "," + finaly ); + l.x = finalx; l.y = finaly; WindowManager wm = (WindowManager)getSystemService(WINDOW_SERVICE); wm.updateViewLayout( root, l ); + + mPendingDragEvent = false; } }; -- cgit v0.10.2