1 #pragma once
2 
3 //********************************************************************************************
4 //*
5 //*    This file is part of Egoboo.
6 //*
7 //*    Egoboo is free software: you can redistribute it and/or modify it
8 //*    under the terms of the GNU General Public License as published by
9 //*    the Free Software Foundation, either version 3 of the License, or
10 //*    (at your option) any later version.
11 //*
12 //*    Egoboo is distributed in the hope that it will be useful, but
13 //*    WITHOUT ANY WARRANTY; without even the implied warranty of
14 //*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 //*    General Public License for more details.
16 //*
17 //*    You should have received a copy of the GNU General Public License
18 //*    along with Egoboo.  If not, see <http://www.gnu.org/licenses/>.
19 //*
20 //********************************************************************************************
21 
22 /// @file file_formats/controls_file.h
23 /// @details routines for reading and writing the file controls.txt and "scancode.txt"
24 
25 #include "egoboo_typedef.h"
26 
27 #include "input.h"
28 
29 #if defined(__cplusplus)
30 extern "C"
31 {
32 #endif
33 
34 //--------------------------------------------------------------------------------------------
35 //--------------------------------------------------------------------------------------------
36 
37 /// All the possible game actions that can be triggered from an input device
38     enum e_input_controls
39     {
40         CONTROL_JUMP = 0,
41         CONTROL_LEFT_USE,
42         CONTROL_LEFT_GET,
43         CONTROL_LEFT_PACK,
44         CONTROL_RIGHT_USE,
45         CONTROL_RIGHT_GET,
46         CONTROL_RIGHT_PACK,
47         CONTROL_MESSAGE,
48         CONTROL_CAMERA_LEFT,
49         CONTROL_CAMERA_RIGHT,
50         CONTROL_CAMERA_IN,
51         CONTROL_CAMERA_OUT,
52         CONTROL_UP,
53         CONTROL_DOWN,
54         CONTROL_LEFT,
55         CONTROL_RIGHT,
56         CONTROL_COMMAND_COUNT,
57 
58         // Aliases
59         CONTROL_CAMERA = CONTROL_MESSAGE,
60         CONTROL_BEGIN  = CONTROL_JUMP,
61         CONTROL_END    = CONTROL_RIGHT
62     };
63 
64 /// All the possible game actions that be assiciated with the keyboard
65     enum e_keyboard_controls
66     {
67         KEY_JUMP = 0,
68         KEY_LEFT_USE,
69         KEY_LEFT_GET,
70         KEY_LEFT_PACK,
71         KEY_RIGHT_USE,
72         KEY_RIGHT_GET,
73         KEY_RIGHT_PACK,
74         KEY_MESSAGE,
75         KEY_CAMERA_LEFT,
76         KEY_CAMERA_RIGHT,
77         KEY_CAMERA_IN,
78         KEY_CAMERA_OUT,
79         KEY_UP,
80         KEY_DOWN,
81         KEY_LEFT,
82         KEY_RIGHT,
83 
84         // Aliases
85         KEY_CONTROL_BEGIN = KEY_JUMP,
86         KEY_CONTROL_END   = KEY_RIGHT
87     };
88 
89 /// All the possible game actions that be assiciated with the mouse
90     enum e_mouse_controls
91     {
92         MOS_JUMP = 0,
93         MOS_LEFT_USE,
94         MOS_LEFT_GET,
95         MOS_LEFT_PACK,
96         MOS_RIGHT_USE,
97         MOS_RIGHT_GET,
98         MOS_RIGHT_PACK,
99         MOS_CAMERA,
100 
101         // Aliases
102         MOS_CONTROL_BEGIN = MOS_JUMP,
103         MOS_CONTROL_END   = MOS_CAMERA
104     };
105 
106 /// All the possible game actions that be assiciated a joystick
107     enum e_joystick_controls
108     {
109         JOY_JUMP = 0,
110         JOY_LEFT_USE,
111         JOY_LEFT_GET,
112         JOY_LEFT_PACK,
113         JOY_RIGHT_USE,
114         JOY_RIGHT_GET,
115         JOY_RIGHT_PACK,
116         JOY_CAMERA,
117 
118         // Aliases
119         JOY_CONTROL_BEGIN = JOY_JUMP,
120         JOY_CONTROL_END   = JOY_CAMERA
121     };
122 
123 //--------------------------------------------------------------------------------------------
124 
125 /// the basic definition of a single control
126     struct s_control
127     {
128         Uint32 tag;
129         bool_t is_key;
130     };
131     typedef struct s_control control_t;
132 
133 //--------------------------------------------------------------------------------------------
134 
135 /// The mapping between the inputs detected by SDL and the device's in-game function
136     struct s_device_controls
137     {
138         size_t    count;
139         Uint32    device;
140         control_t control[CONTROL_COMMAND_COUNT];
141     };
142     typedef struct s_device_controls device_controls_t;
143 
144 //--------------------------------------------------------------------------------------------
145 //--------------------------------------------------------------------------------------------
146 
147     extern device_controls_t controls[INPUT_DEVICE_END + MAXJOYSTICK];
148 
149     extern Uint32 input_device_count;
150 
151 //--------------------------------------------------------------------------------------------
152 //--------------------------------------------------------------------------------------------
153 
154     bool_t input_settings_load_vfs( const char *szFilename );
155     bool_t input_settings_save_vfs( const char* szFilename );
156 
157 //--------------------------------------------------------------------------------------------
158 //--------------------------------------------------------------------------------------------
159 
160 #if defined(__cplusplus)
161 }
162 #endif
163 
164 //--------------------------------------------------------------------------------------------
165 //--------------------------------------------------------------------------------------------
166 
167 #define _controls_file_h