public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: "Tomasz Pakuła" <tomasz.pakula.oficjalny@gmail.com>,
	jikos@kernel.org, bentiss@kernel.org
Cc: anssi.hannula@gmail.com, linux-input@vger.kernel.org,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH v5 02/12] HID: pidff: Do not send effect envelope if it's empty
Date: Tue, 21 Jan 2025 10:59:46 +0100	[thread overview]
Message-ID: <a7df5090-ff71-44d9-83e3-442876522c74@suse.com> (raw)
In-Reply-To: <20250119131356.1006582-3-tomasz.pakula.oficjalny@gmail.com>



On 19.01.25 14:12, Tomasz Pakuła wrote:
> Envelope struct is always initialized, but the envelope itself is
> optional as described in USB PID Device class definition 1.0.
> 
> 5.1.1.1 Type Specific Block Offsets
> ...
> 4) Effects that do not use Condition Blocks use 1 Parameter Block and
> an *optional* Envelope Block.
> 
> Sending out "empty" envelope breaks force feedback on some devices with
> games that use SINE effect + offset to emulate constant force effect, as
> well as generally breaking Constant/Periodic effects. One of the affected
> brands is Moza Racing.

[..]
> @@ -261,10 +261,19 @@ static void pidff_set_envelope_report(struct pidff_device *pidff,
>   static int pidff_needs_set_envelope(struct ff_envelope *envelope,
>   				    struct ff_envelope *old)
>   {
> -	return envelope->attack_level != old->attack_level ||
> -	       envelope->fade_level != old->fade_level ||
> +	bool needs_new_envelope;
> +	needs_new_envelope = envelope->attack_level  != 0 ||
> +		             envelope->fade_level    != 0 ||
> +		             envelope->attack_length != 0 ||
> +		             envelope->fade_length   != 0;
> +
> +	if (!needs_new_envelope || !old)
> +		return needs_new_envelope;

I am afraid this is the most convoluted piece of boolean algebra I've seen
in a long time. In particular because it mixes things that do not belong together.

	Regards
		Oliver



  reply	other threads:[~2025-01-21  9:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-19 13:12 [PATCH v5 00/12] HID: Upgrade the generic pidff driver and add hid-universal-pidff Tomasz Pakuła
2025-01-19 13:12 ` [PATCH v5 01/12] HID: pidff: Convert infinite length from Linux API to PID standard Tomasz Pakuła
2025-01-19 13:12 ` [PATCH v5 02/12] HID: pidff: Do not send effect envelope if it's empty Tomasz Pakuła
2025-01-21  9:59   ` Oliver Neukum [this message]
2025-01-21 10:17     ` Tomasz Pakuła
2025-01-21 13:01       ` Oliver Neukum
2025-01-21 13:15         ` Tomasz Pakuła
2025-01-19 13:12 ` [PATCH v5 03/12] HID: pidff: Clamp PERIODIC effect period to device's logical range Tomasz Pakuła
2025-01-19 13:12 ` [PATCH v5 04/12] HID: pidff: Add MISSING_DELAY quirk and its detection Tomasz Pakuła
2025-01-19 13:12 ` [PATCH v5 05/12] HID: pidff: Add MISSING_PBO " Tomasz Pakuła
2025-01-19 13:12 ` [PATCH v5 06/12] HID: pidff: Add MISSING_DEVICE_CONTROL quirk Tomasz Pakuła
2025-01-19 13:12 ` [PATCH v5 07/12] HID: pidff: Add hid_pidff_init_with_quirks and export as GPL symbol Tomasz Pakuła
2025-01-19 13:12 ` [PATCH v5 08/12] HID: pidff: Add FIX_WHEEL_DIRECTION quirk Tomasz Pakuła
2025-01-19 13:13 ` [PATCH v5 09/12] HID: pidff: Stop all effects before enabling actuators Tomasz Pakuła
2025-01-21 10:10   ` Oliver Neukum
2025-01-21 13:18     ` Tomasz Pakuła
2025-01-22  1:37     ` Tomasz Pakuła
2025-01-19 13:13 ` [PATCH v5 10/12] HID: Add hid-universal-pidff driver and supported device ids Tomasz Pakuła
2025-01-19 13:13 ` [PATCH v5 11/12] MAINTAINERS: Add entry for hid-universal-pidff driver Tomasz Pakuła
2025-01-19 13:13 ` [PATCH v5 12/12] HID: pidff: Add PERIODIC_SINE_ONLY quirk Tomasz Pakuła

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a7df5090-ff71-44d9-83e3-442876522c74@suse.com \
    --to=oneukum@suse.com \
    --cc=anssi.hannula@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=tomasz.pakula.oficjalny@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox