1 /**\file g_controls.h
2  *\section License
3  * License: GPL
4  * Online License Link: http://www.gnu.org/licenses/gpl.html
5  *
6  *\author Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
7  *\author Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor,
22  * Boston, MA  02110-1301  USA
23  */
24 
25 /**
26  * Common code for game controls
27  */
28 
29 #ifndef LIBCOMMON_CONTROLS_H
30 #define LIBCOMMON_CONTROLS_H
31 
32 #include <api_player.h>
33 
34 // Control identifiers.
35 enum {
36     CTL_SPEED = CTL_FIRST_GAME_CONTROL,
37     //CTL_STRAFE,
38     CTL_LOOK_CENTER,
39     CTL_LOOK_PITCH,     ///< Absolute lookdir pitch.
40     CTL_HEAD_YAW,       ///< Offset applied to viewing direction only (yaw); not body turn angle.
41     CTL_BODY_YAW,       ///< Absolute offset applied to player angle.
42     CTL_FALL_DOWN,
43     CTL_USE,
44     CTL_ATTACK,
45     CTL_JUMP,
46     CTL_WEAPON1,
47     CTL_WEAPON2,
48     CTL_WEAPON3,
49     CTL_WEAPON4,
50     CTL_WEAPON5,
51     CTL_WEAPON6,
52     CTL_WEAPON7,
53     CTL_WEAPON8,
54     CTL_WEAPON9,
55 #if __JDOOM64__
56     CTL_WEAPON10,
57 #endif
58     CTL_WEAPON0,
59     CTL_NEXT_WEAPON,
60     CTL_PREV_WEAPON,
61 #if __JHERETIC__ || __JHEXEN__
62     CTL_USE_ITEM,
63     CTL_NEXT_ITEM,
64     CTL_PREV_ITEM,
65     CTL_PANIC,
66 #endif
67 #if __JHERETIC__
68     CTL_TOME_OF_POWER,
69     CTL_INVISIBILITY,
70     CTL_FLY,
71     CTL_TORCH,
72     CTL_HEALTH,
73     CTL_SUPER_HEALTH,
74     CTL_TELEPORT,
75     CTL_FIREBOMB,
76     CTL_INVULNERABILITY,
77     CTL_EGG,
78 #endif
79 #if __JHEXEN__
80     CTL_FLY,
81     CTL_TORCH,
82     CTL_HEALTH,
83     CTL_MYSTIC_URN,
84     CTL_KRATER,
85     CTL_SPEED_BOOTS,
86     CTL_BLAST_RADIUS,
87     CTL_TELEPORT,
88     CTL_TELEPORT_OTHER,
89     CTL_FIREBOMB,
90     CTL_POISONBAG,
91     CTL_INVULNERABILITY,
92     CTL_DARK_SERVANT,
93     CTL_EGG,
94 #endif
95     CTL_MAP,
96     CTL_MAP_PAN_X,
97     CTL_MAP_PAN_Y,
98     CTL_MAP_ZOOM,
99     CTL_MAP_ZOOM_MAX,
100     CTL_MAP_FOLLOW,
101     CTL_MAP_ROTATE,
102     CTL_MAP_MARK_ADD,
103     CTL_MAP_MARK_CLEAR_ALL,
104     CTL_HUD_SHOW,
105     CTL_SCORE_SHOW,
106     CTL_LOG_REFRESH
107 };
108 
109 // This structure replaced ticcmd as the place where players store the intentions
110 // of their human operators.
111 typedef struct playerbrain_s {
112     float       forwardMove;        // 1.0 for maximum movement
113     float       sideMove;           // 1.0 for maximum movement
114     float       upMove;             // 1.0 for maximum movement
115     int         changeWeapon;       // WT_NOCHANGE, or the weapon to change to
116     int         cycleWeapon;        // +1 or -1
117 #if __JHERETIC__ || __JHEXEN__
118     int         cycleInvItem;       // +1 or -1
119 #endif
120     // Bits:
121     uint        speed : 1;
122     uint        use : 1;
123     uint        lunge : 1;
124     uint        attack : 1;
125     uint        lookCenter : 1;
126     uint        fallDown : 1;
127     uint        jump : 1;
128     uint        mapToggle : 1;
129     uint        mapZoomMax : 1;
130     uint        mapFollow : 1;
131     uint        mapRotate : 1;
132     uint        mapMarkAdd : 1;
133     uint        mapMarkClearAll : 1;
134     uint        hudShow : 1;
135     uint        scoreShow : 1;
136     uint        doReborn: 1; // Set when the player wishes to be reborn.
137 #if __JHERETIC__ || __JHEXEN__
138     uint        useInvItem: 1;
139 #endif
140     uint        logRefresh: 1;
141 } playerbrain_t;
142 
143 #ifdef __cplusplus
144 extern "C" {
145 #endif
146 
147 /**
148  * Register the CVars and CCmds for input/controls.
149  */
150 void        G_ControlRegister(void);
151 
152 void        G_DefineControls(void);
153 void        G_DefaultBindings(void);
154 void        G_RegisterBindClasses(void);
155 
156 dd_bool     G_UsingSharpInput();
157 
158 /**
159  * Reset controls for all local players.
160  */
161 void G_ControlReset(void);
162 
163 float       G_GetLookOffset(int pnum);
164 void        G_ResetLookOffset(int pnum);
165 
166 void        P_PlayerThinkHeadTurning(int pnum, timespan_t ticLength);
167 
168 #ifdef __cplusplus
169 } // extern "C"
170 #endif
171 
172 #endif /* LIBCOMMON_CONTROLS_H */
173