USB Keyboard - no bell

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

USB Keyboard - no bell

gjones5555
After getting an USB keyboard, I noticed no beep when hitting the escape
key in Vi.  Plugged in the PS/2 keyboard and I get the beep back!

After doing some googling, it appears that USB keyboards may not support
ascii 0x07 (bel).

Is this covered in the Man pages or is there any way to work around this?

Regards,

Greg

Reply | Threaded
Open this post in threaded view
|

Re: USB Keyboard - no bell

Miod Vallat
> After getting an USB keyboard, I noticed no beep when hitting the escape
> key in Vi.  Plugged in the PS/2 keyboard and I get the beep back!
>
> After doing some googling, it appears that USB keyboards may not support
> ascii 0x07 (bel).

Most keyboards those days do not have built-in beeper devices,
especially in the PC world; however in the OpenBSD kernels, the console
beep is still routed through the keyboard driver, for the old platforms
where the only noise-capable device is the beeper in the keyboard
itself.

When your console keyboard is an USB keyboard, the software glue to have
the beep request sent to the PC speaker is currently missing, so there
is currently no way to work around this situation.

The following diff should fix that.

Miod

Index: dev/isa/pcppi.c
===================================================================
RCS file: /cvs/src/sys/dev/isa/pcppi.c,v
retrieving revision 1.7
diff -N -u -p dev/isa/pcppi.c
--- dev/isa/pcppi.c 12 Feb 2006 20:04:16 -0000 1.7
+++ dev/isa/pcppi.c 29 Sep 2009 04:35:50 -0000
@@ -45,11 +45,12 @@
 #include <dev/ic/i8253reg.h>
 
 #include "pckbd.h"
-#if NPCKBD > 0
+#include "ukbd.h"
+#if NPCKBD > 0 || NUKBD > 0
 #include <dev/ic/pckbcvar.h>
 #include <dev/pckbc/pckbdvar.h>
-
-void pcppi_pckbd_bell(void *, u_int, u_int, u_int, int);
+#include <dev/usb/ukbdvar.h>
+void pcppi_kbd_bell(void *, u_int, u_int, u_int, int);
 #endif
 
 struct pcppi_softc {
@@ -169,10 +170,13 @@ pcppi_attach(parent, self, aux)
 
  sc->sc_bellactive = sc->sc_bellpitch = sc->sc_slp = 0;
 
+ /* Provide a beeper for the keyboard, if there isn't one already. */
 #if NPCKBD > 0
- /* Provide a beeper for the PC Keyboard, if there isn't one already. */
- pckbd_hookup_bell(pcppi_pckbd_bell, sc);
+ pckbd_hookup_bell(pcppi_kbd_bell, sc);
 #endif
+#if NUKBD > 0
+ ukbd_hookup_bell(pcppi_kbd_bell, sc);
+#endif
 
  pa.pa_cookie = sc;
  while (config_found(self, &pa, 0));
@@ -255,9 +259,9 @@ pcppi_bell_stop(arg)
  splx(s);
 }
 
-#if NPCKBD > 0
+#if NPCKBD > 0 || NUKBD > 0
 void
-pcppi_pckbd_bell(arg, pitch, period, volume, poll)
+pcppi_kbd_bell(arg, pitch, period, volume, poll)
  void *arg;
  u_int pitch, period, volume;
  int poll;
@@ -268,4 +272,4 @@ pcppi_pckbd_bell(arg, pitch, period, volume, poll)
  pcppi_bell(arg, volume ? pitch : 0, (period * hz) / 1000,
     poll ? PCPPI_BELL_POLL : 0);
 }
-#endif /* NPCKBD > 0 */
+#endif /* NPCKBD > 0 || NUKBD > 0 */

Reply | Threaded
Open this post in threaded view
|

Re: USB Keyboard - no bell

gjones5555
Miod,

Applied the diff and recompiled current. It works perfectly!!

Thank you,

Greg


Miod Vallat wrote:

>> After getting an USB keyboard, I noticed no beep when hitting the escape
>> key in Vi.  Plugged in the PS/2 keyboard and I get the beep back!
>>
>> After doing some googling, it appears that USB keyboards may not support
>> ascii 0x07 (bel).
>>    
>
> Most keyboards those days do not have built-in beeper devices,
> especially in the PC world; however in the OpenBSD kernels, the console
> beep is still routed through the keyboard driver, for the old platforms
> where the only noise-capable device is the beeper in the keyboard
> itself.
>
> When your console keyboard is an USB keyboard, the software glue to have
> the beep request sent to the PC speaker is currently missing, so there
> is currently no way to work around this situation.
>
> The following diff should fix that.
>
> Miod
>
> Index: dev/isa/pcppi.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/isa/pcppi.c,v
> retrieving revision 1.7
> diff -N -u -p dev/isa/pcppi.c
> --- dev/isa/pcppi.c 12 Feb 2006 20:04:16 -0000  1.7
> +++ dev/isa/pcppi.c 29 Sep 2009 04:35:50 -0000
> @@ -45,11 +45,12 @@
>  #include <dev/ic/i8253reg.h>
>  
>  #include "pckbd.h"
> -#if NPCKBD > 0
> +#include "ukbd.h"
> +#if NPCKBD > 0 || NUKBD > 0
>  #include <dev/ic/pckbcvar.h>
>  #include <dev/pckbc/pckbdvar.h>
> -
> -void   pcppi_pckbd_bell(void *, u_int, u_int, u_int, int);
> +#include <dev/usb/ukbdvar.h>
> +void   pcppi_kbd_bell(void *, u_int, u_int, u_int, int);
>  #endif
>  
>  struct pcppi_softc {
> @@ -169,10 +170,13 @@ pcppi_attach(parent, self, aux)
>  
>     sc->sc_bellactive = sc->sc_bellpitch = sc->sc_slp = 0;
>  
> +   /* Provide a beeper for the keyboard, if there isn't one already. */
>  #if NPCKBD > 0
> -   /* Provide a beeper for the PC Keyboard, if there isn't one already. */
> -   pckbd_hookup_bell(pcppi_pckbd_bell, sc);
> +   pckbd_hookup_bell(pcppi_kbd_bell, sc);
>  #endif
> +#if NUKBD > 0
> +   ukbd_hookup_bell(pcppi_kbd_bell, sc);
> +#endif
>  
>     pa.pa_cookie = sc;
>     while (config_found(self, &pa, 0));
> @@ -255,9 +259,9 @@ pcppi_bell_stop(arg)
>     splx(s);
>  }
>  
> -#if NPCKBD > 0
> +#if NPCKBD > 0 || NUKBD > 0
>  void
> -pcppi_pckbd_bell(arg, pitch, period, volume, poll)
> +pcppi_kbd_bell(arg, pitch, period, volume, poll)
>     void *arg;
>     u_int pitch, period, volume;
>     int poll;
> @@ -268,4 +272,4 @@ pcppi_pckbd_bell(arg, pitch, period, volume, poll)
>     pcppi_bell(arg, volume ? pitch : 0, (period * hz) / 1000,
>         poll ? PCPPI_BELL_POLL : 0);
>  }
> -#endif /* NPCKBD > 0 */
> +#endif /* NPCKBD > 0 || NUKBD > 0 */