2 * Copyright (c) 2020 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>
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;
42 mKeyCode( KEY_INVALID_CODE ),
45 mState( Dali::KeyEvent::DOWN ),
48 mDeviceClass( Device::Class::NONE ),
49 mDeviceSubclass( Device::Subclass::NONE )
53 KeyEvent::KeyEvent( const std::string& keyName,
54 const std::string& logicalKey,
55 const std::string& keyString,
58 unsigned long timeStamp,
59 const Dali::KeyEvent::State& keyState,
60 const std::string& compose,
61 const std::string& deviceName,
62 const Device::Class::Type deviceClass,
63 const Device::Subclass::Type deviceSubclass )
64 : mKeyName( keyName ),
65 mLogicalKey( logicalKey ),
66 mKeyString( keyString ),
68 mKeyModifier( keyModifier ),
72 mDeviceName( deviceName ),
73 mDeviceClass( deviceClass ),
74 mDeviceSubclass( deviceSubclass )
82 KeyEventPtr KeyEvent::New( const std::string& keyName,
83 const std::string& logicalKey,
84 const std::string& keyString,
87 unsigned long timeStamp,
88 const Dali::KeyEvent::State& keyState,
89 const std::string& compose,
90 const std::string& deviceName,
91 const Device::Class::Type deviceClass,
92 const Device::Subclass::Type deviceSubclass )
94 KeyEventPtr keyEvent = new KeyEvent( keyName, logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass );
98 bool KeyEvent::IsShiftModifier() const
100 return ( ( MODIFIER_SHIFT & mKeyModifier ) == MODIFIER_SHIFT );
103 bool KeyEvent::IsCtrlModifier() const
105 return ( ( MODIFIER_CTRL & mKeyModifier ) == MODIFIER_CTRL );
108 bool KeyEvent::IsAltModifier() const
110 return ( ( MODIFIER_ALT & mKeyModifier ) == MODIFIER_ALT );
113 const std::string& KeyEvent::GetCompose() const
118 const std::string& KeyEvent::GetDeviceName() const
124 Device::Class::Type KeyEvent::GetDeviceClass() const
130 Device::Subclass::Type KeyEvent::GetDeviceSubclass() const
132 return mDeviceSubclass;
136 const std::string& KeyEvent::GetKeyName() const
142 const std::string& KeyEvent::GetKeyString() const
148 const std::string& KeyEvent::GetLogicalKey() const
154 int32_t KeyEvent::GetKeyCode() const
160 int32_t KeyEvent::GetKeyModifier() const
166 unsigned long KeyEvent::GetTime() const
172 Dali::KeyEvent::State KeyEvent::GetState() const
178 void KeyEvent::SetKeyName( const std::string& keyName )
184 void KeyEvent::SetKeyString( const std::string& keyString )
186 mKeyString = keyString;
190 void KeyEvent::SetKeyCode( int32_t keyCode )
196 void KeyEvent::SetKeyModifier( int32_t keyModifier )
198 mKeyModifier = keyModifier;
202 void KeyEvent::SetTime( unsigned long time )
208 void KeyEvent::SetState( const Dali::KeyEvent::State& state )
213 } // namespace Internal