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 mouse or touch pad buttons. */ 27 class CursorButtonAccumulator { 28 public: 29 CursorButtonAccumulator(); 30 void reset(const InputDeviceContext& deviceContext); 31 32 void process(const RawEvent& rawEvent); 33 34 uint32_t getButtonState() const; isLeftPressed()35 inline bool isLeftPressed() const { return mBtnLeft; } isRightPressed()36 inline bool isRightPressed() const { return mBtnRight; } isMiddlePressed()37 inline bool isMiddlePressed() const { return mBtnMiddle; } isBackPressed()38 inline bool isBackPressed() const { return mBtnBack; } isSidePressed()39 inline bool isSidePressed() const { return mBtnSide; } isForwardPressed()40 inline bool isForwardPressed() const { return mBtnForward; } isExtraPressed()41 inline bool isExtraPressed() const { return mBtnExtra; } isTaskPressed()42 inline bool isTaskPressed() const { return mBtnTask; } 43 44 private: 45 bool mBtnLeft; 46 bool mBtnRight; 47 bool mBtnMiddle; 48 bool mBtnBack; 49 bool mBtnSide; 50 bool mBtnForward; 51 bool mBtnExtra; 52 bool mBtnTask; 53 54 void clearButtons(); 55 }; 56 57 } // namespace android 58