1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_SENSORHAL_EXT_HID_DEVICE_H 18 #define ANDROID_SENSORHAL_EXT_HID_DEVICE_H 19 #include "Utils.h" 20 #include <string> 21 #include <vector> 22 #include <unordered_set> 23 24 namespace android { 25 namespace SensorHalExt { 26 REF_BASE(HidDevice)27class HidDevice : virtual public REF_BASE(HidDevice) { 28 public: 29 virtual ~HidDevice() = default; 30 31 struct HidDeviceInfo { 32 std::string name; 33 std::string physicalPath; 34 std::string busType; 35 uint16_t vendorId; 36 uint16_t productId; 37 std::vector<uint8_t> descriptor; 38 }; 39 40 virtual const HidDeviceInfo& getDeviceInfo() = 0; 41 42 // get feature from device 43 virtual bool getFeature(uint8_t id, std::vector<uint8_t> *out) = 0; 44 45 // write feature to device 46 virtual bool setFeature(uint8_t id, const std::vector<uint8_t> &in) = 0; 47 48 // send report to default output endpoint 49 virtual bool sendReport(uint8_t id, std::vector<uint8_t> &data) = 0; 50 51 // receive from default input endpoint 52 virtual bool receiveReport(uint8_t *id, std::vector<uint8_t> *data) = 0; 53 }; 54 55 } // namespace SensorHalExt 56 } // namespace android 57 #endif // ANDROID_SENSORHAL_EXT_HID_DEVICE_H 58