RetroArch
input_defines.h
Go to the documentation of this file.
1 /* RetroArch - A frontend for libretro.
2  * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
3  * Copyright (C) 2011-2017 - Daniel De Matteis
4  *
5  * RetroArch is free software: you can redistribute it and/or modify it under the terms
6  * of the GNU General Public License as published by the Free Software Found-
7  * ation, either version 3 of the License, or (at your option) any later version.
8  *
9  * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  * PURPOSE. See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along with RetroArch.
14  * If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef __INPUT_DEFINES__H
18 #define __INPUT_DEFINES__H
19 
20 #include <stdint.h>
21 #include <string.h>
22 
23 #include <retro_common_api.h>
24 
26 
27 #define MAX_USERS 16
28 
29 #define MAX_INPUT_DEVICES 16
30 
31 #define RARCH_MAX_KEYS 137
32 
33 #define RARCH_FIRST_CUSTOM_BIND 16
34 #define RARCH_FIRST_LIGHTGUN_BIND RARCH_ANALOG_BIND_LIST_END
35 #define RARCH_FIRST_MISC_CUSTOM_BIND RARCH_LIGHTGUN_BIND_LIST_END
36 #define RARCH_FIRST_META_KEY RARCH_CUSTOM_BIND_LIST_END
37 
38 #define RARCH_UNMAPPED 1024
39 
40 /* RetroArch specific bind IDs. */
41 enum
42 {
43  /* Custom binds that extend the scope of RETRO_DEVICE_JOYPAD for
44  * RetroArch specifically.
45  * Analogs (RETRO_DEVICE_ANALOG) */
55 
56  /* Lightgun */
69 
70  /* Turbo */
72 
74 
75  /* Command binds. Not related to game input,
76  * only usable for port 0. */
112 
114 
117 
120 };
121 
123 {
128 };
129 
130 /* Specialized _MOUSE that targets the full screen regardless of viewport.
131  */
132 #define RARCH_DEVICE_MOUSE_SCREEN (RETRO_DEVICE_MOUSE | 0x10000)
133 
134 /* Specialized _POINTER that targets the full screen regardless of viewport.
135  * Should not be used by a libretro implementation as coordinates returned
136  * make no sense.
137  *
138  * It is only used internally for overlays. */
139 #define RARCH_DEVICE_POINTER_SCREEN (RETRO_DEVICE_POINTER | 0x10000)
140 
141 #define RARCH_DEVICE_ID_POINTER_BACK (RETRO_DEVICE_ID_POINTER_PRESSED | 0x10000)
142 
143 /* libretro has 16 buttons from 0-15 (libretro.h)
144  * Analog binds use RETRO_DEVICE_ANALOG, but we follow the same scheme
145  * internally in RetroArch for simplicity, so they are mapped into [16, 23].
146  */
147 
148 #define AXIS_NEG(x) (((uint32_t)(x) << 16) | 0xFFFFU)
149 #define AXIS_POS(x) ((uint32_t)(x) | 0xFFFF0000UL)
150 #define AXIS_NONE 0xFFFFFFFFUL
151 #define AXIS_DIR_NONE 0xFFFFU
152 
153 #define AXIS_NEG_GET(x) (((uint32_t)(x) >> 16) & 0xFFFFU)
154 #define AXIS_POS_GET(x) ((uint32_t)(x) & 0xFFFFU)
155 
156 #define NO_BTN 0xFFFFU
157 
158 #define HAT_UP_SHIFT 15
159 #define HAT_DOWN_SHIFT 14
160 #define HAT_LEFT_SHIFT 13
161 #define HAT_RIGHT_SHIFT 12
162 #define HAT_UP_MASK (1 << HAT_UP_SHIFT)
163 #define HAT_DOWN_MASK (1 << HAT_DOWN_SHIFT)
164 #define HAT_LEFT_MASK (1 << HAT_LEFT_SHIFT)
165 #define HAT_RIGHT_MASK (1 << HAT_RIGHT_SHIFT)
166 #define HAT_MAP(x, hat) ((x & ((1 << 12) - 1)) | hat)
167 
168 #define HAT_MASK (HAT_UP_MASK | HAT_DOWN_MASK | HAT_LEFT_MASK | HAT_RIGHT_MASK)
169 #define GET_HAT_DIR(x) (x & HAT_MASK)
170 #define GET_HAT(x) (x & (~HAT_MASK))
171 
173 
174 #endif
#define RARCH_FIRST_META_KEY
Definition: input_defines.h:36
Definition: input_defines.h:107
Definition: input_defines.h:102
Definition: input_defines.h:96
#define RARCH_FIRST_CUSTOM_BIND
Definition: input_defines.h:33
#define RETRO_BEGIN_DECLS
Definition: retro_common_api.h:41
Definition: input_defines.h:79
Definition: input_defines.h:91
Definition: input_defines.h:104
Definition: input_defines.h:54
Definition: input_defines.h:103
Definition: input_defines.h:119
Definition: input_defines.h:99
Definition: input_defines.h:127
Definition: input_defines.h:50
Definition: input_defines.h:98
Definition: input_defines.h:63
Definition: input_defines.h:111
Definition: input_defines.h:81
Definition: input_defines.h:85
Definition: input_defines.h:62
Definition: input_defines.h:105
Definition: input_defines.h:59
Definition: input_defines.h:58
Definition: input_defines.h:66
Definition: input_defines.h:80
Definition: input_defines.h:92
Definition: input_defines.h:64
Definition: input_defines.h:95
Definition: input_defines.h:57
Definition: input_defines.h:125
Definition: input_defines.h:116
Definition: input_defines.h:93
Definition: input_defines.h:53
Definition: input_defines.h:49
Definition: input_defines.h:94
Definition: input_defines.h:90
Definition: input_defines.h:60
Definition: input_defines.h:88
Definition: input_defines.h:46
Definition: input_defines.h:101
Definition: input_defines.h:113
#define RETRO_END_DECLS
Definition: retro_common_api.h:42
Definition: input_defines.h:48
Definition: input_defines.h:77
Definition: input_defines.h:115
Definition: input_defines.h:71
Definition: input_defines.h:118
Definition: input_defines.h:87
Definition: input_defines.h:68
Definition: input_defines.h:82
Definition: input_defines.h:83
analog_dpad_mode
Definition: input_defines.h:122
Definition: input_defines.h:78
Definition: input_defines.h:47
Definition: input_defines.h:51
Definition: input_defines.h:126
Definition: input_defines.h:108
Definition: input_defines.h:124
#define RARCH_FIRST_LIGHTGUN_BIND
Definition: input_defines.h:34
Definition: input_defines.h:109
Definition: input_defines.h:100
Definition: input_defines.h:106
Definition: input_defines.h:67
Definition: input_defines.h:61
Definition: input_defines.h:97
Definition: input_defines.h:84
#define RARCH_FIRST_MISC_CUSTOM_BIND
Definition: input_defines.h:35
Definition: input_defines.h:86
Definition: input_defines.h:52
Definition: input_defines.h:110
Definition: input_defines.h:73
Definition: input_defines.h:89
Definition: input_defines.h:65