udev-builtin-keyboard.c revision 0ba696e20c94ef26275ffc0cfb3e54429d36e806
/***
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 <errno.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include "udev.h"
#include "keyboard-keys-from-name.h"
#include "keyboard-keys-to-name.h"
static int install_force_release(struct udev_device *dev, const unsigned int *release, unsigned int release_count) {
struct udev_device *atkbd;
const char *cur;
char codes[4096];
char *s;
size_t l;
unsigned int 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 udev_list_entry *entry;
struct {
unsigned int scan;
unsigned int key;
} map[1024];
unsigned int map_count = 0;
unsigned int release[1024];
unsigned int release_count = 0;
const char *key;
unsigned int scancode;
char *endptr;
const char *keycode;
const struct key *k;
continue;
/* 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;
}
/* translate identifier to key code */
if (!k) {
continue;
}
map_count++;
}
if (map_count > 0 || release_count > 0) {
const char *node;
int fd;
unsigned int i;
if (!node) {
return EXIT_FAILURE;
}
if (fd < 0) {
return EXIT_FAILURE;
}
/* install list of map codes */
for (i = 0; i < map_count; i++) {
log_debug("keyboard: mapping scan code %d (0x%x) to key code %d (0x%x)\n",
log_error("Error calling EVIOCSKEYCODE (scan code 0x%x, key code %d): %m\n", map[i].scan, map[i].key);
}
/* 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",
};