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 | |
| 17 | #include <stdint.h> |
| 18 | #include <sys/types.h> |
| 19 | |
| 20 | #define LOG_TAG "InputDriver" |
| 21 | |
| 22 | #define LOG_NDEBUG 0 |
| 23 | |
| 24 | #include "InputDriver.h" |
| 25 | #include "InputHost.h" |
| 26 | |
| 27 | #include <hardware/input.h> |
| 28 | #include <utils/Log.h> |
| 29 | #include <utils/String8.h> |
| 30 | |
| 31 | #define INDENT2 " " |
| 32 | |
| 33 | namespace android { |
| 34 | |
| 35 | static input_host_callbacks_t kCallbacks = { |
| 36 | .create_device_identifier = create_device_identifier, |
| 37 | .create_device_definition = create_device_definition, |
| 38 | .create_input_report_definition = create_input_report_definition, |
| 39 | .create_output_report_definition = create_output_report_definition, |
| 40 | .input_device_definition_add_report = input_device_definition_add_report, |
| 41 | .input_report_definition_add_collection = input_report_definition_add_collection, |
| 42 | .input_report_definition_declare_usage_int = input_report_definition_declare_usage_int, |
| 43 | .input_report_definition_declare_usages_bool = input_report_definition_declare_usages_bool, |
| 44 | .register_device = register_device, |
| 45 | .input_allocate_report = input_allocate_report, |
Tim Kilbourn | 8943ce3 | 2015-02-27 15:09:34 -0800 | [diff] [blame] | 46 | .input_report_set_usage_int = input_report_set_usage_int, |
| 47 | .input_report_set_usage_bool = input_report_set_usage_bool, |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 48 | .report_event = report_event, |
Tim Kilbourn | e5364c8 | 2015-04-06 13:48:50 -0700 | [diff] [blame] | 49 | .input_get_device_property_map = input_get_device_property_map, |
| 50 | .input_get_device_property = input_get_device_property, |
| 51 | .input_get_property_key = input_get_property_key, |
| 52 | .input_get_property_value = input_get_property_value, |
| 53 | .input_free_device_property = input_free_device_property, |
| 54 | .input_free_device_property_map = input_free_device_property_map, |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | InputDriver::InputDriver(const char* name) : mName(String8(name)) { |
| 58 | const hw_module_t* module; |
| 59 | int err = input_open(&module, name); |
| 60 | LOG_ALWAYS_FATAL_IF(err != 0, "Input module %s not found", name); |
| 61 | mHal = reinterpret_cast<const input_module_t*>(module); |
| 62 | } |
| 63 | |
| 64 | void InputDriver::init(InputHostInterface* host) { |
| 65 | mHal->init(mHal, static_cast<input_host_t*>(host), kCallbacks); |
| 66 | } |
| 67 | |
| 68 | void InputDriver::dump(String8& result) { |
| 69 | result.appendFormat(INDENT2 "HAL Input Driver (%s)\n", mName.string()); |
| 70 | } |
| 71 | |
Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 72 | |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 73 | // HAL wrapper functions |
| 74 | |
Michael Wright | a16b98c | 2015-09-22 21:04:33 +0100 | [diff] [blame] | 75 | input_device_identifier_t* create_device_identifier(input_host_t* host, |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 76 | const char* name, int32_t product_id, int32_t vendor_id, |
| 77 | input_bus_t bus, const char* unique_id) { |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 78 | return nullptr; |
| 79 | } |
Tim Kilbourn | c472986 | 2015-05-08 17:13:43 -0700 | [diff] [blame] | 80 | |
Michael Wright | a16b98c | 2015-09-22 21:04:33 +0100 | [diff] [blame] | 81 | input_device_definition_t* create_device_definition(input_host_t* host) { |
| 82 | return nullptr; |
| 83 | } |
| 84 | |
| 85 | input_report_definition_t* create_input_report_definition(input_host_t* host) { |
| 86 | return nullptr; |
| 87 | } |
| 88 | |
| 89 | input_report_definition_t* create_output_report_definition(input_host_t* host) { |
| 90 | return nullptr; |
| 91 | } |
| 92 | |
| 93 | void input_device_definition_add_report(input_host_t* host, |
| 94 | input_device_definition_t* d, input_report_definition_t* r) { } |
| 95 | |
| 96 | void input_report_definition_add_collection(input_host_t* host, |
| 97 | input_report_definition_t* report, input_collection_id_t id, int32_t arity) { } |
| 98 | |
| 99 | void input_report_definition_declare_usage_int(input_host_t* host, |
| 100 | input_report_definition_t* report, input_collection_id_t id, |
| 101 | input_usage_t usage, int32_t min, int32_t max, float resolution) { } |
| 102 | |
| 103 | void input_report_definition_declare_usages_bool(input_host_t* host, |
| 104 | input_report_definition_t* report, input_collection_id_t id, |
| 105 | input_usage_t* usage, size_t usage_count) { } |
| 106 | |
| 107 | |
| 108 | input_device_handle_t* register_device(input_host_t* host, |
| 109 | input_device_identifier_t* id, input_device_definition_t* d) { |
| 110 | return nullptr; |
| 111 | } |
| 112 | |
| 113 | input_report_t* input_allocate_report(input_host_t* host, input_report_definition_t* r) { |
| 114 | return nullptr; |
| 115 | } |
Tim Kilbourn | 8943ce3 | 2015-02-27 15:09:34 -0800 | [diff] [blame] | 116 | void input_report_set_usage_int(input_host_t* host, input_report_t* r, |
| 117 | input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index) { } |
| 118 | |
| 119 | void input_report_set_usage_bool(input_host_t* host, input_report_t* r, |
| 120 | input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index) { } |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 121 | |
Michael Wright | a16b98c | 2015-09-22 21:04:33 +0100 | [diff] [blame] | 122 | void report_event(input_host_t* host, input_device_handle_t* d, input_report_t* report) { } |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 123 | |
Tim Kilbourn | e5364c8 | 2015-04-06 13:48:50 -0700 | [diff] [blame] | 124 | input_property_map_t* input_get_device_property_map(input_host_t* host, |
| 125 | input_device_identifier_t* id) { |
| 126 | return nullptr; |
| 127 | } |
| 128 | |
| 129 | input_property_t* input_get_device_property(input_host_t* host, input_property_map_t* map, |
| 130 | const char* key) { |
| 131 | return nullptr; |
| 132 | } |
| 133 | |
| 134 | const char* input_get_property_key(input_host_t* host, input_property_t* property) { |
| 135 | return nullptr; |
| 136 | } |
| 137 | |
| 138 | const char* input_get_property_value(input_host_t* host, input_property_t* property) { |
| 139 | return nullptr; |
| 140 | } |
| 141 | |
Michael Wright | a16b98c | 2015-09-22 21:04:33 +0100 | [diff] [blame] | 142 | void input_free_device_property(input_host_t* host, input_property_t* property) { } |
Tim Kilbourn | e5364c8 | 2015-04-06 13:48:50 -0700 | [diff] [blame] | 143 | |
Michael Wright | a16b98c | 2015-09-22 21:04:33 +0100 | [diff] [blame] | 144 | void input_free_device_property_map(input_host_t* host, input_property_map_t* map) { } |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 145 | |
| 146 | } // namespace android |