/* 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)
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;
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;
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;
#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.
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);
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);
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);
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);