motion range

This commit is contained in:
houzh 2022-12-24 10:05:39 +00:00
parent 9092aaa3ac
commit 00a54c4a9b
5 changed files with 14 additions and 12 deletions

View File

@ -30,7 +30,7 @@ static bool containsNonZeroByte(const uint8_t* array, uint32_t startIndex, uint3
#define SIZEOF_BITS(bits) (((bits) + 7) / 8)
static int getMotionRanges(InputDeviceInfo&info,INPUTDEVICEINFO&dev){
for(int i=0;i<sizeof(dev.axis)/sizeof(INPUTAXISINFO);i++){
for(int i=0;(i<ABS_CNT) && (i<sizeof(dev.axis)/sizeof(INPUTAXISINFO));i++){
INPUTAXISINFO*axis=dev.axis+i;
if(std::abs(axis->maximum-axis->minimum)>0){
info.addMotionRange(axis->axis,0/*source*/,axis->minimum,axis->maximum,axis->flat,axis->fuzz,axis->resolution);

View File

@ -48,7 +48,7 @@ typedef struct{
BYTE ledBitMask[4];
BYTE ffBitMask [16];
BYTE propBitMask[4];
INPUTAXISINFO axis[32];
INPUTAXISINFO axis[64/*ABS_CNT*/];
char name[MAX_DEVICE_NAME];
}INPUTDEVICEINFO;

View File

@ -84,16 +84,17 @@ INT InputGetDeviceInfo(int device,INPUTDEVICEINFO*devinfo){
struct input_id id;
rc1=ioctl(device, EVIOCGNAME(sizeof(devinfo->name) - 1),devinfo->name);
rc2=ioctl(device, EVIOCGID, &id);
for(int i=0;i<ABS_CNT;i++){
for(int i=0,j=0;i<ABS_CNT;i++){
struct input_absinfo info;
INPUTAXISINFO*a = devinfo->axis+i;
if(0==ioctl(device, EVIOCGABS(i),&info)){
if((0==ioctl(device, EVIOCGABS(i),&info))&&(info.minimum!=info.maximum)){
INPUTAXISINFO*a = devinfo->axis+j++;
a->axis = i;
a->fuzz =info.fuzz;
a->flat =info.flat;
a->minimum=info.minimum;
a->maximum=info.maximum;
a->resolution=info.resolution;
LOGD_IF(a->maximum-a->minimum,"axis[%d]=[%d,%d]",i, a->minimum,a->maximum);
LOGI_IF(a->maximum-a->minimum,"axis[%d]=[%d,%d]",a->axis, a->minimum,a->maximum);
}
}
LOGD_IF(rc2,"fd=%d[%s] rc1=%d,rc2=%d x=[%d,%d] y=[%d,%d]",device,devinfo->name,rc1,rc2);

View File

@ -84,16 +84,17 @@ INT InputGetDeviceInfo(int device,INPUTDEVICEINFO*devinfo){
struct input_id id;
rc1=ioctl(device, EVIOCGNAME(sizeof(devinfo->name) - 1),devinfo->name);
rc2=ioctl(device, EVIOCGID, &id);
for(int i=0;i<ABS_CNT;i++){
for(int i=0,j=0;i<ABS_CNT;i++){
struct input_absinfo info;
INPUTAXISINFO*a = devinfo->axis+i;
if(0==ioctl(device, EVIOCGABS(i),&info)){
if((0==ioctl(device, EVIOCGABS(i),&info)) && (info.minimum!=info.maximum)){
INPUTAXISINFO*a = devinfo->axis+j++;
a->axis =i;
a->fuzz =info.fuzz;
a->flat =info.flat;
a->minimum=info.minimum;
a->maximum=info.maximum;
a->resolution=info.resolution;
LOGD_IF(a->maximum-a->minimum,"axis[%d]=[%d,%d]",i, a->minimum,a->maximum);
LOGD_IF(a->maximum-a->minimum,"axis[%d]=[%d,%d]",a->axis, a->minimum,a->maximum);
}
}
LOGD_IF(rc2,"fd=%d[%s] rc1=%d,rc2=%d",device,devinfo->name,rc1,rc2);

View File

@ -56,11 +56,11 @@ TEST_F(INPUT,AxisInfo){
INPUTDEVICEINFO info;
if(0<InputGetEvents(keys,16,500)){
InputGetDeviceInfo(keys[0].device,&info);
for(int j=0;j<ABS_CNT;j++){
for(int j=0;(j<ABS_CNT)&&(j<sizeof(info.axis)/sizeof(INPUTAXISINFO));j++){
INPUTAXISINFO*a=info.axis+j;
if(std::abs(a->maximum-a->minimum)>0){
axises++;
printf("axis[%d] range=[%d,%d]\r\n",j,a->minimum,a->maximum);
printf("axis[%d] range=[%d,%d]\r\n",a->axis,a->minimum,a->maximum);
}
}
}