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 "InputHost.h"
18
19 namespace android {
20
reportEvent(InputDeviceHandle d)21 void InputReport::reportEvent(InputDeviceHandle d) {
22 mCallbacks.report_event(mHost, d, mReport);
23 }
24
addCollection(InputCollectionId id,int32_t arity)25 void InputReportDefinition::addCollection(InputCollectionId id, int32_t arity) {
26 mCallbacks.input_report_definition_add_collection(mHost, mReportDefinition, id, arity);
27 }
28
declareUsage(InputCollectionId id,InputUsage usage,int32_t min,int32_t max,float resolution)29 void 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
declareUsage(InputCollectionId id,InputUsage * usage,size_t usageCount)35 void 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
allocateReport()41 InputReport InputReportDefinition::allocateReport() {
42 return InputReport(mHost, mCallbacks,
43 mCallbacks.input_allocate_report(mHost, mReportDefinition));
44 }
45
addReport(InputReportDefinition r)46 void InputDeviceDefinition::addReport(InputReportDefinition r) {
47 mCallbacks.input_device_definition_add_report(mHost, mDeviceDefinition, r);
48 }
49
~InputProperty()50 InputProperty::~InputProperty() {
51 mCallbacks.input_free_device_property(mHost, mProperty);
52 }
53
getKey()54 const char* InputProperty::getKey() {
55 return mCallbacks.input_get_property_key(mHost, mProperty);
56 }
57
getValue()58 const char* InputProperty::getValue() {
59 return mCallbacks.input_get_property_value(mHost, mProperty);
60 }
61
~InputPropertyMap()62 InputPropertyMap::~InputPropertyMap() {
63 mCallbacks.input_free_device_property_map(mHost, mMap);
64 }
65
getDeviceProperty(const char * key)66 InputProperty InputPropertyMap::getDeviceProperty(const char* key) {
67 return InputProperty(mHost, mCallbacks,
68 mCallbacks.input_get_device_property(mHost, mMap, key));
69 }
70
createDeviceIdentifier(const char * name,int32_t productId,int32_t vendorId,InputBus bus,const char * uniqueId)71 InputDeviceIdentifier 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
createDeviceDefinition()76 InputDeviceDefinition InputHost::createDeviceDefinition() {
77 return InputDeviceDefinition(mHost, mCallbacks, mCallbacks.create_device_definition(mHost));
78 }
79
createInputReportDefinition()80 InputReportDefinition InputHost::createInputReportDefinition() {
81 return InputReportDefinition(mHost, mCallbacks,
82 mCallbacks.create_input_report_definition(mHost));
83 }
84
createOutputReportDefinition()85 InputReportDefinition InputHost::createOutputReportDefinition() {
86 return InputReportDefinition(mHost, mCallbacks,
87 mCallbacks.create_output_report_definition(mHost));
88 }
89
registerDevice(InputDeviceIdentifier id,InputDeviceDefinition d)90 InputDeviceHandle InputHost::registerDevice(InputDeviceIdentifier id,
91 InputDeviceDefinition d) {
92 return mCallbacks.register_device(mHost, id, d);
93 }
94
unregisterDevice(InputDeviceHandle handle)95 void InputHost::unregisterDevice(InputDeviceHandle handle) {
96 return mCallbacks.unregister_device(mHost, handle);
97 }
98
getDevicePropertyMap(InputDeviceIdentifier id)99 InputPropertyMap InputHost::getDevicePropertyMap(InputDeviceIdentifier id) {
100 return InputPropertyMap(mHost, mCallbacks,
101 mCallbacks.input_get_device_property_map(mHost, id));
102 }
103
104 } // namespace android
105