Add some MPD keyboard controls
This commit is contained in:
parent
5f348ccb33
commit
a60bbb9e4f
33
nncmpp.c
33
nncmpp.c
|
@ -1090,6 +1090,8 @@ enum user_action
|
||||||
USER_ACTION_MPD_TOGGLE,
|
USER_ACTION_MPD_TOGGLE,
|
||||||
USER_ACTION_MPD_STOP,
|
USER_ACTION_MPD_STOP,
|
||||||
USER_ACTION_MPD_NEXT,
|
USER_ACTION_MPD_NEXT,
|
||||||
|
USER_ACTION_MPD_VOLUME_UP,
|
||||||
|
USER_ACTION_MPD_VOLUME_DOWN,
|
||||||
|
|
||||||
USER_ACTION_GOTO_ITEM_PREVIOUS,
|
USER_ACTION_GOTO_ITEM_PREVIOUS,
|
||||||
USER_ACTION_GOTO_ITEM_NEXT,
|
USER_ACTION_GOTO_ITEM_NEXT,
|
||||||
|
@ -1139,6 +1141,22 @@ app_process_user_action (enum user_action action)
|
||||||
case USER_ACTION_MPD_NEXT:
|
case USER_ACTION_MPD_NEXT:
|
||||||
MPD_SIMPLE ("next")
|
MPD_SIMPLE ("next")
|
||||||
return true;
|
return true;
|
||||||
|
case USER_ACTION_MPD_VOLUME_UP:
|
||||||
|
if (g_ctx.volume >= 0)
|
||||||
|
{
|
||||||
|
char *volume = xstrdup_printf ("%d", MIN (100, g_ctx.volume + 10));
|
||||||
|
MPD_SIMPLE ("setvol", volume)
|
||||||
|
free (volume);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case USER_ACTION_MPD_VOLUME_DOWN:
|
||||||
|
if (g_ctx.volume >= 0)
|
||||||
|
{
|
||||||
|
char *volume = xstrdup_printf ("%d", MAX (0, g_ctx.volume - 10));
|
||||||
|
MPD_SIMPLE ("setvol", volume)
|
||||||
|
free (volume);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
// TODO: relative seeks
|
// TODO: relative seeks
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -1274,16 +1292,24 @@ static struct binding
|
||||||
g_default_bindings[] =
|
g_default_bindings[] =
|
||||||
{
|
{
|
||||||
{ "Escape", USER_ACTION_QUIT },
|
{ "Escape", USER_ACTION_QUIT },
|
||||||
|
{ "C-l", USER_ACTION_REDRAW },
|
||||||
|
|
||||||
{ "Up", USER_ACTION_GOTO_ITEM_PREVIOUS },
|
{ "Up", USER_ACTION_GOTO_ITEM_PREVIOUS },
|
||||||
{ "Down", USER_ACTION_GOTO_ITEM_NEXT },
|
{ "Down", USER_ACTION_GOTO_ITEM_NEXT },
|
||||||
{ "PageUp", USER_ACTION_GOTO_PAGE_PREVIOUS },
|
{ "PageUp", USER_ACTION_GOTO_PAGE_PREVIOUS },
|
||||||
{ "PageDown", USER_ACTION_GOTO_PAGE_NEXT },
|
{ "PageDown", USER_ACTION_GOTO_PAGE_NEXT },
|
||||||
{ "C-l", USER_ACTION_REDRAW },
|
|
||||||
{ "C-p", USER_ACTION_GOTO_ITEM_PREVIOUS },
|
{ "C-p", USER_ACTION_GOTO_ITEM_PREVIOUS },
|
||||||
{ "C-n", USER_ACTION_GOTO_ITEM_NEXT },
|
{ "C-n", USER_ACTION_GOTO_ITEM_NEXT },
|
||||||
{ "C-b", USER_ACTION_GOTO_PAGE_PREVIOUS },
|
{ "C-b", USER_ACTION_GOTO_PAGE_PREVIOUS },
|
||||||
{ "C-f", USER_ACTION_GOTO_PAGE_NEXT },
|
{ "C-f", USER_ACTION_GOTO_PAGE_NEXT },
|
||||||
// TODO: bindings for MPD control
|
|
||||||
|
// Not sure how to set these up, they're pretty arbitrary so far
|
||||||
|
{ "Left", USER_ACTION_MPD_PREVIOUS },
|
||||||
|
{ "Space", USER_ACTION_MPD_TOGGLE },
|
||||||
|
{ "C-Space", USER_ACTION_MPD_STOP },
|
||||||
|
{ "Right", USER_ACTION_MPD_NEXT },
|
||||||
|
{ "M-PageUp", USER_ACTION_MPD_VOLUME_UP },
|
||||||
|
{ "M-PageDown", USER_ACTION_MPD_VOLUME_DOWN },
|
||||||
{ NULL, USER_ACTION_NONE },
|
{ NULL, USER_ACTION_NONE },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1516,7 +1542,8 @@ mpd_on_events (unsigned subsystems, void *user_data)
|
||||||
(void) user_data;
|
(void) user_data;
|
||||||
struct mpd_client *c = &g_ctx.client;
|
struct mpd_client *c = &g_ctx.client;
|
||||||
|
|
||||||
if (subsystems & (MPD_SUBSYSTEM_PLAYER | MPD_SUBSYSTEM_PLAYLIST))
|
if (subsystems & (MPD_SUBSYSTEM_PLAYER
|
||||||
|
| MPD_SUBSYSTEM_PLAYLIST | MPD_SUBSYSTEM_MIXER))
|
||||||
mpd_request_info ();
|
mpd_request_info ();
|
||||||
else
|
else
|
||||||
mpd_client_idle (c, 0);
|
mpd_client_idle (c, 0);
|
||||||
|
|
Loading…
Reference in New Issue