2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_INPUT_DRIVER_H
18 #define ANDROID_INPUT_DRIVER_H
21 #include <sys/types.h>
23 #include "InputHost.h"
25 #include <hardware/input.h>
26 #include <utils/RefBase.h>
27 #include <utils/String8.h>
31 class InputHostInterface;
33 class InputDriverInterface : public virtual RefBase {
35 InputDriverInterface() = default;
36 virtual ~InputDriverInterface() = default;
39 virtual void init(InputHostInterface* host) = 0;
41 virtual void dump(String8& result) = 0;
44 class InputDriver : public InputDriverInterface {
46 InputDriver(const char* name);
47 virtual ~InputDriver() = default;
49 virtual void init(InputHostInterface* host) override;
51 virtual void dump(String8& result) override;
55 const input_module_t* mHal;
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);
65 input_device_definition_t* create_device_definition(input_host_t* host);
67 input_report_definition_t* create_input_report_definition(input_host_t* host);
69 input_report_definition_t* create_output_report_definition(input_host_t* host);
71 void input_device_definition_add_report(input_host_t* host,
72 input_device_definition_t* d, input_report_definition_t* r);
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);
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);
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);
86 input_device_handle_t* register_device(input_host_t* host,
87 input_device_identifier_t* id, input_device_definition_t* d);
89 void unregister_device(input_host_t* host, input_device_handle_t* handle);
91 input_report_t* input_allocate_report(input_host_t* host, input_report_definition_t* r);
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);
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);
99 void report_event(input_host_t* host, input_device_handle_t* d, input_report_t* report);
101 input_property_map_t* input_get_device_property_map(input_host_t* host,
102 input_device_identifier_t* id);
104 input_property_t* input_get_device_property(input_host_t* host, input_property_map_t* map,
107 const char* input_get_property_key(input_host_t* host, input_property_t* property);
109 const char* input_get_property_value(input_host_t* host, input_property_t* property);
111 void input_free_device_property(input_host_t* host, input_property_t* property);
113 void input_free_device_property_map(input_host_t* host, input_property_map_t* map);
116 } // namespace android
117 #endif // ANDROID_INPUT_DRIVER_H