• 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_GAME_PAD_DEVICE_H
16 #define PROCESSING_GAME_PAD_DEVICE_H
17 
18 #include "msg_head.h"
19 #include "device_base.h"
20 
21 namespace OHOS {
22 namespace MMI {
23 class ProcessingGamePadDevice : public DeviceBase {
24     struct GamePadEvent {
25         std::string eventType;
26         std::string direction;
27         int32_t keyValue;
28         int32_t blockTime;
29         std::vector<uint32_t> gameEvents;
30     };
31 public:
32     ProcessingGamePadDevice() = default;
33     ~ProcessingGamePadDevice() = default;
34     int32_t TransformJsonDataToInputData(const Json& originalEvent, InputEventArray& inputEventArray);
35 private:
36     int32_t AnalysisGamePadEvent(const Json& inputData, std::vector<GamePadEvent>& padEventArray);
37     void TransformPadEventToInputEvent(const std::vector<GamePadEvent>& padEventArray,
38                                        InputEventArray& inputEventArray);
39     void TransformKeyPressEvent(const GamePadEvent& padEvent, InputEventArray& inputEventArray);
40     void TransformKeyReleaseEvent(const GamePadEvent& padEvent, InputEventArray& inputEventArray);
41     void TransformKeyClickEvent(const GamePadEvent& padEvent, InputEventArray& inputEventArray);
42     void TransformRocker1Event(const GamePadEvent& padEvent, InputEventArray& inputEventArray);
43     void TransformRocker2Event(const GamePadEvent& padEvent, InputEventArray& inputEventArray);
44     void TransformDerectionKeyEvent(const GamePadEvent& padEvent, InputEventArray& inputEventArray);
45 };
46 } // namespace MMI
47 } // namespace OHOS
48 #endif // PROCESSING_GAME_PAD_DEVICE_H