mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-03 23:28:58 +00:00
vt: Add devctl message for bells
Generate VT events when the bell beeps. When coupled with disabling the
bell,this allows custom bells to be rung when we'd otherwise beep.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D32656
(cherry picked from commit 4ac3d08a96
)
This commit is contained in:
parent
534fb4b8ae
commit
a82d7aeb3f
|
@ -598,6 +598,15 @@ Notification of a filesystem being unmounted.
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -column "System" "Subsystem" "1234567" -compact
|
.Bl -column "System" "Subsystem" "1234567" -compact
|
||||||
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
|
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
|
||||||
|
.It Li VT Ta BELL Ta RING Ta
|
||||||
|
Notifcation that the console bell has run.
|
||||||
|
See
|
||||||
|
.Xr vt 4
|
||||||
|
for details.
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
.Bl -column "System" "Subsystem" "1234567" -compact
|
||||||
|
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
|
||||||
.It Li ZFS Ta ZFS Ta Ta
|
.It Li ZFS Ta ZFS Ta Ta
|
||||||
Events about the ZFS subsystem.
|
Events about the ZFS subsystem.
|
||||||
See
|
See
|
||||||
|
|
|
@ -297,6 +297,20 @@ console fonts
|
||||||
.It Pa /usr/share/vt/keymaps/*.kbd
|
.It Pa /usr/share/vt/keymaps/*.kbd
|
||||||
keyboard layouts
|
keyboard layouts
|
||||||
.El
|
.El
|
||||||
|
.Sh DEVCTL MESSAGES
|
||||||
|
.Bl -column "System" "Subsystem" "1234567" -compact
|
||||||
|
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
|
||||||
|
.It Li VT Ta BELL Ta RING Ta
|
||||||
|
Notifcation that the console bell has run.
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
.Bl -column "Variable" "Meaning" -compact
|
||||||
|
.Sy "Variable" Ta Sy "Meaning"
|
||||||
|
.It Li duration_ms Ta Length of time the bell was requested to ring in milliseconds.
|
||||||
|
.It Li enabled Ta true or false indicating whether or not the bell was enabled when rung.
|
||||||
|
.It Li hz Ta Tone that was requested in Hz.
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
.Sh EXAMPLES
|
.Sh EXAMPLES
|
||||||
This example changes the default color of normal text to green on a
|
This example changes the default color of normal text to green on a
|
||||||
black background, or black on a green background when reversed.
|
black background, or black on a green background when reversed.
|
||||||
|
|
|
@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/consio.h>
|
#include <sys/consio.h>
|
||||||
|
#include <sys/devctl.h>
|
||||||
#include <sys/eventhandler.h>
|
#include <sys/eventhandler.h>
|
||||||
#include <sys/fbio.h>
|
#include <sys/fbio.h>
|
||||||
#include <sys/font.h>
|
#include <sys/font.h>
|
||||||
|
@ -52,6 +53,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/random.h>
|
#include <sys/random.h>
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
|
#include <sys/sbuf.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/terminal.h>
|
#include <sys/terminal.h>
|
||||||
|
|
||||||
|
@ -1091,12 +1093,35 @@ vt_allocate_keyboard(struct vt_device *vd)
|
||||||
return (idx0);
|
return (idx0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DEVCTL_LEN 64
|
||||||
|
static void
|
||||||
|
vtterm_devctl(bool enabled, int hz, sbintime_t duration)
|
||||||
|
{
|
||||||
|
struct sbuf sb;
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
buf = malloc(DEVCTL_LEN, M_VT, M_NOWAIT);
|
||||||
|
if (buf == NULL)
|
||||||
|
return;
|
||||||
|
sbuf_new(&sb, buf, DEVCTL_LEN, SBUF_FIXEDLEN);
|
||||||
|
sbuf_printf(&sb, "enabled=%s hz=%d duration_ms=%d",
|
||||||
|
enabled ? "true" : "false", hz, (int)(duration / SBT_1MS));
|
||||||
|
sbuf_finish(&sb);
|
||||||
|
if (sbuf_error(&sb) == 0)
|
||||||
|
devctl_notify("VT", "BELL", "RING", sbuf_data(&sb));
|
||||||
|
sbuf_delete(&sb);
|
||||||
|
free(buf, M_VT);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vtterm_bell(struct terminal *tm)
|
vtterm_bell(struct terminal *tm)
|
||||||
{
|
{
|
||||||
struct vt_window *vw = tm->tm_softc;
|
struct vt_window *vw = tm->tm_softc;
|
||||||
struct vt_device *vd = vw->vw_device;
|
struct vt_device *vd = vw->vw_device;
|
||||||
|
|
||||||
|
vtterm_devctl(vt_enable_bell, vw->vw_bell_pitch,
|
||||||
|
vw->vw_bell_duration);
|
||||||
|
|
||||||
if (!vt_enable_bell)
|
if (!vt_enable_bell)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1113,10 +1138,8 @@ vtterm_bell(struct terminal *tm)
|
||||||
static void
|
static void
|
||||||
vtterm_beep(struct terminal *tm, u_int param)
|
vtterm_beep(struct terminal *tm, u_int param)
|
||||||
{
|
{
|
||||||
u_int freq, period;
|
u_int freq;
|
||||||
|
sbintime_t period;
|
||||||
if (!vt_enable_bell)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((param == 0) || ((param & 0xffff) == 0)) {
|
if ((param == 0) || ((param & 0xffff) == 0)) {
|
||||||
vtterm_bell(tm);
|
vtterm_bell(tm);
|
||||||
|
@ -1126,6 +1149,11 @@ vtterm_beep(struct terminal *tm, u_int param)
|
||||||
period = ((param >> 16) & 0xffff) * SBT_1MS;
|
period = ((param >> 16) & 0xffff) * SBT_1MS;
|
||||||
freq = 1193182 / (param & 0xffff);
|
freq = 1193182 / (param & 0xffff);
|
||||||
|
|
||||||
|
vtterm_devctl(vt_enable_bell, freq, period);
|
||||||
|
|
||||||
|
if (!vt_enable_bell)
|
||||||
|
return;
|
||||||
|
|
||||||
sysbeep(freq, period);
|
sysbeep(freq, period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue