From patchwork Sun Nov 1 15:31:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Rojtberg X-Patchwork-Id: 7532411 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CA2F89F2F7 for ; Sun, 1 Nov 2015 15:32:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E005E206B6 for ; Sun, 1 Nov 2015 15:32:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B538920680 for ; Sun, 1 Nov 2015 15:32:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbbKAPcA (ORCPT ); Sun, 1 Nov 2015 10:32:00 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:37569 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751123AbbKAPb7 (ORCPT ); Sun, 1 Nov 2015 10:31:59 -0500 Received: by wmff134 with SMTP id f134so42640133wmf.0 for ; Sun, 01 Nov 2015 07:31:58 -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; bh=atmo5kvzNSvdinSONe1T3dUukzN7cVsQlN+kjnEWgeU=; b=zj3lzXtFO55tvJcHPaiZFYEOulqASOP7UKbvty/16zl34cqN/VZ75d3ueN87AXNCeK wO0eR1f3VMvyLSTqG4rmAsuc4Sv8r7fm5/Lltm8KBtzE0mlz5jnnnVlpScex8zKON96T ySz3jrupzHTxoJGH63Jal3iFNadthJ4PGwfjbgV84HZ9wbLRk42/dimE4tBLwG7rC7Cx E+P1ZhDTpTvGHp/CIF2vyfOdg1ONroE4ZfO8ohtgsnnytEDWNPR1XKe83PHRtDpEsZiE NA1rF7ALUFsteBpHdTlmUuXULeX7scFnboZUiAbolh34nPsTxIogdgMGxApIs0v4oQA7 Izcw== X-Received: by 10.28.93.70 with SMTP id r67mr8052050wmb.16.1446391918564; Sun, 01 Nov 2015 07:31:58 -0800 (PST) Received: from deepwhite.fritz.box (p5DDCEA2E.dip0.t-ipconnect.de. [93.220.234.46]) by smtp.gmail.com with ESMTPSA id iw8sm17505161wjb.5.2015.11.01.07.31.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 01 Nov 2015 07:31:58 -0800 (PST) From: Pavel Rojtberg X-Google-Original-From: Pavel Rojtberg < rojtberg@gmail.com > To: linux-input@vger.kernel.org, pgriffais@valvesoftware.com, dmitry.torokhov@gmail.com, gregkh@linuxfoundation.org Cc: "Pierre-Loup A. Griffais" , Pavel Rojtberg Subject: [PATCH 5/5] Input: xpad: update Xbox One Force Feedback Support Date: Sun, 1 Nov 2015 16:31:39 +0100 Message-Id: <1446391899-24250-6-git-send-email-rojtberg@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446391899-24250-1-git-send-email-rojtberg@gmail.com> References: <1446391899-24250-1-git-send-email-rojtberg@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Pierre-Loup A. Griffais" There's apparently a serial number woven into both input and output packets; neglecting to specify a valid serial number causes the controller to ignore the rumble packets. The scale of the rumble was also apparently halved in the packets. The initialization packet had to be changed to allow force feedback to work. see https://github.com/paroj/xpad/issues/7 for details. Signed-off-by: Pavel Rojtberg --- drivers/input/joystick/xpad.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index e8dcc80..c1107c1 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -351,6 +351,7 @@ struct usb_xpad { int pad_nr; /* the order x360 pads were attached */ const char *name; /* name of the device */ struct work_struct work; /* init/remove device from callback */ + unsigned char odata_serial; /* serial number for xbox one protocol */ }; static int xpad_init_input(struct usb_xpad *xpad); @@ -917,17 +918,18 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect case XTYPE_XBOXONE: xpad->odata[0] = 0x09; /* activate rumble */ xpad->odata[1] = 0x08; - xpad->odata[2] = 0x00; + xpad->odata[2] = xpad->odata_serial++; xpad->odata[3] = 0x08; /* continuous effect */ xpad->odata[4] = 0x00; /* simple rumble mode */ xpad->odata[5] = 0x03; /* L and R actuator only */ xpad->odata[6] = 0x00; /* TODO: LT actuator */ xpad->odata[7] = 0x00; /* TODO: RT actuator */ - xpad->odata[8] = strong / 256; /* left actuator */ - xpad->odata[9] = weak / 256; /* right actuator */ + xpad->odata[8] = strong / 512; /* left actuator */ + xpad->odata[9] = weak / 512; /* right actuator */ xpad->odata[10] = 0x80; /* length of pulse */ xpad->odata[11] = 0x00; /* stop period of pulse */ - xpad->irq_out->transfer_buffer_length = 12; + xpad->odata[12] = 0x00; + xpad->irq_out->transfer_buffer_length = 13; break; default: @@ -1150,7 +1152,10 @@ static int xpad_open(struct input_dev *dev) /* Xbox one controller needs to be initialized. */ xpad->odata[0] = 0x05; xpad->odata[1] = 0x20; - xpad->irq_out->transfer_buffer_length = 2; + xpad->odata[2] = xpad->odata_serial++; /* packet serial */ + xpad->odata[3] = 0x01; /* rumble bit enable? */ + xpad->odata[4] = 0x00; + xpad->irq_out->transfer_buffer_length = 5; retval = usb_submit_urb(xpad->irq_out, GFP_KERNEL); spin_unlock_irqrestore(&xpad->odata_lock, flags); return retval;