aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-06-16 19:58:30 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-06-16 20:31:09 +0300
commitcafd0f46535df3674098754c6c693cd34274810c (patch)
tree8a1a0bf83052ac70d1c10907d1a7e9ebf84e82aa /src
parent3af1e6106366d3d8acc6ba8bea8f047489c1d4d0 (diff)
downloadhid-tmff2-cafd0f46535df3674098754c6c693cd34274810c.tar.gz
hid-tmff2-cafd0f46535df3674098754c6c693cd34274810c.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/hid-tmff2.c9
-rw-r--r--src/tmt300rs/hid-tmt300rs.c10
2 files changed, 11 insertions, 8 deletions
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);
diff --git a/src/tmt300rs/hid-tmt300rs.c b/src/tmt300rs/hid-tmt300rs.c
index 0191620..24354ca 100644
--- a/src/tmt300rs/hid-tmt300rs.c
+++ b/src/tmt300rs/hid-tmt300rs.c
@@ -383,14 +383,20 @@ int t300rs_play_effect(void *data, struct tmff2_effect_state *state)
struct t300rs_device_entry *t300rs = data;
struct __packed t300rs_packet_play {
struct t300rs_packet_header header;
- uint8_t value;
+ uint8_t code;
+ uint16_t count;
} *play_packet = (struct t300rs_packet_play *)t300rs->send_buffer;
int ret;
t300rs_fill_header(&play_packet->header, state->effect.id, 0x89);
- play_packet->value = 0x01;
+ play_packet->code = 0x41;
+
+ if (state->count == 0 || state->count >= 65535)
+ play_packet->count = 0;
+ else
+ play_packet->count = cpu_to_le16(state->count);
ret = t300rs_send_int(t300rs);
if (ret)