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