Exemple #1
0
static int sparse_keymap_setkeycode(struct input_dev *dev,
				    const struct input_keymap_entry *ke,
				    unsigned int *old_keycode)
{
	struct key_entry *key;

	if (dev->keycode) {
		key = sparse_keymap_locate(dev, ke);
		if (key && key->type == KE_KEY) {
			*old_keycode = key->keycode;
			key->keycode = ke->keycode;
			set_bit(ke->keycode, dev->keybit);
			if (!sparse_keymap_entry_from_keycode(dev, *old_keycode))
				clear_bit(*old_keycode, dev->keybit);
			return 0;
		}
	}

	return -EINVAL;
}
static int sparse_keymap_setkeycode(struct input_dev *dev,
				    unsigned int scancode,
				    unsigned int keycode)
{
	struct key_entry *key;
	int old_keycode;

	if (dev->keycode) {
		key = sparse_keymap_entry_from_scancode(dev, scancode);
		if (key && key->type == KE_KEY) {
			old_keycode = key->keycode;
			key->keycode = keycode;
			set_bit(keycode, dev->keybit);
			if (!sparse_keymap_entry_from_keycode(dev, old_keycode))
				clear_bit(old_keycode, dev->keybit);
			return 0;
		}
	}

	return -EINVAL;
}