• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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 
16 #ifndef HID_DDK_SERVICE_H
17 #define HID_DDK_SERVICE_H
18 
19 #include "hid_adapter.h"
20 #include "v1_1/ihid_ddk.h"
21 
22 namespace OHOS {
23 namespace HDI {
24 namespace Input {
25 namespace Ddk {
26 namespace V1_1 {
27 class HidDdkService : public IHidDdk {
28 public:
HidDdkService(std::shared_ptr<HidOsAdapter> & osAdapter)29     HidDdkService(std::shared_ptr<HidOsAdapter>& osAdapter) : osAdapter_(osAdapter) {}
30     virtual ~HidDdkService() = default;
31 
32     int32_t CreateDevice(const Hid_Device& hidDevice,
33          const Hid_EventProperties& hidEventProperties, uint32_t& deviceId) override;
34 
35     int32_t EmitEvent(uint32_t deviceId, const std::vector<Hid_EmitItem>& items) override;
36 
37     int32_t DestroyDevice(uint32_t deviceId) override;
38 
39     int32_t Init() override;
40 
41     int32_t Release() override;
42 
43     int32_t Open(uint64_t deviceId, uint8_t interfaceIndex, HidDeviceHandle& dev) override;
44 
45     int32_t Close(const HidDeviceHandle& dev) override;
46 
47     int32_t Write(const HidDeviceHandle& dev, const std::vector<uint8_t>& data, uint32_t& bytesWritten) override;
48 
49     int32_t ReadTimeout(const HidDeviceHandle& dev, std::vector<uint8_t>& data, uint32_t buffSize, int32_t timeout,
50         uint32_t& bytesRead) override;
51 
52     int32_t SetNonBlocking(const HidDeviceHandle& dev, int32_t nonBlock) override;
53 
54     int32_t GetRawInfo(const HidDeviceHandle& dev, HidRawDevInfo& rawDevInfo) override;
55 
56     int32_t GetRawName(const HidDeviceHandle& dev, std::vector<uint8_t>& data, uint32_t buffSize) override;
57 
58     int32_t GetPhysicalAddress(const HidDeviceHandle& dev, std::vector<uint8_t>& data, uint32_t buffSize) override;
59 
60     int32_t GetRawUniqueId(const HidDeviceHandle& dev, std::vector<uint8_t>& data, uint32_t buffSize) override;
61 
62     int32_t SendReport(const HidDeviceHandle& dev, HidReportType reportType, const std::vector<uint8_t>& data) override;
63 
64     int32_t GetReport(const HidDeviceHandle& dev, HidReportType reportType, uint8_t reportNumber,
65         std::vector<uint8_t>& data, uint32_t buffSize) override;
66 
67     int32_t GetReportDescriptor(const HidDeviceHandle& dev, std::vector<uint8_t>& buf, uint32_t buffSize,
68         uint32_t& bytesRead) override;
69 
70 private:
71     std::shared_ptr<HidOsAdapter> osAdapter_;
72 };
73 } // V1_1
74 } // Ddk
75 } // Input
76 } // HDI
77 } // OHOS
78 
79 #endif // HID_DDK_SERVICE_H