]> git.sesse.net Git - vlc/blob - include/vlc_keys.h
First part of code to allow configurable hotkeys.
[vlc] / include / vlc_keys.h
1 /*****************************************************************************
2  * hotkeys.h: keycode defines
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: vlc_keys.h,v 1.1 2003/08/14 19:25:55 sigmunau Exp $
6  *
7  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
8  *
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.
13  *
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.
18  *
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #define KEY_MODIFIER         0xFF000000
25 #define KEY_MODIFIER_ALT     0x01000000
26 #define KEY_MODIFIER_SHIFT   0x02000000
27 #define KEY_MODIFIER_CTRL    0x04000000
28 #define KEY_MODIFIER_META    0x08000000
29 #define KEY_MODIFIER_COMMAND 0x10000000
30
31 #define KEY_SPECIAL          0x00FF0000
32 #define KEY_LEFT             0x00010000
33 #define KEY_RIGHT            0x00020000
34 #define KEY_UP               0x00030000
35 #define KEY_DOWN             0x00040000
36 #define KEY_SPACE            0x00050000
37 #define KEY_ENTER            0x00060000
38 #define KEY_F1               0x00070000
39 #define KEY_F2               0x00080000
40 #define KEY_F3               0x00090000
41 #define KEY_F4               0x000A0000
42 #define KEY_F5               0x000B0000
43 #define KEY_F6               0x000C0000
44 #define KEY_F7               0x000D0000
45 #define KEY_F8               0x000E0000
46 #define KEY_F9               0x000F0000
47 #define KEY_F10              0x00100000
48 #define KEY_F11              0x00110000
49 #define KEY_F12              0x00120000
50 #define KEY_HOME             0x00130000
51 #define KEY_END              0x00140000
52 #define KEY_MENU             0x00150000
53 #define KEY_ESC              0x00160000
54 #define KEY_PAGEUP           0x00170000
55 #define KEY_PAGEDOWN         0x00180000
56 #define KEY_TAB              0x00190000
57 #define KEY_BACKSPACE        0x001A0000
58
59 #define KEY_ASCII            0x0000007F
60 #define KEY_UNSET            0
61 typedef struct key_descriptor_s
62 {
63     char *psz_key_string;
64     int i_key_code;
65 } key_descriptor_t;
66 #define ADD_KEY(a) { a, *a }
67 static const struct key_descriptor_s modifiers[] =
68 {
69     { "Alt", KEY_MODIFIER_ALT },
70     { "Shift", KEY_MODIFIER_SHIFT },
71     { "Ctrl", KEY_MODIFIER_CTRL },
72     { "Meta", KEY_MODIFIER_META },
73     { "Command", KEY_MODIFIER_COMMAND }
74 };
75
76 static const struct key_descriptor_s keys[] =
77 {
78     { "Unset", KEY_UNSET },
79     { "Left", KEY_LEFT },
80     { "Right", KEY_RIGHT },
81     { "Up", KEY_UP },
82     { "Down", KEY_DOWN },
83     { "Space", KEY_SPACE },
84     { "Enter", KEY_ENTER },
85     { "F1", KEY_F1 },
86     { "F2", KEY_F2 },
87     { "F3", KEY_F3 },
88     { "F4", KEY_F4 },
89     { "F5", KEY_F5 },
90     { "F6", KEY_F6 },
91     { "F7", KEY_F7 },
92     { "F8", KEY_F8 },
93     { "F9", KEY_F9 },
94     { "F10", KEY_F10 },
95     { "F11", KEY_F11 },
96     { "F12", KEY_F12 },
97     { "Home", KEY_HOME },
98     { "End", KEY_END },
99     { "Menu", KEY_MENU },
100     { "Esc", KEY_ESC },
101     { "Page Up", KEY_PAGEUP },
102     { "Page Down", KEY_PAGEDOWN },
103     { "Tab", KEY_TAB },
104     { "Backspace", KEY_BACKSPACE },
105     { "a", 'a' },
106     { "b", 'b' },
107     { "c", 'c' },
108     { "d", 'd' },
109     { "e", 'e' },
110     { "f", 'f' },
111     { "g", 'g' },
112     { "h", 'h' },
113     { "i", 'i' },
114     { "j", 'j' },
115     { "k", 'k' },
116     { "l", 'l' },
117     { "m", 'm' },
118     { "n", 'n' },
119     { "o", 'o' },
120     { "p", 'p' },
121     { "q", 'q' },
122     { "r", 'r' },
123     { "s", 's' },
124     { "t", 't' },
125     { "u", 'u' },
126     { "v", 'v' },
127     { "w", 'w' },
128     { "x", 'x' },
129     { "y", 'y' },
130     { "z", 'z' },
131     { "+", '+' },
132     { "-", '-' },
133     { ",", ',' },
134     { ".", '.' },
135     { "<", '<' },
136     { ">", '>' }
137 };
138
139 static char *KeyToString( int i_key )
140 {
141     unsigned int i = 0;
142     for ( i = 0; i < sizeof(keys) / sizeof(key_descriptor_t); i++ )
143     {
144         if ( keys[i].i_key_code == i_key )
145         {
146             return keys[i].psz_key_string;
147         }
148     }
149     return NULL;
150 }