blob: 9bc14a7a3dc35ea16e00c68b08833c5ce3b30250 [file] [log] [blame]
Michael Wright6f783602015-02-13 17:35:16 -08001/*
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
29namespace android {
30
31class InputHostInterface;
32
33class InputDriverInterface : public virtual RefBase {
34protected:
35 InputDriverInterface() = default;
36 virtual ~InputDriverInterface() = default;
37
38public:
39 virtual void init(InputHostInterface* host) = 0;
40
41 virtual void dump(String8& result) = 0;
42};
43
44class InputDriver : public InputDriverInterface {
45public:
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
53private:
54 String8 mName;
55 const input_module_t* mHal;
56};
57
58
59extern "C" {
60
61input_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
65input_device_definition_t* create_device_definition(input_host_t* host);
66
67input_report_definition_t* create_input_report_definition(input_host_t* host);
68
69input_report_definition_t* create_output_report_definition(input_host_t* host);
70
Tim Kilbournc4729862015-05-08 17:13:43 -070071void free_report_definition(input_host_t* host, input_report_definition_t* report_def);
72
Michael Wright6f783602015-02-13 17:35:16 -080073void input_device_definition_add_report(input_host_t* host,
74 input_device_definition_t* d, input_report_definition_t* r);
75
76void input_report_definition_add_collection(input_host_t* host,
77 input_report_definition_t* report, input_collection_id_t id, int32_t arity);
78
79void input_report_definition_declare_usage_int(input_host_t* host,
80 input_report_definition_t* report, input_collection_id_t id,
81 input_usage_t usage, int32_t min, int32_t max, float resolution);
82
83void input_report_definition_declare_usages_bool(input_host_t* host,
84 input_report_definition_t* report, input_collection_id_t id,
85 input_usage_t* usage, size_t usage_count);
86
87
88input_device_handle_t* register_device(input_host_t* host,
89 input_device_identifier_t* id, input_device_definition_t* d);
90
91void unregister_device(input_host_t* host, input_device_handle_t* handle);
92
93input_report_t* input_allocate_report(input_host_t* host, input_report_definition_t* r);
94
Tim Kilbourn8943ce32015-02-27 15:09:34 -080095void input_report_set_usage_int(input_host_t* host, input_report_t* r,
96 input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index);
97
98void input_report_set_usage_bool(input_host_t* host, input_report_t* r,
99 input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index);
100
Michael Wright6f783602015-02-13 17:35:16 -0800101void report_event(input_host_t* host, input_device_handle_t* d, input_report_t* report);
102
Tim Kilbourne5364c82015-04-06 13:48:50 -0700103input_property_map_t* input_get_device_property_map(input_host_t* host,
104 input_device_identifier_t* id);
105
106input_property_t* input_get_device_property(input_host_t* host, input_property_map_t* map,
107 const char* key);
108
109const char* input_get_property_key(input_host_t* host, input_property_t* property);
110
111const char* input_get_property_value(input_host_t* host, input_property_t* property);
112
113void input_free_device_property(input_host_t* host, input_property_t* property);
114
115void input_free_device_property_map(input_host_t* host, input_property_map_t* map);
Michael Wright6f783602015-02-13 17:35:16 -0800116}
117
118} // namespace android
119#endif // ANDROID_INPUT_DRIVER_H