add some MotionEvent's missing api

This commit is contained in:
侯歌 2024-05-10 15:01:48 +08:00
parent f5ffaebcb5
commit 1cc9a0570f
3 changed files with 40 additions and 4 deletions

View File

@ -300,13 +300,13 @@ void Assets::loadStrings(const std::string&lan) {
const std::string suffix = "/strings-"+lan+".xml";
for(auto a:mResources) {
std::vector<std::string>files;
a.second->getEntries(files);
for(auto fileName:files){
a.second->getEntries(files);
for(auto fileName:files){
if( (TextUtils::endWith(fileName,".xml") && TextUtils::endWith(fileName,suffix) )==false)continue;
loadKeyValues(fileName,nullptr,std::bind(&Assets::parseItem,this,a.first,fileName,std::placeholders::_1,
std::placeholders::_2,std::placeholders::_3,std::placeholders::_4));
LOGD("load %s for '%s'",fileName.c_str(),lan.c_str());
}
}
}
}

View File

@ -604,7 +604,35 @@ float MotionEvent::getHistoricalX(size_t pointerIndex, size_t historicalIndex) c
}
float MotionEvent::getHistoricalY(size_t pointerIndex, size_t historicalIndex) const{
return getHistoricalRawAxisValue(AXIS_Y, pointerIndex, historicalIndex);
return getHistoricalRawAxisValue(AXIS_Y, pointerIndex, historicalIndex);
}
float MotionEvent::getHistoricalPressure(size_t pointerIndex, size_t historicalIndex) const{
return getHistoricalRawAxisValue(AXIS_PRESSURE, pointerIndex, historicalIndex);
}
float MotionEvent::getHistoricalSize(size_t pointerIndex, size_t historicalIndex) const{
return getHistoricalRawAxisValue(AXIS_SIZE, pointerIndex, historicalIndex);
}
float MotionEvent::getHistoricalTouchMajor(size_t pointerIndex, size_t historicalIndex) const{
return getHistoricalRawAxisValue(AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex);
}
float MotionEvent::getHistoricalTouchMinor(size_t pointerIndex, size_t historicalIndex) const{
return getHistoricalRawAxisValue(AXIS_TOUCH_MINOR, pointerIndex, historicalIndex);
}
float MotionEvent::getHistoricalToolMajor(size_t pointerIndex, size_t historicalIndex) const{
return getHistoricalRawAxisValue(AXIS_TOOL_MAJOR, pointerIndex, historicalIndex);
}
float MotionEvent::getHistoricalToolMinor(size_t pointerIndex, size_t historicalIndex) const{
return getHistoricalRawAxisValue(AXIS_TOOL_MINOR, pointerIndex, historicalIndex);
}
float MotionEvent::getHistoricalOrientation(size_t pointerIndex, size_t historicalIndex) const{
return getHistoricalRawAxisValue(AXIS_ORIENTATION, pointerIndex, historicalIndex);
}
template <typename T>
@ -612,6 +640,7 @@ static void appendUnless(T defValue, std::ostringstream& os,const std::string& k
if (/*DEBUG_CONCISE_TOSTRING &&*/ defValue==value) return;
os<<key<<value;
}
void MotionEvent::toStream(std::ostream& os)const{
os<<"MotionEvent { action="<<actionToString(getAction());
//appendUnless("0", msg, ", actionButton=", buttonStateToString(getActionButton()));

View File

@ -263,6 +263,13 @@ public:
float getHistoricalAxisValue(int axis, size_t pointerIndex,size_t historicalIndex) const;
float getHistoricalX(size_t pointerIndex, size_t historicalIndex) const;
float getHistoricalY(size_t pointerIndex, size_t historicalIndex) const;
float getHistoricalPressure(size_t pointerIndex, size_t historicalIndex) const;
float getHistoricalSize(size_t pointerIndex, size_t historicalIndex) const;
float getHistoricalTouchMajor(size_t pointerIndex, size_t historicalIndex) const;
float getHistoricalTouchMinor(size_t pointerIndex, size_t historicalIndex) const;
float getHistoricalToolMajor(size_t pointerIndex, size_t historicalIndex) const;
float getHistoricalToolMinor(size_t pointerIndex, size_t historicalIndex) const;
float getHistoricalOrientation(size_t pointerIndex, size_t historicalIndex) const;
float getAxisValue(int32_t axis)const;
float getAxisValue(int32_t axis, size_t pointerIndex)const;
float getX(size_t pointerIndex=0) const { return getAxisValue(AXIS_X,pointerIndex); }