1885b47fbSopenharmony_ci/* 2885b47fbSopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 3885b47fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4885b47fbSopenharmony_ci * you may not use this file except in compliance with the License. 5885b47fbSopenharmony_ci * You may obtain a copy of the License at 6885b47fbSopenharmony_ci * 7885b47fbSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8885b47fbSopenharmony_ci * 9885b47fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10885b47fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11885b47fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12885b47fbSopenharmony_ci * See the License for the specific language governing permissions and 13885b47fbSopenharmony_ci * limitations under the License. 14885b47fbSopenharmony_ci */ 15885b47fbSopenharmony_ci 16885b47fbSopenharmony_ci#ifndef ACCESSIBILITY_MOUSE_KEY_H 17885b47fbSopenharmony_ci#define ACCESSIBILITY_MOUSE_KEY_H 18885b47fbSopenharmony_ci 19885b47fbSopenharmony_ci#include "accessibility_event_transmission.h" 20885b47fbSopenharmony_ci 21885b47fbSopenharmony_cinamespace OHOS { 22885b47fbSopenharmony_cinamespace Accessibility { 23885b47fbSopenharmony_ciclass AccessibilityMouseKey : public EventTransmission { 24885b47fbSopenharmony_cipublic: 25885b47fbSopenharmony_ci /** 26885b47fbSopenharmony_ci * @brief A constructor used to create a AccessibilityMouseKey instance. 27885b47fbSopenharmony_ci */ 28885b47fbSopenharmony_ci AccessibilityMouseKey() = default; 29885b47fbSopenharmony_ci 30885b47fbSopenharmony_ci /** 31885b47fbSopenharmony_ci * @brief A destructor used to delete the AccessibilityMouseKey instance. 32885b47fbSopenharmony_ci */ 33885b47fbSopenharmony_ci virtual ~AccessibilityMouseKey() = default; 34885b47fbSopenharmony_ci 35885b47fbSopenharmony_ci /** 36885b47fbSopenharmony_ci * @brief Handle mouse events from previous event stream node. 37885b47fbSopenharmony_ci * @param event the pointer event from Multimodal 38885b47fbSopenharmony_ci * @return true: the event has been processed and does not need to be passed to the next node; 39885b47fbSopenharmony_ci * false: the event is not processed. 40885b47fbSopenharmony_ci */ 41885b47fbSopenharmony_ci bool OnPointerEvent(MMI::PointerEvent &event) override; 42885b47fbSopenharmony_ci 43885b47fbSopenharmony_ci /** 44885b47fbSopenharmony_ci * @brief Handle key events from previous event stream node. 45885b47fbSopenharmony_ci * @param event the key event from Multimodal 46885b47fbSopenharmony_ci * @return true: the event has been processed and does not need to be passed to the next node; 47885b47fbSopenharmony_ci * false: the event is not processed. 48885b47fbSopenharmony_ci */ 49885b47fbSopenharmony_ci bool OnKeyEvent(MMI::KeyEvent &event) override; 50885b47fbSopenharmony_ciprivate: 51885b47fbSopenharmony_ci enum SELECTED_KEY_TYPE : uint32_t { 52885b47fbSopenharmony_ci LEFT_KEY = 0, 53885b47fbSopenharmony_ci RIGHT_KEY, 54885b47fbSopenharmony_ci BOOTH_KEY, 55885b47fbSopenharmony_ci }; 56885b47fbSopenharmony_ci 57885b47fbSopenharmony_ci enum CLICK_TYPE : uint32_t { 58885b47fbSopenharmony_ci SINGLE_CLICK = 1, 59885b47fbSopenharmony_ci DOUBLE_CLICK = 2, 60885b47fbSopenharmony_ci }; 61885b47fbSopenharmony_ci 62885b47fbSopenharmony_ci void UpdateLastMouseEvent(const MMI::PointerEvent &event); 63885b47fbSopenharmony_ci bool IsMouseKey(const std::vector<int32_t> &pressedKeys, int32_t &actionKey, 64885b47fbSopenharmony_ci int32_t &metaKey1, int32_t &metaKey2) const; 65885b47fbSopenharmony_ci bool ExecuteMouseKey(int32_t actionKey, int32_t metaKey1, int32_t metaKey2); 66885b47fbSopenharmony_ci void MoveMousePointer(int32_t offsetX, int32_t offsetY); 67885b47fbSopenharmony_ci void SendMouseClickEvent(CLICK_TYPE clickType); 68885b47fbSopenharmony_ci int64_t GetSystemTime() const; 69885b47fbSopenharmony_ci void PerformMouseAction(int32_t buttonId, int32_t actionType); 70885b47fbSopenharmony_ci int32_t ParseMetaKey(int32_t metaKey1, int32_t metaKey2) const; 71885b47fbSopenharmony_ci 72885b47fbSopenharmony_ci std::shared_ptr<MMI::PointerEvent> lastMouseMoveEvent_ = nullptr; 73885b47fbSopenharmony_ci SELECTED_KEY_TYPE selectedKeyType_ = LEFT_KEY; 74885b47fbSopenharmony_ci}; 75885b47fbSopenharmony_ci} // namespace Accessibility 76885b47fbSopenharmony_ci} // namespace OHOS 77885b47fbSopenharmony_ci#endif // ACCESSIBILITY_MOUSE_KEY_H