1 /*
2 * (c) 2004-2008 The Music Player Daemon Project
3 * http://www.musicpd.org/
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
20 #ifndef COMMAND_H
21 #define COMMAND_H
23 #include "config.h"
25 #include <stddef.h>
27 #ifndef NCMPC_MINI
28 #include <stdio.h>
29 #endif
31 #define MAX_COMMAND_KEYS 3
33 /* commands */
34 typedef enum {
35 CMD_NONE = 0,
36 CMD_PLAY,
37 CMD_SELECT,
38 CMD_SELECT_ALL,
39 CMD_PAUSE,
40 CMD_STOP,
41 CMD_CROP,
42 CMD_TRACK_NEXT,
43 CMD_TRACK_PREVIOUS,
44 CMD_SEEK_FORWARD,
45 CMD_SEEK_BACKWARD,
46 CMD_SHUFFLE,
47 CMD_RANDOM,
48 CMD_CLEAR,
49 CMD_DELETE,
50 CMD_REPEAT,
51 CMD_CROSSFADE,
52 CMD_DB_UPDATE,
53 CMD_VOLUME_UP,
54 CMD_VOLUME_DOWN,
55 CMD_ADD,
56 CMD_SAVE_PLAYLIST,
57 CMD_TOGGLE_FIND_WRAP,
58 CMD_TOGGLE_AUTOCENTER,
59 CMD_SEARCH_MODE,
60 CMD_LIST_PREVIOUS,
61 CMD_LIST_NEXT,
62 CMD_LIST_FIRST,
63 CMD_LIST_LAST,
64 CMD_LIST_NEXT_PAGE,
65 CMD_LIST_PREVIOUS_PAGE,
66 CMD_LIST_FIND,
67 CMD_LIST_FIND_NEXT,
68 CMD_LIST_RFIND,
69 CMD_LIST_RFIND_NEXT,
70 CMD_LIST_MOVE_UP,
71 CMD_LIST_MOVE_DOWN,
72 CMD_MOUSE_EVENT,
73 CMD_SCREEN_UPDATE,
74 CMD_SCREEN_PREVIOUS,
75 CMD_SCREEN_NEXT,
76 CMD_SCREEN_PLAY,
77 CMD_SCREEN_FILE,
78 CMD_SCREEN_ARTIST,
79 CMD_SCREEN_SEARCH,
80 CMD_SCREEN_KEYDEF,
81 CMD_SCREEN_HELP,
82 CMD_SCREEN_LYRICS,
83 CMD_SCREEN_OUTPUTS,
84 CMD_LYRICS_UPDATE,
85 CMD_INTERRUPT,
86 CMD_GO_ROOT_DIRECTORY,
87 CMD_GO_PARENT_DIRECTORY,
88 CMD_VIEW,
89 CMD_LOCATE,
90 CMD_QUIT
91 } command_t;
94 #ifndef NCMPC_MINI
95 /* command definition flags */
96 #define COMMAND_KEY_MODIFIED 0x01
97 #define COMMAND_KEY_CONFLICT 0x02
98 #endif
100 /* write key bindings flags */
101 #define KEYDEF_WRITE_HEADER 0x01
102 #define KEYDEF_WRITE_ALL 0x02
103 #define KEYDEF_COMMENT_ALL 0x04
105 typedef struct {
106 int keys[MAX_COMMAND_KEYS];
107 char flags;
108 command_t command;
109 const char *name;
110 const char *description;
111 } command_definition_t;
113 #ifdef ENABLE_KEYDEF_SCREEN
114 command_definition_t *get_command_definitions(void);
115 #endif
117 command_t find_key_command(int key, command_definition_t *cmds);
119 void command_dump_keys(void);
121 #ifndef NCMPC_MINI
123 int check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
124 int write_key_bindings(FILE *f, int all);
126 #endif
128 const char *key2str(int key);
129 const char *get_key_description(command_t command);
130 const char *get_key_command_name(command_t command);
131 const char *get_key_names(command_t command, int all);
132 command_t get_key_command(int key);
133 command_t get_key_command_from_name(char *name);
134 int assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);
136 command_t get_keyboard_command(void);
138 #endif