kdrive: move bell ringing into an OS function
Move the bell into an OS function, and use that if it's declared; else, fall back to using the driver's function. Remove the Linux keyboard bell function; just move it into the OS layer. Use named initialisers when converting the old structures, and eliminate unused functions.
This commit is contained in:
parent
96e32805d1
commit
738d2e8817
|
@ -34,34 +34,8 @@ EphyrInit (void)
|
|||
return hostx_init();
|
||||
}
|
||||
|
||||
static void
|
||||
EphyrEnable (void)
|
||||
{
|
||||
EPHYR_DBG("mark");
|
||||
}
|
||||
|
||||
static Bool
|
||||
EphyrSpecialKey (KeySym sym)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
EphyrDisable (void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
EphyrFini (void)
|
||||
{
|
||||
}
|
||||
|
||||
KdOsFuncs EphyrOsFuncs = {
|
||||
EphyrInit,
|
||||
EphyrEnable,
|
||||
EphyrSpecialKey,
|
||||
EphyrDisable,
|
||||
EphyrFini,
|
||||
ephyrPoll
|
||||
.Init = EphyrInit,
|
||||
.pollEvents = ephyrPoll,
|
||||
};
|
||||
|
||||
|
|
|
@ -790,11 +790,6 @@ LinuxKeyboardInit (KdKeyboardInfo *ki)
|
|||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
LinuxKeyboardFini (KdKeyboardInfo *ki)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
LinuxKeyboardLeds (KdKeyboardInfo *ki, int leds)
|
||||
{
|
||||
|
@ -804,29 +799,10 @@ LinuxKeyboardLeds (KdKeyboardInfo *ki, int leds)
|
|||
ioctl ((int)ki->driverPrivate, KDSETLED, leds & 7);
|
||||
}
|
||||
|
||||
static void
|
||||
LinuxKeyboardBell (KdKeyboardInfo *ki, int volume, int pitch, int duration)
|
||||
{
|
||||
if (!ki)
|
||||
return;
|
||||
|
||||
if (volume && pitch)
|
||||
{
|
||||
ioctl((int)ki->driverPrivate, KDMKTONE,
|
||||
((1193190 / pitch) & 0xffff) |
|
||||
(((unsigned long)duration *
|
||||
volume / 50) << 16));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
KdKeyboardDriver LinuxKeyboardDriver = {
|
||||
"keyboard",
|
||||
LinuxKeyboardInit,
|
||||
LinuxKeyboardEnable,
|
||||
LinuxKeyboardLeds,
|
||||
LinuxKeyboardBell,
|
||||
LinuxKeyboardDisable,
|
||||
LinuxKeyboardFini,
|
||||
NULL,
|
||||
.Init = LinuxKeyboardInit,
|
||||
.Enable = LinuxKeyboardEnable,
|
||||
.Leds = LinuxKeyboardLeds,
|
||||
.Disable = LinuxKeyboardDisable,
|
||||
};
|
||||
|
|
|
@ -373,26 +373,6 @@ LinuxEnable (void)
|
|||
enabled = TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
LinuxSpecialKey (KeySym sym)
|
||||
{
|
||||
struct vt_stat vts;
|
||||
int con;
|
||||
|
||||
if (XK_F1 <= sym && sym <= XK_F12)
|
||||
{
|
||||
con = sym - XK_F1 + 1;
|
||||
memset (&vts, '\0', sizeof (vts)); /* valgrind */
|
||||
ioctl (LinuxConsoleFd, VT_GETSTATE, &vts);
|
||||
if (con != vts.v_active && (vts.v_state & (1 << con)))
|
||||
{
|
||||
ioctl (LinuxConsoleFd, VT_ACTIVATE, con);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
LinuxDisable (void)
|
||||
{
|
||||
|
@ -481,13 +461,20 @@ KdOsAddInputDrivers ()
|
|||
KdAddKeyboardDriver(&LinuxKeyboardDriver);
|
||||
}
|
||||
|
||||
static void
|
||||
LinuxBell(int volume, int pitch, int duration)
|
||||
{
|
||||
if (volume && pitch)
|
||||
ioctl(LinuxConsoleFd, KDMKTONE, ((1193190 / pitch) & 0xffff) |
|
||||
(((unsigned long)duration * volume / 50) << 16));
|
||||
}
|
||||
|
||||
KdOsFuncs LinuxFuncs = {
|
||||
LinuxInit,
|
||||
LinuxEnable,
|
||||
LinuxSpecialKey,
|
||||
LinuxDisable,
|
||||
LinuxFini,
|
||||
0
|
||||
.Init = LinuxInit,
|
||||
.Enable = LinuxEnable,
|
||||
.Disable = LinuxDisable,
|
||||
.Fini = LinuxFini,
|
||||
.Bell = LinuxBell,
|
||||
};
|
||||
|
||||
void
|
||||
|
|
|
@ -369,6 +369,7 @@ typedef struct _KdOsFuncs {
|
|||
void (*Disable) (void);
|
||||
void (*Fini) (void);
|
||||
void (*pollEvents) (void);
|
||||
void (*Bell) (int, int, int);
|
||||
} KdOsFuncs;
|
||||
|
||||
typedef enum _KdSyncPolarity {
|
||||
|
|
|
@ -523,22 +523,46 @@ LegalModifier(unsigned int key, DeviceIntPtr pDev)
|
|||
}
|
||||
|
||||
static void
|
||||
KdBell (int volume, DeviceIntPtr pDev, pointer ctrl, int something)
|
||||
KdBell (int volume, DeviceIntPtr pDev, pointer arg, int something)
|
||||
{
|
||||
KeybdCtrl *ctrl = arg;
|
||||
KdKeyboardInfo *ki = NULL;
|
||||
|
||||
|
||||
for (ki = kdKeyboards; ki; ki = ki->next) {
|
||||
if (ki->dixdev && (ki->dixdev->id == pDev->id))
|
||||
if (ki->dixdev && ki->dixdev->id == pDev->id)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ki || !ki->dixdev || ki->dixdev->id != pDev->id || !ki->driver)
|
||||
return;
|
||||
|
||||
if (kdInputEnabled) {
|
||||
if (ki->driver->Bell)
|
||||
(*ki->driver->Bell) (ki, volume, ki->bellPitch, ki->bellDuration);
|
||||
|
||||
KdRingBell(ki, volume, ctrl->bell_pitch, ctrl->bell_duration);
|
||||
}
|
||||
|
||||
void
|
||||
DDXRingBell(int volume, int pitch, int duration)
|
||||
{
|
||||
KdKeyboardInfo *ki = NULL;
|
||||
|
||||
if (kdOsFuncs->Bell) {
|
||||
(*kdOsFuncs->Bell)(volume, pitch, duration);
|
||||
}
|
||||
else {
|
||||
for (ki = kdKeyboards; ki; ki = ki->next) {
|
||||
if (ki->dixdev->coreEvents)
|
||||
KdRingBell(ki, volume, pitch, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
KdRingBell(KdKeyboardInfo *ki, int volume, int pitch, int duration)
|
||||
{
|
||||
if (!ki || !ki->driver || !ki->driver->Bell)
|
||||
return;
|
||||
|
||||
if (kdInputEnabled)
|
||||
(*ki->driver->Bell) (ki, volume, pitch, duration);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,17 +12,6 @@
|
|||
#include "kdrive.h"
|
||||
#include <X11/keysym.h>
|
||||
|
||||
int
|
||||
VxWorksInit (void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
VxWorksEnable (void)
|
||||
{
|
||||
}
|
||||
|
||||
Bool
|
||||
VxWorksSpecialKey (KeySym sym)
|
||||
{
|
||||
|
@ -37,16 +26,6 @@ VxWorksSpecialKey (KeySym sym)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
VxWorksDisable (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VxWorksFini (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
KdOsAddInputDrivers (void)
|
||||
{
|
||||
|
@ -55,12 +34,7 @@ KdOsAddInputDrivers (void)
|
|||
}
|
||||
|
||||
KdOsFuncs VxWorksFuncs = {
|
||||
VxWorksInit,
|
||||
VxWorksEnable,
|
||||
VxWorksSpecialKey,
|
||||
VxWorksDisable,
|
||||
VxWorksFini,
|
||||
0
|
||||
.SpecialKey = VxWorksSpecialKey,
|
||||
};
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue
Block a user