From d5f5f04e40e86708bc5f8b8d03621fb1636445c8 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 6 Sep 2021 08:57:03 +0000 Subject: [PATCH 01/10] add trackball Signed-off-by: YOUR_NAME --- model/input/driver/hdf_hid_adapter.c | 10 +++++++++- model/input/driver/hdf_hid_adapter.h | 19 +++++++++++++++---- model/input/driver/hdf_input_device_manager.c | 6 +++++- model/input/driver/hdf_input_device_manager.h | 3 ++- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/model/input/driver/hdf_hid_adapter.c b/model/input/driver/hdf_hid_adapter.c index ca3d4e8e..56e896d9 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 dbf393b0..ed04dad8 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 c3e762c5..b7be4010 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 be36197a..98d247d8 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 From c699e67f08f8c7fdeee1ef0692b079a806364c9c Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 6 Sep 2021 09:21:42 +0000 Subject: [PATCH 02/10] add trackball Signed-off-by: YOUR_NAME --- model/input/driver/hdf_hid_adapter.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/model/input/driver/hdf_hid_adapter.c b/model/input/driver/hdf_hid_adapter.c index 56e896d9..6d3916c5 100644 --- a/model/input/driver/hdf_hid_adapter.c +++ b/model/input/driver/hdf_hid_adapter.c @@ -101,6 +101,19 @@ static void FreeCachedInfo() } } +static int32_t SetInputDevAbsAttr(InputDevice *inputDev, HidInfo *info) +{ + int32_t 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); + return ret; + } + } + return HDF_SUCCESS; +} + static void SetInputDevAbility(InputDevice *inputDev) { HidInfo *info = NULL; @@ -149,14 +162,8 @@ 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; - } - } + ret = SetInputDevAbsAttr(inputDev, info); + MEMCPY_CHECK_RETURN(ret); inputDev->attrSet.id.busType = info->bustype; inputDev->attrSet.id.vendor = info->vendor; From 89ec00f009520f4ca34cf3201590e768e00bc2c7 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 6 Sep 2021 09:32:45 +0000 Subject: [PATCH 03/10] add trackball Signed-off-by: YOUR_NAME --- model/input/driver/hdf_hid_adapter.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/model/input/driver/hdf_hid_adapter.c b/model/input/driver/hdf_hid_adapter.c index 6d3916c5..f9fd3629 100644 --- a/model/input/driver/hdf_hid_adapter.c +++ b/model/input/driver/hdf_hid_adapter.c @@ -114,12 +114,10 @@ static int32_t SetInputDevAbsAttr(InputDevice *inputDev, HidInfo *info) return HDF_SUCCESS; } -static void SetInputDevAbility(InputDevice *inputDev) +static int32_t GetInfoFromCache(HidInfo *info) { - HidInfo *info = NULL; - int32_t id = 0; - uint32_t len; int32_t ret; + int32_t id = 0; while (id < MAX_INPUT_DEV_NUM) { if(g_cachedInfo[id] != NULL && !strcmp(inputDev->devName, g_cachedInfo[id]->devName)) { info = g_cachedInfo[id]; @@ -129,8 +127,19 @@ static void SetInputDevAbility(InputDevice *inputDev) } if (id == MAX_INPUT_DEV_NUM || info == NULL) { HDF_LOGE("%s: match cached info failed", __func__); - return; + return HDF_FAILURE; } + return HDF_SUCCESS; +} + +static void SetInputDevAbility(InputDevice *inputDev) +{ + HidInfo *info = NULL; + uint32_t len; + int32_t ret; + + ret = GetInfoFromCache(info); + MEMCPY_CHECK_RETURN(ret); len = sizeof(unsigned long); ret = memcpy_s(inputDev->abilitySet.devProp, len * BITS_TO_LONG(INPUT_PROP_CNT), info->devProp, len * BITS_TO_LONG(INPUT_PROP_CNT)); From df96815239ee4a93baf20804853f4f8855809ded Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 6 Sep 2021 09:48:00 +0000 Subject: [PATCH 04/10] add trackball Signed-off-by: YOUR_NAME --- model/input/driver/hdf_hid_adapter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/input/driver/hdf_hid_adapter.c b/model/input/driver/hdf_hid_adapter.c index f9fd3629..5144a3ad 100644 --- a/model/input/driver/hdf_hid_adapter.c +++ b/model/input/driver/hdf_hid_adapter.c @@ -114,7 +114,7 @@ static int32_t SetInputDevAbsAttr(InputDevice *inputDev, HidInfo *info) return HDF_SUCCESS; } -static int32_t GetInfoFromCache(HidInfo *info) +static int32_t GetInfoFromCache(InputDevice *inputDev, HidInfo *info) { int32_t ret; int32_t id = 0; @@ -138,7 +138,7 @@ static void SetInputDevAbility(InputDevice *inputDev) uint32_t len; int32_t ret; - ret = GetInfoFromCache(info); + ret = GetInfoFromCache(inputDev, info); MEMCPY_CHECK_RETURN(ret); len = sizeof(unsigned long); ret = memcpy_s(inputDev->abilitySet.devProp, len * BITS_TO_LONG(INPUT_PROP_CNT), From 5e51b5feaaea82d3f0df84e3ea1be9049677cb08 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 6 Sep 2021 10:58:49 +0000 Subject: [PATCH 05/10] add trackball Signed-off-by: YOUR_NAME --- model/input/driver/hdf_hid_adapter.c | 1 - 1 file changed, 1 deletion(-) diff --git a/model/input/driver/hdf_hid_adapter.c b/model/input/driver/hdf_hid_adapter.c index 5144a3ad..b5ddae8f 100644 --- a/model/input/driver/hdf_hid_adapter.c +++ b/model/input/driver/hdf_hid_adapter.c @@ -116,7 +116,6 @@ static int32_t SetInputDevAbsAttr(InputDevice *inputDev, HidInfo *info) static int32_t GetInfoFromCache(InputDevice *inputDev, HidInfo *info) { - int32_t ret; int32_t id = 0; while (id < MAX_INPUT_DEV_NUM) { if(g_cachedInfo[id] != NULL && !strcmp(inputDev->devName, g_cachedInfo[id]->devName)) { From ba11a3246ee20fb8ec52f9e53cfd3ea371677308 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 6 Sep 2021 11:17:25 +0000 Subject: [PATCH 06/10] add trackball Signed-off-by: YOUR_NAME --- model/input/driver/hdf_hid_adapter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/input/driver/hdf_hid_adapter.c b/model/input/driver/hdf_hid_adapter.c index b5ddae8f..e6869b48 100644 --- a/model/input/driver/hdf_hid_adapter.c +++ b/model/input/driver/hdf_hid_adapter.c @@ -107,7 +107,7 @@ static int32_t SetInputDevAbsAttr(InputDevice *inputDev, HidInfo *info) 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); + info->axisInfo, sizeof(AbsAttr) * ABS_CNT); return ret; } } @@ -118,7 +118,7 @@ static int32_t GetInfoFromCache(InputDevice *inputDev, HidInfo *info) { int32_t id = 0; while (id < MAX_INPUT_DEV_NUM) { - if(g_cachedInfo[id] != NULL && !strcmp(inputDev->devName, g_cachedInfo[id]->devName)) { + if (g_cachedInfo[id] != NULL && !strcmp(inputDev->devName, g_cachedInfo[id]->devName)) { info = g_cachedInfo[id]; break; } From bc7b36967ddcb11c425b8483d2766b4a39817822 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 6 Sep 2021 11:39:04 +0000 Subject: [PATCH 07/10] add trackball Signed-off-by: YOUR_NAME --- model/input/driver/hdf_hid_adapter.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/model/input/driver/hdf_hid_adapter.c b/model/input/driver/hdf_hid_adapter.c index e6869b48..94c57baa 100644 --- a/model/input/driver/hdf_hid_adapter.c +++ b/model/input/driver/hdf_hid_adapter.c @@ -107,7 +107,7 @@ static int32_t SetInputDevAbsAttr(InputDevice *inputDev, HidInfo *info) 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); + info->axisInfo, sizeof(AbsAttr) * ABS_CNT); return ret; } } @@ -172,12 +172,10 @@ static void SetInputDevAbility(InputDevice *inputDev) MEMCPY_CHECK_RETURN(ret); ret = SetInputDevAbsAttr(inputDev, info); MEMCPY_CHECK_RETURN(ret); - inputDev->attrSet.id.busType = info->bustype; inputDev->attrSet.id.vendor = info->vendor; inputDev->attrSet.id.product = info->product; inputDev->attrSet.id.version = info->version; - FreeCachedInfo(); } From ec682168315c17afb188023ebd5168131201ac56 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Tue, 7 Sep 2021 01:27:14 +0000 Subject: [PATCH 08/10] add trackball Signed-off-by: YOUR_NAME --- model/input/driver/hdf_input_device_manager.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/model/input/driver/hdf_input_device_manager.c b/model/input/driver/hdf_input_device_manager.c index b7be4010..097288ed 100644 --- a/model/input/driver/hdf_input_device_manager.c +++ b/model/input/driver/hdf_input_device_manager.c @@ -250,8 +250,13 @@ static uint32_t AllocDeviceID(InputDevice *inputDev) InputDevice *tmpDev = g_inputManager->inputDevList; 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)); + int32_t ret; + ret = memset_s(idList, (MAX_INPUT_DEV_NUM + 1) * sizeof(uint32_t), 0, + (MAX_INPUT_DEV_NUM + 1) * sizeof(uint32_t)); + if (ret != 0) { + HDF_LOGE("%s: memset_s is failed", __func__); + return HDF_FAILURE; + } while (tmpDev != NULL) { if (idList[tmpDev->devId] == 0) { idList[tmpDev->devId] = FILLER_FLAG; From cb93f9c55a205510f430458416ab340b8172e1db Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Tue, 7 Sep 2021 01:40:11 +0000 Subject: [PATCH 09/10] add trackball Signed-off-by: YOUR_NAME --- model/input/driver/hdf_hid_adapter.c | 6 +----- model/input/driver/hdf_input_device_manager.c | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/model/input/driver/hdf_hid_adapter.c b/model/input/driver/hdf_hid_adapter.c index 94c57baa..1ab56824 100644 --- a/model/input/driver/hdf_hid_adapter.c +++ b/model/input/driver/hdf_hid_adapter.c @@ -89,7 +89,7 @@ void SendInfoToHdf(HidInfo *info) } } -static void FreeCachedInfo() +static void FreeCachedInfo(void) { int32_t id = 0; while (id < MAX_INPUT_DEV_NUM) { @@ -364,7 +364,6 @@ static int32_t HidGetDeviceAttr(InputDevice *inputDev, struct HdfSBuf *reply) return HDF_FAILURE; } - HDF_LOGE("%s: enter", __func__); ret = strncpy_s(inputDev->attrSet.devName, DEV_NAME_LEN, inputDev->devName, strlen(inputDev->devName)); if (ret != 0) { HDF_LOGE("%s: copy name from inputDev failed, ret = %d", __func__, ret); @@ -376,7 +375,6 @@ static int32_t HidGetDeviceAttr(InputDevice *inputDev, struct HdfSBuf *reply) return HDF_FAILURE; } - HDF_LOGI("%s: get dev attr succ", __func__); return HDF_SUCCESS; } @@ -385,14 +383,12 @@ static int32_t HidGetDeviceAbility(InputDevice *inputDev, struct HdfSBuf *reply) if (inputDev == NULL) { return HDF_FAILURE; } - HDF_LOGE("%s: enter", __func__); if (!HdfSbufWriteBuffer(reply, &inputDev->abilitySet, sizeof(DevAbility))) { HDF_LOGE("%s: sbuf write dev ability failed", __func__); return HDF_FAILURE; } - HDF_LOGI("%s: get dev ability succ", __func__); return HDF_SUCCESS; } diff --git a/model/input/driver/hdf_input_device_manager.c b/model/input/driver/hdf_input_device_manager.c index 097288ed..9be0cce5 100644 --- a/model/input/driver/hdf_input_device_manager.c +++ b/model/input/driver/hdf_input_device_manager.c @@ -252,7 +252,7 @@ static uint32_t AllocDeviceID(InputDevice *inputDev) uint32_t id; int32_t ret; ret = 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)); if (ret != 0) { HDF_LOGE("%s: memset_s is failed", __func__); return HDF_FAILURE; From 34260f56ecb3a1baff13e6400b399887bf1d8dac Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Tue, 7 Sep 2021 02:48:30 +0000 Subject: [PATCH 10/10] add trackball Signed-off-by: YOUR_NAME --- model/input/driver/hdf_hid_adapter.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/model/input/driver/hdf_hid_adapter.h b/model/input/driver/hdf_hid_adapter.h index ed04dad8..83efe614 100644 --- a/model/input/driver/hdf_hid_adapter.h +++ b/model/input/driver/hdf_hid_adapter.h @@ -92,9 +92,9 @@ enum HidType { HID_TYPE_UNKNOWN, /* Unknown input device type */ }; -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); +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