]> Devoid-pointer.net GitWeb - KLGD_FF_plugin.git/commitdiff
API Change!:
authorMichal Malý <madcatxster@devoid-pointer.net>
Sun, 27 Sep 2015 23:23:48 +0000 (01:23 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Sun, 27 Sep 2015 23:23:48 +0000 (01:23 +0200)
Remove the supported_effects field from ffpl_init(), read supported
force feedback capabilities from dev->ffbit directly instead

plugin/klgd_ff_plugin.c
plugin/klgd_ff_plugin.h
testmod/klgdff.c

index 3ce328a05435b476db1addefd57d3496508bc62d..4d1f9977306ce6f88bb5bcdc78196b43d5f9c259 100644 (file)
@@ -1487,7 +1487,6 @@ static int ffpl_init(struct klgd_plugin *self)
 
 /* Initialize the plugin */
 int ffpl_init_plugin(struct klgd_plugin **plugin, struct input_dev *dev, const size_t effect_count,
-                    const unsigned long supported_effects,
                     const unsigned long flags,
                     int (*control)(struct input_dev *dev, struct klgd_command_stream *s, const enum ffpl_control_command cmd, const union ffpl_control_data data, void *user),
                     void *user)
@@ -1522,7 +1521,6 @@ int ffpl_init_plugin(struct klgd_plugin **plugin, struct input_dev *dev, const s
        self->get_commands = ffpl_get_commands;
        self->get_update_time = ffpl_get_update_time;
        self->init = ffpl_init;
-       priv->supported_effects = supported_effects;
        priv->effect_count = effect_count;
        priv->dev = dev;
        priv->control = control;
@@ -1567,12 +1565,12 @@ int ffpl_init_plugin(struct klgd_plugin **plugin, struct input_dev *dev, const s
                printk("KLGDFF: Using REPLACE STARTED\n");
        }
 
-       if ((FFPL_MEMLESS_RUMBLE & flags) && !test_bit(FF_CONSTANT - FF_EFFECT_MIN, &priv->supported_effects)) {
+       if ((FFPL_MEMLESS_RUMBLE & flags) && !test_bit(FF_CONSTANT, dev->ffbit)) {
                priv->memless_periodic = true;
                printk(KERN_NOTICE "KLGDFF: Emulating PERIODIC through RUMBLE\n");
        }
        else if ((FFPL_MEMLESS_CONSTANT | FFPL_MEMLESS_PERIODIC | FFPL_MEMLESS_RAMP) & flags) {
-               if (!test_bit(FF_CONSTANT - FF_EFFECT_MIN, &priv->supported_effects)) {
+               if (!test_bit(FF_CONSTANT, dev->ffbit)) {
                        printk(KERN_ERR "The driver asked for memless mode but the device does not support FF_CONSTANT\n");
                        ret = -EINVAL;
                        goto err_out3;
@@ -1594,20 +1592,7 @@ int ffpl_init_plugin(struct klgd_plugin **plugin, struct input_dev *dev, const s
                priv->has_native_gain = true;
                printk(KERN_NOTICE "KLGDFF: Using HAS_NATIVE_GAIN\n");
        }
-
-       if (FF_AUTOCENTER & priv->supported_effects) {
-               priv->has_autocenter = true;
-               input_set_capability(dev, EV_FF, FF_AUTOCENTER);
-               printk(KERN_NOTICE "KLGDFF: Using HAS_AUTOCENTER\n");
-       }
-
        input_set_capability(dev, EV_FF, FF_GAIN);
-       for (idx = 0; idx <= (FF_WAVEFORM_MAX - FF_EFFECT_MIN); idx++) {
-               if (test_bit(idx, &priv->supported_effects)) {
-                       printk(KERN_NOTICE "KLGDFF: Has bit %d, effect type %d\n", idx, FF_EFFECT_MIN + idx);
-                       input_set_capability(dev, EV_FF, idx + FF_EFFECT_MIN);
-               }
-       }
 
        return 0;
 
index 3b6b9ce6449c752153c0bbb8e7c3a41109f904cd..b74f4a7db0eea8824b70379dc1d1d25481ad98b7 100644 (file)
@@ -1,8 +1,6 @@
 #include <linux/input.h>
 #include "../../KLGD/klgd.h"
 
-#define FFPL_EFBIT(x) BIT(x - FF_EFFECT_MIN)
-
 /*
  * Preserving full direction for FF_RUMBLE effects is not necessary
  * since the rumble motors can effectively spin in only two directions.
@@ -85,7 +83,6 @@ union ffpl_control_data {
 
 void ffpl_lvl_dir_to_x_y(const s32 level, const u16 direction, s32 *x, s32 *y);
 int ffpl_init_plugin(struct klgd_plugin **plugin, struct input_dev *dev, const size_t effect_count,
-                    const unsigned long supported_effects,
                     const unsigned long flags,
                     int (*control)(struct input_dev *dev, struct klgd_command_stream *s, const enum ffpl_control_command cmd, const union ffpl_control_data data, void *user),
                     void *user);
index a838e45f1156edc019b1c3cde85752f0720ee077..8b57b7576cca54bec24bef06431ea55cfc43a050 100644 (file)
@@ -351,16 +351,6 @@ static void __exit klgdff_exit(void)
 
 static int __init klgdff_init(void)
 {
-       unsigned long ffbits = FFPL_EFBIT(FF_CONSTANT) |
-                              FFPL_EFBIT(FF_RUMBLE) |
-                              FFPL_EFBIT(FF_PERIODIC) | FFPL_EFBIT(FF_SINE)
-                                                      | FFPL_EFBIT(FF_SQUARE)
-                                                      | FFPL_EFBIT(FF_SAW_UP)
-                                                      | FFPL_EFBIT(FF_SAW_DOWN)
-                                                      | FFPL_EFBIT(FF_TRIANGLE) |
-                              FFPL_EFBIT(FF_RAMP) |
-                              FFPL_EFBIT(FF_SPRING);
-
        int ret;
 
        klgdff_obj = kobject_create_and_add("klgdff_obj", kernel_kobj);
@@ -389,6 +379,17 @@ static int __init klgdff_init(void)
        dev->dev.parent = NULL;
        gain = 0xFFFF;
 
+       input_set_capability(dev, EV_FF, FF_CONSTANT);
+       input_set_capability(dev, EV_FF, FF_RUMBLE);
+       input_set_capability(dev, EV_FF, FF_PERIODIC);
+               input_set_capability(dev, EV_FF, FF_SINE);
+               input_set_capability(dev, EV_FF, FF_SQUARE);
+               input_set_capability(dev, EV_FF, FF_SAW_UP);
+               input_set_capability(dev, EV_FF, FF_SAW_DOWN);
+               input_set_capability(dev, EV_FF, FF_TRIANGLE);
+       input_set_capability(dev, EV_FF, FF_RAMP);
+       input_set_capability(dev, EV_FF, FF_SPRING);
+
        input_set_capability(dev, EV_ABS, ABS_X);
        input_set_capability(dev, EV_ABS, ABS_Y);
        input_set_capability(dev, EV_KEY, BTN_0);
@@ -397,7 +398,7 @@ static int __init klgdff_init(void)
        input_set_abs_params(dev, ABS_X, -0x7fff, 0x7fff, 0, 0);
        input_set_abs_params(dev, ABS_Y, -0x7fff, 0x7fff, 0, 0);
 
-       ret = ffpl_init_plugin(&ff_plugin, dev, EFFECT_COUNT, ffbits,
+       ret = ffpl_init_plugin(&ff_plugin, dev, EFFECT_COUNT,
                               FFPL_HAS_EMP_TO_SRT | FFPL_REPLACE_STARTED |
                               FFPL_MEMLESS_CONSTANT | FFPL_MEMLESS_RUMBLE | FFPL_TIMING_CONDITION,
                               klgdff_control, &test_user);