Re: [PATCH] Input: Add direction to ff-memless

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jari Vanhala wrote:
> On Mon, 2009-12-07 at 22:16 +0100, ext Anssi Hannula wrote:
>> Jari Vanhala wrote:
>>> +static unsigned int ml_calculate_direction(
>>> +	unsigned int direction, unsigned int force,
>>> +	unsigned int new_direction, unsigned int new_force)
>>> +{
>>> +	return ((u32)direction * force + new_direction * new_force) /
>>> +		(force + new_force);
>>> +}
>> What if direction is 0xf000 and new_direction is 0x1000? The correct
>> behaviour would be to use direction 0x0000 or so, but this code would
>> return 0x8000 (assuming equal forces).
> 
> I know it's not perfect, but it's simple and gives good enough result.
> And I just need to know which side of 0x8000 it is.

Ah, I assumed the motor directions (forward, reverse) were mapped to
up/down (180/0), not left/right.

Your way seems somewhat counter-intuitive, but it indeed makes
ml_calculate_direction() simpler :) And as there are no other rumble
drivers using the direction field, I guess the wrong results do not
matter, then.

I think a comment should be added in ml_calculate_direction(), anyway,
to make it clear that it only works correctly with motors with
left/right directions only.

-- 
Anssi Hannula
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux