1 /* 2 * Copyright (c) 2023 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 FINGERSENSE_WRAPPER_H 17 #define FINGERSENSE_WRAPPER_H 18 #include "singleton.h" 19 20 namespace OHOS { 21 namespace MMI { 22 struct TouchInfo { 23 float x { 0 }; 24 float y { 0 }; 25 int32_t touch_type { 0 }; 26 }; 27 class FingersenseWrapper final { 28 DECLARE_DELAYED_SINGLETON(FingersenseWrapper); 29 public: 30 DISALLOW_COPY_AND_MOVE(FingersenseWrapper); 31 void InitFingerSenseWrapper(); 32 void SaveTouchInfo(float pointX, float pointY, int32_t toolType); 33 int32_t CheckKnuckleEvent(float pointX, float pointY, bool &isKnuckleType); 34 typedef void (*SET_CURRENT_TOOL_TYPE)(struct TouchType, int32_t&); 35 typedef void (*NOTIFY_TOUCH_UP)(struct TouchType*); 36 typedef void (*ENABLE_FINGERSENSE)(); 37 typedef void (*DISABLE_FINGERSENSE)(); 38 typedef void (*SEND_FINGERSENSE_DISPLAYMODE)(int32_t); 39 40 SET_CURRENT_TOOL_TYPE setCurrentToolType_ { nullptr }; 41 NOTIFY_TOUCH_UP notifyTouchUp_ { nullptr }; 42 ENABLE_FINGERSENSE enableFingersense_ { nullptr }; 43 DISABLE_FINGERSENSE disableFingerSense_ { nullptr }; 44 SEND_FINGERSENSE_DISPLAYMODE sendFingerSenseDisplayMode_ { nullptr }; 45 private: 46 void* fingerSenseWrapperHandle_ { nullptr }; 47 std::vector<TouchInfo> touchInfos_; 48 bool IsEqual(float a, float b, float epsilon = 10.0); 49 std::mutex lock_; 50 }; 51 52 #define FINGERSENSE_WRAPPER ::OHOS::DelayedSingleton<FingersenseWrapper>::GetInstance() 53 } // namespace MMI 54 } // namespace OHOS 55 #endif // FINGERSENSE_WRAPPER_H