| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 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 |  | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 17 | #include <functional> | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 18 | #include <stdint.h> | 
 | 19 | #include <sys/types.h> | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 20 | #include <unordered_map> | 
 | 21 | #include <vector> | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 22 |  | 
 | 23 | #define LOG_TAG "InputDriver" | 
 | 24 |  | 
 | 25 | #define LOG_NDEBUG 0 | 
 | 26 |  | 
 | 27 | #include "InputDriver.h" | 
 | 28 | #include "InputHost.h" | 
 | 29 |  | 
 | 30 | #include <hardware/input.h> | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 31 | #include <input/InputDevice.h> | 
| Siarhei Vishniakou | 32f36ae | 2020-09-02 20:17:10 -0700 | [diff] [blame] | 32 | #include <input/PropertyMap.h> | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 33 | #include <utils/Log.h> | 
 | 34 | #include <utils/String8.h> | 
 | 35 |  | 
 | 36 | #define INDENT2 "    " | 
 | 37 |  | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 38 | struct input_property_map { | 
| Siarhei Vishniakou | 4d9f977 | 2020-09-02 22:28:29 -0500 | [diff] [blame] | 39 |     std::unique_ptr<android::PropertyMap> propertyMap; | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 40 | }; | 
 | 41 |  | 
 | 42 | struct input_property { | 
 | 43 |     android::String8 key; | 
 | 44 |     android::String8 value; | 
 | 45 | }; | 
 | 46 |  | 
 | 47 | struct input_device_identifier { | 
 | 48 |     const char* name; | 
 | 49 |     const char* uniqueId; | 
 | 50 |     input_bus_t bus; | 
 | 51 |     int32_t     vendorId; | 
 | 52 |     int32_t     productId; | 
 | 53 |     int32_t     version; | 
 | 54 | }; | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 55 |  | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 56 | struct input_device_definition { | 
 | 57 |     std::vector<input_report_definition*> reportDefs; | 
 | 58 | }; | 
 | 59 |  | 
 | 60 | struct input_device_handle { | 
 | 61 |     input_device_identifier_t* id; | 
 | 62 |     input_device_definition_t* def; | 
 | 63 | }; | 
 | 64 |  | 
 | 65 | struct input_int_usage { | 
 | 66 |     input_usage_t usage; | 
 | 67 |     int32_t min; | 
 | 68 |     int32_t max; | 
 | 69 |     float   resolution; | 
 | 70 | }; | 
 | 71 |  | 
 | 72 | struct input_collection { | 
 | 73 |     int32_t arity; | 
 | 74 |     std::vector<input_int_usage> intUsages; | 
 | 75 |     std::vector<input_usage_t> boolUsages; | 
 | 76 | }; | 
 | 77 |  | 
 | 78 | struct InputCollectionIdHasher { | 
 | 79 |     std::size_t operator()(const input_collection_id& id) const { | 
 | 80 |         return std::hash<int>()(static_cast<int>(id)); | 
 | 81 |     } | 
 | 82 | }; | 
 | 83 |  | 
 | 84 | struct input_report_definition { | 
 | 85 |     std::unordered_map<input_collection_id_t, input_collection, InputCollectionIdHasher> collections; | 
 | 86 | }; | 
 | 87 |  | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 88 |  | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 89 | namespace android { | 
 | 90 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 91 | static input_host_callbacks_t kCallbacks = { | 
 | 92 |     .create_device_identifier = create_device_identifier, | 
 | 93 |     .create_device_definition = create_device_definition, | 
 | 94 |     .create_input_report_definition = create_input_report_definition, | 
 | 95 |     .create_output_report_definition = create_output_report_definition, | 
 | 96 |     .free_report_definition = free_report_definition, | 
 | 97 |     .input_device_definition_add_report = input_device_definition_add_report, | 
 | 98 |     .input_report_definition_add_collection = input_report_definition_add_collection, | 
 | 99 |     .input_report_definition_declare_usage_int = input_report_definition_declare_usage_int, | 
 | 100 |     .input_report_definition_declare_usages_bool = input_report_definition_declare_usages_bool, | 
 | 101 |     .register_device = register_device, | 
 | 102 |     .input_allocate_report = input_allocate_report, | 
 | 103 |     .input_report_set_usage_int = input_report_set_usage_int, | 
 | 104 |     .input_report_set_usage_bool = input_report_set_usage_bool, | 
 | 105 |     .report_event = report_event, | 
 | 106 |     .input_get_device_property_map = input_get_device_property_map, | 
 | 107 |     .input_get_device_property = input_get_device_property, | 
 | 108 |     .input_get_property_key = input_get_property_key, | 
 | 109 |     .input_get_property_value = input_get_property_value, | 
 | 110 |     .input_free_device_property = input_free_device_property, | 
 | 111 |     .input_free_device_property_map = input_free_device_property_map, | 
 | 112 | }; | 
 | 113 |  | 
 | 114 | InputDriver::InputDriver(const char* name) : mName(String8(name)) { | 
 | 115 |     const hw_module_t* module; | 
 | 116 |     int err = input_open(&module, name); | 
 | 117 |     LOG_ALWAYS_FATAL_IF(err != 0, "Input module %s not found", name); | 
 | 118 |     mHal = reinterpret_cast<const input_module_t*>(module); | 
 | 119 | } | 
 | 120 |  | 
 | 121 | void InputDriver::init() { | 
 | 122 |     mHal->init(mHal, static_cast<input_host_t*>(this), kCallbacks); | 
 | 123 | } | 
 | 124 |  | 
 | 125 | input_device_identifier_t* InputDriver::createDeviceIdentifier( | 
 | 126 |             const char* name, int32_t productId, int32_t vendorId, | 
 | 127 |             input_bus_t bus, const char* uniqueId) { | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 128 |     auto identifier = new ::input_device_identifier { | 
 | 129 |         .name = name, | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 130 |         .uniqueId = uniqueId, | 
| Nick Desaulniers | 2183448 | 2019-10-15 19:09:46 -0700 | [diff] [blame] | 131 |         .bus = bus, | 
 | 132 |         .vendorId = vendorId, | 
 | 133 |         .productId = productId, | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 134 |     }; | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 135 |     // TODO: store this identifier somewhere | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 136 |     return identifier; | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 137 | } | 
 | 138 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 139 | input_device_definition_t* InputDriver::createDeviceDefinition() { | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 140 |     return new ::input_device_definition; | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 141 | } | 
 | 142 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 143 | input_report_definition_t* InputDriver::createInputReportDefinition() { | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 144 |     return new ::input_report_definition; | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 145 | } | 
 | 146 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 147 | input_report_definition_t* InputDriver::createOutputReportDefinition() { | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 148 |     return new ::input_report_definition; | 
 | 149 | } | 
 | 150 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 151 | void InputDriver::freeReportDefinition(input_report_definition_t* reportDef) { | 
 | 152 |     delete reportDef; | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 153 | } | 
 | 154 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 155 | void InputDriver::inputDeviceDefinitionAddReport(input_device_definition_t* d, | 
 | 156 |         input_report_definition_t* r) { | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 157 |     d->reportDefs.push_back(r); | 
 | 158 | } | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 159 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 160 | void InputDriver::inputReportDefinitionAddCollection(input_report_definition_t* report, | 
 | 161 |         input_collection_id_t id, int32_t arity) { | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 162 |     report->collections[id] = {.arity = arity}; | 
 | 163 | } | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 164 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 165 | void InputDriver::inputReportDefinitionDeclareUsageInt(input_report_definition_t* report, | 
 | 166 |         input_collection_id_t id, input_usage_t usage, int32_t min, int32_t max, | 
 | 167 |         float resolution) { | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 168 |     if (report->collections.find(id) != report->collections.end()) { | 
 | 169 |         report->collections[id].intUsages.push_back({ | 
 | 170 |                 .usage = usage, .min = min, .max = max, .resolution = resolution}); | 
 | 171 |     } | 
 | 172 | } | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 173 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 174 | void InputDriver::inputReportDefinitionDeclareUsagesBool(input_report_definition_t* report, | 
 | 175 |         input_collection_id_t id, input_usage_t* usage, size_t usageCount) { | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 176 |     if (report->collections.find(id) != report->collections.end()) { | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 177 |         for (size_t i = 0; i < usageCount; ++i) { | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 178 |             report->collections[id].boolUsages.push_back(usage[i]); | 
 | 179 |         } | 
 | 180 |     } | 
 | 181 | } | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 182 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 183 | input_device_handle_t* InputDriver::registerDevice(input_device_identifier_t* id, | 
 | 184 |         input_device_definition_t* d) { | 
 | 185 |     ALOGD("Registering device %s with %zu input reports", id->name, d->reportDefs.size()); | 
 | 186 |     // TODO: save this device handle | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 187 |     return new input_device_handle{ .id = id, .def = d }; | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 188 | } | 
 | 189 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 190 | void InputDriver::unregisterDevice(input_device_handle_t* handle) { | 
 | 191 |     delete handle; | 
 | 192 | } | 
 | 193 |  | 
 | 194 | input_report_t* InputDriver::inputAllocateReport(input_report_definition_t* r) { | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 195 |     ALOGD("Allocating input report for definition %p", r); | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 196 |     return nullptr; | 
 | 197 | } | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 198 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 199 | void InputDriver::inputReportSetUsageInt(input_report_t* r, input_collection_id_t id, | 
 | 200 |         input_usage_t usage, int32_t value, int32_t arity_index) { | 
 | 201 | } | 
| Tim Kilbourn | 8943ce3 | 2015-02-27 15:09:34 -0800 | [diff] [blame] | 202 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 203 | void InputDriver::inputReportSetUsageBool(input_report_t* r, input_collection_id_t id, | 
 | 204 |         input_usage_t usage, bool value, int32_t arity_index) { | 
 | 205 | } | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 206 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 207 | void InputDriver::reportEvent(input_device_handle_t* d, input_report_t* report) { | 
| Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 208 |     ALOGD("report_event %p for handle %p", report, d); | 
 | 209 | } | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 210 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 211 | input_property_map_t* InputDriver::inputGetDevicePropertyMap(input_device_identifier_t* id) { | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 212 |     InputDeviceIdentifier idi; | 
 | 213 |     idi.name = id->name; | 
 | 214 |     idi.uniqueId = id->uniqueId; | 
 | 215 |     idi.bus = id->bus; | 
 | 216 |     idi.vendor = id->vendorId; | 
 | 217 |     idi.product = id->productId; | 
 | 218 |     idi.version = id->version; | 
 | 219 |  | 
| Chris Ye | 1d927aa | 2020-07-04 18:22:41 -0700 | [diff] [blame] | 220 |     std::string configFile = | 
 | 221 |             getInputDeviceConfigurationFilePathByDeviceIdentifier(idi, | 
 | 222 |                                                                   InputDeviceConfigurationFileType:: | 
 | 223 |                                                                           CONFIGURATION); | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 224 |     if (configFile.empty()) { | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 225 |         ALOGD("No input device configuration file found for device '%s'.", | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 226 |                 idi.name.c_str()); | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 227 |     } else { | 
| Siarhei Vishniakou | 4d9f977 | 2020-09-02 22:28:29 -0500 | [diff] [blame] | 228 |         std::unique_ptr<input_property_map_t> propMap = std::make_unique<input_property_map_t>(); | 
 | 229 |         android::base::Result<std::unique_ptr<PropertyMap>> result = | 
 | 230 |                 PropertyMap::load(configFile.c_str()); | 
 | 231 |         if (!result.ok()) { | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 232 |             ALOGE("Error loading input device configuration file for device '%s'. " | 
 | 233 |                     "Using default configuration.", | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 234 |                     idi.name.c_str()); | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 235 |             return nullptr; | 
 | 236 |         } | 
| Siarhei Vishniakou | 4d9f977 | 2020-09-02 22:28:29 -0500 | [diff] [blame] | 237 |         propMap->propertyMap = std::move(*result); | 
 | 238 |         return propMap.release(); | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 239 |     } | 
| Tim Kilbourn | e5364c8 | 2015-04-06 13:48:50 -0700 | [diff] [blame] | 240 |     return nullptr; | 
 | 241 | } | 
 | 242 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 243 | input_property_t* InputDriver::inputGetDeviceProperty(input_property_map_t* map, | 
| Tim Kilbourn | e5364c8 | 2015-04-06 13:48:50 -0700 | [diff] [blame] | 244 |         const char* key) { | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 245 |     String8 keyString(key); | 
 | 246 |     if (map != nullptr) { | 
 | 247 |         if (map->propertyMap->hasProperty(keyString)) { | 
 | 248 |             auto prop = new input_property_t(); | 
 | 249 |             if (!map->propertyMap->tryGetProperty(keyString, prop->value)) { | 
 | 250 |                 delete prop; | 
 | 251 |                 return nullptr; | 
 | 252 |             } | 
 | 253 |             prop->key = keyString; | 
 | 254 |             return prop; | 
 | 255 |         } | 
 | 256 |     } | 
| Tim Kilbourn | e5364c8 | 2015-04-06 13:48:50 -0700 | [diff] [blame] | 257 |     return nullptr; | 
 | 258 | } | 
 | 259 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 260 | const char* InputDriver::inputGetPropertyKey(input_property_t* property) { | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 261 |     if (property != nullptr) { | 
 | 262 |         return property->key.string(); | 
 | 263 |     } | 
| Tim Kilbourn | e5364c8 | 2015-04-06 13:48:50 -0700 | [diff] [blame] | 264 |     return nullptr; | 
 | 265 | } | 
 | 266 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 267 | const char* InputDriver::inputGetPropertyValue(input_property_t* property) { | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 268 |     if (property != nullptr) { | 
 | 269 |         return property->value.string(); | 
 | 270 |     } | 
| Tim Kilbourn | e5364c8 | 2015-04-06 13:48:50 -0700 | [diff] [blame] | 271 |     return nullptr; | 
 | 272 | } | 
 | 273 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 274 | void InputDriver::inputFreeDeviceProperty(input_property_t* property) { | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 275 |     if (property != nullptr) { | 
 | 276 |         delete property; | 
 | 277 |     } | 
 | 278 | } | 
| Tim Kilbourn | e5364c8 | 2015-04-06 13:48:50 -0700 | [diff] [blame] | 279 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 280 | void InputDriver::inputFreeDevicePropertyMap(input_property_map_t* map) { | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 281 |     if (map != nullptr) { | 
| Tim Kilbourn | 3e38aad | 2015-04-07 13:02:27 -0700 | [diff] [blame] | 282 |         delete map; | 
 | 283 |     } | 
 | 284 | } | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 285 |  | 
| Tim Kilbourn | 2e7f014 | 2015-09-09 16:11:54 -0700 | [diff] [blame] | 286 | void InputDriver::dump(String8& result) { | 
 | 287 |     result.appendFormat(INDENT2 "HAL Input Driver (%s)\n", mName.string()); | 
 | 288 | } | 
 | 289 |  | 
 | 290 | } // namespace android | 
 | 291 |  | 
 | 292 | // HAL wrapper functions | 
 | 293 |  | 
 | 294 | namespace android { | 
 | 295 |  | 
 | 296 | ::input_device_identifier_t* create_device_identifier(input_host_t* host, | 
 | 297 |         const char* name, int32_t product_id, int32_t vendor_id, | 
 | 298 |         input_bus_t bus, const char* unique_id) { | 
 | 299 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 300 |     return driver->createDeviceIdentifier(name, product_id, vendor_id, bus, unique_id); | 
 | 301 | } | 
 | 302 |  | 
 | 303 | input_device_definition_t* create_device_definition(input_host_t* host) { | 
 | 304 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 305 |     return driver->createDeviceDefinition(); | 
 | 306 | } | 
 | 307 |  | 
 | 308 | input_report_definition_t* create_input_report_definition(input_host_t* host) { | 
 | 309 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 310 |     return driver->createInputReportDefinition(); | 
 | 311 | } | 
 | 312 |  | 
 | 313 | input_report_definition_t* create_output_report_definition(input_host_t* host) { | 
 | 314 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 315 |     return driver->createOutputReportDefinition(); | 
 | 316 | } | 
 | 317 |  | 
 | 318 | void free_report_definition(input_host_t* host, input_report_definition_t* report_def) { | 
 | 319 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 320 |     driver->freeReportDefinition(report_def); | 
 | 321 | } | 
 | 322 |  | 
 | 323 | void input_device_definition_add_report(input_host_t* host, | 
 | 324 |         input_device_definition_t* d, input_report_definition_t* r) { | 
 | 325 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 326 |     driver->inputDeviceDefinitionAddReport(d, r); | 
 | 327 | } | 
 | 328 |  | 
 | 329 | void input_report_definition_add_collection(input_host_t* host, | 
 | 330 |         input_report_definition_t* report, input_collection_id_t id, int32_t arity) { | 
 | 331 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 332 |     driver->inputReportDefinitionAddCollection(report, id, arity); | 
 | 333 | } | 
 | 334 |  | 
 | 335 | void input_report_definition_declare_usage_int(input_host_t* host, | 
 | 336 |         input_report_definition_t* report, input_collection_id_t id, | 
 | 337 |         input_usage_t usage, int32_t min, int32_t max, float resolution) { | 
 | 338 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 339 |     driver->inputReportDefinitionDeclareUsageInt(report, id, usage, min, max, resolution); | 
 | 340 | } | 
 | 341 |  | 
 | 342 | void input_report_definition_declare_usages_bool(input_host_t* host, | 
 | 343 |         input_report_definition_t* report, input_collection_id_t id, | 
 | 344 |         input_usage_t* usage, size_t usage_count) { | 
 | 345 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 346 |     driver->inputReportDefinitionDeclareUsagesBool(report, id, usage, usage_count); | 
 | 347 | } | 
 | 348 |  | 
 | 349 | input_device_handle_t* register_device(input_host_t* host, | 
 | 350 |         input_device_identifier_t* id, input_device_definition_t* d) { | 
 | 351 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 352 |     return driver->registerDevice(id, d); | 
 | 353 | } | 
 | 354 |  | 
 | 355 | void unregister_device(input_host_t* host, input_device_handle_t* handle) { | 
 | 356 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 357 |     driver->unregisterDevice(handle); | 
 | 358 | } | 
 | 359 |  | 
 | 360 | input_report_t* input_allocate_report(input_host_t* host, input_report_definition_t* r) { | 
 | 361 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 362 |     return driver->inputAllocateReport(r); | 
 | 363 | } | 
 | 364 |  | 
 | 365 | void input_report_set_usage_int(input_host_t* host, input_report_t* r, | 
 | 366 |         input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index) { | 
 | 367 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 368 |     driver->inputReportSetUsageInt(r, id, usage, value, arity_index); | 
 | 369 | } | 
 | 370 |  | 
 | 371 | void input_report_set_usage_bool(input_host_t* host, input_report_t* r, | 
 | 372 |         input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index) { | 
 | 373 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 374 |     driver->inputReportSetUsageBool(r, id, usage, value, arity_index); | 
 | 375 | } | 
 | 376 |  | 
 | 377 | void report_event(input_host_t* host, input_device_handle_t* d, input_report_t* report) { | 
 | 378 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 379 |     driver->reportEvent(d, report); | 
 | 380 | } | 
 | 381 |  | 
 | 382 | input_property_map_t* input_get_device_property_map(input_host_t* host, | 
 | 383 |         input_device_identifier_t* id) { | 
 | 384 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 385 |     return driver->inputGetDevicePropertyMap(id); | 
 | 386 | } | 
 | 387 |  | 
 | 388 | input_property_t* input_get_device_property(input_host_t* host, input_property_map_t* map, | 
 | 389 |         const char* key) { | 
 | 390 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 391 |     return driver->inputGetDeviceProperty(map, key); | 
 | 392 | } | 
 | 393 |  | 
 | 394 | const char* input_get_property_key(input_host_t* host, input_property_t* property) { | 
 | 395 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 396 |     return driver->inputGetPropertyKey(property); | 
 | 397 | } | 
 | 398 |  | 
 | 399 | const char* input_get_property_value(input_host_t* host, input_property_t* property) { | 
 | 400 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 401 |     return driver->inputGetPropertyValue(property); | 
 | 402 | } | 
 | 403 |  | 
 | 404 | void input_free_device_property(input_host_t* host, input_property_t* property) { | 
 | 405 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 406 |     driver->inputFreeDeviceProperty(property); | 
 | 407 | } | 
 | 408 |  | 
 | 409 | void input_free_device_property_map(input_host_t* host, input_property_map_t* map) { | 
 | 410 |     auto driver = static_cast<InputDriverInterface*>(host); | 
 | 411 |     driver->inputFreeDevicePropertyMap(map); | 
 | 412 | } | 
 | 413 |  | 
| Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 414 | } // namespace android |