Currently audio hotkeys keys invoke the audio driver code to
raise/lower the volume. The hot key is not consumed, and is send to
X which generates XF86XK_Audio{Lower,Raise}Volume, which in turn
are consumed by programs, which in turn change the volume a second
time, and we end up with a messed volume. Furthermore hot keys are
auto-repeated in X but on in the wskbd layer, which makes the
volume changes even more confusing.

IMO, we have to chose: either hot keys are consumed by the kernel
to adjust the volume or they are passed to X.

The diff below, is to make hot keys adjust the volume without
propagating events to X.

This can be tested on non-thinkpad and non-asus laptops. For
instance start a video in mplayer and press the hot-keys; with this
diff hot keys should adjust the hardware volume only instead of
both the hardware volume and the mplayer softvol.

Comments? OK?

-- Alexandre

Index: pckbc/pckbd.c
===================================================================
RCS file: /cvs/src/sys/dev/pckbc/pckbd.c,v
retrieving revision 1.32
diff -u -p -r1.32 pckbd.c
--- pckbc/pckbd.c       10 Aug 2012 17:49:31 -0000      1.32
+++ pckbc/pckbd.c       25 Nov 2012 18:54:06 -0000
@@ -902,6 +902,13 @@ pckbd_input(void *vsc, int data)
 
        rc = pckbd_decode(sc->id, data, &type, &key);
 
+       /*
+        * Pass audio keys to wskbd_input and discard them.
+        */
+       if (rc != 0 && (key == 160 || key == 174 || key == 176)) {
+               wskbd_input(sc->sc_wskbddev, type, key);
+               return;
+       }
 #ifdef WSDISPLAY_COMPAT_RAWKBD
        if (sc->rawkbd) {
                sc->sc_rawbuf[sc->sc_rawcnt++] = (char)data;
@@ -911,12 +918,7 @@ pckbd_input(void *vsc, int data)
                            sc->sc_rawcnt);
                        sc->sc_rawcnt = 0;
                }
-
-               /*
-                * Pass audio keys to wskbd_input anyway.
-                */
-               if (rc == 0 || (key != 160 && key != 174 && key != 176))
-                       return;
+               return;
        }
 #endif
        if (rc != 0)
Index: wscons/wskbd.c
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wskbd.c,v
retrieving revision 1.71
diff -u -p -r1.71 wskbd.c
--- wscons/wskbd.c      17 Oct 2012 00:48:23 -0000      1.71
+++ wscons/wskbd.c      25 Nov 2012 18:54:07 -0000
@@ -1648,11 +1648,11 @@ wskbd_translate(struct wskbd_internal *i
                case KS_AudioMute:
                        workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
                            (void *)(long)0, (void *)(int)1);
-                       break;
+                       return (0);
                case KS_AudioLower:
                        workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
                            (void *)(long)-1, (void*)(int)1);
-                       break;
+                       return (0);
                case KS_AudioRaise:
                        workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
                            (void *)(long)1, (void*)(int)1);

Reply via email to