From 00a54c4a9b366e76be0e4d3248ff8af728da463b Mon Sep 17 00:00:00 2001 From: houzh Date: Sat, 24 Dec 2022 10:05:39 +0000 Subject: [PATCH] motion range --- src/gui/core/inputdevice.cc | 2 +- src/porting/include/cdinput.h | 2 +- src/porting/sigma/input_linux.cc | 9 +++++---- src/porting/x64/input_linux.cc | 9 +++++---- tests/porting/input_unittests.cc | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/gui/core/inputdevice.cc b/src/gui/core/inputdevice.cc index 747d1023..a74fc7cc 100644 --- a/src/gui/core/inputdevice.cc +++ b/src/gui/core/inputdevice.cc @@ -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;imaximum-axis->minimum)>0){ info.addMotionRange(axis->axis,0/*source*/,axis->minimum,axis->maximum,axis->flat,axis->fuzz,axis->resolution); diff --git a/src/porting/include/cdinput.h b/src/porting/include/cdinput.h index 735b8b44..9099f4a0 100755 --- a/src/porting/include/cdinput.h +++ b/src/porting/include/cdinput.h @@ -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; diff --git a/src/porting/sigma/input_linux.cc b/src/porting/sigma/input_linux.cc index ad5435c9..21ca42ae 100755 --- a/src/porting/sigma/input_linux.cc +++ b/src/porting/sigma/input_linux.cc @@ -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;iaxis+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); diff --git a/src/porting/x64/input_linux.cc b/src/porting/x64/input_linux.cc index 2b8625cd..6b2d88ef 100755 --- a/src/porting/x64/input_linux.cc +++ b/src/porting/x64/input_linux.cc @@ -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;iaxis+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); diff --git a/tests/porting/input_unittests.cc b/tests/porting/input_unittests.cc index e93f32f7..a633847d 100755 --- a/tests/porting/input_unittests.cc +++ b/tests/porting/input_unittests.cc @@ -56,11 +56,11 @@ TEST_F(INPUT,AxisInfo){ INPUTDEVICEINFO info; if(0maximum-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); } } }