diff --git a/framework/model/input/driver/hdf_hid_adapter.c b/framework/model/input/driver/hdf_hid_adapter.c index a5f714c6205a8e5642505fdc0df354b4a7987717..35f80e173e0c9ce72a345c0edad402c79c739872 100644 --- a/framework/model/input/driver/hdf_hid_adapter.c +++ b/framework/model/input/driver/hdf_hid_adapter.c @@ -219,7 +219,7 @@ static void DoRegisterInputDev(InputDevice* inputDev) } } -static void CacheHid(InputDevice* inputDev) +void CacheHid(InputDevice* inputDev) { int32_t i = 0; while ((i < MAX_INPUT_DEV_NUM) && (cachedHid[i] != NULL)) { diff --git a/framework/model/input/driver/hdf_hid_adapter.h b/framework/model/input/driver/hdf_hid_adapter.h index 83efe6140afc619894f529c24ee6ec20b34551ff..2b4a5af2cfc55cafb831ed6b33b6ca9cf33b815a 100644 --- a/framework/model/input/driver/hdf_hid_adapter.h +++ b/framework/model/input/driver/hdf_hid_adapter.h @@ -96,5 +96,5 @@ 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 CacheHid(InputDevice* inputDev); #endif diff --git a/framework/model/input/driver/hdf_input_device_manager.c b/framework/model/input/driver/hdf_input_device_manager.c index 175a74d78ac3bc392241c0b822e9683dd10633ae..cc6483546c87a7292ce22a4fadca1e488128bc48 100644 --- a/framework/model/input/driver/hdf_input_device_manager.c +++ b/framework/model/input/driver/hdf_input_device_manager.c @@ -107,13 +107,21 @@ static void HotPlugNotify(const InputDevice *inputDev, uint32_t status) static int32_t CreateDeviceNode(InputDevice *inputDev) { + static bool existNonHid = false ; if (IsHidDevice(inputDev)) { + if (!existNonHid) { + CacheHid(inputDev); + HDF_LOGI("%s: is first hid dev add cache, devId is %d ", __func__, inputDev->devId); + return HDF_SUCCESS; + } HDF_LOGI("%s: prepare to register hdf device", __func__); inputDev->hdfDevObj = HidRegisterHdfDevice(inputDev); if (inputDev->hdfDevObj == NULL) { return HDF_DEV_ERR_NO_DEVICE; } inputDev->hdfDevObj->priv = (void *)inputDev; + } else { + existNonHid = true ; } HDF_LOGI("%s: create node succ, devId is %d ", __func__, inputDev->devId);