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 CROWN_TRANSFORM_PROCESSOR_H 17 #define CROWN_TRANSFORM_PROCESSOR_H 18 19 #include "libinput.h" 20 #include "singleton.h" 21 22 #include "pointer_event.h" 23 24 namespace OHOS { 25 namespace MMI { 26 class CrownTransformProcessor final : public std::enable_shared_from_this<CrownTransformProcessor> { 27 DECLARE_DELAYED_SINGLETON(CrownTransformProcessor); 28 29 public: 30 DISALLOW_COPY_AND_MOVE(CrownTransformProcessor); 31 std::shared_ptr<PointerEvent> GetPointerEvent() const; 32 bool IsCrownEvent(struct libinput_event *event); 33 int32_t NormalizeRotateEvent(struct libinput_event *event); 34 void Dump(int32_t fd, const std::vector<std::string> &args); 35 36 private: 37 int32_t HandleCrownRotateBegin(struct libinput_event_pointer *rawPointerEvent); 38 int32_t HandleCrownRotateUpdate(struct libinput_event_pointer *rawPointerEvent); 39 int32_t HandleCrownRotateEnd(); 40 int32_t HandleCrownRotateBeginAndUpdate(struct libinput_event_pointer *rawPointerEvent, int32_t action); 41 void HandleCrownRotatePostInner(double angularVelocity, double degree, int32_t action); 42 void DumpInner(); 43 44 std::shared_ptr<PointerEvent> pointerEvent_ { nullptr }; 45 int32_t deviceId_ { -1 }; 46 int32_t timerId_ { -1 }; 47 uint64_t lastTime_ { 0 }; 48 }; 49 #define CROWN_EVENT_HDR ::OHOS::DelayedSingleton<CrownTransformProcessor>::GetInstance() 50 } // namespace MMI 51 } // namespace OHOS 52 #endif // CROWN_TRANSFORM_PROCESSOR_H