Home | History | Annotate | Download | only in evdev
      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 
     21 void InputReport::setIntUsage(InputCollectionId id, InputUsage usage, int32_t value,
     22         int32_t arityIndex) {
     23     mCallbacks.input_report_set_usage_int(mHost, mReport, id, usage, value, arityIndex);
     24 }
     25 
     26 void InputReport::setBoolUsage(InputCollectionId id, InputUsage usage, bool value,
     27         int32_t arityIndex) {
     28     mCallbacks.input_report_set_usage_bool(mHost, mReport, id, usage, value, arityIndex);
     29 }
     30 
     31 void InputReport::reportEvent(InputDeviceHandle* d) {
     32     mCallbacks.report_event(mHost, d, mReport);
     33 }
     34 
     35 void InputReportDefinition::addCollection(InputCollectionId id, int32_t arity) {
     36     mCallbacks.input_report_definition_add_collection(mHost, mReportDefinition, id, arity);
     37 }
     38 
     39 void InputReportDefinition::declareUsage(InputCollectionId id, InputUsage usage,
     40         int32_t min, int32_t max, float resolution) {
     41     mCallbacks.input_report_definition_declare_usage_int(mHost, mReportDefinition,
     42             id, usage, min, max, resolution);
     43 }
     44 
     45 void InputReportDefinition::declareUsages(InputCollectionId id, InputUsage* usage,
     46         size_t usageCount) {
     47     mCallbacks.input_report_definition_declare_usages_bool(mHost, mReportDefinition,
     48             id, usage, usageCount);
     49 }
     50 
     51 InputReport* InputReportDefinition::allocateReport() {
     52     return new InputReport(mHost, mCallbacks,
     53             mCallbacks.input_allocate_report(mHost, mReportDefinition));
     54 }
     55 
     56 void InputDeviceDefinition::addReport(InputReportDefinition* r) {
     57     mCallbacks.input_device_definition_add_report(mHost, mDeviceDefinition, *r);
     58 }
     59 
     60 const char* InputProperty::getKey() const {
     61     return mCallbacks.input_get_property_key(mHost, mProperty);
     62 }
     63 
     64 const char* InputProperty::getValue() const {
     65     return mCallbacks.input_get_property_value(mHost, mProperty);
     66 }
     67 
     68 InputProperty* InputPropertyMap::getDeviceProperty(const char* key) const {
     69     return new InputProperty(mHost, mCallbacks,
     70             mCallbacks.input_get_device_property(mHost, mMap, key));
     71 }
     72 
     73 void InputPropertyMap::freeDeviceProperty(InputProperty* property) const {
     74     mCallbacks.input_free_device_property(mHost, *property);
     75 }
     76 
     77 InputDeviceIdentifier* InputHost::createDeviceIdentifier(const char* name, int32_t productId,
     78         int32_t vendorId, InputBus bus, const char* uniqueId) {
     79     return mCallbacks.create_device_identifier(
     80                 mHost, name, productId, vendorId, bus, uniqueId);
     81 }
     82 
     83 InputDeviceDefinition* InputHost::createDeviceDefinition() {
     84     return new InputDeviceDefinition(mHost, mCallbacks, mCallbacks.create_device_definition(mHost));
     85 }
     86 
     87 InputReportDefinition* InputHost::createInputReportDefinition() {
     88     return new InputReportDefinition(mHost, mCallbacks,
     89             mCallbacks.create_input_report_definition(mHost));
     90 }
     91 
     92 InputReportDefinition* InputHost::createOutputReportDefinition() {
     93     return new InputReportDefinition(mHost, mCallbacks,
     94             mCallbacks.create_output_report_definition(mHost));
     95 }
     96 
     97 void InputHost::freeReportDefinition(InputReportDefinition* reportDef) {
     98     mCallbacks.free_report_definition(mHost, *reportDef);
     99 }
    100 
    101 InputDeviceHandle* InputHost::registerDevice(InputDeviceIdentifier* id,
    102         InputDeviceDefinition* d) {
    103     return mCallbacks.register_device(mHost, id, *d);
    104 }
    105 
    106 void InputHost::unregisterDevice(InputDeviceHandle* handle) {
    107     mCallbacks.unregister_device(mHost, handle);
    108 }
    109 
    110 InputPropertyMap* InputHost::getDevicePropertyMap(InputDeviceIdentifier* id) {
    111     return new InputPropertyMap(mHost, mCallbacks,
    112             mCallbacks.input_get_device_property_map(mHost, id));
    113 }
    114 
    115 void InputHost::freeDevicePropertyMap(InputPropertyMap* propertyMap) {
    116     mCallbacks.input_free_device_property_map(mHost, *propertyMap);
    117 }
    118 
    119 }  // namespace android
    120