1 /* 2 * Copyright (C) 2019 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 <stdint.h> 20 21 namespace android { 22 23 class InputDeviceContext; 24 struct RawEvent; 25 26 /* Keeps track of the state of single-touch protocol. */ 27 class SingleTouchMotionAccumulator { 28 public: 29 SingleTouchMotionAccumulator(); 30 31 void process(const RawEvent& rawEvent); 32 void reset(InputDeviceContext& deviceContext); 33 getAbsoluteX()34 inline int32_t getAbsoluteX() const { return mAbsX; } getAbsoluteY()35 inline int32_t getAbsoluteY() const { return mAbsY; } getAbsolutePressure()36 inline int32_t getAbsolutePressure() const { return mAbsPressure; } getAbsoluteToolWidth()37 inline int32_t getAbsoluteToolWidth() const { return mAbsToolWidth; } getAbsoluteDistance()38 inline int32_t getAbsoluteDistance() const { return mAbsDistance; } getAbsoluteTiltX()39 inline int32_t getAbsoluteTiltX() const { return mAbsTiltX; } getAbsoluteTiltY()40 inline int32_t getAbsoluteTiltY() const { return mAbsTiltY; } 41 42 private: 43 int32_t mAbsX; 44 int32_t mAbsY; 45 int32_t mAbsPressure; 46 int32_t mAbsToolWidth; 47 int32_t mAbsDistance; 48 int32_t mAbsTiltX; 49 int32_t mAbsTiltY; 50 51 void clearAbsoluteAxes(); 52 }; 53 54 } // namespace android 55