1 /** @file g_eventsequence.h  Input (keyboard) event sequences.
2  *
3  * An "event sequence" is a chain of two or more keyboard input events which
4  * when entered in-sequence trigger a callback when the last event of that
5  * sequence is received.
6  *
7  * @ingroup libcommon
8  *
9  * @author Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
10  * @author Copyright © 2005-2014 Daniel Swanson <danij@dengine.net>
11  * @author Copyright © 1999 Activision
12  * @author Copyright © 1993-1996 by id Software, Inc.
13  *
14  * @par License
15  * GPL: http://www.gnu.org/licenses/gpl.html
16  *
17  * <small>This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by the
19  * Free Software Foundation; either version 2 of the License, or (at your
20  * option) any later version. This program is distributed in the hope that it
21  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
22  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
23  * Public License for more details. You should have received a copy of the GNU
24  * General Public License along with this program; if not, write to the Free
25  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26  * 02110-1301 USA</small>
27  */
28 
29 #ifndef LIBCOMMON_EVENTSEQUENCE_H
30 #define LIBCOMMON_EVENTSEQUENCE_H
31 
32 #include "doomsday.h"
33 
34 #if __cplusplus
35 extern "C" {
36 #endif
37 
38 /**
39  * Event sequence arguments (passed to the callback handler).
40  */
41 typedef int EventSequenceArg;
42 
43 /**
44  * Event sequence callback handler.
45  */
46 typedef int (*eventsequencehandler_t) (int player, EventSequenceArg const *args, int numArgs);
47 
48 // Initialize this subsystem.
49 void G_InitEventSequences(void);
50 
51 // Shutdown this subsystem.
52 void G_ShutdownEventSequences(void);
53 
54 /**
55  * Responds to an input event if determined to be part of a known event sequence.
56  *
57  * @param ev  Input event to be processed.
58  * @return  @c true= input event @a ev was 'eaten'.
59  */
60 int G_EventSequenceResponder(event_t *ev);
61 
62 /**
63  * Add a new event sequence.
64  *
65  * @param sequence  Text description of the sequence.
66  * @param callback  Handler function to be called upon sequence completion.
67  */
68 void G_AddEventSequence(char const *sequence, eventsequencehandler_t callback);
69 
70 /**
71  * Add a new event sequence.
72  *
73  * @param sequence     Text description of the sequence.
74  * @param cmdTemplate  Templated console command to be executed upon sequence completion.
75  */
76 void G_AddEventSequenceCommand(char const *sequence, char const *commandTemplate);
77 
78 #if __cplusplus
79 } // extern "C"
80 #endif
81 
82 #endif  // LIBCOMMON_EVENTSEQUENCE_H
83