blob: 6a65fcd063406d462bdca01838065b83fae51530 [file] [log] [blame]
Tim Kilbourn73475a42015-02-13 10:35:20 -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#include "InputHost.h"
18
19namespace android {
20
21void InputReport::reportEvent(InputDeviceHandle d) {
22 mCallbacks.report_event(mHost, d, mReport);
23}
24
25void InputReportDefinition::addCollection(InputCollectionId id, int32_t arity) {
26 mCallbacks.input_report_definition_add_collection(mHost, mReportDefinition, id, arity);
27}
28
29void InputReportDefinition::declareUsage(InputCollectionId id, InputUsage usage,
30 int32_t min, int32_t max, float resolution) {
31 mCallbacks.input_report_definition_declare_usage_int(mHost, mReportDefinition,
32 id, usage, min, max, resolution);
33}
34
35void InputReportDefinition::declareUsage(InputCollectionId id, InputUsage* usage,
36 size_t usageCount) {
37 mCallbacks.input_report_definition_declare_usages_bool(mHost, mReportDefinition,
38 id, usage, usageCount);
39}
40
41InputReport InputReportDefinition::allocateReport() {
42 return InputReport(mHost, mCallbacks,
43 mCallbacks.input_allocate_report(mHost, mReportDefinition));
44}
45
46void InputDeviceDefinition::addReport(InputReportDefinition r) {
47 mCallbacks.input_device_definition_add_report(mHost, mDeviceDefinition, r);
48}
49
Tim Kilbourn6fa82482015-04-06 13:49:40 -070050InputProperty::~InputProperty() {
51 mCallbacks.input_free_device_property(mHost, mProperty);
52}
53
54const char* InputProperty::getKey() {
55 return mCallbacks.input_get_property_key(mHost, mProperty);
56}
57
58const char* InputProperty::getValue() {
59 return mCallbacks.input_get_property_value(mHost, mProperty);
60}
61
62InputPropertyMap::~InputPropertyMap() {
63 mCallbacks.input_free_device_property_map(mHost, mMap);
64}
65
66InputProperty InputPropertyMap::getDeviceProperty(const char* key) {
67 return InputProperty(mHost, mCallbacks,
68 mCallbacks.input_get_device_property(mHost, mMap, key));
69}
70
Tim Kilbourn73475a42015-02-13 10:35:20 -080071InputDeviceIdentifier InputHost::createDeviceIdentifier(const char* name, int32_t productId,
72 int32_t vendorId, InputBus bus, const char* uniqueId) {
73 return mCallbacks.create_device_identifier(mHost, name, productId, vendorId, bus, uniqueId);
74}
75
76InputDeviceDefinition InputHost::createDeviceDefinition() {
77 return InputDeviceDefinition(mHost, mCallbacks, mCallbacks.create_device_definition(mHost));
78}
79
80InputReportDefinition InputHost::createInputReportDefinition() {
81 return InputReportDefinition(mHost, mCallbacks,
82 mCallbacks.create_input_report_definition(mHost));
83}
84
85InputReportDefinition InputHost::createOutputReportDefinition() {
86 return InputReportDefinition(mHost, mCallbacks,
87 mCallbacks.create_output_report_definition(mHost));
88}
89
90InputDeviceHandle InputHost::registerDevice(InputDeviceIdentifier id,
91 InputDeviceDefinition d) {
92 return mCallbacks.register_device(mHost, id, d);
93}
94
95void InputHost::unregisterDevice(InputDeviceHandle handle) {
96 return mCallbacks.unregister_device(mHost, handle);
97}
98
Tim Kilbourn6fa82482015-04-06 13:49:40 -070099InputPropertyMap InputHost::getDevicePropertyMap(InputDeviceIdentifier id) {
100 return InputPropertyMap(mHost, mCallbacks,
101 mCallbacks.input_get_device_property_map(mHost, id));
102}
103
Tim Kilbourn73475a42015-02-13 10:35:20 -0800104} // namespace android