Skip to content

Commit

Permalink
Cast FFB level operations to s32
Browse files Browse the repository at this point in the history
  • Loading branch information
berarma committed Jun 8, 2024
1 parent 89d2b09 commit 0df0013
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hid-lg4ff.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,15 +872,15 @@ static __always_inline int lg4ff_timer(struct lg4ff_device_entry *entry)

spin_unlock_irqrestore(&entry->timer_lock, flags);

parameters[0].level = (long)parameters[0].level * gain / 0xffff;
parameters[0].level = (s32)parameters[0].level * (s32)gain / 0xffff;
parameters[1].clip = parameters[1].clip * spring_level / 100;
parameters[2].clip = parameters[2].clip * damper_level / 100;
parameters[3].clip = parameters[3].clip * friction_level / 100;

ffb_level = abs(parameters[0].level);
for (i = 1; i < 4; i++) {
parameters[i].k1 = (long)parameters[i].k1 * gain / 0xffff;
parameters[i].k2 = (long)parameters[i].k2 * gain / 0xffff;
parameters[i].k1 = (s32)parameters[i].k1 * (s32)gain / 0xffff;
parameters[i].k2 = (s32)parameters[i].k2 * (s32)gain / 0xffff;
parameters[i].clip = parameters[i].clip * gain / 0xffff;
ffb_level += parameters[i].clip * 0x7fff / 0xffff;
}
Expand Down

0 comments on commit 0df0013

Please sign in to comment.