2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/event/events/key-event-impl.h>
22 #include <dali/public-api/common/dali-vector.h>
28 const uint32_t MODIFIER_SHIFT = 0x1;
29 const uint32_t MODIFIER_CTRL = 0x2;
30 const uint32_t MODIFIER_ALT = 0x4;
31 const int32_t KEY_INVALID_CODE = -1;
40 mKeyCode(KEY_INVALID_CODE),
43 mState(Dali::KeyEvent::DOWN),
46 mDeviceClass(Device::Class::NONE),
47 mDeviceSubclass(Device::Subclass::NONE)
51 KeyEvent::KeyEvent(const std::string& keyName,
52 const std::string& logicalKey,
53 const std::string& keyString,
56 unsigned long timeStamp,
57 const Dali::KeyEvent::State& keyState,
58 const std::string& compose,
59 const std::string& deviceName,
60 const Device::Class::Type deviceClass,
61 const Device::Subclass::Type deviceSubclass)
63 mLogicalKey(logicalKey),
64 mKeyString(keyString),
66 mKeyModifier(keyModifier),
70 mDeviceName(deviceName),
71 mDeviceClass(deviceClass),
72 mDeviceSubclass(deviceSubclass)
76 KeyEventPtr KeyEvent::New(const std::string& keyName,
77 const std::string& logicalKey,
78 const std::string& keyString,
81 unsigned long timeStamp,
82 const Dali::KeyEvent::State& keyState,
83 const std::string& compose,
84 const std::string& deviceName,
85 const Device::Class::Type deviceClass,
86 const Device::Subclass::Type deviceSubclass)
88 KeyEventPtr keyEvent = new KeyEvent(keyName, logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass);
92 bool KeyEvent::IsShiftModifier() const
94 return ((MODIFIER_SHIFT & mKeyModifier) == MODIFIER_SHIFT);
97 bool KeyEvent::IsCtrlModifier() const
99 return ((MODIFIER_CTRL & mKeyModifier) == MODIFIER_CTRL);
102 bool KeyEvent::IsAltModifier() const
104 return ((MODIFIER_ALT & mKeyModifier) == MODIFIER_ALT);
107 const std::string& KeyEvent::GetCompose() const
112 const std::string& KeyEvent::GetDeviceName() const
117 Device::Class::Type KeyEvent::GetDeviceClass() const
122 Device::Subclass::Type KeyEvent::GetDeviceSubclass() const
124 return mDeviceSubclass;
127 const std::string& KeyEvent::GetKeyName() const
132 const std::string& KeyEvent::GetKeyString() const
137 const std::string& KeyEvent::GetLogicalKey() const
142 int32_t KeyEvent::GetKeyCode() const
147 int32_t KeyEvent::GetKeyModifier() const
152 unsigned long KeyEvent::GetTime() const
157 Dali::KeyEvent::State KeyEvent::GetState() const
162 void KeyEvent::SetKeyName(const std::string& keyName)
167 void KeyEvent::SetKeyString(const std::string& keyString)
169 mKeyString = keyString;
172 void KeyEvent::SetKeyCode(int32_t keyCode)
177 void KeyEvent::SetKeyModifier(int32_t keyModifier)
179 mKeyModifier = keyModifier;
182 void KeyEvent::SetTime(unsigned long time)
187 void KeyEvent::SetState(const Dali::KeyEvent::State& state)
192 } // namespace Internal