Tim Kilbourn | 73475a4 | 2015-02-13 10:35:20 -0800 | [diff] [blame^] | 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::reportEvent(InputDeviceHandle d) { |
| 22 | mCallbacks.report_event(mHost, d, mReport); |
| 23 | } |
| 24 | |
| 25 | void InputReportDefinition::addCollection(InputCollectionId id, int32_t arity) { |
| 26 | mCallbacks.input_report_definition_add_collection(mHost, mReportDefinition, id, arity); |
| 27 | } |
| 28 | |
| 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 | |
| 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 | |
| 41 | InputReport InputReportDefinition::allocateReport() { |
| 42 | return InputReport(mHost, mCallbacks, |
| 43 | mCallbacks.input_allocate_report(mHost, mReportDefinition)); |
| 44 | } |
| 45 | |
| 46 | void InputDeviceDefinition::addReport(InputReportDefinition r) { |
| 47 | mCallbacks.input_device_definition_add_report(mHost, mDeviceDefinition, r); |
| 48 | } |
| 49 | |
| 50 | InputDeviceIdentifier InputHost::createDeviceIdentifier(const char* name, int32_t productId, |
| 51 | int32_t vendorId, InputBus bus, const char* uniqueId) { |
| 52 | return mCallbacks.create_device_identifier(mHost, name, productId, vendorId, bus, uniqueId); |
| 53 | } |
| 54 | |
| 55 | InputDeviceDefinition InputHost::createDeviceDefinition() { |
| 56 | return InputDeviceDefinition(mHost, mCallbacks, mCallbacks.create_device_definition(mHost)); |
| 57 | } |
| 58 | |
| 59 | InputReportDefinition InputHost::createInputReportDefinition() { |
| 60 | return InputReportDefinition(mHost, mCallbacks, |
| 61 | mCallbacks.create_input_report_definition(mHost)); |
| 62 | } |
| 63 | |
| 64 | InputReportDefinition InputHost::createOutputReportDefinition() { |
| 65 | return InputReportDefinition(mHost, mCallbacks, |
| 66 | mCallbacks.create_output_report_definition(mHost)); |
| 67 | } |
| 68 | |
| 69 | InputDeviceHandle InputHost::registerDevice(InputDeviceIdentifier id, |
| 70 | InputDeviceDefinition d) { |
| 71 | return mCallbacks.register_device(mHost, id, d); |
| 72 | } |
| 73 | |
| 74 | void InputHost::unregisterDevice(InputDeviceHandle handle) { |
| 75 | return mCallbacks.unregister_device(mHost, handle); |
| 76 | } |
| 77 | |
| 78 | } // namespace android |