NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/56738: ukbd(4): PMFE_AUDIO_VOLUME* event issue, Xorg KeyPress events ...



The following reply was made to PR kern/56738; it has been noted by GNATS.

From: Anthony Mallet <anthony.mallet%laas.fr@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/56738: ukbd(4): PMFE_AUDIO_VOLUME* event issue, Xorg KeyPress events ...
Date: Thu, 3 Mar 2022 23:53:58 +0100

 --Qa0zlsVIL6
 Content-Type: text/plain; charset=us-ascii
 Content-Description: message body text
 Content-Transfer-Encoding: 7bit
 
 So I tried the attached patch and this actually fixes 1/ and 2/ for me.
 
 For 1/, I simply call pmf_event_inject() with NULL as the 'dev'
 parameter, so that the event is actually dispatched to audio(4) that
 has the appropriate callback registered and not to the ukbd itself
 that doesn't care about it. Now audio volume is properly
 muted/adjusted when I press the corresponding keys.
 
 For 2/, I added a IS_SELF flag, that prevents
 ukbd_translate_keycodes() from eating up the keypress event, so that
 it still eventually generates a X KeyPress event that can be caught
 independently of the PMF event.
 
 I added the IS_SELF flag to not change the behaviour for
 trtab_apple_fn[] or trtab_gdium_fn[] translation tables, for which I
 don't know if the keypress event should still be generated in addition
 to the PMF event or not.
 
 Now that 1/ works, I'm still missing 3/: a way to disable this
 behaviour with some user setting, so that the keys do not mess with
 the local audio at all, but only perform some action of my choice.
 Any hint? Adding a new sysctl?
 
 
 --Qa0zlsVIL6
 Content-Type: text/plain;
 	 name="patch-ukbd.c"
 Content-Disposition: inline;
 	 filename="patch-ukbd.c"
 Content-Transfer-Encoding: 7bit
 
 Index: sys/dev/usb/ukbd.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/ukbd.c,v
 retrieving revision 1.153
 diff -u -r1.153 ukbd.c
 --- sys/dev/usb/ukbd.c	11 Oct 2021 00:00:03 -0000	1.153
 +++ sys/dev/usb/ukbd.c	3 Mar 2022 22:36:31 -0000
 @@ -101,6 +101,7 @@
  };
  
  #define IS_PMF	0x8000
 +#define IS_SELF	0x4000
  
  Static const struct ukbd_keycodetrans trtab_apple_fn[] = {
  	{ 0x0c, 0x5d },	/* i -> KP 5 */
 @@ -177,9 +178,9 @@
  #endif
  
  Static const struct ukbd_keycodetrans trtab_generic[] = {
 -	{ 0x7f, IS_PMF | PMFE_AUDIO_VOLUME_TOGGLE },
 -	{ 0x80, IS_PMF | PMFE_AUDIO_VOLUME_UP },
 -	{ 0x81, IS_PMF | PMFE_AUDIO_VOLUME_DOWN },
 +	{ 0x7f, IS_SELF | IS_PMF | PMFE_AUDIO_VOLUME_TOGGLE },
 +	{ 0x80, IS_SELF | IS_PMF | PMFE_AUDIO_VOLUME_UP },
 +	{ 0x81, IS_SELF | IS_PMF | PMFE_AUDIO_VOLUME_DOWN },
  	{ 0x00, 0x00 }
  };
  
 @@ -595,11 +596,12 @@
  				if (tp->from == i) {
  					if (tp->to & IS_PMF) {
  						pmf_event_inject(
 -						    sc->sc_hdev.sc_dev,
 +						    NULL,
  						    tp->to & 0xff);
  					} else
  						setbit(ud->keys, tp->to);
 -					clrbit(ud->keys, i);
 +					if (!(tp->to & IS_SELF))
 +						clrbit(ud->keys, i);
  					break;
  				}
  	}
 
 --Qa0zlsVIL6--
 


Home | Main Index | Thread Index | Old Index