• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 PROCESSING_JOYSTICK_DEVICE_H
16 #define PROCESSING_JOYSTICK_DEVICE_H
17 
18 #include "msg_head.h"
19 #include "device_base.h"
20 
21 namespace OHOS {
22 namespace MMI {
23 class ProcessingJoystickDevice : public DeviceBase {
24     struct JoystickEvent {
25         std::string eventType;
26         std::string direction;
27         int32_t keyValue;
28         int32_t blockTime;
29         std::vector<int32_t> gameEvents;
30     };
31 public:
32     ProcessingJoystickDevice() = default;
33     ~ProcessingJoystickDevice() = default;
34     int32_t TransformJsonDataToInputData(const Json& originalEvent, InputEventArray& inputEventArray);
35 private:
36     int32_t AnalysisJoystickEvent(const Json& inputData, std::vector<JoystickEvent>& JoystickEventArray);
37     void TransformPadEventToInputEvent(const std::vector<JoystickEvent>& JoystickEventArray,
38                                        InputEventArray& inputEventArray);
39     void TransformKeyPressEvent(const JoystickEvent& joystickEvent, InputEventArray& inputEventArray);
40     void TransformKeyReleaseEvent(const JoystickEvent& joystickEvent, InputEventArray& inputEventArray);
41     void TransformKeyClickEvent(const JoystickEvent& joystickEvent, InputEventArray& inputEventArray);
42     void TransformRocker1Event(const JoystickEvent& joystickEvent, InputEventArray& inputEventArray);
43     void TransformDerectionKeyEvent(const JoystickEvent& joystickEvent, InputEventArray& inputEventArray);
44     void TransformThrottle1Event(const JoystickEvent& joystickEvent, InputEventArray& inputEventArray);
45 private:
46     static constexpr int32_t default_absx_value = 8188;
47     static constexpr int32_t default_absy_value = 8192;
48     static constexpr int32_t default_absz_value = 125;
49 };
50 } // namespace MMI
51 } // namespace OHOS
52 #endif // PROCESSING_JOYSTICK_DEVICE_H