From patchwork Fri Nov 25 22:18:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cameron Gutman X-Patchwork-Id: 9448165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BBD4560235 for ; Fri, 25 Nov 2016 22:19:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABEA426220 for ; Fri, 25 Nov 2016 22:19:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A09342808F; Fri, 25 Nov 2016 22:19:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C624426220 for ; Fri, 25 Nov 2016 22:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751056AbcKYWT1 (ORCPT ); Fri, 25 Nov 2016 17:19:27 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34984 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750997AbcKYWTZ (ORCPT ); Fri, 25 Nov 2016 17:19:25 -0500 Received: by mail-pg0-f68.google.com with SMTP id p66so6461573pga.2 for ; Fri, 25 Nov 2016 14:18:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=s7bWyo5hwiWPtYxpoRW5tO3x61jErcge94Hama3oHUw=; b=0OybSSRRDt7fr/i24er6dbpgOW6GLltlcxWUxygDVR/z+byI4cDBxNlM7mNl0zDysR p1FEr/ObV+bLc9YxmL+IUVTWsLH21wYmCcdHCpWmGAcQ8PxY7cF0/DzzizkLKcnSph3H E8qtk5grZ6dViGDcQSzClxad7RL9W8LvA6eQTY+YwEup6uzqhHjclHYW5+DMklnjh0Db 3BvGnsAf+xFIydt58jnQpwQ2fKGahEDBepuxrJC1r7Xlj0S5Dwao0MGmWuH1bUJ4D1xb 5NJ0naQhxZIHnfW12GhMjubW0N7mHw0cSwgBYZIRlYXwovYSdDe3YEZ2gyQJ/VZL32NK 4ZMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=s7bWyo5hwiWPtYxpoRW5tO3x61jErcge94Hama3oHUw=; b=UcdQRL9shaAFEtaHojvOGgN44391YK+7yeF+JtisTD+l6sQVD8wK1D5hsx4u/UTWsn FrY28rNbG/Zf2exdLaC0YEVIPCtOhQDRCH1xZuziO3VlrvQECD3LK4n43i2NSHiqptIX jcBmE8hFT5ev/wFdsf8NmHnodkbPeynhsBvlzRkmuvJ6ftCiLqden6yMvXUcD2TS1oIm p5yNTVQFZ0ORMdHXMmB6oU35S8gqBpE8TAT1KVbP/rh1kwjO25IcCC3xVcio8ZMlvlAw 4HsNoKunVrJ9AcXDToMMA+M9Mmg/ub7JGm8+TyjwWa9aHQ2I2F/VL7Yf/l7aHWz2rv9E DHbw== X-Gm-Message-State: AKaTC025jYc1mTJHN8iyghcA1WWaBhRcvJq7/XYbcqk2P7ptx6pfd09ofQTUJZ0Nxcy2XQ== X-Received: by 10.99.149.90 with SMTP id t26mr18290674pgn.156.1480112332025; Fri, 25 Nov 2016 14:18:52 -0800 (PST) Received: from localhost.localdomain ([174.127.240.168]) by smtp.gmail.com with ESMTPSA id t20sm69966543pfk.48.2016.11.25.14.18.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 14:18:51 -0800 (PST) From: Cameron Gutman To: dmitry.torokhov@gmail.com, rojtberg@gmail.com Cc: linux-input@vger.kernel.org, Cameron Gutman Subject: [PATCH v3 2/2] Input: xpad - fix Xbox One rumble stopping after 2.5 secs Date: Fri, 25 Nov 2016 14:18:35 -0800 Message-Id: <0c07f12f63b5bf21374eb35a84a160bffc4f97e4.1480111549.git.aicommander@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Unlike previous Xbox pads, the Xbox One pad doesn't have "sticky" rumble packets. The duration is encoded into the command and expiration is handled by the pad firmware. ff-memless needs pseudo-sticky behavior for rumble effects to behave properly for long duration effects. We already specify the maximum rumble on duration in the command packets, but it's still only good for about 2.5 seconds of rumble. This is easily reproducable running fftest's sine vibration test. It turns out there's a repeat count encoded in the rumble command. We can abuse that to get the pseudo-sticky behavior needed for rumble to behave as expected for effects with long duration. By my math, this change should allow a single ff_effect to rumble for 10 minutes straight, which should be more than enough for most needs. Signed-off-by: Cameron Gutman --- No changes in v3. --- drivers/input/joystick/xpad.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 19886db..6d94996 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1045,9 +1045,9 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect packet->data[7] = 0x00; packet->data[8] = strong / 512; /* left actuator */ packet->data[9] = weak / 512; /* right actuator */ - packet->data[10] = 0xFF; - packet->data[11] = 0x00; - packet->data[12] = 0x00; + packet->data[10] = 0xFF; /* on period */ + packet->data[11] = 0x00; /* off period */ + packet->data[12] = 0xFF; /* repeat count */ packet->len = 13; packet->pending = true; break;