2 * Copyright (c) 2018 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/public-api/events/key-event.h>
22 #include <dali/internal/event/events/key-event-impl.h>
29 const uint32_t MODIFIER_SHIFT = 0x1;
30 const uint32_t MODIFIER_CTRL = 0x2;
31 const uint32_t MODIFIER_ALT = 0x4;
32 const int32_t KEY_INVALID_CODE = -1;
38 keyCode(KEY_INVALID_CODE),
43 new Internal::KeyEventImpl( this );
46 KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyString, int32_t keyCode, int32_t keyModifier,unsigned long timeStamp, const State& keyState)
47 : keyPressedName(keyName),
48 keyPressed(keyString),
50 keyModifier(keyModifier),
54 new Internal::KeyEventImpl( this );
57 KeyEvent::KeyEvent( const KeyEvent& rhs )
58 : keyPressedName( rhs.keyPressedName ),
59 keyPressed( rhs.keyPressed ),
60 keyCode( rhs.keyCode ),
61 keyModifier( rhs.keyModifier ),
65 Internal::KeyEventImpl* impl = new Internal::KeyEventImpl( this );
66 *impl = *GetImplementation( &rhs );
69 KeyEvent& KeyEvent::operator=( const KeyEvent& rhs )
73 keyPressedName = rhs.keyPressedName;
74 keyPressed = rhs.keyPressed;
75 keyCode = rhs.keyCode;
76 keyModifier = rhs.keyModifier;
80 *GetImplementation( this ) = *GetImplementation( &rhs );
88 delete GetImplementation( this );
91 bool KeyEvent::IsShiftModifier() const
93 if ((MODIFIER_SHIFT & keyModifier) == MODIFIER_SHIFT)
101 bool KeyEvent::IsCtrlModifier() const
103 if ((MODIFIER_CTRL & keyModifier) == MODIFIER_CTRL)
111 bool KeyEvent::IsAltModifier() const
113 if ((MODIFIER_ALT & keyModifier) == MODIFIER_ALT)
121 std::string KeyEvent::GetCompose() const
123 return GetImplementation( this )->GetCompose();
126 std::string KeyEvent::GetDeviceName() const
128 return GetImplementation( this )->GetDeviceName();
131 Device::Class::Type KeyEvent::GetDeviceClass() const
133 return GetImplementation( this )->GetDeviceClass();
136 Device::Subclass::Type KeyEvent::GetDeviceSubclass() const
138 return GetImplementation( this )->GetDeviceSubclass();