2 * Copyright (c) 2015 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/devel-api/events/key-event-devel.h>
23 #include <dali/internal/event/events/key-event-impl.h>
30 const unsigned int MODIFIER_SHIFT = 0x1;
31 const unsigned int MODIFIER_CTRL = 0x2;
32 const unsigned int MODIFIER_ALT = 0x4;
33 const int KEY_INVALID_CODE = -1;
39 keyCode(KEY_INVALID_CODE),
44 new Internal::KeyEventImpl( this );
47 KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyString, int keyCode, int keyModifier,unsigned long timeStamp, const State& keyState)
48 : keyPressedName(keyName),
49 keyPressed(keyString),
51 keyModifier(keyModifier),
55 new Internal::KeyEventImpl( this );
58 KeyEvent::KeyEvent( const KeyEvent& rhs )
59 : keyPressedName( rhs.keyPressedName ),
60 keyPressed( rhs.keyPressed ),
61 keyCode( rhs.keyCode ),
62 keyModifier( rhs.keyModifier ),
66 Internal::KeyEventImpl* impl = new Internal::KeyEventImpl( this );
67 *impl = *GetImplementation( &rhs );
70 KeyEvent& KeyEvent::operator=( const KeyEvent& rhs )
74 keyPressedName = rhs.keyPressedName;
75 keyPressed = rhs.keyPressed;
76 keyCode = rhs.keyCode;
77 keyModifier = rhs.keyModifier;
81 *GetImplementation( this ) = *GetImplementation( &rhs );
89 delete GetImplementation( this );
92 bool KeyEvent::IsShiftModifier() const
94 if ((MODIFIER_SHIFT & keyModifier) == MODIFIER_SHIFT)
102 bool KeyEvent::IsCtrlModifier() const
104 if ((MODIFIER_CTRL & keyModifier) == MODIFIER_CTRL)
112 bool KeyEvent::IsAltModifier() const
114 if ((MODIFIER_ALT & keyModifier) == MODIFIER_ALT)
122 std::string DevelKeyEvent::GetDeviceName( const KeyEvent& keyEvent )
124 return GetImplementation( &keyEvent )->GetDeviceName();
127 DevelKeyEvent::DeviceClass::Type DevelKeyEvent::GetDeviceClass( const KeyEvent& keyEvent )
129 return GetImplementation( &keyEvent )->GetDeviceClass();