1 /* 2 * Copyright (C) 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 16 #include "mock_key_event.h" 17 18 namespace OHOS { 19 namespace MMI { 20 const int32_t KeyEvent::KEYCODE_VOLUME_UP = 16; 21 const int32_t KeyEvent::KEYCODE_VOLUME_DOWN = 17; 22 KeyItem()23KeyEvent::KeyItem::KeyItem() {} 24 ~KeyItem()25KeyEvent::KeyItem::~KeyItem() {} 26 GetKeyCode() const27int32_t KeyEvent::KeyItem::GetKeyCode() const 28 { 29 return keyCode_; 30 } 31 SetKeyCode(int32_t keyCode)32void KeyEvent::KeyItem::SetKeyCode(int32_t keyCode) 33 { 34 keyCode_ = keyCode; 35 } 36 GetDownTime() const37int64_t KeyEvent::KeyItem::GetDownTime() const 38 { 39 return downTime_; 40 } 41 SetDownTime(int64_t downTime)42void KeyEvent::KeyItem::SetDownTime(int64_t downTime) 43 { 44 downTime_ = downTime; 45 } 46 GetDeviceId() const47int32_t KeyEvent::KeyItem::GetDeviceId() const 48 { 49 return deviceId_; 50 } 51 SetDeviceId(int32_t deviceId)52void KeyEvent::KeyItem::SetDeviceId(int32_t deviceId) 53 { 54 deviceId_ = deviceId; 55 } 56 IsPressed() const57bool KeyEvent::KeyItem::IsPressed() const 58 { 59 return pressed_; 60 } 61 SetPressed(bool pressed)62void KeyEvent::KeyItem::SetPressed(bool pressed) 63 { 64 pressed_ = pressed; 65 } 66 KeyEvent(int32_t eventType)67KeyEvent::KeyEvent(int32_t eventType) : InputEvent(eventType) {} 68 KeyEvent(const KeyEvent & other)69KeyEvent::KeyEvent(const KeyEvent& other) 70 : InputEvent(other), 71 keyCode_(other.keyCode_), 72 keys_(other.keys_), 73 keyAction_(other.keyAction_) {} 74 ~KeyEvent()75KeyEvent::~KeyEvent() {} 76 Create()77std::shared_ptr<KeyEvent> KeyEvent::Create() 78 { 79 return std::shared_ptr<KeyEvent>(new KeyEvent(InputEvent::EVENT_TYPE_KEY)); 80 } 81 AddKeyItem(const KeyItem & keyItem)82void KeyEvent::AddKeyItem(const KeyItem& keyItem) 83 { 84 keys_.push_back(keyItem); 85 } 86 GetKeyCode() const87int32_t KeyEvent::GetKeyCode() const 88 { 89 return keyCode_; 90 } 91 SetKeyCode(int32_t keyCode)92void KeyEvent::SetKeyCode(int32_t keyCode) 93 { 94 keyCode_ = keyCode; 95 } 96 WriteToParcel(Parcel & out) const97bool KeyEvent::WriteToParcel(Parcel &out) const 98 { 99 return true; 100 } 101 ReadFromParcel(Parcel & in)102bool KeyEvent::ReadFromParcel(Parcel &in) 103 { 104 return true; 105 } 106 } 107 }