• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <hdf_log.h>
16 #include <unistd.h>
17 #include "input_server.h"
18 
19 #define HDF_LOG_TAG InputServer
20 
21 namespace OHOS {
22 namespace Input {
23 #define GET_INSTANCE_INPUT_DEVICE_MANAGER inputDeviceManager_
24 std::map<int32_t, OHOS::sptr<InputReportEventCb>> InputServer::reportEventPkgCallback_;
ScanInputDevice(DevDesc * staArr,uint32_t arrLen)25 int32_t InputServer::ScanInputDevice(DevDesc *staArr, uint32_t arrLen)
26 {
27     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
28     return GET_INSTANCE_INPUT_DEVICE_MANAGER->ScanDevice(staArr, arrLen);
29 }
30 
OpenInputDevice(uint32_t devIndex)31 int32_t InputServer::OpenInputDevice(uint32_t devIndex)
32 {
33     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
34     return GET_INSTANCE_INPUT_DEVICE_MANAGER->OpenDevice(devIndex);
35 }
36 
CloseInputDevice(uint32_t devIndex)37 int32_t InputServer::CloseInputDevice(uint32_t devIndex)
38 {
39     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
40     return GET_INSTANCE_INPUT_DEVICE_MANAGER->CloseDevice(devIndex);
41 }
42 
GetInputDevice(uint32_t devIndex,DeviceInfo ** devInfo)43 int32_t InputServer::GetInputDevice(uint32_t devIndex, DeviceInfo **devInfo)
44 {
45     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
46     return GET_INSTANCE_INPUT_DEVICE_MANAGER->GetDevice(devIndex, devInfo);
47 }
48 
GetInputDeviceList(uint32_t * devNum,DeviceInfo ** devList,uint32_t size)49 int32_t InputServer::GetInputDeviceList(uint32_t *devNum, DeviceInfo **devList, uint32_t size)
50 {
51     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
52     return GET_INSTANCE_INPUT_DEVICE_MANAGER->GetDeviceList(devNum, devList, size);
53 }
54 
SetPowerStatus(uint32_t devIndex,uint32_t status)55 int32_t InputServer::SetPowerStatus(uint32_t devIndex, uint32_t status)
56 {
57     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
58     return GET_INSTANCE_INPUT_DEVICE_MANAGER->SetPowerStatus(devIndex, status);
59 }
60 
GetPowerStatus(uint32_t devIndex,uint32_t * status)61 int32_t InputServer::GetPowerStatus(uint32_t devIndex, uint32_t *status)
62 {
63     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
64     return GET_INSTANCE_INPUT_DEVICE_MANAGER->GetPowerStatus(devIndex, status);
65 }
66 
GetDeviceType(uint32_t devIndex,uint32_t * type)67 int32_t InputServer::GetDeviceType(uint32_t devIndex, uint32_t *type)
68 {
69     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
70     return GET_INSTANCE_INPUT_DEVICE_MANAGER->GetDeviceType(devIndex, type);
71 }
72 
GetChipInfo(uint32_t devIndex,char * chipInfo,uint32_t length)73 int32_t InputServer::GetChipInfo(uint32_t devIndex, char *chipInfo, uint32_t length)
74 {
75     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
76     return GET_INSTANCE_INPUT_DEVICE_MANAGER->GetChipInfo(devIndex, chipInfo, length);
77 }
78 
GetVendorName(uint32_t devIndex,char * vendorName,uint32_t length)79 int32_t InputServer::GetVendorName(uint32_t devIndex, char *vendorName, uint32_t length)
80 {
81     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
82     return GET_INSTANCE_INPUT_DEVICE_MANAGER->GetVendorName(devIndex, vendorName, length);
83 }
84 
GetChipName(uint32_t devIndex,char * chipName,uint32_t length)85 int32_t InputServer::GetChipName(uint32_t devIndex, char *chipName, uint32_t length)
86 {
87     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
88     return GET_INSTANCE_INPUT_DEVICE_MANAGER->GetChipName(devIndex, chipName, length);
89 }
90 
SetGestureMode(uint32_t devIndex,uint32_t gestureMode)91 int32_t InputServer::SetGestureMode(uint32_t devIndex, uint32_t gestureMode)
92 {
93     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
94     return GET_INSTANCE_INPUT_DEVICE_MANAGER->SetGestureMode(devIndex, gestureMode);
95 }
96 
RunCapacitanceTest(uint32_t devIndex,uint32_t testType,char * result,uint32_t length)97 int32_t InputServer::RunCapacitanceTest(uint32_t devIndex, uint32_t testType, char *result, uint32_t length)
98 {
99     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
100     return GET_INSTANCE_INPUT_DEVICE_MANAGER->RunCapacitanceTest(devIndex, testType, result, length);
101 }
102 
RunExtraCommand(uint32_t devIndex,InputExtraCmd * cmd)103 int32_t InputServer::RunExtraCommand(uint32_t devIndex, InputExtraCmd *cmd)
104 {
105     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
106     return GET_INSTANCE_INPUT_DEVICE_MANAGER->RunExtraCommand(devIndex, cmd);
107 }
108 
RegisterReportCallback(uint32_t devIndex,OHOS::sptr<InputReportEventCb> callback)109 int32_t InputServer::RegisterReportCallback(uint32_t devIndex, OHOS::sptr<InputReportEventCb> callback)
110 {
111     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
112     return GET_INSTANCE_INPUT_DEVICE_MANAGER->RegisterReportCallback(devIndex, callback);
113 }
114 
UnregisterReportCallback(uint32_t devIndex)115 int32_t InputServer::UnregisterReportCallback(uint32_t devIndex)
116 {
117     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
118     return GET_INSTANCE_INPUT_DEVICE_MANAGER->UnregisterReportCallback(devIndex);
119 }
120 
RegisterHotPlugCallback(sptr<InputReportHostCb> callback)121 int32_t InputServer::RegisterHotPlugCallback(sptr<InputReportHostCb> callback)
122 {
123     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
124     return GET_INSTANCE_INPUT_DEVICE_MANAGER->RegisterHotPlugCallback(callback);
125 }
126 
UnregisterHotPlugCallback(void)127 int32_t InputServer::UnregisterHotPlugCallback(void)
128 {
129     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
130     return GET_INSTANCE_INPUT_DEVICE_MANAGER->UnregisterHotPlugCallback();
131 }
132 
InputServer()133 InputServer::InputServer()
134 {
135     HDF_LOGI("InputServer %{public}s: line:%{public}d", __func__, __LINE__);
136     inputDeviceManager_ = std::make_shared<InputDeviceManager>();
137     if (inputDeviceManager_ != nullptr) {
138         inputDeviceManager_->Init();
139     }
140 }
141 }  // namespace Input
142 }  // namespace OHOS
143