1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HGM_TOUCH_MANAGER_H 17 #define HGM_TOUCH_MANAGER_H 18 19 #include <memory> 20 21 #include "hgm_one_shot_timer.h" 22 #include "hgm_state_machine.h" 23 24 namespace OHOS::Rosen { 25 enum TouchEvent : int32_t { 26 DOWN_EVENT, 27 UP_EVENT, 28 UP_TIMEOUT_EVENT, 29 RS_IDLE_TIMEOUT_EVENT, 30 }; 31 32 enum TouchState : int32_t { 33 IDLE_STATE, 34 DOWN_STATE, 35 UP_STATE, 36 }; 37 38 class HgmFrameRateManager; 39 class HgmTouchManager final : public HgmStateMachine<TouchState, TouchEvent> { 40 public: 41 HgmTouchManager(); 42 ~HgmTouchManager() override; 43 44 void HandleTouchEvent(TouchEvent event, const std::string& pkgName = ""); 45 void HandleRsFrame(); 46 void HandleThirdFrameIdle(); 47 GetPkgName()48 std::string GetPkgName() const { return pkgName_; } 49 protected: 50 std::string State2String(State state) const override; 51 bool CheckChangeStateValid(State lastState, State newState) override; 52 void ExecuteCallback(const std::function<void()>& callback) override; 53 private: 54 std::string pkgName_; 55 std::shared_ptr<AppExecFwk::EventHandler> handler_ = nullptr; 56 HgmOneShotTimer upTimeoutTimer_; 57 HgmOneShotTimer rsIdleTimeoutTimer_; 58 }; 59 } // OHOS::Rosen 60 #endif // HGM_TOUCH_MANAGER_H