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 INPUT_EVENT_DATA_TRANSFORMATION_H 16 #define INPUT_EVENT_DATA_TRANSFORMATION_H 17 #include "key_event.h" 18 #include "net_packet.h" 19 #include "pointer_event.h" 20 21 namespace OHOS { 22 namespace MMI { 23 class InputEventDataTransformation { 24 InputEventDataTransformation() = delete; 25 DISALLOW_COPY_AND_MOVE(InputEventDataTransformation); 26 27 public: 28 static int32_t KeyEventToNetPacket(const std::shared_ptr<KeyEvent> key, NetPacket &pkt); 29 static int32_t NetPacketToKeyEvent(NetPacket &pkt, std::shared_ptr<KeyEvent> key); 30 static int32_t SerializeInputEvent(std::shared_ptr<InputEvent> event, NetPacket &pkt); 31 static int32_t DeserializeInputEvent(NetPacket &pkt, std::shared_ptr<InputEvent> event); 32 static int32_t Marshalling(std::shared_ptr<PointerEvent> event, NetPacket &pkt); 33 static int32_t Unmarshalling(NetPacket &pkt, std::shared_ptr<PointerEvent> event); 34 private: 35 static int32_t SerializePointerItem(NetPacket &pkt, PointerEvent::PointerItem &item); 36 static int32_t DeserializePointerItem(NetPacket &pkt, PointerEvent::PointerItem &item); 37 }; 38 } // namespace MMI 39 } // namespace OHOS 40 #endif // INPUT_EVENT_DATA_TRANSFORMATION_H 41