• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 INPUT_DEV_H
17 #define INPUT_DEV_H
18 
19 #include "dock/pointer_input_device.h"
20 #include "input_manager.h"
21 #include "cmsis_os2.h"
22 #include "graphic_locker.h"
23 
24 namespace OHOS {
25 class InputDev : public PointerInputDevice {
26 public:
InputDev()27     InputDev() {}
~InputDev()28     virtual ~InputDev() {}
29     static InputDev* GetInstance();
30     bool Read(DeviceData& data) override;
31 
GetEventData(DeviceData * data)32     void GetEventData(DeviceData* data)
33     {
34         GraphicLocker lock(eventLock_);
35         if (data != nullptr) {
36             *data = deviceData_;
37         }
38     }
39 
SetEventData(DeviceData data)40     void SetEventData(DeviceData data)
41     {
42         GraphicLocker lock(eventLock_);
43         deviceData_.point.x = data.point.x;
44         deviceData_.point.y = data.point.y;
45         deviceData_.state = data.state;
46     }
47 
48 private:
49     static void ReportEventPkgCallback(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex);
50     bool init = false;
51     IInputInterface *inputInterface = nullptr;
52     InputEventCb inputEventCb = {0};
53     DeviceData deviceData_;
54     pthread_mutex_t eventLock_;
55 };
56 } // namespace OHOS
57 #endif // INPUT_DEV_H