diff --git a/model/input/driver/hdf_hid_adapter.c b/model/input/driver/hdf_hid_adapter.c index ca3d4e8e8cc3796d55f8fcd09943d1799d1ec8fc..56e896d9e3ab5c04df0f23c8fa7cda207e677e44 100644 --- a/model/input/driver/hdf_hid_adapter.c +++ b/model/input/driver/hdf_hid_adapter.c @@ -149,6 +149,14 @@ static void SetInputDevAbility(InputDevice *inputDev) ret = memcpy_s(inputDev->abilitySet.switchCode, len * BITS_TO_LONG(SW_CNT), info->switchCode, len * BITS_TO_LONG(SW_CNT)); MEMCPY_CHECK_RETURN(ret); + for (int i = 0; i < BITS_TO_LONG(ABS_CNT); i++) { + if (inputDev->abilitySet.absCode[i] != 0) { + ret = memcpy_s(inputDev->attrSet.axisInfo, sizeof(AbsAttr) * ABS_CNT, + info->axisInfo, sizeof(AbsAttr) * ABS_CNT); + MEMCPY_CHECK_RETURN(ret); + break; + } + } inputDev->attrSet.id.busType = info->bustype; inputDev->attrSet.id.vendor = info->vendor; @@ -345,7 +353,7 @@ static int32_t HidGetDeviceAttr(InputDevice *inputDev, struct HdfSBuf *reply) HDF_LOGE("%s: enter", __func__); ret = strncpy_s(inputDev->attrSet.devName, DEV_NAME_LEN, inputDev->devName, strlen(inputDev->devName)); - if (ret) { + if (ret != 0) { HDF_LOGE("%s: copy name from inputDev failed, ret = %d", __func__, ret); return HDF_FAILURE; } diff --git a/model/input/driver/hdf_hid_adapter.h b/model/input/driver/hdf_hid_adapter.h index dbf393b0525edeb392aeeccfc55b8f93f1694d4d..ed04dad8ad0b909b8c98f9de9f50837f645bf078 100644 --- a/model/input/driver/hdf_hid_adapter.h +++ b/model/input/driver/hdf_hid_adapter.h @@ -47,6 +47,15 @@ #define FF_MAX 0x7f #define HDF_FF_CNT (FF_MAX + 1) +typedef struct { + int32_t axis; + int32_t min; + int32_t max; + int32_t fuzz; + int32_t flat; + int32_t range; +} AbsAttr; + typedef struct HidInformation { uint32_t devType; const char *devName; @@ -61,6 +70,7 @@ typedef struct HidInformation { unsigned long soundCode[BITS_TO_LONG(HDF_SND_CNT)]; unsigned long forceCode[BITS_TO_LONG(HDF_FF_CNT)]; unsigned long switchCode[BITS_TO_LONG(HDF_SW_CNT)]; + AbsAttr axisInfo[HDF_ABS_CNT]; uint16_t bustype; uint16_t vendor; @@ -78,12 +88,13 @@ enum HidType { HID_TYPE_MOUSE, /* Mouse */ HID_TYPE_KEYBOARD, /* Keyboard */ HID_TYPE_ROCKER, /* ROCKER */ + HID_TYPE_TRACKBALL, /* TRACKBALL */ HID_TYPE_UNKNOWN, /* Unknown input device type */ }; -void SendInfoToHdf(HidInfo *info); -void* HidRegisterHdfInputDev(HidInfo *dev); -void HidUnregisterHdfInputDev(const void *inputDev); -void HidReportEvent(const void *inputDev, uint32_t type, uint32_t code, int32_t value); +void SendInfoToHdf(HidInfo* info); +void* HidRegisterHdfInputDev(HidInfo* info); +void HidUnregisterHdfInputDev(const void* inputDev); +void HidReportEvent(const void* inputDev, uint32_t type, uint32_t code, int32_t value); #endif diff --git a/model/input/driver/hdf_input_device_manager.c b/model/input/driver/hdf_input_device_manager.c index c3e762c5f6a0f498c74c291ba10fd2098823e596..b7be4010a5cf355ea539e6d54081d2fef4f46354 100644 --- a/model/input/driver/hdf_input_device_manager.c +++ b/model/input/driver/hdf_input_device_manager.c @@ -197,6 +197,7 @@ EXIT: #define DEFAULT_CROWN_BUF_PKG_NUM 20 #define DEFAULT_ENCODER_BUF_PKG_NUM 20 #define DEFAULT_ROCKER_BUF_PKG_NUM 40 +#define DEFAULT_TRACKBALL_BUF_PKG_NUM 30 static int32_t AllocPackageBuffer(InputDevice *inputDev) { @@ -223,6 +224,9 @@ static int32_t AllocPackageBuffer(InputDevice *inputDev) case INDEV_TYPE_ROCKER: pkgNum = DEFAULT_ROCKER_BUF_PKG_NUM; break; + case INDEV_TYPE_TRACKBALL: + pkgNum = DEFAULT_TRACKBALL_BUF_PKG_NUM; + break; default: HDF_LOGE("%s: devType not exist", __func__); return HDF_FAILURE; @@ -247,7 +251,7 @@ static uint32_t AllocDeviceID(InputDevice *inputDev) uint32_t idList[MAX_INPUT_DEV_NUM + 1]; uint32_t id; (void)memset_s(idList, (MAX_INPUT_DEV_NUM + 1) * sizeof(uint32_t), 0, - (MAX_INPUT_DEV_NUM + 1) * sizeof(uint32_t)); + (MAX_INPUT_DEV_NUM + 1) * sizeof(uint32_t)); while (tmpDev != NULL) { if (idList[tmpDev->devId] == 0) { idList[tmpDev->devId] = FILLER_FLAG; diff --git a/model/input/driver/hdf_input_device_manager.h b/model/input/driver/hdf_input_device_manager.h index be36197abe59534535b80fa23856389268af5954..98d247d88b91cef0c54e753daf958bfe448e790e 100644 --- a/model/input/driver/hdf_input_device_manager.h +++ b/model/input/driver/hdf_input_device_manager.h @@ -134,6 +134,7 @@ enum InputDevType { INDEV_TYPE_MOUSE, /* Mouse */ INDEV_TYPE_KEYBOARD, /* Keyboard */ INDEV_TYPE_ROCKER, /* ROCKER */ + INDEV_TYPE_TRACKBALL, /* TRACKBALL */ INDEV_TYPE_UNKNOWN, /* Unknown input device type */ }; @@ -165,6 +166,6 @@ enum TouchIoctlCmd { }; InputManager* GetInputManager(void); int32_t RegisterInputDevice(InputDevice *device); -void UnregisterInputDevice(InputDevice *device); +void UnregisterInputDevice(InputDevice *inputDev); #endif \ No newline at end of file