int getUinputDevice (void) { static int uinputDevice = -1; #ifdef HAVE_LINUX_UINPUT_H if (uinputDevice == -1) { const char *name; { static int status = 0; int wait = !status; if (!installKernelModule("uinput", &status)) wait = 0; if (wait) approximateDelay(500); } { static const char *const names[] = {"uinput", "input/uinput", NULL}; name = resolveDeviceName(names, "uinput"); } if (name) { int device = openCharacterDevice(name, O_WRONLY, 10, 223); if (device != -1) { struct uinput_user_dev description; logMessage(LOG_DEBUG, "uinput opened: %s fd=%d", name, device); memset(&description, 0, sizeof(description)); strcpy(description.name, "brltty"); if (write(device, &description, sizeof(description)) != -1) { if (enableUinputKeyEvents(device)) { if (enableUinputAutorepeat(device)) { if (ioctl(device, UI_DEV_CREATE) != -1) { uinputDevice = device; } else { logSystemError("ioctl[UI_DEV_CREATE]"); } } } } else { logSystemError("write(struct uinput_user_dev)"); } if (device != uinputDevice) { close(device); logMessage(LOG_DEBUG, "uinput closed"); } } else { logMessage(LOG_DEBUG, "cannot open uinput"); } } } #endif /* HAVE_LINUX_UINPUT_H */ return uinputDevice; }
static void enableBeeps (void) { static unsigned char status = 0; installKernelModule("pcspkr", &status); }