# HG changeset patch
# User Paulo Matias <matias@dotbsd.org>
# Date 1231003438 7200
# Node ID 32ed29b04da7ccbd64f917ef9708c1ad0686d0fd
# Parent  faac71eb818d49271e6b9c67392e80deaba44542
Added TOGGLE option to ossmix.

diff -r faac71eb818d -r 32ed29b04da7 cmd/ossmix/ossmix.c
--- a/cmd/ossmix/ossmix.c	Sat Jan 03 15:23:26 2009 -0200
+++ b/cmd/ossmix/ossmix.c	Sat Jan 03 15:23:58 2009 -0200
@@ -741,7 +741,8 @@
 {
   enum {
     RELLEFT = 1,
-    RELRIGHT = 2
+    RELRIGHT = 2,
+    RELTOGGLE = 4
   };
   int ctrl, lefti, righti, dist = 0, vol = 0;
   float left = -1, right = 0;
@@ -801,6 +802,8 @@
     left = 1;
   else if (strcmp (arg, "OFF") == 0 || strcmp (arg, "off") == 0)
     left = 0;
+  else if (strcmp (arg, "TOGGLE") == 0 || strcmp (arg, "toggle") == 0)
+    relative = RELTOGGLE;
   else if ((p = strchr (arg, ':')) != NULL)
     {
       if (sscanf (arg, "%f:%f", &left, &right) != 2)
@@ -853,6 +856,7 @@
         }
       if (relative & RELLEFT) lefti += left;
       if (relative & RELRIGHT) righti += right;
+      if (relative & RELTOGGLE) lefti = !left;
     }
 
   if (lefti < 0) lefti = 0;
diff -r faac71eb818d -r 32ed29b04da7 cmd/ossmix/ossmix.man
--- a/cmd/ossmix/ossmix.man	Sat Jan 03 15:23:26 2009 -0200
+++ b/cmd/ossmix/ossmix.man	Sat Jan 03 15:23:58 2009 -0200
@@ -26,7 +26,8 @@
 their possible values. Currently all controls accept an ON/OFF value, a
 mono value (0 to 100) or a stereo value (left:right where both channel
 volumes can be between 0 and 100). The value can also be expressed in a
-relative form (e.g. +1 to add 1 to the previous volume).
+relative form (e.g. +1 to add 1 to the previous volume). An ON/OFF control
+can also receive a TOGGLE value.
 The following is a sample printout produced by ossmix:
 
 	Selected mixer 0/Creative AudioPCI
