]> icculus.org git repositories - btb/d2x.git/blob - include/cmd.h
command queueing
[btb/d2x.git] / include / cmd.h
1 #ifndef _CMD_H_
2 #define _CMD_H_ 1
3
4
5 void cmd_init(void);
6
7 /* Maximum length for a single command */
8 #define CMD_MAX_LENGTH 2048
9 /* Maximum number of tokens per command */
10 #define CMD_MAX_TOKENS 64
11
12 /* Parse an input string */
13 void cmd_parse(char *input);  // FIXME: make this handle compound statements, add flag for insert/append?
14 void cmd_parsef(char *fmt, ...);
15 /* Add some commands to the queue to be executed */
16 void cmd_enqueue(int insert, char *input);
17 void cmd_enqueuef(int insert, char *fmt, ...);
18 #define cmd_append(input) cmd_enqueue(0, (input))
19 #define cmd_appendf(...) cmd_enqueue(0, __VA_ARGS__)
20 #define cmd_insert(input) cmd_enqueue(1, (input))
21 #define cmd_insertf(...) cmd_enqueue(1, __VA_ARGS__)
22
23
24 /* Attempt to autocomplete an input string */
25 char *cmd_complete(char *input);
26
27 typedef void (*cmd_handler_t)(int argc, char *argv[]);
28
29 void cmd_addcommand(char *cmd_name, cmd_handler_t cmd_func);
30
31
32 /* +/- actions */
33
34 #define CMD_NUM_BUTTONS 2
35
36 typedef enum
37 {
38         CMD_ATTACK,  // Fire primary weapon
39         CMD_ATTACK2, // Fire secondary weapon
40 } cmd_button;
41
42 extern int Console_button_states[CMD_NUM_BUTTONS];
43
44
45 /* execute a bound key's command */
46 int cmd_handle_keybinding(unsigned char key);
47
48
49 #endif /* _CMD_H_ */