summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2013-07-07 15:54:23 +0200
committerLars-Dominik Braun <lars@6xq.net>2013-07-07 15:54:23 +0200
commit02b89aa2d2e0df87cb51bae8ffcbfb6439e474dc (patch)
tree7baec4fcdb02ee926af4947513ae9dad2697d503
parentf6df7d7e510f2d8879ec54dce32fee2b691dc32d (diff)
downloadpianobar-windows-02b89aa2d2e0df87cb51bae8ffcbfb6439e474dc.tar.gz
pianobar-windows-02b89aa2d2e0df87cb51bae8ffcbfb6439e474dc.tar.bz2
pianobar-windows-02b89aa2d2e0df87cb51bae8ffcbfb6439e474dc.zip
Add keyboard shortcut to reset volume
Closes #377.
-rw-r--r--contrib/config-example1
-rw-r--r--contrib/pianobar.14
-rw-r--r--src/settings.h7
-rw-r--r--src/ui_act.c18
-rw-r--r--src/ui_act.h1
-rw-r--r--src/ui_dispatch.h2
6 files changed, 26 insertions, 7 deletions
diff --git a/contrib/config-example b/contrib/config-example
index 4958e66..b1648fd 100644
--- a/contrib/config-example
+++ b/contrib/config-example
@@ -37,6 +37,7 @@
#act_stationselectquickmix = x
#act_voldown = (
#act_volup = )
+#act_volreset = ^
# Misc
#audio_quality = low
diff --git a/contrib/pianobar.1 b/contrib/pianobar.1
index 5efaca1..490ee23 100644
--- a/contrib/pianobar.1
+++ b/contrib/pianobar.1
@@ -162,6 +162,10 @@ with 'a' or select none with 'n'.
Decrease volume.
.TP
+.B act_volreset = ^
+Reset volume.
+
+.TP
.B act_volup = )
Increase volume.
diff --git a/src/settings.h b/src/settings.h
index 819f8cb..aad1fc4 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -57,10 +57,11 @@ typedef enum {
BAR_KS_MANAGESTATION = 23,
BAR_KS_PLAYPAUSE2 = 24,
BAR_KS_CREATESTATIONFROMSONG = 25,
- BAR_KS_PLAY = 26,
- BAR_KS_PAUSE = 27,
+ BAR_KS_PLAY = 26,
+ BAR_KS_PAUSE = 27,
+ BAR_KS_VOLRESET = 28,
/* insert new shortcuts _before_ this element and increase its value */
- BAR_KS_COUNT = 28,
+ BAR_KS_COUNT = 29,
} BarKeyShortcutId_t;
#define BAR_KS_DISABLED '\x00'
diff --git a/src/ui_act.c b/src/ui_act.c
index 0f73018..270c1f5 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -647,20 +647,30 @@ BarUiActCallback(BarUiActBookmark) {
}
}
+static void BarUiActUpdateScale (BarApp_t *app) {
+ /* FIXME: assuming unsigned integer store is atomic operation */
+ app->player.scale = BarPlayerCalcScale (app->player.gain + app->settings.volume);
+}
+
/* decrease volume
*/
BarUiActCallback(BarUiActVolDown) {
--app->settings.volume;
- /* FIXME: assuming unsigned integer store is atomic operation */
- app->player.scale = BarPlayerCalcScale (app->player.gain + app->settings.volume);
+ BarUiActUpdateScale (app);
}
/* increase volume
*/
BarUiActCallback(BarUiActVolUp) {
++app->settings.volume;
- /* FIXME: assuming unsigned integer store is atomic operation */
- app->player.scale = BarPlayerCalcScale (app->player.gain + app->settings.volume);
+ BarUiActUpdateScale (app);
+}
+
+/* reset volume
+ */
+BarUiActCallback(BarUiActVolReset) {
+ app->settings.volume = 0;
+ BarUiActUpdateScale (app);
}
/* manage station (remove seeds or feedback)
diff --git a/src/ui_act.h b/src/ui_act.h
index 3e6c4c5..bd2cf88 100644
--- a/src/ui_act.h
+++ b/src/ui_act.h
@@ -60,5 +60,6 @@ BarUiActCallback(BarUiActBookmark);
BarUiActCallback(BarUiActVolDown);
BarUiActCallback(BarUiActVolUp);
BarUiActCallback(BarUiActManageStation);
+BarUiActCallback(BarUiActVolReset);
#endif /* _UI_ACT_H */
diff --git a/src/ui_dispatch.h b/src/ui_dispatch.h
index 6b96ae3..ca8a292 100644
--- a/src/ui_dispatch.h
+++ b/src/ui_dispatch.h
@@ -101,6 +101,8 @@ static const BarUiDispatchAction_t dispatchActions[BAR_KS_COUNT] = {
"act_songplay"},
{'S', BAR_DC_GLOBAL | BAR_DC_STATION, BarUiActPause, "pause playback",
"act_songpause"},
+ {'^', BAR_DC_GLOBAL, BarUiActVolReset, "reset volume",
+ "act_volreset"},
};
#include <piano.h>