udev-builtin-keyboard.c revision 3b64e4d4f40baac56148c7d333d6a0053358ec7a
/***
This file is part of systemd.
Copyright 2013 Kay Sievers <kay@vrfy.org>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "udev.h"
#include "keyboard-keys-from-name.h"
static int install_force_release(struct udev_device *dev, const unsigned *release, unsigned release_count) {
struct udev_device *atkbd;
const char *cur;
char codes[4096];
char *s;
size_t l;
unsigned i;
int ret;
if (!atkbd)
return -ENODEV;
if (!cur)
return -ENODEV;
s = codes;
l = sizeof(codes);
/* copy current content */
/* append new codes */
for (i = 0; i < release_count; i++)
if (ret < 0)
return ret;
}
{
struct {
unsigned scan;
unsigned key;
} map;
char *endptr;
const struct key *k;
unsigned keycode_num;
/* translate identifier to key code */
if (k) {
keycode_num = k->id;
} else {
/* check if it's a numeric code already */
if (endptr[0] !='\0') {
return;
}
}
log_debug("keyboard: mapping scan code %d (0x%x) to key code %d (0x%x)",
log_error_errno(errno, "Error calling EVIOCSKEYCODE on device node '%s' (scan code 0x%x, key code %d): %m", devnode, map.scan, map.key);
}
char *next;
if (!current)
return NULL;
return NULL;
if (*next)
next++;
return next;
}
struct input_absinfo absinfo;
int rc;
char *next;
if (rc < 0) {
return;
}
if (!next) {
return;
}
log_debug("keyboard: %x overridden with %"PRIi32"/%"PRIi32"/%"PRIi32"/%"PRIi32"/%"PRIi32" for \"%s\"",
devnode);
if (rc < 0)
}
{
struct udev_device *pdev;
char val_s[DECIMAL_STR_MAX(int)];
int r, val_i;
/* The sensitivity sysfs attr belongs to the serio parent device */
if (!pdev) {
return;
}
if (r < 0) {
log_error("Unable to parse POINTINGSTICK_SENSITIVITY '%s' for '%s'", value, udev_device_get_devnode(dev));
return;
}
if (r < 0)
log_error_errno(r, "Failed to write 'sensitivity' attribute for '%s': %m", udev_device_get_devnode(pdev));
}
static int open_device(const char *devnode) {
int fd;
if (fd < 0)
return fd;
}
struct udev_list_entry *entry;
unsigned release[1024];
unsigned release_count = 0;
const char *node;
if (!node) {
return EXIT_FAILURE;
}
const char *key;
char *endptr;
const char *keycode;
unsigned scancode;
/* KEYBOARD_KEY_<hex scan code>=<key identifier string> */
if (endptr[0] != '\0') {
continue;
}
/* a leading '!' needs a force-release entry */
if (keycode[0] == '!') {
keycode++;
if (keycode[0] == '\0')
continue;
}
if (fd == -1) {
if (fd < 0)
return EXIT_FAILURE;
}
unsigned evcode;
/* EVDEV_ABS_<EV_ABS code>=<min>:<max>:<res>:<fuzz>:<flat> */
if (endptr[0] != '\0') {
continue;
}
if (fd == -1) {
if (fd < 0)
return EXIT_FAILURE;
}
}
}
/* install list of force-release codes */
if (release_count > 0)
return EXIT_SUCCESS;
}
const struct udev_builtin udev_builtin_keyboard = {
.name = "keyboard",
.cmd = builtin_keyboard,
.help = "Keyboard scan code to key mapping",
};