2 * Copyright (c) 2017 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>
30 * This container stores a mapping between public key event and impl as we cannot add data members in public one.
31 * In practice this keeps the impl "alive" in between KeyEvent constructor and destructor calls so that getter
32 * methods can be called to access the new data members. There is a 1:1 mapping between KeyEvent and KeyEventImpl.
37 Internal::KeyEventImpl* impl;
39 Vector< KeyImplMapping > gKeyEventToImplMapping;
46 KeyEventImpl::KeyEventImpl( KeyEvent* keyEvent )
50 mDeviceClass( Device::Class::NONE ),
51 mDeviceSubclass( Device::Subclass::NONE )
53 gKeyEventToImplMapping.PushBack( { keyEvent, this } );
56 KeyEventImpl::~KeyEventImpl()
58 for( auto&& iter : gKeyEventToImplMapping )
60 if( this == iter.impl )
62 gKeyEventToImplMapping.Erase( &iter ); // iter is reference to KeyImplMapping, take address of it for Erase
68 KeyEventImpl& KeyEventImpl::operator=( const KeyEventImpl& rhs )
72 mLogicalKey = rhs.mLogicalKey;
73 mCompose = rhs.mCompose;
74 mDeviceName = rhs.mDeviceName;
75 mDeviceClass = rhs.mDeviceClass;
76 mDeviceSubclass = rhs.mDeviceSubclass;
82 std::string KeyEventImpl::GetLogicalKey() const
87 void KeyEventImpl::SetLogicalKey( const std::string& logicalKey )
89 mLogicalKey = logicalKey;
92 std::string KeyEventImpl::GetCompose() const
97 void KeyEventImpl::SetCompose( const std::string& compose )
102 std::string KeyEventImpl::GetDeviceName() const
107 void KeyEventImpl::SetDeviceName( const std::string& deviceName )
109 mDeviceName = deviceName;
112 Device::Class::Type KeyEventImpl::GetDeviceClass() const
117 void KeyEventImpl::SetDeviceClass( Device::Class::Type deviceClass )
119 mDeviceClass = deviceClass;
122 Device::Subclass::Type KeyEventImpl::GetDeviceSubclass() const
124 return mDeviceSubclass;
127 void KeyEventImpl::SetDeviceSubclass( Device::Subclass::Type deviceSubclass )
129 mDeviceSubclass = deviceSubclass;
132 } // namsespace Internal
134 Internal::KeyEventImpl* GetImplementation( KeyEvent* keyEvent )
136 Internal::KeyEventImpl* impl( NULL );
137 for( auto&& iter : gKeyEventToImplMapping )
139 if( iter.keyEvent == keyEvent )
147 const Internal::KeyEventImpl* GetImplementation( const KeyEvent* keyEvent )
149 Internal::KeyEventImpl* impl( NULL );
150 for( auto&& iter : gKeyEventToImplMapping )
152 if( iter.keyEvent == keyEvent )