Revert "[Tizen] Not execute the remove callback"
[platform/core/uifw/dali-core.git] / dali / internal / event / events / key-event-impl.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/event/events/key-event-impl.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23
24 namespace Dali
25 {
26 namespace
27 {
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;
32 } // namespace
33
34 namespace Internal
35 {
36 KeyEvent::KeyEvent()
37 : mKeyName(""),
38   mLogicalKey(""),
39   mKeyString(""),
40   mKeyCode(KEY_INVALID_CODE),
41   mKeyModifier(0),
42   mTime(0),
43   mState(Dali::KeyEvent::DOWN),
44   mCompose(""),
45   mDeviceName(""),
46   mDeviceClass(Device::Class::NONE),
47   mDeviceSubclass(Device::Subclass::NONE)
48 {
49 }
50
51 KeyEvent::KeyEvent(const std::string&           keyName,
52                    const std::string&           logicalKey,
53                    const std::string&           keyString,
54                    int                          keyCode,
55                    int                          keyModifier,
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)
62 : mKeyName(keyName),
63   mLogicalKey(logicalKey),
64   mKeyString(keyString),
65   mKeyCode(keyCode),
66   mKeyModifier(keyModifier),
67   mTime(timeStamp),
68   mState(keyState),
69   mCompose(compose),
70   mDeviceName(deviceName),
71   mDeviceClass(deviceClass),
72   mDeviceSubclass(deviceSubclass)
73 {
74 }
75
76 KeyEventPtr KeyEvent::New(const std::string&           keyName,
77                           const std::string&           logicalKey,
78                           const std::string&           keyString,
79                           int                          keyCode,
80                           int                          keyModifier,
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)
87 {
88   KeyEventPtr keyEvent = new KeyEvent(keyName, logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass);
89   return keyEvent;
90 }
91
92 bool KeyEvent::IsShiftModifier() const
93 {
94   return ((MODIFIER_SHIFT & mKeyModifier) == MODIFIER_SHIFT);
95 }
96
97 bool KeyEvent::IsCtrlModifier() const
98 {
99   return ((MODIFIER_CTRL & mKeyModifier) == MODIFIER_CTRL);
100 }
101
102 bool KeyEvent::IsAltModifier() const
103 {
104   return ((MODIFIER_ALT & mKeyModifier) == MODIFIER_ALT);
105 }
106
107 const std::string& KeyEvent::GetCompose() const
108 {
109   return mCompose;
110 }
111
112 const std::string& KeyEvent::GetDeviceName() const
113 {
114   return mDeviceName;
115 }
116
117 Device::Class::Type KeyEvent::GetDeviceClass() const
118 {
119   return mDeviceClass;
120 }
121
122 Device::Subclass::Type KeyEvent::GetDeviceSubclass() const
123 {
124   return mDeviceSubclass;
125 }
126
127 const std::string& KeyEvent::GetKeyName() const
128 {
129   return mKeyName;
130 }
131
132 const std::string& KeyEvent::GetKeyString() const
133 {
134   return mKeyString;
135 }
136
137 const std::string& KeyEvent::GetLogicalKey() const
138 {
139   return mLogicalKey;
140 }
141
142 int32_t KeyEvent::GetKeyCode() const
143 {
144   return mKeyCode;
145 }
146
147 int32_t KeyEvent::GetKeyModifier() const
148 {
149   return mKeyModifier;
150 }
151
152 unsigned long KeyEvent::GetTime() const
153 {
154   return mTime;
155 }
156
157 Dali::KeyEvent::State KeyEvent::GetState() const
158 {
159   return mState;
160 }
161
162 void KeyEvent::SetKeyName(const std::string& keyName)
163 {
164   mKeyName = keyName;
165 }
166
167 void KeyEvent::SetKeyString(const std::string& keyString)
168 {
169   mKeyString = keyString;
170 }
171
172 void KeyEvent::SetKeyCode(int32_t keyCode)
173 {
174   mKeyCode = keyCode;
175 }
176
177 void KeyEvent::SetKeyModifier(int32_t keyModifier)
178 {
179   mKeyModifier = keyModifier;
180 }
181
182 void KeyEvent::SetTime(unsigned long time)
183 {
184   mTime = time;
185 }
186
187 void KeyEvent::SetState(const Dali::KeyEvent::State& state)
188 {
189   mState = state;
190 }
191
192 } // namespace Internal
193
194 } // namespace Dali