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 JS_JOYSTICK_EVENT 17 #define JS_JOYSTICK_EVENT 18 19 #include "napi/native_api.h" 20 #include "napi/native_node_api.h" 21 #include "nocopyable.h" 22 23 namespace OHOS { 24 namespace MMI { 25 class JsJoystickEvent final { 26 public: 27 enum class Action : int32_t { 28 CANCEL = 0, 29 BUTTON_DOWN = 1, 30 BUTTON_UP = 2, 31 ABS_BEGIN = 3, 32 ABS_UPDATE = 4, 33 ABS_END = 5, 34 }; 35 36 enum class Button : int32_t { 37 BUTTON_TL2 = 0, 38 BUTTON_TR2 = 1, 39 BUTTON_TL = 2, 40 BUTTON_TR = 3, 41 BUTTON_WEST = 4, 42 BUTTON_SOUTH = 5, 43 BUTTON_NORTH = 6, 44 BUTTON_EAST = 7, 45 BUTTON_START = 8, 46 BUTTON_SELECT = 9, 47 BUTTON_HOMEPAGE = 10, 48 BUTTON_THUMBL = 11, 49 BUTTON_THUMBR = 12, 50 BUTTON_TRIGGER = 13, 51 BUTTON_THUMB = 14, 52 BUTTON_THUMB2 = 15, 53 BUTTON_TOP = 16, 54 BUTTON_TOP2 = 17, 55 BUTTON_PINKIE = 18, 56 BUTTON_BASE = 19, 57 BUTTON_BASE2 = 20, 58 BUTTON_BASE3 = 21, 59 BUTTON_BASE4 = 22, 60 BUTTON_BASE5 = 23, 61 BUTTON_BASE6 = 24, 62 BUTTON_DEAD = 25, 63 BUTTON_C = 26, 64 BUTTON_Z = 27, 65 BUTTON_MODE = 28 66 }; 67 68 enum class Axis : int32_t { 69 ABS_X = 0, 70 ABS_Y = 1, 71 ABS_Z = 2, 72 ABS_RZ = 3, 73 ABS_GAS = 4, 74 ABS_BRAKE = 5, 75 ABS_HAT0X = 6, 76 ABS_HAT0Y = 7, 77 ABS_THROTTLE = 8, 78 }; 79 80 public: 81 JsJoystickEvent() = default; 82 ~JsJoystickEvent() = default; 83 DISALLOW_COPY_AND_MOVE(JsJoystickEvent); 84 static napi_value Export(napi_env env, napi_value exports); 85 private: 86 static napi_value GetNapiInt32(napi_env env, int32_t code); 87 static napi_value EnumClassConstructor(napi_env env, napi_callback_info info); 88 static napi_value HandleButtonPropertyArr(napi_env env, napi_value exports); 89 }; 90 } // namespace MMI 91 } // namespace OHOS 92 93 #endif // JS_JOYSTICK_EVENT