• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 TOUCH_SCREEN_H
17 #define TOUCH_SCREEN_H
18 
19 #include <dlfcn.h>
20 
21 #include "nocopyable.h"
22 #include "singleton.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 class TouchScreen final {
27 public:
28     using TsSetFeatureConfig = int32_t (*)(int32_t, const char *);
29     using TsSetAftConfig = int32_t (*)(const char *);
30 
31     DISALLOW_COPY_AND_MOVE(TouchScreen);
32 
33     void InitTouchScreen();
34 
IsSetFeatureConfigHandleValid()35     bool IsSetFeatureConfigHandleValid() const
36     {
37         return setFeatureConfigHandle_ != nullptr;
38     }
39 
SetFeatureConfig(int32_t feature,const char * config)40     int32_t SetFeatureConfig(int32_t feature, const char *config)
41     {
42         return setFeatureConfigHandle_(feature, config);
43     }
44 
IsSetAftConfigHandleValid()45     bool IsSetAftConfigHandleValid() const
46     {
47         return setAftConfigHandle_ != nullptr;
48     }
49 
SetAftConfig(const char * config)50     int32_t SetAftConfig(const char *config)
51     {
52         return setAftConfigHandle_(config);
53     }
54 
55 private:
56     DECLARE_DELAYED_SINGLETON(TouchScreen);
57 
58     void* touchScreenHandle_ = nullptr;
59     TsSetFeatureConfig setFeatureConfigHandle_ = nullptr;
60     TsSetAftConfig setAftConfigHandle_ = nullptr;
61 };
62 
63 #define TOUCH_SCREEN ::OHOS::DelayedSingleton<TouchScreen>::GetInstance()
64 } // namespace Rosen
65 } // namespace OHOS
66 #endif // TOUCH_SCREEN_H