2 * Copyright (c) 2023 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 uint32_t MODIFIER_NO_INTERCEPT = (1U << 31);
32 const int32_t KEY_INVALID_CODE = -1;
41 mKeyCode(KEY_INVALID_CODE),
44 mState(Dali::KeyEvent::DOWN),
47 mDeviceClass(Device::Class::NONE),
48 mDeviceSubclass(Device::Subclass::NONE),
54 KeyEvent::KeyEvent(const std::string& keyName,
55 const std::string& logicalKey,
56 const std::string& keyString,
59 unsigned long timeStamp,
60 const Dali::KeyEvent::State& keyState,
61 const std::string& compose,
62 const std::string& deviceName,
63 const Device::Class::Type deviceClass,
64 const Device::Subclass::Type deviceSubclass)
66 mLogicalKey(logicalKey),
67 mKeyString(keyString),
69 mKeyModifier(keyModifier),
73 mDeviceName(deviceName),
74 mDeviceClass(deviceClass),
75 mDeviceSubclass(deviceSubclass),
81 KeyEventPtr KeyEvent::New()
83 KeyEventPtr keyEvent = new KeyEvent();
87 KeyEventPtr KeyEvent::New(const std::string& keyName,
88 const std::string& logicalKey,
89 const std::string& keyString,
92 unsigned long timeStamp,
93 const Dali::KeyEvent::State& keyState,
94 const std::string& compose,
95 const std::string& deviceName,
96 const Device::Class::Type deviceClass,
97 const Device::Subclass::Type deviceSubclass)
99 KeyEventPtr keyEvent = new KeyEvent(keyName, logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass);
103 bool KeyEvent::IsShiftModifier() const
105 return ((MODIFIER_SHIFT & mKeyModifier) == MODIFIER_SHIFT);
108 bool KeyEvent::IsCtrlModifier() const
110 return ((MODIFIER_CTRL & mKeyModifier) == MODIFIER_CTRL);
113 bool KeyEvent::IsAltModifier() const
115 return ((MODIFIER_ALT & mKeyModifier) == MODIFIER_ALT);
118 bool KeyEvent::IsNoInterceptModifier() const
120 return ((MODIFIER_NO_INTERCEPT & mKeyModifier) == MODIFIER_NO_INTERCEPT);
123 const std::string& KeyEvent::GetCompose() const
128 const std::string& KeyEvent::GetDeviceName() const
133 Device::Class::Type KeyEvent::GetDeviceClass() const
138 Device::Subclass::Type KeyEvent::GetDeviceSubclass() const
140 return mDeviceSubclass;
143 const std::string& KeyEvent::GetKeyName() const
148 const std::string& KeyEvent::GetKeyString() const
153 const std::string& KeyEvent::GetLogicalKey() const
158 int32_t KeyEvent::GetKeyCode() const
163 int32_t KeyEvent::GetKeyModifier() const
168 unsigned long KeyEvent::GetTime() const
173 Dali::KeyEvent::State KeyEvent::GetState() const
178 bool KeyEvent::IsRepeat() const
183 uint32_t KeyEvent::GetWindowId() const
188 void KeyEvent::SetKeyName(const std::string& keyName)
193 void KeyEvent::SetKeyString(const std::string& keyString)
195 mKeyString = keyString;
198 void KeyEvent::SetKeyCode(int32_t keyCode)
203 void KeyEvent::SetKeyModifier(int32_t keyModifier)
205 mKeyModifier = keyModifier;
208 void KeyEvent::SetNoInterceptModifier(bool noIntercept)
212 mKeyModifier |= MODIFIER_NO_INTERCEPT;
216 mKeyModifier &= ~MODIFIER_NO_INTERCEPT;
220 void KeyEvent::SetTime(unsigned long time)
225 void KeyEvent::SetState(const Dali::KeyEvent::State& state)
230 void KeyEvent::SetRepeat(const bool repeat)
235 void KeyEvent::SetWindowId(uint32_t windowId)
237 mWindowId = windowId;
240 } // namespace Internal