1 /*****************************************************************************
2 * vlc_keys.h: keycode defines
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
29 * This file defines keys, functions and structures for hotkey handling in vlc
33 #define KEY_MODIFIER 0xFF000000
34 #define KEY_MODIFIER_ALT 0x01000000
35 #define KEY_MODIFIER_SHIFT 0x02000000
36 #define KEY_MODIFIER_CTRL 0x04000000
37 #define KEY_MODIFIER_META 0x08000000
38 #define KEY_MODIFIER_COMMAND 0x10000000
40 #define KEY_UNSET 0x00000000
41 /* End of Unicode range: 0x0010FFFF */
42 #define KEY_LEFT 0x00210000
43 #define KEY_RIGHT 0x00220000
44 #define KEY_UP 0x00230000
45 #define KEY_DOWN 0x00240000
46 #define KEY_SPACE 0x00250000
47 #define KEY_ENTER 0x00260000
48 #define KEY_F1 0x00270000
49 #define KEY_F2 0x00280000
50 #define KEY_F3 0x00290000
51 #define KEY_F4 0x002A0000
52 #define KEY_F5 0x002B0000
53 #define KEY_F6 0x002C0000
54 #define KEY_F7 0x002D0000
55 #define KEY_F8 0x002E0000
56 #define KEY_F9 0x002F0000
57 #define KEY_F10 0x00300000
58 #define KEY_F11 0x00310000
59 #define KEY_F12 0x00320000
60 #define KEY_HOME 0x00330000
61 #define KEY_END 0x00340000
62 #define KEY_INSERT 0x00350000
63 #define KEY_DELETE 0x00360000
64 #define KEY_MENU 0x00370000
65 #define KEY_ESC 0x00380000
66 #define KEY_PAGEUP 0x00390000
67 #define KEY_PAGEDOWN 0x003A0000
68 #define KEY_TAB 0x003B0000
69 #define KEY_BACKSPACE 0x003C0000
71 #define KEY_BROWSER_BACK 0x003F0000
72 #define KEY_BROWSER_FORWARD 0x00400000
73 #define KEY_BROWSER_REFRESH 0x00410000
74 #define KEY_BROWSER_STOP 0x00420000
75 #define KEY_BROWSER_SEARCH 0x00430000
76 #define KEY_BROWSER_FAVORITES 0x00440000
77 #define KEY_BROWSER_HOME 0x00450000
78 #define KEY_VOLUME_MUTE 0x00460000
79 #define KEY_VOLUME_DOWN 0x00470000
80 #define KEY_VOLUME_UP 0x00480000
81 #define KEY_MEDIA_NEXT_TRACK 0x00490000
82 #define KEY_MEDIA_PREV_TRACK 0x004A0000
83 #define KEY_MEDIA_STOP 0x004B0000
84 #define KEY_MEDIA_PLAY_PAUSE 0x004C0000
86 #define KEY_MOUSEWHEELUP 0x00F00000
87 #define KEY_MOUSEWHEELDOWN 0x00F10000
88 #define KEY_MOUSEWHEELLEFT 0x00F20000
89 #define KEY_MOUSEWHEELRIGHT 0x00F30000
91 typedef struct key_descriptor_s
93 const char *psz_key_string;
97 #define ADD_KEY(a) { a, *a }
99 static const struct key_descriptor_s vlc_modifiers[] =
101 { "Alt", KEY_MODIFIER_ALT },
102 { "Shift", KEY_MODIFIER_SHIFT },
103 { "Ctrl", KEY_MODIFIER_CTRL },
104 { "Meta", KEY_MODIFIER_META },
105 { "Command", KEY_MODIFIER_COMMAND }
107 enum { vlc_num_modifiers=sizeof(vlc_modifiers)
108 /sizeof(struct key_descriptor_s) };
110 static const struct key_descriptor_s vlc_keys[] =
112 { "Unset", KEY_UNSET },
177 { "Left", KEY_LEFT },
178 { "Right", KEY_RIGHT },
180 { "Down", KEY_DOWN },
181 { "Space", KEY_SPACE },
182 { "Enter", KEY_ENTER },
195 { "Home", KEY_HOME },
197 { "Insert", KEY_INSERT },
198 { "Delete", KEY_DELETE },
199 { "Menu", KEY_MENU },
201 { "Page Up", KEY_PAGEUP },
202 { "Page Down", KEY_PAGEDOWN },
204 { "Backspace", KEY_BACKSPACE },
205 { "Browser Back", KEY_BROWSER_BACK },
206 { "Browser Forward", KEY_BROWSER_FORWARD },
207 { "Browser Refresh", KEY_BROWSER_REFRESH },
208 { "Browser Stop", KEY_BROWSER_STOP },
209 { "Browser Search", KEY_BROWSER_SEARCH },
210 { "Browser Favorites", KEY_BROWSER_FAVORITES },
211 { "Browser Home", KEY_BROWSER_HOME },
212 { "Volume Mute", KEY_VOLUME_MUTE },
213 { "Volume Down", KEY_VOLUME_DOWN },
214 { "Volume Up", KEY_VOLUME_UP },
215 { "Media Next Track", KEY_MEDIA_NEXT_TRACK },
216 { "Media Prev Track", KEY_MEDIA_PREV_TRACK },
217 { "Media Stop", KEY_MEDIA_STOP },
218 { "Media Play Pause", KEY_MEDIA_PLAY_PAUSE },
219 { "Mouse Wheel Up", KEY_MOUSEWHEELUP },
220 { "Mouse Wheel Down", KEY_MOUSEWHEELDOWN },
221 { "Mouse Wheel Left", KEY_MOUSEWHEELLEFT },
222 { "Mouse Wheel Right", KEY_MOUSEWHEELRIGHT },
224 enum { vlc_num_keys=sizeof(vlc_keys)/sizeof(struct key_descriptor_s) };
228 static inline int cmpkey (const void *key, const void *elem)
230 return ((uintptr_t)key) - ((key_descriptor_t *)elem)->i_key_code;
233 static inline const char *KeyToString( uint32_t i_key )
237 d = (key_descriptor_t *)
238 bsearch ((void *)(uintptr_t)i_key, vlc_keys, vlc_num_keys,
239 sizeof (vlc_keys[0]), cmpkey);
240 return d ? d->psz_key_string : NULL;
243 static inline int StringToKey( char *psz_key )
246 for ( i = 0; i < vlc_num_keys; ++i )
248 if ( !strcmp( vlc_keys[i].psz_key_string, psz_key ))
250 return vlc_keys[i].i_key_code;
256 typedef enum vlc_key {
266 ACTIONID_TOGGLE_FULLSCREEN,
269 ACTIONID_NAV_ACTIVATE,
274 ACTIONID_JUMP_BACKWARD_EXTRASHORT,
275 ACTIONID_JUMP_FORWARD_EXTRASHORT,
276 ACTIONID_JUMP_BACKWARD_SHORT,
277 ACTIONID_JUMP_FORWARD_SHORT,
278 ACTIONID_JUMP_BACKWARD_MEDIUM,
279 ACTIONID_JUMP_FORWARD_MEDIUM,
280 ACTIONID_JUMP_BACKWARD_LONG,
281 ACTIONID_JUMP_FORWARD_LONG,
285 /* let ACTIONID_SET_BOOMARK* and ACTIONID_PLAY_BOOKMARK* be contiguous */
286 ACTIONID_SET_BOOKMARK1,
287 ACTIONID_SET_BOOKMARK2,
288 ACTIONID_SET_BOOKMARK3,
289 ACTIONID_SET_BOOKMARK4,
290 ACTIONID_SET_BOOKMARK5,
291 ACTIONID_SET_BOOKMARK6,
292 ACTIONID_SET_BOOKMARK7,
293 ACTIONID_SET_BOOKMARK8,
294 ACTIONID_SET_BOOKMARK9,
295 ACTIONID_SET_BOOKMARK10,
296 ACTIONID_PLAY_BOOKMARK1,
297 ACTIONID_PLAY_BOOKMARK2,
298 ACTIONID_PLAY_BOOKMARK3,
299 ACTIONID_PLAY_BOOKMARK4,
300 ACTIONID_PLAY_BOOKMARK5,
301 ACTIONID_PLAY_BOOKMARK6,
302 ACTIONID_PLAY_BOOKMARK7,
303 ACTIONID_PLAY_BOOKMARK8,
304 ACTIONID_PLAY_BOOKMARK9,
305 ACTIONID_PLAY_BOOKMARK10,
306 /* end of contiguous zone */
307 ACTIONID_SUBDELAY_UP,
308 ACTIONID_SUBDELAY_DOWN,
309 ACTIONID_HISTORY_BACK,
310 ACTIONID_HISTORY_FORWARD,
311 ACTIONID_AUDIO_TRACK,
312 ACTIONID_SUBTITLE_TRACK,
313 ACTIONID_CUBESPEED_UP,
314 ACTIONID_CUBESPEED_DOWN,
317 /* chapter and title navigation */
320 ACTIONID_CHAPTER_PREV,
321 ACTIONID_CHAPTER_NEXT,
322 /* end of chapter and title navigation */
323 ACTIONID_AUDIODELAY_UP,
324 ACTIONID_AUDIODELAY_DOWN,
328 ACTIONID_ASPECT_RATIO,
330 ACTIONID_DEINTERLACE,
336 ACTIONID_UNCROP_LEFT,
337 ACTIONID_CROP_BOTTOM,
338 ACTIONID_UNCROP_BOTTOM,
340 ACTIONID_UNCROP_RIGHT,
345 ACTIONID_LEAVE_FULLSCREEN,
352 ACTIONID_MENU_SELECT,
354 ACTIONID_ZOOM_QUARTER,
356 ACTIONID_ZOOM_ORIGINAL,
357 ACTIONID_ZOOM_DOUBLE,
358 /* Cycle Through Audio Devices */
359 ACTIONID_AUDIODEVICE_CYCLE,
361 ACTIONID_TOGGLE_AUTOSCALE,
365 ACTIONID_RATE_NORMAL,
366 ACTIONID_RATE_SLOWER_FINE,
367 ACTIONID_RATE_FASTER_FINE,