1 /* 2 * Copyright (c) 2020-2021 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 /** 17 * @addtogroup UI_Events 18 * @{ 19 * 20 * @brief Defines UI events, such as press, click and drag events. 21 * 22 * @since 1.0 23 * @version 1.0 24 */ 25 26 /** 27 * @file virtual_device_event.h 28 * 29 * @brief Declares a virtual device event, which is used to receive a customized input event and call back 30 * the listening function registered. 31 * 32 * @since 1.0 33 * @version 1.0 34 */ 35 36 #ifndef GRAPHIC_LITE_VIRTUAL_DEVICE_EVENT_H 37 #define GRAPHIC_LITE_VIRTUAL_DEVICE_EVENT_H 38 39 #include "event.h" 40 41 namespace OHOS { 42 /** 43 * @brief Defines a virtual device event, which is used to receive a customized input event and call back 44 * the listening function registered. 45 * 46 * @since 1.0 47 * @version 1.0 48 */ 49 class VirtualDeviceEvent : public Event { 50 public: 51 VirtualDeviceEvent() = delete; 52 53 /** 54 * @brief A constructor used to create a <b>VirtualDeviceEvent</b> instance. 55 * 56 * @param type Indicates the virtual device type. The options are <b>AOD</b> and <b>PRIVATE</b>. 57 * @param value Indicates the virtual event value. 58 * @since 1.0 59 * @version 1.0 60 */ VirtualDeviceEvent(uint16_t type,uint16_t value)61 VirtualDeviceEvent(uint16_t type, uint16_t value) : type_(type), state_(value) {} 62 63 /** 64 * @brief A destructor used to delete the <b>VirtualDeviceEvent</b> instance. 65 * 66 * @since 1.0 67 * @version 1.0 68 */ ~VirtualDeviceEvent()69 ~VirtualDeviceEvent() {} 70 71 /** 72 * @brief Enumerates virtual device types. 73 * 74 */ 75 enum DeviceType { 76 AOD, // Standby event 77 PRIVATE, // Other customized events 78 }; 79 80 /** 81 * @brief Obtains the type of the virtual device. 82 * 83 * @return Returns the type. 84 * @since 1.0 85 * @version 1.0 86 */ GetType()87 uint16_t GetType() const 88 { 89 return type_; 90 } 91 92 /** 93 * @brief Obtains the state of the virtual event. 94 * 95 * @return Returns the state. 96 * @since 1.0 97 * @version 1.0 98 */ GetState()99 uint16_t GetState() const 100 { 101 return state_; 102 } 103 104 private: 105 uint16_t type_; 106 uint16_t state_; 107 static constexpr uint16_t INVALID_VIRTUAL_INPUT_STATE = UINT16_MAX; 108 }; 109 } // namespace OHOS 110 #endif // GRAPHIC_LITE_VIRTUAL_DEVICE_EVENT_H 111