static dd_list *handle_list;
static char ff_path[PATH_MAX];
static int unique_number;
+static int current_effect_id = -1;
static int stop_device(int device_handle);
}
/* upload an effect */
- if (ioctl(fd, EVIOCSFF, effect) == -1) {
- _E("Failed to ioctl");
- return -errno;
- }
+ if (current_effect_id == -1) {
+ if (ioctl(fd, EVIOCSFF, effect) == -1) {
+ _E("Failed to ioctl");
+ return -errno;
+ }
+ current_effect_id = effect->id;
+ } else
+ effect->id = current_effect_id;
/* play vibration*/
play.type = EV_FF;
if (fd < 0 || !effect)
return -EINVAL;
+ if (effect->id == -1) {
+ if (current_effect_id == -1)
+ return 0;
+ effect->id = current_effect_id;
+ }
+
/* Stop vibration */
stop.type = EV_FF;
stop.code = effect->id;
/* reset effect id */
effect->id = -1;
+ current_effect_id = -1;
return 0;
}