1 #include <lirc/lirc_client.h>
2 #include "lirc.h"
4 static struct lirc_config *lc = NULL;
5 static int lirc_socket = 0;
7 int ncmpc_lirc_open()
8 {
9 char prog[] = "ncmpc";
11 if ((lirc_socket = lirc_init(prog, 0)) == -1)
12 return -1;
14 if (lirc_readconfig(NULL, &lc, NULL)) {
15 lirc_deinit();
16 return -1;
17 }
19 return lirc_socket;
20 }
22 void ncmpc_lirc_close()
23 {
24 if (lc)
25 lirc_freeconfig(lc);
26 lirc_deinit();
27 }
29 command_t ncmpc_lirc_get_command()
30 {
31 char *code = NULL, *cmd = NULL;
33 if (lirc_nextcode(&code) != 0)
34 return CMD_NONE;
36 if (lirc_code2char(lc, code, &cmd) != 0)
37 return CMD_NONE;
39 if (!cmd)
40 return CMD_NONE;
42 return get_key_command_from_name(cmd);
43 }