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.
27 #include <dali/integration-api/debug.h>
33 const KEY DALI_KEY_INVALID = -1;
34 const KEY DALI_KEY_ESCAPE = 9;
35 const KEY DALI_KEY_BACK = 166;
36 const KEY DALI_KEY_CAMERA = 167;
37 const KEY DALI_KEY_CONFIG = 168;
38 const KEY DALI_KEY_POWER = 169;
39 const KEY DALI_KEY_PAUSE = 170;
40 const KEY DALI_KEY_CANCEL = 171;
41 const KEY DALI_KEY_PLAY_CD = 172;
42 const KEY DALI_KEY_STOP_CD = 173;
43 const KEY DALI_KEY_PAUSE_CD = 174;
44 const KEY DALI_KEY_NEXT_SONG = 175;
45 const KEY DALI_KEY_PREVIOUS_SONG = 176;
46 const KEY DALI_KEY_REWIND = 177;
47 const KEY DALI_KEY_FASTFORWARD = 178;
48 const KEY DALI_KEY_MEDIA = 179;
49 const KEY DALI_KEY_PLAY_PAUSE = 180;
50 const KEY DALI_KEY_MUTE = 181;
51 const KEY DALI_KEY_SEND = 182;
52 const KEY DALI_KEY_SELECT = 183;
53 const KEY DALI_KEY_END = DALI_KEY_BACK;
54 const KEY DALI_KEY_MENU = DALI_KEY_SEND;
55 const KEY DALI_KEY_HOME = DALI_KEY_SELECT;
56 const KEY DALI_KEY_HOMEPAGE = 187;
57 const KEY DALI_KEY_WEBPAGE = 188;
58 const KEY DALI_KEY_MAIL = 189;
59 const KEY DALI_KEY_SCREENSAVER = 190;
60 const KEY DALI_KEY_BRIGHTNESS_UP = 191;
61 const KEY DALI_KEY_BRIGHTNESS_DOWN = 192;
62 const KEY DALI_KEY_SOFT_KBD = 193;
63 const KEY DALI_KEY_QUICK_PANEL = 194;
64 const KEY DALI_KEY_TASK_SWITCH = 195;
65 const KEY DALI_KEY_APPS = 196;
66 const KEY DALI_KEY_SEARCH = 197;
67 const KEY DALI_KEY_VOICE = 198;
68 const KEY DALI_KEY_LANGUAGE = 199;
69 const KEY DALI_KEY_VOLUME_UP = 200;
70 const KEY DALI_KEY_VOLUME_DOWN = 201;
86 const char* keyName; ///< X string representation
87 const int daliKeyCode; ///< Dali Enum Representation
88 const bool deviceButton; ///< Whether the key is from a button on the device
91 // matches a DALI_KEY enum, to a X key name
92 KeyLookup KeyLookupTable[]=
94 // more than one key name can be assigned to a single dali-key code
95 // e.g. Menu and KEY_MENU("FS86KeyMenu") are both assigned to DALI_KEY_MENU
97 { "Escape", DALI_KEY_ESCAPE, false }, // item not defined in utilX
98 { "Menu", DALI_KEY_MENU, false }, // item not defined in utilX
101 const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable))/ (sizeof(KeyLookup));
111 for( size_t i = 0; i < KEY_LOOKUP_COUNT ; ++i )
113 const KeyLookup& keyLookup( KeyLookupTable[i] );
114 mLookup[ keyLookup.keyName ] = DaliKeyType( keyLookup.daliKeyCode, keyLookup.deviceButton );
118 int GetDaliKeyEnum( const char* keyName ) const
120 Lookup::const_iterator i = mLookup.find( keyName );
121 if( i == mLookup.end() )
127 return (*i).second.first;
131 bool IsDeviceButton( const char* keyName ) const
133 Lookup::const_iterator i = mLookup.find( keyName );
134 if ( i != mLookup.end() )
136 return (*i).second.second;
144 * compare function, to compare string by pointer
146 static bool cmpString( const char* a, const char* b)
148 return strcmp(a, b) < 0;
151 typedef std::pair< int, bool > DaliKeyType;
152 typedef std::map<const char* /* key name */, DaliKeyType /* key code */, bool(*) ( char const* a, char const* b) > Lookup;
156 const KeyMap globalKeyLookup;
158 } // un-named name space
160 bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey)
162 int key = globalKeyLookup.GetDaliKeyEnum( keyEvent.keyPressedName.c_str() );
163 return daliKey == key;
166 bool IsDeviceButton( const char* keyName )
168 return globalKeyLookup.IsDeviceButton( keyName );
171 } // namespace KeyLookup
173 } // namespace Adaptor
175 } // namespace Internal