data.effects.cur = &eff->active;
data.effects.old = NULL;
- ret = priv->control(dev, s, FFPL_UPL_TO_EMP, data);
+ ret = priv->control(dev, s, FFPL_UPL_TO_EMP, data, priv->user);
if (ret)
return ret;
}
data.effects.cur = &eff->latest;
data.effects.old = &eff->active;
data.effects.repeat = eff->repeat;
- ret = priv->control(dev, s, cmd, data);
+ ret = priv->control(dev, s, cmd, data, priv->user);
if (!ret) {
eff->active = eff->latest;
eff->state = (cmd == FFPL_OWR_TO_UPL) ? FFPL_UPLOADED : FFPL_STARTED;
else
cmd = FFPL_EMP_TO_SRT;
- ret = priv->control(dev, s, cmd, data);
+ ret = priv->control(dev, s, cmd, data, priv->user);
if (ret)
return ret;
} else {
cmd = FFPL_UPL_TO_SRT;
}
- ret = priv->control(dev, s, cmd, data);
+ ret = priv->control(dev, s, cmd, data, priv->user);
if (ret)
return ret;
if (cmd == FFPL_EMP_TO_SRT)
else
cmd = FFPL_SRT_TO_UPL;
- ret = priv->control(dev, s, cmd, data);
+ ret = priv->control(dev, s, cmd, data, priv->user);
if (ret)
return ret;
if (cmd == FFPL_SRT_TO_EMP)
data.effects.cur = &eff->latest;
data.effects.old = NULL;
- ret = priv->control(dev, s, FFPL_SRT_TO_UDT, data);
+ ret = priv->control(dev, s, FFPL_SRT_TO_UDT, data, priv->user);
if (ret)
return ret;
eff->active = eff->latest;
data.effects.cur = &eff->latest;
data.effects.old = NULL;
- ret = priv->control(dev, s, FFPL_EMP_TO_UPL, data);
+ ret = priv->control(dev, s, FFPL_EMP_TO_UPL, data, priv->user);
if (ret)
return ret;
eff->uploaded_to_device = true;
union ffpl_control_data data;
data.autocenter = priv->autocenter;
- return priv->control(priv->dev, s, FFPL_SET_AUTOCENTER, data);
+ return priv->control(priv->dev, s, FFPL_SET_AUTOCENTER, data, priv->user);
}
static int ffpl_set_gain(struct klgd_plugin_private *priv, struct klgd_command_stream *s)
union ffpl_control_data data;
data.gain = priv->gain;
- return priv->control(priv->dev, s, FFPL_SET_GAIN, data);
+ return priv->control(priv->dev, s, FFPL_SET_GAIN, data, priv->user);
}
static void ffpl_calculate_trip_times(struct ffpl_effect *eff, const unsigned long now)
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))
+ 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)
{
struct klgd_plugin *self;
struct klgd_plugin_private *priv;
priv->effect_count = effect_count;
priv->dev = dev;
priv->control = control;
+ priv->user = user;
priv->gain = 0xFFFF;
self->private = priv;
static struct klgd_plugin *ff_plugin;
static u16 gain;
static u16 autocenter;
+static u32 test_user = 0xC001CAFE;
static int klgdff_erase(struct klgd_command_stream *s, const struct ff_effect *effect)
{
for (idx = 0; idx < s->count; idx++) {
printk(KERN_NOTICE "KLGDFF-TD: EFF %s\n", s->commands[idx]->bytes);
if (s->commands[idx]->user.data[0])
- printk("KLGDFF-TD: User 0x%X\n", s->commands[idx]->user.data[0]);
+ printk(KERN_NOTICE "KLGDFF-TD: User1 0x%X\n", s->commands[idx]->user.data[0]);
}
/* Simulate default USB polling rate of 125 Hz */
return 0;
}
-int klgdff_control(struct input_dev *dev, struct klgd_command_stream *s, const enum ffpl_control_command cmd, const union ffpl_control_data data)
+int klgdff_control(struct input_dev *dev, struct klgd_command_stream *s, const enum ffpl_control_command cmd,
+ const union ffpl_control_data data, void *user)
{
if (!s)
return -EINVAL;
- if (!data.effects.cur) {
- printk(KERN_WARNING "KLGDFF-TM: NULL effect, this _cannot_ happen!\n");
- return -EINVAL;
- }
-
+ printk(KERN_NOTICE "KLGDFF-TD: User data: 0x%X\n", *(u32 *)user);
switch (cmd) {
case FFPL_EMP_TO_UPL:
return klgdff_upload(s, data.effects.cur);
ret = ffpl_init_plugin(&ff_plugin, dev, EFFECT_COUNT, ffbits,
FFPL_HAS_EMP_TO_SRT | FFPL_REPLACE_STARTED | FFPL_HAS_AUTOCENTER | FFPL_MEMLESS_MODE,
- klgdff_control);
+ klgdff_control, &test_user);
if (ret) {
printk(KERN_ERR "KLGDFF-TD: Cannot init plugin\n");
goto errout_idev;