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, |
| 46 | .report_event = report_event, |
| 47 | }; |
| 48 | |
| 49 | InputDriver::InputDriver(const char* name) : mName(String8(name)) { |
| 50 | const hw_module_t* module; |
| 51 | int err = input_open(&module, name); |
| 52 | LOG_ALWAYS_FATAL_IF(err != 0, "Input module %s not found", name); |
| 53 | mHal = reinterpret_cast<const input_module_t*>(module); |
| 54 | } |
| 55 | |
| 56 | void InputDriver::init(InputHostInterface* host) { |
| 57 | mHal->init(mHal, static_cast<input_host_t*>(host), kCallbacks); |
| 58 | } |
| 59 | |
| 60 | void InputDriver::dump(String8& result) { |
| 61 | result.appendFormat(INDENT2 "HAL Input Driver (%s)\n", mName.string()); |
| 62 | } |
| 63 | |
| 64 | |
| 65 | // HAL wrapper functions |
| 66 | |
| 67 | input_device_identifier_t* create_device_identifier(input_host_t* host, |
| 68 | const char* name, int32_t product_id, int32_t vendor_id, |
| 69 | input_bus_t bus, const char* unique_id) { |
| 70 | return nullptr; |
| 71 | } |
| 72 | |
| 73 | input_device_definition_t* create_device_definition(input_host_t* host) { |
| 74 | return nullptr; |
| 75 | } |
| 76 | |
| 77 | input_report_definition_t* create_input_report_definition(input_host_t* host) { |
| 78 | return nullptr; |
| 79 | } |
| 80 | |
| 81 | input_report_definition_t* create_output_report_definition(input_host_t* host) { |
| 82 | return nullptr; |
| 83 | } |
| 84 | |
| 85 | void input_device_definition_add_report(input_host_t* host, |
| 86 | input_device_definition_t* d, input_report_definition_t* r) { } |
| 87 | |
| 88 | void input_report_definition_add_collection(input_host_t* host, |
| 89 | input_report_definition_t* report, input_collection_id_t id, int32_t arity) { } |
| 90 | |
| 91 | void input_report_definition_declare_usage_int(input_host_t* host, |
| 92 | input_report_definition_t* report, input_collection_id_t id, |
| 93 | input_usage_t usage, int32_t min, int32_t max, float resolution) { } |
| 94 | |
| 95 | void input_report_definition_declare_usages_bool(input_host_t* host, |
| 96 | input_report_definition_t* report, input_collection_id_t id, |
| 97 | input_usage_t* usage, size_t usage_count) { } |
| 98 | |
| 99 | |
| 100 | input_device_handle_t* register_device(input_host_t* host, |
| 101 | input_device_identifier_t* id, input_device_definition_t* d) { |
| 102 | return nullptr; |
| 103 | } |
| 104 | |
| 105 | input_report_t* input_allocate_report(input_host_t* host, input_report_definition_t* r) { |
| 106 | return nullptr; |
| 107 | } |
| 108 | |
| 109 | void report_event(input_host_t* host, input_device_handle_t* d, input_report_t* report) { } |
| 110 | |
| 111 | |
| 112 | } // namespace android |