1*e01b6f76SAndroid Build Coastguard Worker /*
2*e01b6f76SAndroid Build Coastguard Worker * Copyright (C) 2015 The Android Open Source Project
3*e01b6f76SAndroid Build Coastguard Worker *
4*e01b6f76SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*e01b6f76SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*e01b6f76SAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*e01b6f76SAndroid Build Coastguard Worker *
8*e01b6f76SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*e01b6f76SAndroid Build Coastguard Worker *
10*e01b6f76SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*e01b6f76SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*e01b6f76SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*e01b6f76SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*e01b6f76SAndroid Build Coastguard Worker * limitations under the License.
15*e01b6f76SAndroid Build Coastguard Worker */
16*e01b6f76SAndroid Build Coastguard Worker
17*e01b6f76SAndroid Build Coastguard Worker #include "InputHost.h"
18*e01b6f76SAndroid Build Coastguard Worker
19*e01b6f76SAndroid Build Coastguard Worker namespace android {
20*e01b6f76SAndroid Build Coastguard Worker
setIntUsage(InputCollectionId id,InputUsage usage,int32_t value,int32_t arityIndex)21*e01b6f76SAndroid Build Coastguard Worker void InputReport::setIntUsage(InputCollectionId id, InputUsage usage, int32_t value,
22*e01b6f76SAndroid Build Coastguard Worker int32_t arityIndex) {
23*e01b6f76SAndroid Build Coastguard Worker mCallbacks.input_report_set_usage_int(mHost, mReport, id, usage, value, arityIndex);
24*e01b6f76SAndroid Build Coastguard Worker }
25*e01b6f76SAndroid Build Coastguard Worker
setBoolUsage(InputCollectionId id,InputUsage usage,bool value,int32_t arityIndex)26*e01b6f76SAndroid Build Coastguard Worker void InputReport::setBoolUsage(InputCollectionId id, InputUsage usage, bool value,
27*e01b6f76SAndroid Build Coastguard Worker int32_t arityIndex) {
28*e01b6f76SAndroid Build Coastguard Worker mCallbacks.input_report_set_usage_bool(mHost, mReport, id, usage, value, arityIndex);
29*e01b6f76SAndroid Build Coastguard Worker }
30*e01b6f76SAndroid Build Coastguard Worker
reportEvent(InputDeviceHandle * d)31*e01b6f76SAndroid Build Coastguard Worker void InputReport::reportEvent(InputDeviceHandle* d) {
32*e01b6f76SAndroid Build Coastguard Worker mCallbacks.report_event(mHost, d, mReport);
33*e01b6f76SAndroid Build Coastguard Worker }
34*e01b6f76SAndroid Build Coastguard Worker
addCollection(InputCollectionId id,int32_t arity)35*e01b6f76SAndroid Build Coastguard Worker void InputReportDefinition::addCollection(InputCollectionId id, int32_t arity) {
36*e01b6f76SAndroid Build Coastguard Worker mCallbacks.input_report_definition_add_collection(mHost, mReportDefinition, id, arity);
37*e01b6f76SAndroid Build Coastguard Worker }
38*e01b6f76SAndroid Build Coastguard Worker
declareUsage(InputCollectionId id,InputUsage usage,int32_t min,int32_t max,float resolution)39*e01b6f76SAndroid Build Coastguard Worker void InputReportDefinition::declareUsage(InputCollectionId id, InputUsage usage,
40*e01b6f76SAndroid Build Coastguard Worker int32_t min, int32_t max, float resolution) {
41*e01b6f76SAndroid Build Coastguard Worker mCallbacks.input_report_definition_declare_usage_int(mHost, mReportDefinition,
42*e01b6f76SAndroid Build Coastguard Worker id, usage, min, max, resolution);
43*e01b6f76SAndroid Build Coastguard Worker }
44*e01b6f76SAndroid Build Coastguard Worker
declareUsages(InputCollectionId id,InputUsage * usage,size_t usageCount)45*e01b6f76SAndroid Build Coastguard Worker void InputReportDefinition::declareUsages(InputCollectionId id, InputUsage* usage,
46*e01b6f76SAndroid Build Coastguard Worker size_t usageCount) {
47*e01b6f76SAndroid Build Coastguard Worker mCallbacks.input_report_definition_declare_usages_bool(mHost, mReportDefinition,
48*e01b6f76SAndroid Build Coastguard Worker id, usage, usageCount);
49*e01b6f76SAndroid Build Coastguard Worker }
50*e01b6f76SAndroid Build Coastguard Worker
allocateReport()51*e01b6f76SAndroid Build Coastguard Worker InputReport* InputReportDefinition::allocateReport() {
52*e01b6f76SAndroid Build Coastguard Worker return new InputReport(mHost, mCallbacks,
53*e01b6f76SAndroid Build Coastguard Worker mCallbacks.input_allocate_report(mHost, mReportDefinition));
54*e01b6f76SAndroid Build Coastguard Worker }
55*e01b6f76SAndroid Build Coastguard Worker
addReport(InputReportDefinition * r)56*e01b6f76SAndroid Build Coastguard Worker void InputDeviceDefinition::addReport(InputReportDefinition* r) {
57*e01b6f76SAndroid Build Coastguard Worker mCallbacks.input_device_definition_add_report(mHost, mDeviceDefinition, *r);
58*e01b6f76SAndroid Build Coastguard Worker }
59*e01b6f76SAndroid Build Coastguard Worker
getKey() const60*e01b6f76SAndroid Build Coastguard Worker const char* InputProperty::getKey() const {
61*e01b6f76SAndroid Build Coastguard Worker return mCallbacks.input_get_property_key(mHost, mProperty);
62*e01b6f76SAndroid Build Coastguard Worker }
63*e01b6f76SAndroid Build Coastguard Worker
getValue() const64*e01b6f76SAndroid Build Coastguard Worker const char* InputProperty::getValue() const {
65*e01b6f76SAndroid Build Coastguard Worker return mCallbacks.input_get_property_value(mHost, mProperty);
66*e01b6f76SAndroid Build Coastguard Worker }
67*e01b6f76SAndroid Build Coastguard Worker
getDeviceProperty(const char * key) const68*e01b6f76SAndroid Build Coastguard Worker InputProperty* InputPropertyMap::getDeviceProperty(const char* key) const {
69*e01b6f76SAndroid Build Coastguard Worker return new InputProperty(mHost, mCallbacks,
70*e01b6f76SAndroid Build Coastguard Worker mCallbacks.input_get_device_property(mHost, mMap, key));
71*e01b6f76SAndroid Build Coastguard Worker }
72*e01b6f76SAndroid Build Coastguard Worker
freeDeviceProperty(InputProperty * property) const73*e01b6f76SAndroid Build Coastguard Worker void InputPropertyMap::freeDeviceProperty(InputProperty* property) const {
74*e01b6f76SAndroid Build Coastguard Worker mCallbacks.input_free_device_property(mHost, *property);
75*e01b6f76SAndroid Build Coastguard Worker }
76*e01b6f76SAndroid Build Coastguard Worker
createDeviceIdentifier(const char * name,int32_t productId,int32_t vendorId,InputBus bus,const char * uniqueId)77*e01b6f76SAndroid Build Coastguard Worker InputDeviceIdentifier* InputHost::createDeviceIdentifier(const char* name, int32_t productId,
78*e01b6f76SAndroid Build Coastguard Worker int32_t vendorId, InputBus bus, const char* uniqueId) {
79*e01b6f76SAndroid Build Coastguard Worker return mCallbacks.create_device_identifier(
80*e01b6f76SAndroid Build Coastguard Worker mHost, name, productId, vendorId, bus, uniqueId);
81*e01b6f76SAndroid Build Coastguard Worker }
82*e01b6f76SAndroid Build Coastguard Worker
createDeviceDefinition()83*e01b6f76SAndroid Build Coastguard Worker InputDeviceDefinition* InputHost::createDeviceDefinition() {
84*e01b6f76SAndroid Build Coastguard Worker return new InputDeviceDefinition(mHost, mCallbacks, mCallbacks.create_device_definition(mHost));
85*e01b6f76SAndroid Build Coastguard Worker }
86*e01b6f76SAndroid Build Coastguard Worker
createInputReportDefinition()87*e01b6f76SAndroid Build Coastguard Worker InputReportDefinition* InputHost::createInputReportDefinition() {
88*e01b6f76SAndroid Build Coastguard Worker return new InputReportDefinition(mHost, mCallbacks,
89*e01b6f76SAndroid Build Coastguard Worker mCallbacks.create_input_report_definition(mHost));
90*e01b6f76SAndroid Build Coastguard Worker }
91*e01b6f76SAndroid Build Coastguard Worker
createOutputReportDefinition()92*e01b6f76SAndroid Build Coastguard Worker InputReportDefinition* InputHost::createOutputReportDefinition() {
93*e01b6f76SAndroid Build Coastguard Worker return new InputReportDefinition(mHost, mCallbacks,
94*e01b6f76SAndroid Build Coastguard Worker mCallbacks.create_output_report_definition(mHost));
95*e01b6f76SAndroid Build Coastguard Worker }
96*e01b6f76SAndroid Build Coastguard Worker
freeReportDefinition(InputReportDefinition * reportDef)97*e01b6f76SAndroid Build Coastguard Worker void InputHost::freeReportDefinition(InputReportDefinition* reportDef) {
98*e01b6f76SAndroid Build Coastguard Worker mCallbacks.free_report_definition(mHost, *reportDef);
99*e01b6f76SAndroid Build Coastguard Worker }
100*e01b6f76SAndroid Build Coastguard Worker
registerDevice(InputDeviceIdentifier * id,InputDeviceDefinition * d)101*e01b6f76SAndroid Build Coastguard Worker InputDeviceHandle* InputHost::registerDevice(InputDeviceIdentifier* id,
102*e01b6f76SAndroid Build Coastguard Worker InputDeviceDefinition* d) {
103*e01b6f76SAndroid Build Coastguard Worker return mCallbacks.register_device(mHost, id, *d);
104*e01b6f76SAndroid Build Coastguard Worker }
105*e01b6f76SAndroid Build Coastguard Worker
unregisterDevice(InputDeviceHandle * handle)106*e01b6f76SAndroid Build Coastguard Worker void InputHost::unregisterDevice(InputDeviceHandle* handle) {
107*e01b6f76SAndroid Build Coastguard Worker mCallbacks.unregister_device(mHost, handle);
108*e01b6f76SAndroid Build Coastguard Worker }
109*e01b6f76SAndroid Build Coastguard Worker
getDevicePropertyMap(InputDeviceIdentifier * id)110*e01b6f76SAndroid Build Coastguard Worker InputPropertyMap* InputHost::getDevicePropertyMap(InputDeviceIdentifier* id) {
111*e01b6f76SAndroid Build Coastguard Worker return new InputPropertyMap(mHost, mCallbacks,
112*e01b6f76SAndroid Build Coastguard Worker mCallbacks.input_get_device_property_map(mHost, id));
113*e01b6f76SAndroid Build Coastguard Worker }
114*e01b6f76SAndroid Build Coastguard Worker
freeDevicePropertyMap(InputPropertyMap * propertyMap)115*e01b6f76SAndroid Build Coastguard Worker void InputHost::freeDevicePropertyMap(InputPropertyMap* propertyMap) {
116*e01b6f76SAndroid Build Coastguard Worker mCallbacks.input_free_device_property_map(mHost, *propertyMap);
117*e01b6f76SAndroid Build Coastguard Worker }
118*e01b6f76SAndroid Build Coastguard Worker
119*e01b6f76SAndroid Build Coastguard Worker } // namespace android
120