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.
22 #define KEY_VOLUMEUP "XF86AudioRaiseVolume" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Volume Up' key */
23 #define KEY_VOLUMEDOWN "XF86AudioLowerVolume" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Volume Down' key */
25 #define KEY_CAMERA "XF86WebCam" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Half-Press of Camera' key */
26 #define KEY_CONFIG "XF86Pictures" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Full-Press of Camera' key */
28 #define KEY_POWER "XF86PowerOff" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Power' key */
29 #define KEY_PAUSE "XF86Standby" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Pause' key */
30 #define KEY_CANCEL "Cancel" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Cancel' key */
32 // Earjack/BT Headset/Multimedia keys
33 #define KEY_PLAYCD "XF86AudioPlay" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Play Audio' key */
34 #define KEY_STOPCD "XF86AudioStop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Stop Audio' key */
35 #define KEY_PAUSECD "XF86AudioPause" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Pause Audio' key */
36 #define KEY_NEXTSONG "XF86AudioNext" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Next Song' key */
37 #define KEY_PREVIOUSSONG "XF86AudioPrev" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Previous Song' key */
38 #define KEY_REWIND "XF86AudioRewind" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Rewind Song' key */
39 #define KEY_FASTFORWARD "XF86AudioForward" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Forward Song' key */
40 #define KEY_MEDIA "XF86AudioMedia" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Media' key */
41 #define KEY_PLAYPAUSE "XF86AudioPlayPause" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'PlayPause' key */
42 #define KEY_MUTE "XF86AudioMute" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Mute' key */
45 #define KEY_SEND "XF86Send" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Send' key */
46 #define KEY_SELECT "XF86Phone" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Home' key */
47 #define KEY_END "XF86Stop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'End' key */
49 // Renamed 3-Touch key
50 #define KEY_MENU "XF86Send" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Send' key */
51 #define KEY_HOME "XF86Phone" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Home' key */
52 #define KEY_BACK "XF86Stop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'End' key */
54 //Other functions keys
55 #define KEY_HOMEPAGE "XF86HomePage" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'HomePage' key */
56 #define KEY_WEBPAGE "XF86WWW" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'WWW' key */
57 #define KEY_MAIL "XF86Mail" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Mail' key */
58 #define KEY_SCREENSAVER "XF86ScreenSaver" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'ScreenSaver' key */
59 #define KEY_BRIGHTNESSUP "XF86MonBrightnessUp" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'BrightnessUp' key */
60 #define KEY_BRIGHTNESSDOWN "XF86MonBrightnessDown" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'BrightnessDown' key */
61 #define KEY_SOFTKBD "XF86MenuKB" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Soft keyboard(toggle)' key */
62 #define KEY_QUICKPANEL "XF86Tools" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Quick panel(toggle)' key */
63 #define KEY_TASKSWITCH "XF86TaskPane" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Task switcher(toggle)' key */
64 #define KEY_APPS "XF86Launch0" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Apptray(toggle)' key */
65 #define KEY_SEARCH "XF86Search" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Search(toggle)' key */
66 #define KEY_VOICE "XF86Launch2" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Voice(toggle)' key */
67 #define KEY_LANGUAGE "Hangul" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Language(toggle)' key */
74 #include <dali/integration-api/debug.h>
80 const KEY DALI_KEY_INVALID = -1;
81 const KEY DALI_KEY_ESCAPE = 9;
82 const KEY DALI_KEY_BACK = 166;
83 const KEY DALI_KEY_CAMERA = 167;
84 const KEY DALI_KEY_CONFIG = 168;
85 const KEY DALI_KEY_POWER = 169;
86 const KEY DALI_KEY_PAUSE = 170;
87 const KEY DALI_KEY_CANCEL = 171;
88 const KEY DALI_KEY_PLAY_CD = 172;
89 const KEY DALI_KEY_STOP_CD = 173;
90 const KEY DALI_KEY_PAUSE_CD = 174;
91 const KEY DALI_KEY_NEXT_SONG = 175;
92 const KEY DALI_KEY_PREVIOUS_SONG = 176;
93 const KEY DALI_KEY_REWIND = 177;
94 const KEY DALI_KEY_FASTFORWARD = 178;
95 const KEY DALI_KEY_MEDIA = 179;
96 const KEY DALI_KEY_PLAY_PAUSE = 180;
97 const KEY DALI_KEY_MUTE = 181;
98 const KEY DALI_KEY_SEND = 182;
99 const KEY DALI_KEY_SELECT = 183;
100 const KEY DALI_KEY_END = DALI_KEY_BACK;
101 const KEY DALI_KEY_MENU = DALI_KEY_SEND;
102 const KEY DALI_KEY_HOME = DALI_KEY_SELECT;
103 const KEY DALI_KEY_HOMEPAGE = 187;
104 const KEY DALI_KEY_WEBPAGE = 188;
105 const KEY DALI_KEY_MAIL = 189;
106 const KEY DALI_KEY_SCREENSAVER = 190;
107 const KEY DALI_KEY_BRIGHTNESS_UP = 191;
108 const KEY DALI_KEY_BRIGHTNESS_DOWN = 192;
109 const KEY DALI_KEY_SOFT_KBD = 193;
110 const KEY DALI_KEY_QUICK_PANEL = 194;
111 const KEY DALI_KEY_TASK_SWITCH = 195;
112 const KEY DALI_KEY_APPS = 196;
113 const KEY DALI_KEY_SEARCH = 197;
114 const KEY DALI_KEY_VOICE = 198;
115 const KEY DALI_KEY_LANGUAGE = 199;
116 const KEY DALI_KEY_VOLUME_UP = 200;
117 const KEY DALI_KEY_VOLUME_DOWN = 201;
133 const char* keyName; ///< X string representation
134 const int daliKeyCode; ///< Dali Enum Representation
135 const bool deviceButton; ///< Whether the key is from a button on the device
138 // matches a DALI_KEY enum, to a X key name
139 KeyLookup KeyLookupTable[]=
141 // more than one key name can be assigned to a single dali-key code
142 // e.g. Menu and KEY_MENU("FS86KeyMenu") are both assigned to DALI_KEY_MENU
144 { "Escape", DALI_KEY_ESCAPE, false }, // item not defined in utilX
145 { "Menu", DALI_KEY_MENU, false }, // item not defined in utilX
146 { KEY_CAMERA, DALI_KEY_CAMERA, false },
147 { KEY_CONFIG, DALI_KEY_CONFIG, false },
148 { KEY_POWER, DALI_KEY_POWER, true },
149 { KEY_PAUSE, DALI_KEY_PAUSE, false },
150 { KEY_CANCEL, DALI_KEY_CANCEL, false },
151 { KEY_PLAYCD, DALI_KEY_PLAY_CD, false },
152 { KEY_STOPCD, DALI_KEY_STOP_CD, false },
153 { KEY_PAUSECD, DALI_KEY_PAUSE_CD, false },
154 { KEY_NEXTSONG, DALI_KEY_NEXT_SONG, false },
155 { KEY_PREVIOUSSONG, DALI_KEY_PREVIOUS_SONG, false },
156 { KEY_REWIND, DALI_KEY_REWIND, false },
157 { KEY_FASTFORWARD, DALI_KEY_FASTFORWARD, false },
158 { KEY_MEDIA, DALI_KEY_MEDIA, false },
159 { KEY_PLAYPAUSE, DALI_KEY_PLAY_PAUSE, false },
160 { KEY_MUTE, DALI_KEY_MUTE, false },
161 { KEY_SEND, DALI_KEY_SEND, true },
162 { KEY_SELECT, DALI_KEY_SELECT, true },
163 { KEY_END, DALI_KEY_END, true },
164 { KEY_MENU, DALI_KEY_MENU, true },
165 { KEY_HOME, DALI_KEY_HOME, true },
166 { KEY_BACK, DALI_KEY_BACK, true },
167 { KEY_HOMEPAGE, DALI_KEY_HOMEPAGE, false },
168 { KEY_WEBPAGE, DALI_KEY_WEBPAGE, false },
169 { KEY_MAIL, DALI_KEY_MAIL, false },
170 { KEY_SCREENSAVER, DALI_KEY_SCREENSAVER, false },
171 { KEY_BRIGHTNESSUP, DALI_KEY_BRIGHTNESS_UP, false },
172 { KEY_BRIGHTNESSDOWN, DALI_KEY_BRIGHTNESS_DOWN, false },
173 { KEY_SOFTKBD, DALI_KEY_SOFT_KBD, false },
174 { KEY_QUICKPANEL, DALI_KEY_QUICK_PANEL, false },
175 { KEY_TASKSWITCH, DALI_KEY_TASK_SWITCH, false },
176 { KEY_APPS, DALI_KEY_APPS, false },
177 { KEY_SEARCH, DALI_KEY_SEARCH, false },
178 { KEY_VOICE, DALI_KEY_VOICE, false },
179 { KEY_LANGUAGE, DALI_KEY_LANGUAGE, false },
180 { KEY_VOLUMEUP, DALI_KEY_VOLUME_UP, true },
181 { KEY_VOLUMEDOWN, DALI_KEY_VOLUME_DOWN, true },
184 const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable))/ (sizeof(KeyLookup));
194 for( size_t i = 0; i < KEY_LOOKUP_COUNT ; ++i )
196 const KeyLookup& keyLookup( KeyLookupTable[i] );
197 mLookup[ keyLookup.keyName ] = DaliKeyType( keyLookup.daliKeyCode, keyLookup.deviceButton );
201 int GetDaliKeyEnum( const char* keyName ) const
203 Lookup::const_iterator i = mLookup.find( keyName );
204 if( i == mLookup.end() )
210 return (*i).second.first;
214 bool IsDeviceButton( const char* keyName ) const
216 Lookup::const_iterator i = mLookup.find( keyName );
217 if ( i != mLookup.end() )
219 return (*i).second.second;
227 * compare function, to compare string by pointer
229 static bool cmpString( const char* a, const char* b)
231 return strcmp(a, b) < 0;
234 typedef std::pair< int, bool > DaliKeyType;
235 typedef std::map<const char* /* key name */, DaliKeyType /* key code */, bool(*) ( char const* a, char const* b) > Lookup;
239 const KeyMap globalKeyLookup;
241 } // un-named name space
243 bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey)
245 int key = globalKeyLookup.GetDaliKeyEnum( keyEvent.keyPressedName.c_str() );
246 return daliKey == key;
249 bool IsDeviceButton( const char* keyName )
251 return globalKeyLookup.IsDeviceButton( keyName );
254 } // namespace KeyLookup
256 } // namespace Adaptor
258 } // namespace Internal