2 * Copyright (c) 2014 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.
26 #include <dali/integration-api/debug.h>
52 for( size_t i = 0; i < KEY_LOOKUP_COUNT ; ++i )
54 const KeyLookup& keyLookup( KeyLookupTable[i] );
55 mLookup[ keyLookup.keyName ] = DaliKeyType( keyLookup.daliKeyCode, keyLookup.deviceButton );
59 int GetDaliKeyEnum( const char* keyName ) const
61 Lookup::const_iterator i = mLookup.find( keyName );
62 if( i == mLookup.end() )
68 return (*i).second.first;
72 const char* GetKeyName( int daliKeyCode ) const
74 for( size_t i = 0; i < KEY_LOOKUP_COUNT ; ++i )
76 const KeyLookup& keyLookup( KeyLookupTable[i] );
77 if( keyLookup.daliKeyCode == daliKeyCode )
79 return keyLookup.keyName;
85 bool IsDeviceButton( const char* keyName ) const
87 Lookup::const_iterator i = mLookup.find( keyName );
88 if ( i != mLookup.end() )
90 return (*i).second.second;
98 * compare function, to compare string by pointer
100 static bool cmpString( const char* a, const char* b)
102 return strcmp(a, b) < 0;
105 typedef std::pair< int, bool > DaliKeyType;
106 typedef std::map<const char* /* key name */, DaliKeyType /* key code */, bool(*) ( char const* a, char const* b) > Lookup;
110 const KeyMap globalKeyLookup;
112 } // un-named name space
114 bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey)
116 int key = globalKeyLookup.GetDaliKeyEnum( keyEvent.keyPressedName.c_str() );
117 return daliKey == key;
120 bool IsDeviceButton( const char* keyName )
122 return globalKeyLookup.IsDeviceButton( keyName );
125 const char* GetKeyName( Dali::KEY daliKey )
127 return globalKeyLookup.GetKeyName( daliKey );
130 int GetDaliKeyCode( const char* keyName )
132 return globalKeyLookup.GetDaliKeyEnum( keyName );
135 } // namespace KeyLookup
137 } // namespace Adaptor
139 } // namespace Internal