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 SWITCH_EVENT_H
17 #define SWITCH_EVENT_H
18 
19 #include "nocopyable.h"
20 
21 #include "input_event.h"
22 
23 namespace OHOS {
24 namespace MMI {
25 class SwitchEvent : public InputEvent {
26 public:
27     static constexpr int32_t SWITCH_ON = 0;
28     static constexpr int32_t SWITCH_OFF = 1;
29 
30     /**
31      * @brief Enumerated values of switch type.
32     *
33     * @since 12
34     */
35     enum SwitchType {
36         /** Default, used to be compatible with calls to previously none switch type parameter */
37         SWITCH_DEFAULT = 0,
38         /** Lid switch type  */
39         SWITCH_LID,
40         /** Tablet switch type  */
41         SWITCH_TABLET,
42         /** Privacy switch type  */
43         SWITCH_PRIVACY
44     };
45 
46 public:
GetSwitchType()47     int32_t GetSwitchType() const
48     {
49         return switchType_;
50     }
51 
GetSwitchValue()52     int32_t GetSwitchValue() const
53     {
54         return switchValue_;
55     }
56 
GetSwitchMask()57     int32_t GetSwitchMask() const
58     {
59         return updateSwitchMask_;
60     }
61 
SetSwitchType(int32_t type)62     void SetSwitchType(int32_t type)
63     {
64         switchType_ = type;
65     }
66 
SetSwitchValue(int32_t value)67     void SetSwitchValue(int32_t value)
68     {
69         switchValue_ = value;
70     }
71 
SetSwitchMask(int32_t switchMask)72     void SetSwitchMask(int32_t switchMask)
73     {
74         updateSwitchMask_ = switchMask;
75     }
76 
SwitchEvent(int32_t value)77     explicit SwitchEvent(int32_t value)
78         : InputEvent(value),
79         switchValue_(value),
80         updateSwitchMask_(0),
81         switchType_(SwitchType::SWITCH_DEFAULT) {}
82 private:
83         int32_t switchValue_ { 0 };
84         int32_t updateSwitchMask_ { 0 };
85         int32_t switchType_ { SwitchType::SWITCH_DEFAULT };
86 };
87 } // namespace MMI
88 } // namespace OHOS
89 #endif // SWITCH_EVENT_H