Android触屏事件处理策略
来源:互联网 发布:淘宝店全屏自定义代码 编辑:程序博客网 时间:2024/06/05 11:22
在frameworks/base/libs/androidfw/VelocityTracker.cpp
VelocityTrackerStrategy* VelocityTracker::createStrategy(const char* strategy) {
if (!strcmp("lsq1", strategy)) {
// 1st order least squares. Quality: POOR.
// Frequently underfits the touch data especially when the finger accelerates
// or changes direction. Often underestimates velocity. The direction
// is overly influenced by historical touch points.
return new LeastSquaresVelocityTrackerStrategy(1);
}
if (!strcmp("lsq2", strategy)) {
// 2nd order least squares. Quality: VERY GOOD.
// Pretty much ideal, but can be confused by certain kinds of touch data,
// particularly if the panel has a tendency to generate delayed,
// duplicate or jittery touch coordinates when the finger is released.
return new LeastSquaresVelocityTrackerStrategy(2);
}
if (!strcmp("lsq3", strategy)) {
// 3rd order least squares. Quality: UNUSABLE.
// Frequently overfits the touch data yielding wildly divergent estimates
// of the velocity when the finger is released.
return new LeastSquaresVelocityTrackerStrategy(3);
}
if (!strcmp("wlsq2-delta", strategy)) {
// 2nd order weighted least squares, delta weighting. Quality: EXPERIMENTAL
return new LeastSquaresVelocityTrackerStrategy(2,
LeastSquaresVelocityTrackerStrategy::WEIGHTING_DELTA);
}
if (!strcmp("wlsq2-central", strategy)) {
// 2nd order weighted least squares, central weighting. Quality: EXPERIMENTAL
return new LeastSquaresVelocityTrackerStrategy(2,
LeastSquaresVelocityTrackerStrategy::WEIGHTING_CENTRAL);
}
if (!strcmp("wlsq2-recent", strategy)) {
// 2nd order weighted least squares, recent weighting. Quality: EXPERIMENTAL
return new LeastSquaresVelocityTrackerStrategy(2,
LeastSquaresVelocityTrackerStrategy::WEIGHTING_RECENT);
}
if (!strcmp("int1", strategy)) {
// 1st order integrating filter. Quality: GOOD.
// Not as good as 'lsq2' because it cannot estimate acceleration but it is
// more tolerant of errors. Like 'lsq1', this strategy tends to underestimate
// the velocity of a fling but this strategy tends to respond to changes in
// direction more quickly and accurately.
return new IntegratingVelocityTrackerStrategy(1);
}
if (!strcmp("int2", strategy)) {
// 2nd order integrating filter. Quality: EXPERIMENTAL.
// For comparison purposes only. Unlike 'int1' this strategy can compensate
// for acceleration but it typically overestimates the effect.
return new IntegratingVelocityTrackerStrategy(2);
}
if (!strcmp("legacy", strategy)) {
// Legacy velocity tracker algorithm. Quality: POOR.
// For comparison purposes only. This algorithm is strongly influenced by
// old data points, consistently underestimates velocity and takes a very long
// time to adjust to changes in direction.
return new LegacyVelocityTrackerStrategy();
}
return NULL;
}
默认策略是:
const char* VelocityTracker::DEFAULT_STRATEGY = "lsq2";
可通过
property "debug.velocitytracker.strategy" 修改。如修改为lsq1 。这个需要和kernel中的TP驱动一起调试,
lsq2是最优效果,表示上报的速度是一个抛物线;lsq1上报的速度是一个加速度直线。这个需要和kernel上报一致。才能触动流畅。
VelocityTracker::VelocityTracker(const char* strategy) :
mLastEventTime(0), mCurrentPointerIdBits(0), mActivePointerId(-1) {
char value[PROPERTY_VALUE_MAX];
// Allow the default strategy to be overridden using a system property for debugging.
if (!strategy) {
int length = property_get("debug.velocitytracker.strategy", value, NULL);
if (length > 0) {
strategy = value;
} else {
strategy = DEFAULT_STRATEGY;
}
}
// Configure the strategy.
if (!configureStrategy(strategy)) {
ALOGD("Unrecognized velocity tracker strategy name '%s'.", strategy);
if (!configureStrategy(DEFAULT_STRATEGY)) {
LOG_ALWAYS_FATAL("Could not create the default velocity tracker strategy '%s'!",
strategy);
}
}
}
阅读全文
0 0
- Android触屏事件处理策略
- android事件过滤策略
- android触屏事件处理onInterceptTouchEvent
- android触屏事件处理总结--dispatchTouchEvent
- android触屏事件处理总结--dispatchTouchEvent
- Android触屏事件处理流程浅析
- android触屏事件处理onInterceptTo…
- Android 触屏事件处理_手势识别 鼠标事件
- android处理处理触屏事件的流程
- 【Android】 Android 事件处理
- android触屏事件处理onInterceptTouchEvent的问题
- android触屏事件处理onInterceptTouchEvent的问题
- android游戏开发(二)触屏事件处理
- 事件处理机制之触屏事件
- Android 触屏事件 OnTouch onClick onTouchEvent对于触屏事件的处理和分发
- Android怎样处理横屏事件
- Android 处理横竖屏切换事件
- android按键事件和触屏事件(4)-listview的setOnItemClickListener点击无效的处理
- [转] Android xml资源文件中@、@android:type、@*、?、@+含义和区别
- Mms中加入附件的处理
- 转:Android定制出厂默认输入法
- 分布式锁
- 脚本统计ip的海外用户分布情况或者国内省份的分布情况
- Android触屏事件处理策略
- Flask网页框架实践
- android转屏时数据保存问题
- git diff 的功能与用法
- Android中使用RadioGroup实现Fragment的切换
- 日期加减 mysql
- Android各种帮助开发工具
- PowerManager规则
- volatile关键字