Colobot
key.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
25 #pragma once
26 
27 
28 #include <SDL_keysym.h>
29 
30 /* Key definitions are specially defined here so that it is clear in other parts of the code
31  that these are used. It is to avoid having SDL-related enum values or #defines lying around
32  unchecked. With this approach it will be easier to maintain the code later on. */
33 
34 // Key symbol defined as concatenation to SDLK_...
35 // If need arises, it can be changed to custom function or anything else
36 #define KEY(x) SDLK_ ## x
37 
38 
39 // Key modifier defined as concatenation to KMOD_...
40 // If need arises, it can be changed to custom function or anything else
41 #define KEY_MOD(x) KMOD_ ## x
42 
50 {
51  VIRTUAL_KMOD_CTRL = SDLK_LAST + 100,
52  VIRTUAL_KMOD_SHIFT = SDLK_LAST + 101,
53  VIRTUAL_KMOD_ALT = SDLK_LAST + 102,
54  VIRTUAL_KMOD_META = SDLK_LAST + 103
55 };
56 
57 // Just syntax sugar
58 // So it is the same as other macros
59 #define VIRTUAL_KMOD(x) VIRTUAL_KMOD_ ## x
60 
62 unsigned int GetVirtualKey(unsigned int key);
63 
64 // Virtual key code generated on joystick button presses
65 // num is number of joystick button
66 #define VIRTUAL_JOY(num) (SDLK_LAST + 200 + num)
67 
69 const unsigned int KEY_INVALID = SDLK_LAST + 1000;
70 
77 {
78  INPUT_SLOT_LEFT = 0,
79  INPUT_SLOT_RIGHT = 1,
80  INPUT_SLOT_UP = 2,
81  INPUT_SLOT_DOWN = 3,
82  INPUT_SLOT_GUP = 4,
83  INPUT_SLOT_GDOWN = 5,
84  INPUT_SLOT_CAMERA = 6,
85  INPUT_SLOT_DESEL = 7,
86  INPUT_SLOT_ACTION = 8,
87  INPUT_SLOT_NEAR = 9,
88  INPUT_SLOT_AWAY = 10,
89  INPUT_SLOT_NEXT = 11,
90  INPUT_SLOT_HUMAN = 12,
91  INPUT_SLOT_QUIT = 13,
92  INPUT_SLOT_HELP = 14,
93  INPUT_SLOT_PROG = 15,
94  INPUT_SLOT_VISIT = 16,
95  INPUT_SLOT_SPEED05 = 17,
96  INPUT_SLOT_SPEED10 = 18,
97  INPUT_SLOT_SPEED15 = 19,
98  INPUT_SLOT_SPEED20 = 20,
99  INPUT_SLOT_SPEED30 = 21,
100  INPUT_SLOT_SPEED40 = 22,
101  INPUT_SLOT_CAMERA_UP = 23,
102  INPUT_SLOT_CAMERA_DOWN = 24,
103  INPUT_SLOT_PAUSE = 25,
104 
105  INPUT_SLOT_MAX
106 };
107 
113 {
114  JOY_AXIS_SLOT_X,
115  JOY_AXIS_SLOT_Y,
116  JOY_AXIS_SLOT_Z,
117 
118  JOY_AXIS_SLOT_MAX
119 };
unsigned int GetVirtualKey(unsigned int key)
Converts individual codes to virtual keys if needed.
Definition: key.cpp:22
InputSlot
Available slots for input bindings NOTE: When adding new values, remember to also update keyTable in ...
Definition: key.h:76
const unsigned int KEY_INVALID
Special value for invalid key bindings.
Definition: key.h:69
< shift (left or right)
Definition: key.h:53
VirtualKmod
Virtual key codes generated on kmod presses.
Definition: key.h:49
< control (left or right)
Definition: key.h:52
< alt (left or right)
Definition: key.h:54
JoyAxisSlot
Slots for joystick axes inputs.
Definition: key.h:112