mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-05 21:58:44 +08:00
remove MotionEvent's global data
This commit is contained in:
parent
ab33bf0c91
commit
0d3f89a106
@ -477,13 +477,13 @@ int TouchDevice::getActionByBits(int& pointIndex){
|
||||
|
||||
static std::string printEvent(MotionEvent*e){
|
||||
std::ostringstream oss;
|
||||
oss<<"MotionEvent::Acion="<<e->getActionMasked()<<" Index="<<e->getActionIndex()<<" eventTime:"<<e->getEventTime();
|
||||
oss<<"MotionEvent::Acion="<<e->getActionMasked()<<" Index="<<e->getActionIndex()<<" eventTime:"<<e->getDownTime()<<"/"<<e->getEventTime();
|
||||
oss<<" ("<<int(e->getX())<<","<<int(e->getY())<<"}"<<" historySize="<<e->getHistorySize();
|
||||
for(int i=0;i<e->getPointerCount();i++){
|
||||
oss<<std::endl<<" Pointer["<<i<<"].id="<<e->getPointerId(i)<<" ";
|
||||
oss<<"("<<int(e->getX(i))<<","<<int(e->getY(i))<<") {";
|
||||
for(int j=0;j<e->getHistorySize();j++){
|
||||
oss<<"("<<int(e->getHistoricalX(i,j))<<","<<int(e->getHistoricalY(i,j))<<")";
|
||||
oss<<"("<<e->getHistoricalEventTime(j)<<":"<<int(e->getHistoricalX(i,j))<<","<<int(e->getHistoricalY(i,j))<<")";
|
||||
}
|
||||
oss<<"}";
|
||||
}
|
||||
@ -534,19 +534,19 @@ int TouchDevice::putRawEvent(const struct timeval&tv,int type,int code,int value
|
||||
case EV_SYN:
|
||||
if((code!=SYN_REPORT) && (code!=SYN_MT_REPORT))break;
|
||||
#if defined(USE_TRACKINGID_AS_POINTERID)&&USE_TRACKINGID_AS_POINTERID
|
||||
slot = mTrack2Slot.indexOfKey(mProp.id);
|
||||
slot = mTrack2Slot.indexOfKey(mProp.id);
|
||||
#else
|
||||
slot = mProp.id;
|
||||
slot = mProp.id;
|
||||
#endif
|
||||
slot = slot>=0?slot:0;
|
||||
mPointerProps [slot] = mProp;
|
||||
mPointerCoords[slot] = mCoord;
|
||||
if(code==SYN_MT_REPORT)break;
|
||||
if(code==SYN_MT_REPORT)break;
|
||||
action = getActionByBits(pointerIndex);
|
||||
mMoveTime =(tv.tv_sec * 1000LL + tv.tv_usec/1000);
|
||||
lastEvent = mEvents.size()>1?(MotionEvent*)mEvents.back():nullptr;
|
||||
pointerCount =(mDeviceClasses&INPUT_DEVICE_CLASS_TOUCH_MT)?std::max(mLastBits.count(),mCurrBits.count()):1;
|
||||
if(lastEvent&&(lastEvent->getActionMasked()==MotionEvent::ACTION_MOVE)&&(action==MotionEvent::ACTION_MOVE)&&(mMoveTime-lastEvent->getDownTime()<10)){
|
||||
if(lastEvent&&(lastEvent->getActionMasked()==MotionEvent::ACTION_MOVE)&&(action==MotionEvent::ACTION_MOVE)&&(mMoveTime-lastEvent->getDownTime()<100)){
|
||||
auto lastTime = lastEvent->getDownTime();
|
||||
lastEvent->addSample(mMoveTime,mPointerCoords.data());
|
||||
LOGV("eventdur=%d %s",int(mMoveTime-lastTime),printEvent(lastEvent).c_str());
|
||||
@ -556,7 +556,7 @@ int TouchDevice::putRawEvent(const struct timeval&tv,int type,int code,int value
|
||||
const PointerProperties*props= useBackupProps ? mPointerPropsBak.data() : mPointerProps.data();
|
||||
mEvent = MotionEvent::obtain(mMoveTime , mMoveTime , action , pointerCount,props,coords, 0/*metaState*/,mButtonState,
|
||||
0,0/*x/yPrecision*/,getId()/*deviceId*/, 0/*edgeFlags*/, getSources(), 0/*flags*/);
|
||||
LOGV_IF(action!=MotionEvent::ACTION_MOVE||1,"mask=%08x,%08x (%.f,%.f)\n%s",mLastBits.value,mCurrBits.value,mCoord.getX(),mCoord.getY(),printEvent(mEvent).c_str());
|
||||
LOGV_IF(action!=MotionEvent::ACTION_MOVE,"mask=%08x,%08x (%.f,%.f)\n%s",mLastBits.value,mCurrBits.value,mCoord.getX(),mCoord.getY(),printEvent(mEvent).c_str());
|
||||
mEvent->setActionButton(mActionButton);
|
||||
mEvent->setAction(action|(pointerIndex<<MotionEvent::ACTION_POINTER_INDEX_SHIFT));
|
||||
|
||||
@ -587,7 +587,7 @@ int TouchDevice::putRawEvent(const struct timeval&tv,int type,int code,int value
|
||||
if( (mDeviceClasses&INPUT_DEVICE_CLASS_TOUCH_MT) && (mTypeB==false) ){
|
||||
mCurrBits.clear(); //only typeA
|
||||
mTrack2Slot.clear();
|
||||
for(int i=0;i<pointerCount;i++){mPointerCoords[i].clear();mPointerCoords[i].clear();};
|
||||
for(int i = 0;i < pointerCount;i++){mPointerCoords[i].clear();mPointerCoords[i].clear();};
|
||||
}
|
||||
break;/*caseof EV_SYN*/
|
||||
}
|
||||
|
@ -106,9 +106,6 @@ void PointerProperties::copyFrom(const PointerProperties& other) {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
PointerCoords* MotionEvent::gSharedTempPointerCoords=nullptr;
|
||||
PointerProperties* MotionEvent::gSharedTempPointerProperties=nullptr;
|
||||
int* MotionEvent::gSharedTempPointerIndexMap=nullptr;
|
||||
|
||||
void MotionEvent::ensureSharedTempPointerCapacity(int desiredCapacity){
|
||||
}
|
||||
@ -235,7 +232,7 @@ void MotionEvent::copyFrom(const MotionEvent* other, bool keepHistory) {
|
||||
mDownTime = other->mDownTime;
|
||||
mEventTime= other->mEventTime;
|
||||
mSource = other->mSource;
|
||||
mDisplayId =other->mDisplayId;
|
||||
mDisplayId = other->mDisplayId;
|
||||
mPointerProperties = other->mPointerProperties;
|
||||
|
||||
if (keepHistory) {
|
||||
@ -348,7 +345,7 @@ MotionEvent* MotionEvent::clampNoHistory(float left, float top, float right, flo
|
||||
for (int i = 0; i < pointerCount; i++) {
|
||||
pp[i] = mPointerProperties[i];//nativeGetPointerProperties(mNativePtr,i,pp[i]);
|
||||
getPointerCoords(i,pc[i]);//nativeGetPointerCoords(mNativePtr,i,HISTORY_CURRENT,pc[i]);
|
||||
pc[i].x = clamp(pc[i].x, left, right);
|
||||
pc[i].x = clamp(pc[i].x, left, right);
|
||||
pc[i].y = clamp(pc[i].y, top, bottom);
|
||||
}
|
||||
#endif
|
||||
@ -388,17 +385,17 @@ nsecs_t MotionEvent::getHistoricalEventTime(size_t historyPos) const{
|
||||
return getEventTime();
|
||||
}else{
|
||||
const size_t historySize = getHistorySize();
|
||||
if(historyPos<0||historyPos>=historySize)return 0;
|
||||
if((historyPos<0)||(historyPos>=historySize))return 0;
|
||||
return mSampleEventTimes[historyPos];
|
||||
}
|
||||
}
|
||||
|
||||
nsecs_t MotionEvent::getHistoricalEventTimeNanos(size_t historyPos) const{
|
||||
if(historyPos==HISTORY_CURRENT){
|
||||
return getEventTimeNanos();
|
||||
return getEventTimeNanos();
|
||||
}else{
|
||||
const size_t historySize = getHistorySize();
|
||||
if(historyPos<0||historyPos>=historySize)return 0;
|
||||
if((historyPos<0)||(historyPos>=historySize))return 0;
|
||||
return mSampleEventTimes[historyPos]*NS_PER_MS;
|
||||
}
|
||||
}
|
||||
|
@ -164,9 +164,6 @@ public:
|
||||
};
|
||||
private:
|
||||
static const int HISTORY_CURRENT = -0x80000000;
|
||||
static PointerCoords* gSharedTempPointerCoords;
|
||||
static PointerProperties* gSharedTempPointerProperties;
|
||||
static int* gSharedTempPointerIndexMap;
|
||||
static MotionEvent*obtain();
|
||||
static void ensureSharedTempPointerCapacity(int desiredCapacity);
|
||||
protected:
|
||||
|
@ -122,7 +122,7 @@ private:
|
||||
static VelocityTrackerStrategy* createStrategy(const char* strategy);
|
||||
};
|
||||
|
||||
const char* VelocityTrackerImpl::DEFAULT_STRATEGY = "impulse";//"impulse";//"lsq2";
|
||||
const char* VelocityTrackerImpl::DEFAULT_STRATEGY = "lsq2";//"impulse";//"lsq2";
|
||||
|
||||
VelocityTrackerImpl::VelocityTrackerImpl(const char* strategy) :
|
||||
mLastEventTime(0), mCurrentPointerIdBits(0), mActivePointerId(-1) {
|
||||
@ -514,7 +514,7 @@ static float calculateImpulseVelocity(const nsecs_t* t, const float* x, size_t c
|
||||
return 0; // if 0 or 1 points, velocity is zero
|
||||
}
|
||||
if (t[1] > t[0]) { // Algorithm will still work, but not perfectly
|
||||
LOGE("Samples provided to calculateImpulseVelocity in the wrong order");
|
||||
LOGE("Samples(%lld,%lld) provided to calculateImpulseVelocity in the wrong order",t[1],t[0]);
|
||||
}
|
||||
if (count == 2) { // if 2 points, basic linear calculation
|
||||
if (t[1] == t[0]) {
|
||||
|
Loading…
Reference in New Issue
Block a user