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