1 /*****************************************************************************
2 * vlc_keys.h: keycode defines
3 *****************************************************************************
4 * Copyright (C) 2003-2009 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 *****************************************************************************/
33 * This file defines keys, functions and structures for hotkey handling in vlc
37 #define KEY_MODIFIER 0xFF000000
38 #define KEY_MODIFIER_ALT 0x01000000
39 #define KEY_MODIFIER_SHIFT 0x02000000
40 #define KEY_MODIFIER_CTRL 0x04000000
41 #define KEY_MODIFIER_META 0x08000000
42 #define KEY_MODIFIER_COMMAND 0x10000000
44 #define KEY_UNSET 0x00000000
45 /* End of Unicode range: 0x0010FFFF */
46 #define KEY_LEFT 0x00210000
47 #define KEY_RIGHT 0x00220000
48 #define KEY_UP 0x00230000
49 #define KEY_DOWN 0x00240000
50 #define KEY_SPACE 0x00250000
51 #define KEY_ENTER 0x00260000
52 #define KEY_F1 0x00270000
53 #define KEY_F2 0x00280000
54 #define KEY_F3 0x00290000
55 #define KEY_F4 0x002A0000
56 #define KEY_F5 0x002B0000
57 #define KEY_F6 0x002C0000
58 #define KEY_F7 0x002D0000
59 #define KEY_F8 0x002E0000
60 #define KEY_F9 0x002F0000
61 #define KEY_F10 0x00300000
62 #define KEY_F11 0x00310000
63 #define KEY_F12 0x00320000
64 #define KEY_HOME 0x00330000
65 #define KEY_END 0x00340000
66 #define KEY_INSERT 0x00350000
67 #define KEY_DELETE 0x00360000
68 #define KEY_MENU 0x00370000
69 #define KEY_ESC 0x00380000
70 #define KEY_PAGEUP 0x00390000
71 #define KEY_PAGEDOWN 0x003A0000
72 #define KEY_TAB 0x003B0000
73 #define KEY_BACKSPACE 0x003C0000
75 #define KEY_BROWSER_BACK 0x003F0000
76 #define KEY_BROWSER_FORWARD 0x00400000
77 #define KEY_BROWSER_REFRESH 0x00410000
78 #define KEY_BROWSER_STOP 0x00420000
79 #define KEY_BROWSER_SEARCH 0x00430000
80 #define KEY_BROWSER_FAVORITES 0x00440000
81 #define KEY_BROWSER_HOME 0x00450000
82 #define KEY_VOLUME_MUTE 0x00460000
83 #define KEY_VOLUME_DOWN 0x00470000
84 #define KEY_VOLUME_UP 0x00480000
85 #define KEY_MEDIA_NEXT_TRACK 0x00490000
86 #define KEY_MEDIA_PREV_TRACK 0x004A0000
87 #define KEY_MEDIA_STOP 0x004B0000
88 #define KEY_MEDIA_PLAY_PAUSE 0x004C0000
90 #define KEY_MOUSEWHEELUP 0x00F00000
91 #define KEY_MOUSEWHEELDOWN 0x00F10000
92 #define KEY_MOUSEWHEELLEFT 0x00F20000
93 #define KEY_MOUSEWHEELRIGHT 0x00F30000
95 typedef struct key_descriptor_s
97 const char *psz_key_string
;
101 #define ADD_KEY(a) { a, *a }
103 static const struct key_descriptor_s vlc_modifiers
[] =
105 { "Alt", KEY_MODIFIER_ALT
},
106 { "Shift", KEY_MODIFIER_SHIFT
},
107 { "Ctrl", KEY_MODIFIER_CTRL
},
108 { "Meta", KEY_MODIFIER_META
},
109 { "Command", KEY_MODIFIER_COMMAND
}
111 enum { vlc_num_modifiers
=sizeof(vlc_modifiers
)
112 /sizeof(struct key_descriptor_s
) };
114 static const struct key_descriptor_s vlc_keys
[] =
116 { "Unset", KEY_UNSET
},
181 { "Left", KEY_LEFT
},
182 { "Right", KEY_RIGHT
},
184 { "Down", KEY_DOWN
},
185 { "Space", KEY_SPACE
},
186 { "Enter", KEY_ENTER
},
199 { "Home", KEY_HOME
},
201 { "Insert", KEY_INSERT
},
202 { "Delete", KEY_DELETE
},
203 { "Menu", KEY_MENU
},
205 { "Page Up", KEY_PAGEUP
},
206 { "Page Down", KEY_PAGEDOWN
},
208 { "Backspace", KEY_BACKSPACE
},
209 { "Browser Back", KEY_BROWSER_BACK
},
210 { "Browser Forward", KEY_BROWSER_FORWARD
},
211 { "Browser Refresh", KEY_BROWSER_REFRESH
},
212 { "Browser Stop", KEY_BROWSER_STOP
},
213 { "Browser Search", KEY_BROWSER_SEARCH
},
214 { "Browser Favorites", KEY_BROWSER_FAVORITES
},
215 { "Browser Home", KEY_BROWSER_HOME
},
216 { "Volume Mute", KEY_VOLUME_MUTE
},
217 { "Volume Down", KEY_VOLUME_DOWN
},
218 { "Volume Up", KEY_VOLUME_UP
},
219 { "Media Next Track", KEY_MEDIA_NEXT_TRACK
},
220 { "Media Prev Track", KEY_MEDIA_PREV_TRACK
},
221 { "Media Stop", KEY_MEDIA_STOP
},
222 { "Media Play Pause", KEY_MEDIA_PLAY_PAUSE
},
223 { "Mouse Wheel Up", KEY_MOUSEWHEELUP
},
224 { "Mouse Wheel Down", KEY_MOUSEWHEELDOWN
},
225 { "Mouse Wheel Left", KEY_MOUSEWHEELLEFT
},
226 { "Mouse Wheel Right", KEY_MOUSEWHEELRIGHT
},
228 enum { vlc_num_keys
=sizeof(vlc_keys
)/sizeof(struct key_descriptor_s
) };
232 static inline int cmpkey (const void *key
, const void *elem
)
234 return ((uintptr_t)key
) - ((key_descriptor_t
*)elem
)->i_key_code
;
237 static inline const char *KeyToString( uint32_t i_key
)
241 d
= (key_descriptor_t
*)
242 bsearch ((void *)(uintptr_t)i_key
, vlc_keys
, vlc_num_keys
,
243 sizeof (vlc_keys
[0]), cmpkey
);
244 return d
? d
->psz_key_string
: NULL
;
247 static inline int StringToKey( char *psz_key
)
250 for ( i
= 0; i
< vlc_num_keys
; ++i
)
252 if ( !strcmp( vlc_keys
[i
].psz_key_string
, psz_key
))
254 return vlc_keys
[i
].i_key_code
;
260 typedef enum vlc_key
{
270 ACTIONID_TOGGLE_FULLSCREEN
,
273 ACTIONID_NAV_ACTIVATE
,
278 ACTIONID_JUMP_BACKWARD_EXTRASHORT
,
279 ACTIONID_JUMP_FORWARD_EXTRASHORT
,
280 ACTIONID_JUMP_BACKWARD_SHORT
,
281 ACTIONID_JUMP_FORWARD_SHORT
,
282 ACTIONID_JUMP_BACKWARD_MEDIUM
,
283 ACTIONID_JUMP_FORWARD_MEDIUM
,
284 ACTIONID_JUMP_BACKWARD_LONG
,
285 ACTIONID_JUMP_FORWARD_LONG
,
289 /* let ACTIONID_SET_BOOMARK* and ACTIONID_PLAY_BOOKMARK* be contiguous */
290 ACTIONID_SET_BOOKMARK1
,
291 ACTIONID_SET_BOOKMARK2
,
292 ACTIONID_SET_BOOKMARK3
,
293 ACTIONID_SET_BOOKMARK4
,
294 ACTIONID_SET_BOOKMARK5
,
295 ACTIONID_SET_BOOKMARK6
,
296 ACTIONID_SET_BOOKMARK7
,
297 ACTIONID_SET_BOOKMARK8
,
298 ACTIONID_SET_BOOKMARK9
,
299 ACTIONID_SET_BOOKMARK10
,
300 ACTIONID_PLAY_BOOKMARK1
,
301 ACTIONID_PLAY_BOOKMARK2
,
302 ACTIONID_PLAY_BOOKMARK3
,
303 ACTIONID_PLAY_BOOKMARK4
,
304 ACTIONID_PLAY_BOOKMARK5
,
305 ACTIONID_PLAY_BOOKMARK6
,
306 ACTIONID_PLAY_BOOKMARK7
,
307 ACTIONID_PLAY_BOOKMARK8
,
308 ACTIONID_PLAY_BOOKMARK9
,
309 ACTIONID_PLAY_BOOKMARK10
,
310 /* end of contiguous zone */
311 ACTIONID_SUBDELAY_UP
,
312 ACTIONID_SUBDELAY_DOWN
,
313 ACTIONID_HISTORY_BACK
,
314 ACTIONID_HISTORY_FORWARD
,
315 ACTIONID_AUDIO_TRACK
,
316 ACTIONID_SUBTITLE_TRACK
,
317 ACTIONID_CUBESPEED_UP
,
318 ACTIONID_CUBESPEED_DOWN
,
321 /* chapter and title navigation */
324 ACTIONID_CHAPTER_PREV
,
325 ACTIONID_CHAPTER_NEXT
,
326 /* end of chapter and title navigation */
327 ACTIONID_AUDIODELAY_UP
,
328 ACTIONID_AUDIODELAY_DOWN
,
332 ACTIONID_ASPECT_RATIO
,
334 ACTIONID_DEINTERLACE
,
340 ACTIONID_UNCROP_LEFT
,
341 ACTIONID_CROP_BOTTOM
,
342 ACTIONID_UNCROP_BOTTOM
,
344 ACTIONID_UNCROP_RIGHT
,
349 ACTIONID_LEAVE_FULLSCREEN
,
356 ACTIONID_MENU_SELECT
,
358 ACTIONID_ZOOM_QUARTER
,
360 ACTIONID_ZOOM_ORIGINAL
,
361 ACTIONID_ZOOM_DOUBLE
,
362 /* Cycle Through Audio Devices */
363 ACTIONID_AUDIODEVICE_CYCLE
,
365 ACTIONID_TOGGLE_AUTOSCALE
,
369 ACTIONID_RATE_NORMAL
,
370 ACTIONID_RATE_SLOWER_FINE
,
371 ACTIONID_RATE_FASTER_FINE
,