Drop code for kernel-enabling bits
authorPeter Hutterer <peter.hutterer@who-t.net>
Sun, 30 Jun 2013 05:27:24 +0000 (15:27 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Sun, 30 Jun 2013 05:27:24 +0000 (15:27 +1000)
We can't enable axes on devices at runtime in the kernel, not even
for uinput devices. So this API can't work anyway, remove it before
someone thinks it does work.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
libevdev/libevdev.c
libevdev/libevdev.h
test/test-libevdev-has-event.c

index c3db8a1..4a9ab0e 100644 (file)
@@ -848,65 +848,6 @@ libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned in
 }
 
 int
-libevdev_kernel_enable_event_type(struct libevdev *dev, unsigned int type)
-{
-       int rc;
-
-       if (type > EV_MAX)
-               return -1;
-
-       rc = ioctl(dev->fd, UI_SET_EVBIT, type);
-       if (rc != -1)
-               libevdev_enable_event_type(dev, type);
-
-       return (rc != -1) ? 0 : -errno;
-}
-
-int
-libevdev_kernel_enable_event_code(struct libevdev *dev, unsigned int type,
-                                 unsigned int code, const void *data)
-{
-       int rc;
-       int uinput_bit;
-       int max;
-       const unsigned long *mask;
-
-       rc = libevdev_kernel_enable_event_type(dev, type);
-       if (rc != 0)
-               return rc;
-
-       max = type_to_mask_const(dev, type, &mask);
-       if (max == -1 || code > max)
-               return -EINVAL;
-
-       switch(type) {
-               case EV_KEY: uinput_bit = UI_SET_KEYBIT; break;
-               case EV_REL: uinput_bit = UI_SET_RELBIT; break;
-               case EV_ABS: uinput_bit = UI_SET_ABSBIT; break;
-               case EV_MSC: uinput_bit = UI_SET_MSCBIT; break;
-               case EV_LED: uinput_bit = UI_SET_LEDBIT; break;
-               case EV_SND: uinput_bit = UI_SET_SNDBIT; break;
-               case EV_FF: uinput_bit = UI_SET_FFBIT; break;
-               case EV_SW: uinput_bit = UI_SET_SWBIT; break;
-       }
-
-       rc = ioctl(dev->fd, uinput_bit, type);
-       if (rc == -1)
-               goto out;
-
-       rc = libevdev_enable_event_type(dev, type);
-       if (rc == -1)
-               goto out;
-
-       /* FIXME: can't back out of this if it fails */
-       if (type == EV_ABS)
-               rc = libevdev_kernel_set_abs_value(dev, code, (const struct input_absinfo*)data);
-
-out:
-       return (rc != -1) ? 0 : -errno;
-}
-
-int
 libevdev_kernel_set_abs_value(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs)
 {
        int rc;
@@ -914,7 +855,7 @@ libevdev_kernel_set_abs_value(struct libevdev *dev, unsigned int code, const str
        if (code > ABS_MAX)
                return -EINVAL;
 
-       rc = ioctl(dev->fd, EVIOCSABS(code), *abs);
+       rc = ioctl(dev->fd, EVIOCSABS(code), abs);
        if (rc < 0)
                rc = -errno;
        else
index 0472302..9c489db 100644 (file)
@@ -706,50 +706,6 @@ int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned
  */
 int libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code);
 
-
-/**
- * @ingroup kernel
- *
- * Forcibly enable an event type on this device, even if the underlying
- * device does not support it. While this cannot make the device actually
- * report such events, it will now return true for libevdev_has_event_code().
- *
- * This will be written to the kernel.
- *
- * This cannot be undone, the kernel only allows to enable axes, not disable
- * them.
- *
- * This function calls libevdev_kernel_enable_event_type() if necessary.
- *
- * @param type The event type to enable (EV_ABS, EV_KEY, ...)
- */
-int libevdev_kernel_enable_event_type(struct libevdev *dev, unsigned int type);
-
-/**
- * @ingroup kernel
- *
- * Forcibly enable an event code on this device, even if the underlying
- * device does not support it. While this cannot make the device actually
- * report such events, it will now return true for libevdev_has_event_code().
- *
- * This will be written to the kernel.
- *
- * This cannot be undone, the kernel only allows to enable axes, not disable
- * them.
- *
- * The last argument depends on the type and code:
- * - If type is EV_ABS, the vararg must be a pointer to a struct input_absinfo
- * containing the data for this axis.
- * - For all other types, the argument is ignored.
- *
- * This function calls libevdev_kernel_enable_event_type() if necessary.
- *
- * @param type The event type to enable (EV_ABS, EV_KEY, ...)
- * @param code The event code to enable (ABS_X, REL_X, etc.)
- * @param data Axis/key data, depending on type and code
- */
-int libevdev_kernel_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data);
-
 /**
  * @ingroup kernel
  *
index a769f25..72eba2c 100644 (file)
@@ -465,53 +465,6 @@ START_TEST(test_device_disable_bit_invalid)
 }
 END_TEST
 
-START_TEST(test_device_enable_kernel_bit)
-{
-       struct uinput_device* uidev;
-       struct libevdev *dev, *dev2;
-       struct input_absinfo abs;
-       int rc;
-
-       rc = test_create_device(&uidev, &dev,
-                               EV_ABS, ABS_X,
-                               -1);
-       ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
-
-       ck_assert(!libevdev_has_event_code(dev, EV_ABS, ABS_Y));
-       ck_assert(!libevdev_has_event_type(dev, EV_REL));
-       ck_assert(!libevdev_has_event_code(dev, EV_REL, REL_X));
-
-       abs.value = 0;
-       abs.minimum = 0;
-       abs.maximum = 100;
-       abs.fuzz = 1;
-       abs.flat = 2;
-       abs.resolution = 3;
-
-       ck_assert_int_eq(libevdev_kernel_enable_event_code(dev, EV_ABS, ABS_Y, &abs), 0);
-       ck_assert(libevdev_has_event_code(dev, EV_ABS, ABS_Y));
-
-       ck_assert_msg(libevdev_kernel_enable_event_type(dev, EV_REL), 0);
-       ck_assert(libevdev_has_event_type(dev, EV_REL));
-       ck_assert(!libevdev_has_event_code(dev, EV_REL, REL_X));
-
-       ck_assert_int_eq(libevdev_kernel_enable_event_code(dev, EV_REL, REL_X, NULL), 0);
-       ck_assert(libevdev_has_event_code(dev, EV_REL, REL_X));
-
-       /* make sure kernel device is unchanged */
-       rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev2);
-       ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));
-       ck_assert(libevdev_has_event_code(dev2, EV_ABS, ABS_X));
-       ck_assert(libevdev_has_event_code(dev2, EV_ABS, ABS_Y));
-       ck_assert(libevdev_has_event_type(dev2, EV_REL));
-       ck_assert(libevdev_has_event_code(dev2, EV_REL, REL_X));
-       libevdev_free(dev2);
-
-       uinput_device_free(uidev);
-       libevdev_free(dev);
-}
-END_TEST
-
 Suite *
 libevdev_has_event_test(void)
 {
@@ -550,7 +503,6 @@ libevdev_has_event_test(void)
        tcase_add_test(tc, test_device_enable_bit_invalid);
        tcase_add_test(tc, test_device_disable_bit);
        tcase_add_test(tc, test_device_disable_bit_invalid);
-       tcase_add_test(tc, test_device_enable_kernel_bit);
        suite_add_tcase(s, tc);
 
        return s;