1 /* 2 * Copyright 2022 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 #pragma once 18 19 #include <optional> 20 #include <set> 21 22 #include <utils/Timers.h> 23 24 #include "EventHub.h" 25 #include "InputDevice.h" 26 #include "accumulator/CursorButtonAccumulator.h" 27 #include "accumulator/MultiTouchMotionAccumulator.h" 28 #include "accumulator/TouchButtonAccumulator.h" 29 #include "include/TouchpadHardwareState.h" 30 31 #include "TouchpadHardwareState.h" 32 #include "include/gestures.h" 33 34 namespace android { 35 36 // Converts RawEvents into the HardwareState structs used by the gestures library. 37 class HardwareStateConverter { 38 public: 39 HardwareStateConverter(const InputDeviceContext& deviceContext, 40 MultiTouchMotionAccumulator& motionAccumulator); 41 42 std::optional<SelfContainedHardwareState> processRawEvent(const RawEvent& event); 43 void reset(); 44 45 private: 46 SelfContainedHardwareState produceHardwareState(nsecs_t when); 47 48 const InputDeviceContext& mDeviceContext; 49 CursorButtonAccumulator mCursorButtonAccumulator; 50 MultiTouchMotionAccumulator& mMotionAccumulator; 51 TouchButtonAccumulator mTouchButtonAccumulator; 52 int32_t mMscTimestamp = 0; 53 }; 54 55 } // namespace android 56