From cafd0f46535df3674098754c6c693cd34274810c Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 16 Jun 2024 19:58:30 +0300 Subject: move effect repeat count to wheel + This avoids a slight stutter when an effect is restarted. I also had a bug in the original code that effectively stopped the playing of some effects, whoops --- src/hid-tmff2.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/hid-tmff2.c') diff --git a/src/hid-tmff2.c b/src/hid-tmff2.c index b028a28..8b79c6e 100644 --- a/src/hid-tmff2.c +++ b/src/hid-tmff2.c @@ -306,15 +306,11 @@ static void tmff2_work_handler(struct work_struct *w) effect_length = state->effect.replay.length; if (test_bit(FF_EFFECT_PLAYING, &state->flags) && effect_length) { - if ((time_now - state->start_time) >= effect_length) { + if ((time_now - state->start_time) >= effect_length * state->count) { __clear_bit(FF_EFFECT_PLAYING, &state->flags); __clear_bit(FF_EFFECT_QUEUE_UPDATE, &state->flags); - if (state->count) - state->count--; - - if (state->count) - __set_bit(FF_EFFECT_QUEUE_START, &state->flags); + state->count = 0; } } @@ -359,6 +355,7 @@ static void tmff2_work_handler(struct work_struct *w) max_count = state->count; spin_unlock(&tmff2->lock); + /* wait for each effect update to actually be sent out to avoid * filling up usb output queue */ hid_hw_wait(tmff2->hdev); -- cgit v1.3