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 | #ifndef ANDROID_INPUT_DEVICE_H_ |
| 18 | #define ANDROID_INPUT_DEVICE_H_ |
| 19 | |
| 20 | #include <memory> |
| 21 | |
| 22 | #include <utils/Timers.h> |
| 23 | |
| 24 | #include "InputHub.h" |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | /** |
| 29 | * InputDeviceInterface represents an input device in the HAL. It processes |
| 30 | * input events before passing them to the input host. |
| 31 | */ |
| 32 | class InputDeviceInterface { |
| 33 | public: |
| 34 | virtual void processInput(InputEvent& event, nsecs_t currentTime) = 0; |
| 35 | |
| 36 | protected: |
| 37 | InputDeviceInterface() = default; |
| 38 | virtual ~InputDeviceInterface() = default; |
| 39 | }; |
| 40 | |
| 41 | /** |
| 42 | * EvdevDevice is an input device backed by a Linux evdev node. |
| 43 | */ |
| 44 | class EvdevDevice : public InputDeviceInterface { |
| 45 | public: |
Tim Kilbourn | c929d25 | 2015-04-29 13:50:17 -0700 | [diff] [blame^] | 46 | explicit EvdevDevice(const std::shared_ptr<InputDeviceNode>& node); |
Tim Kilbourn | 73475a4 | 2015-02-13 10:35:20 -0800 | [diff] [blame] | 47 | virtual ~EvdevDevice() override = default; |
| 48 | |
| 49 | virtual void processInput(InputEvent& event, nsecs_t currentTime) override; |
| 50 | |
| 51 | private: |
| 52 | std::shared_ptr<InputDeviceNode> mDeviceNode; |
| 53 | |
| 54 | int32_t mOverrideSec = 0; |
| 55 | int32_t mOverrideUsec = 0; |
| 56 | }; |
| 57 | |
| 58 | } // namespace android |
| 59 | |
| 60 | #endif // ANDROID_INPUT_DEVICE_H_ |