Fix accidental switch/teleporter behavior changes
[neverball] / share / keynames.c
1 /*
2  * Copyright (C) 2008 Jānis Rūcis
3  *
4  * NEVERBALL is  free software; you can redistribute  it and/or modify
5  * it under the  terms of the GNU General  Public License as published
6  * by the Free  Software Foundation; either version 2  of the License,
7  * or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
11  * MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
12  * General Public License for more details.
13  */
14
15 #include <SDL_keyboard.h>
16 #include <string.h>
17
18 #include "lang.h"
19 #include "common.h"
20
21 /*---------------------------------------------------------------------------*/
22
23 /* Initial template generated from $SDL/src/events/SDL_keyboard.c */
24
25 static const char *table[][2] = {
26     /* Translators,
27      *
28      * This is a mostly-complete list of human-readable SDL key names.  There
29      * might not be corresponding names for all these keys in your language,
30      * and that's perfectly fine -- in such cases just copy the source string.
31      */
32     { "backspace", N_("Backspace") },
33     { "tab", N_("Tab") },
34     { "clear", N_("Clear") },
35     { "return", N_("Return") },
36     { "pause", N_("Pause") },
37     { "escape", N_("Escape") },
38     { "space", N_("Space") },
39     { "delete", N_("Delete") },
40     { "enter", N_("Enter") },
41     { "equals", N_("Equals") },
42     { "up", N_("Up") },
43     { "down", N_("Down") },
44     { "right", N_("Right") },
45     { "left", N_("Left") },
46     { "down", N_("Down") },
47     { "insert", N_("Insert") },
48     { "home", N_("Home") },
49     { "end", N_("End") },
50     { "page up", N_("Page Up") },
51     { "page down", N_("Page Down") },
52     { "f1", N_("F1") },
53     { "f2", N_("F2") },
54     { "f3", N_("F3") },
55     { "f4", N_("F4") },
56     { "f5", N_("F5") },
57     { "f6", N_("F6") },
58     { "f7", N_("F7") },
59     { "f8", N_("F8") },
60     { "f9", N_("F9") },
61     { "f10", N_("F10") },
62     { "f11", N_("F11") },
63     { "f12", N_("F12") },
64     { "f13", N_("F13") },
65     { "f14", N_("F14") },
66     { "f15", N_("F15") },
67     { "numlock", N_("Num Lock") },
68     { "caps lock", N_("Caps Lock") },
69     { "scroll lock", N_("Scroll Lock") },
70     { "right shift", N_("Right Shift") },
71     { "left shift", N_("Left Shift") },
72     { "right ctrl", N_("Right CTRL") },
73     { "left ctrl", N_("Left CTRL") },
74     { "right alt", N_("Right Alt") },
75     { "left alt", N_("Left Alt") },
76     { "right meta", N_("Right Meta") },
77     { "left meta", N_("Left Meta") },
78     { "left super", N_("Left Super") },
79     { "right super", N_("Right Super") },
80     { "alt gr", N_("Alt Gr") },
81     { "compose", N_("Compose") },
82     { "help", N_("Help") },
83     { "print screen", N_("Print Screen") },
84     { "sys req", N_("Sys Req") },
85     { "break", N_("Break") },
86     { "menu", N_("Menu") },
87     { "power", N_("Power") },
88     { "euro", N_("Euro") },
89     { "undo", N_("Undo") },
90 };
91
92 /*---------------------------------------------------------------------------*/
93
94 const char *pretty_keyname(SDLKey key)
95 {
96     const char *ugly_keyname;
97     int i;
98
99     if ((ugly_keyname = SDL_GetKeyName(key)) == NULL)
100         return NULL;
101
102     for (i = 0; i < ARRAYSIZE(table); i++)
103         if (strcmp(table[i][0], ugly_keyname) == 0)
104             return _(table[i][1]);
105
106     return ugly_keyname;
107 }
108
109 /*---------------------------------------------------------------------------*/