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-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.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_keycode.h>
29 
30 // TODO: This is a bit ugly hack
31 #define SDLK_LAST (SDLK_SCANCODE_MASK << 1)
32 
33 /* Key definitions are specially defined here so that it is clear in other parts of the code
34  that these are used. It is to avoid having SDL-related enum values or #defines lying around
35  unchecked. With this approach it will be easier to maintain the code later on. */
36 
37 // Key symbol defined as concatenation to SDLK_...
38 // If need arises, it can be changed to custom function or anything else
39 #define KEY(x) SDLK_ ## x
40 
41 
42 // Key modifier defined as concatenation to KMOD_...
43 // If need arises, it can be changed to custom function or anything else
44 #define KEY_MOD(x) KMOD_ ## x
45 
53 {
54  VIRTUAL_KMOD_CTRL = SDLK_LAST + 100,
55  VIRTUAL_KMOD_SHIFT = SDLK_LAST + 101,
56  VIRTUAL_KMOD_ALT = SDLK_LAST + 102,
57  VIRTUAL_KMOD_GUI = SDLK_LAST + 103
58 };
59 
60 // Just syntax sugar
61 // So it is the same as other macros
62 #define VIRTUAL_KMOD(x) VIRTUAL_KMOD_ ## x
63 
65 unsigned int GetVirtualKey(unsigned int key);
66 
67 // Virtual key code generated on joystick button presses
68 // num is number of joystick button
69 #define VIRTUAL_JOY(num) (SDLK_LAST + 200 + num)
70 
72 const unsigned int KEY_INVALID = SDLK_LAST + 1000;
73 
80 {
81  INPUT_SLOT_LEFT,
82  INPUT_SLOT_RIGHT,
83  INPUT_SLOT_UP,
84  INPUT_SLOT_DOWN,
85  INPUT_SLOT_GUP,
86  INPUT_SLOT_GDOWN,
87  INPUT_SLOT_CAMERA,
88  INPUT_SLOT_DESEL,
89  INPUT_SLOT_ACTION,
90  INPUT_SLOT_CAM_LEFT,
91  INPUT_SLOT_CAM_RIGHT,
92  INPUT_SLOT_CAM_UP,
93  INPUT_SLOT_CAM_DOWN,
94  INPUT_SLOT_CAM_NEAR,
95  INPUT_SLOT_CAM_AWAY,
96  INPUT_SLOT_CAM_ALT,
97  INPUT_SLOT_NEXT,
98  INPUT_SLOT_HUMAN,
99  INPUT_SLOT_QUIT,
100  INPUT_SLOT_HELP,
101  INPUT_SLOT_PROG,
102  INPUT_SLOT_VISIT,
103  INPUT_SLOT_SPEED05,
104  INPUT_SLOT_SPEED10,
105  INPUT_SLOT_SPEED15,
106  INPUT_SLOT_SPEED20,
107  INPUT_SLOT_SPEED30,
108  INPUT_SLOT_SPEED40,
109  INPUT_SLOT_SPEED60,
110  INPUT_SLOT_PAUSE,
111  INPUT_SLOT_CMDLINE,
112 
113  INPUT_SLOT_MAX
114 };
115 
121 {
122  JOY_AXIS_SLOT_X,
123  JOY_AXIS_SLOT_Y,
124  JOY_AXIS_SLOT_Z,
125  JOY_AXIS_SLOT_CAM_X,
126  JOY_AXIS_SLOT_CAM_Y,
127  JOY_AXIS_SLOT_CAM_Z,
128 
129  JOY_AXIS_SLOT_MAX
130 };
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:79
const unsigned int KEY_INVALID
Special value for invalid key bindings.
Definition: key.h:72
< shift (left or right)
Definition: key.h:56
VirtualKmod
Virtual key codes generated on kmod presses.
Definition: key.h:52
< control (left or right)
Definition: key.h:55
< alt (left or right)
Definition: key.h:57
JoyAxisSlot
Slots for joystick axes inputs.
Definition: key.h:120