1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2017 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
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.
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.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "ncmpc_curses.h"
33 translate_key(int key
)
35 if (key
== ERR
|| key
== '\0')
40 return CMD_MOUSE_EVENT
;
43 return get_key_command(key
);
47 get_keyboard_command(void)
49 return translate_key(wgetch(screen
.main_window
.w
));
53 keyboard_event(gcc_unused GIOChannel
*source
,
54 gcc_unused GIOCondition condition
,
55 gcc_unused gpointer data
)
59 command_t cmd
= get_keyboard_command();
61 if (!do_input_event(cmd
))
71 GIOChannel
*channel
= g_io_channel_unix_new(STDIN_FILENO
);
72 g_io_add_watch(channel
, G_IO_IN
, keyboard_event
, NULL
);
73 g_io_channel_unref(channel
);
77 keyboard_unread(int key
)
79 command_t cmd
= translate_key(key
);