• 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 #ifndef UPDATER_UI_KEYS_INPUT_DEVICE_H
16 #define UPDATER_UI_KEYS_INPUT_DEVICE_H
17 
18 #include <atomic>
19 #include <linux/input.h>
20 #include "input_manager.h"
21 #include "macros.h"
22 #include "dock/key_input_device.h"
23 #include "events/key_event.h"
24 
25 namespace Updater {
26 class KeysInputDevice : public OHOS::KeyInputDevice {
27     DISALLOW_COPY_MOVE(KeysInputDevice);
28 public:
29     KeysInputDevice() = default;
30     virtual ~KeysInputDevice() = default;
31     static KeysInputDevice &GetInstance();
32     bool Read(OHOS::DeviceData &data) override;
33     int HandleKeyEvent(const input_event &ev, uint32_t type);
34 
35 private:
36     void PowerVolumeDownPress(const input_event &ev);
37     void OnLongKeyPressUp();
38     void OnLongKeyPressDown();
39     /* for KeysInputDevice */
40     uint16_t lastKeyId_ { 0 };
41     uint16_t keyState_ = OHOS::INVALID_KEY_STATE;
42     std::atomic<bool> timerStop_ {false};
43 };
44 } // namespace Updater
45 #endif // UPDATER_UI_KEYS_INPUT_DEVICE_H
46