1 /* 2 * Copyright (C) 2015 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_INPUT_DRIVER_H 18 #define ANDROID_INPUT_DRIVER_H 19 20 #include <stdint.h> 21 #include <sys/types.h> 22 23 #include "InputHost.h" 24 25 #include <hardware/input.h> 26 #include <utils/RefBase.h> 27 #include <utils/String8.h> 28 29 namespace android { 30 31 class InputHostInterface; 32 33 class InputDriverInterface : public virtual RefBase { 34 protected: 35 InputDriverInterface() = default; 36 virtual ~InputDriverInterface() = default; 37 38 public: 39 virtual void init(InputHostInterface* host) = 0; 40 41 virtual void dump(String8& result) = 0; 42 }; 43 44 class InputDriver : public InputDriverInterface { 45 public: 46 InputDriver(const char* name); 47 virtual ~InputDriver() = default; 48 49 virtual void init(InputHostInterface* host) override; 50 51 virtual void dump(String8& result) override; 52 53 private: 54 String8 mName; 55 const input_module_t* mHal; 56 }; 57 58 59 extern "C" { 60 61 input_device_identifier_t* create_device_identifier(input_host_t* host, 62 const char* name, int32_t product_id, int32_t vendor_id, 63 input_bus_t bus, const char* unique_id); 64 65 input_device_definition_t* create_device_definition(input_host_t* host); 66 67 input_report_definition_t* create_input_report_definition(input_host_t* host); 68 69 input_report_definition_t* create_output_report_definition(input_host_t* host); 70 71 void input_device_definition_add_report(input_host_t* host, 72 input_device_definition_t* d, input_report_definition_t* r); 73 74 void input_report_definition_add_collection(input_host_t* host, 75 input_report_definition_t* report, input_collection_id_t id, int32_t arity); 76 77 void input_report_definition_declare_usage_int(input_host_t* host, 78 input_report_definition_t* report, input_collection_id_t id, 79 input_usage_t usage, int32_t min, int32_t max, float resolution); 80 81 void input_report_definition_declare_usages_bool(input_host_t* host, 82 input_report_definition_t* report, input_collection_id_t id, 83 input_usage_t* usage, size_t usage_count); 84 85 86 input_device_handle_t* register_device(input_host_t* host, 87 input_device_identifier_t* id, input_device_definition_t* d); 88 89 void unregister_device(input_host_t* host, input_device_handle_t* handle); 90 91 input_report_t* input_allocate_report(input_host_t* host, input_report_definition_t* r); 92 93 void input_report_set_usage_int(input_host_t* host, input_report_t* r, 94 input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index); 95 96 void input_report_set_usage_bool(input_host_t* host, input_report_t* r, 97 input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index); 98 99 void report_event(input_host_t* host, input_device_handle_t* d, input_report_t* report); 100 101 input_property_map_t* input_get_device_property_map(input_host_t* host, 102 input_device_identifier_t* id); 103 104 input_property_t* input_get_device_property(input_host_t* host, input_property_map_t* map, 105 const char* key); 106 107 const char* input_get_property_key(input_host_t* host, input_property_t* property); 108 109 const char* input_get_property_value(input_host_t* host, input_property_t* property); 110 111 void input_free_device_property(input_host_t* host, input_property_t* property); 112 113 void input_free_device_property_map(input_host_t* host, input_property_map_t* map); 114 } 115 116 } // namespace android 117 #endif // ANDROID_INPUT_DRIVER_H 118