Received: by 10.213.65.68 with SMTP id h4csp1103091imn; Wed, 14 Mar 2018 09:40:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELuZCWDaQVJTq/A7nWrPO1vQ9UKYdI6mXVl3iHklf3mwckB2vkQ5u3ArPlTzshneFOXskeqn X-Received: by 10.101.93.138 with SMTP id f10mr4205754pgt.255.1521045637014; Wed, 14 Mar 2018 09:40:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521045636; cv=none; d=google.com; s=arc-20160816; b=bIvi8uHeKsq60IxSARYGkD3eeMqrRqqgEWcjKuaTWTWJqE7LBTEqGkW0R1/agbAG3H Lv9ykSR+rk5tUbIPtHO2QHmIBiztKo06u13f6JW6EMLjN97BmqR4SqbhIdtgSCd/XV/Y k7zgT7nCwSUqlgSLaBY/4n/jp3sTka3T31LppVJ0evRVu46THPW/ULncta5XhKZETSl9 nw0ifUR8xNBgfbi1tY9iaUJ/80DMnOpiO5jpBj88se7TspWc5cKRqtEYZeMEKlrbYMWf TZuCY67hhDAzbNd3oUOlnLX9gsZ2+0HDPLKw2J8nGfLol/Tgtvk7HTONG7Z2ZObtUXVc CBFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :arc-authentication-results; bh=jTF+YQ1WJvuGVSknYxOxxigfPkXcdoJo2a8rNzkLV9M=; b=ByoIAzvwKBH6e3e4H4urtaw62gqsnTdoBYIUW5qnQE9N1c9TmTwukH9o+9tofRrzIx LEde5iqcWNd9M6CDKlNyAqDFNLsIAF2HYTGON332pKbFCmUK6DWJCvbTTRRm219clkUw oitmteg3UuUY/DkjfCDS0kerA5cwe3InVK8D32gtIPapdxxiuweZt9ba2OOqo6IOKmnS DeEBWH5IKkemqKlOXa4donwxpoVTbGKVwyihro+wccep6m3Di7WDUkzEqXy3QO8O+pZ1 69kjkU/PHdIht5QVD3do3XAcWpdOi52/T0ITG9IhrgJM0BtYZ3QGHHTHsG5oO8MWoRYu 6hpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12-v6si2207109plo.91.2018.03.14.09.40.22; Wed, 14 Mar 2018 09:40:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752249AbeCNQja convert rfc822-to-8bit (ORCPT + 99 others); Wed, 14 Mar 2018 12:39:30 -0400 Received: from mail-qt0-f176.google.com ([209.85.216.176]:34752 "EHLO mail-qt0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751901AbeCNQj1 (ORCPT ); Wed, 14 Mar 2018 12:39:27 -0400 Received: by mail-qt0-f176.google.com with SMTP id l25so4129741qtj.1 for ; Wed, 14 Mar 2018 09:39:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=bdwvPslV7jGtIIUzSuqoRrv/Ofs8Nuli20TouUuNVpE=; b=VeygwwB17GM8yrunNvm0a7FsLgT+YCcpcmw07NeYs8gmQ1JKts+uoLMdww6WZbGk4z TRU5s5R4ZcJeCYH3/RgmjTkd8JwlAFjM2ztQrJgstSr4Ws+zDUkh14dAWwIqAjyTEilE UdWUBfNiOM4fHQlOVG6eIk3ccfanE+rudPKvAsrDYB+BrOP4kEYKl5lkN5KQR3tJQsOd a2rVhz3xNeQtCs8ciScvMayaNj5f69lcVK7r7Y4aBKVIHGBqsnSJDadhE/j4MGTkBADn RKZ2aomAYg5Xzok6yMeG7s7sGDWEQ1hltzdZdESOa0mop9MLlv14+MG1ILIu0dWK3C6J eHxg== X-Gm-Message-State: AElRT7F+TKyro+UP8s8Ty2L2ASfMMahiPe9mbG1z6HWDNVbzhFKvTe3S 3mWU2gKpBpaSsXCduSLtMgYXwdxpvlsVOq1pbRPwQQ== X-Received: by 10.200.64.198 with SMTP id f6mr8031116qtm.108.1521045566094; Wed, 14 Mar 2018 09:39:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.36.243 with HTTP; Wed, 14 Mar 2018 09:39:25 -0700 (PDT) In-Reply-To: <20180312205158.GB21621@casa> References: <20180311195842.5551-1-rodrigorivascosta@gmail.com> <20180312205158.GB21621@casa> From: Benjamin Tissoires Date: Wed, 14 Mar 2018 17:39:25 +0100 Message-ID: Subject: Re: [PATCH v5 0/4] new driver for Valve Steam Controller To: Rodrigo Rivas Costa Cc: =?UTF-8?Q?Cl=C3=A9ment_VUCHENER?= , Jiri Kosina , "Pierre-Loup A. Griffais" , Cameron Gutman , lkml , linux-input Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 12, 2018 at 9:51 PM, Rodrigo Rivas Costa wrote: > On Mon, Mar 12, 2018 at 03:30:43PM +0100, Clément VUCHENER wrote: >> 2018-03-11 20:58 GMT+01:00 Rodrigo Rivas Costa : >> > This patchset implements a driver for Valve Steam Controller, based on a >> > reverse analysis by myself. >> > >> > Sorry, I've been out of town for a few weeks and couldn't keep up with this... >> > >> > @Pierre-Loup and @Clément, could you please have another look at this and >> > check if it is worthy? Benjamin will not commit it without an express ACK from >> > Valve. Of course he is right to be cautious, but I checked this driver with >> > the Steam Client and all seems to go just fine. I think that there is a lot of >> > Linux out of the desktop that could use this driver and cannot use the Steam >> > Client. Worst case scenario, this driver can now be blacklisted, but I hope >> > that will not be needed. >> >> I tested the driver with my 4.15 fedora kernel (I only built the >> module not the whole kernel) and I got double inputs (your driver >> input device + steam uinput device) when testing Shovel Knight with >> Steam Big Picture. It seems to work fine when the inputs are the same, >> but after changing the controller configuration in Steam, the issue >> became apparent. > > I assumed that when several joysticks are available, games would listen > to one one of them. It looks like I'm wrong, and some (many?) games will > listen to all available joysticks at the same time. Thus having two > logical joysticks that represent the same physical one is not good. Yeah, the general rule of thumb is "think of the worst thing that can happen, someone will do something worst". > > An easy solution would be that Steam Client grabs this driver > (ioctl(EVIOCGRAB)) when creating the uinput device. Another solution > would be that Steam Client blacklists this driver, of course. This is 2 solutions that rely on a userspace change, and this is not acceptable in its current form. What if people do not upgrade Steam client but upgrade their kernel? Well, Steam might be able to force people to always run the latest shiny available version, but for other games, you can't expect people to have a compatible version of the userspace stack. Also, "blacklisting the driver" from Steam client is something the OS can do, but not the client when you run on a different distribution. You need root for that, and I don't want to give root permissions to Steam (or to any user space client that shouldn't have root privileges for what it matters). > >> And without Steam and your external tool, you get double inputs too. I >> tried RetroArch and it was unusable because of the keyboard inputs >> from the lizard mode (e.g. pressing B also presses Esc and quits >> RetroArch). Having to download and compile an external tool to make >> the driver work properly may be too difficult for the user. Your goal >> was to provide an alternative to user space drivers but now you >> actually depend on (a very simple) one. > > Yes, I noticed that. TBH, this driver without Steam Client or the > user-space tool is not very nice, precisely because you'll get constant > Escape and Enter presses, and most games react to those. > > Frankly speaking, I'm not sure how to proceed. I can think of the > following options: > 1.Steam Client installation could add a file to blacklist > hid-steam, just as it adds a few udev rules. But what about RetroArch? And what if you install Steam but want to play SDL games that could benefit from your driver? > 2.The default CONFIG_HID_STEAM can be changed to "n". Maybe only > on the architectures for which there is a Steam Client available. > This way DIY projects will still be able to use it. But this will make the decision to include or not the driver in distributions harder. And if no distribution uses it, you won't have free tests, and you will be alone to maintain it. So that's not ideal either > 3.This driver could be abandoned :-(. Just use Steam Client if possible or > any of the user-mode drivers available. This would be a waste for everybody as it's always better when we share. > > If we decide for 1 or 2, then the lizard mode could be disabled without > ill effects. We could even enable the gyro and all the other gadgets > without worring about current compatibility. To me, 1 is out of the question. The kernel can't expect a user space change especially if you are knowingly introducing a bug for the end user. 2 is still on the table IMO, and 3 would be a shame. I know we already discussed about sysfs and module parameters, but if the driver will conflict with a userspace stack, the only way would be to have a (dynamic) parameter "enhanced_mode" or "kernel_awesome_support" or whatever which would be a boolean, that defaults to false that Steam can eventually lookup if they want so in the future we can default it to true. When this parameter is set, the driver will create the inputs and toggle the various modes, while when it's toggled off, it'll clean up itself and keep the device as if it were connected to hid-generic. Bonus point, this removes the need for the simple user space tool that enables the mode. > > At the end of the day, I think that it is up to Valve what to do. Again, Valve is a big player here, but do not underestimate other projects (like RetroArch mentioned above) because if you break their workflow, they will have the right to request a revert of the commit because it breaks some random user playing games in the far end of Antarctica (yes, penguins do love to play games :-P ) Cheers, Benjamin > Best Regards. > Rodrigo. > >> Also the button and axis codes do not match the gamepad API doc >> (https://www.kernel.org/doc/Documentation/input/gamepad.txt). >> >> > >> > For full reference, I'm adding a full changelog of this patchset. >> > >> > Changes in v5: >> > * Fix license SPDX to GPL-2.0+. >> > * Minor stylistic changes (BIT(3) instead 0x08 and so on). >> > >> > Changes in v4: >> > * Add command to check the wireless connection status on probe, without >> > waiting for a message (thanks to Clément Vuchener for the tip). >> > * Removed the error code on redundant connection/disconnection messages. That >> > was harmless but polluted dmesg. >> > * Added buttons for touching the left-pad and right-pad. >> > * Fixed a misplaced #include from 2/4 to 1/4. >> > >> > Changes in v3: >> > * Use RCU to do the dynamic connec/disconnect of wireless devices. >> > * Remove entries in hid-quirks.c as they are no longer needed. This allows >> > this module to be blacklisted without side effects. >> > * Do not bypass the virtual keyboard/mouse HID devices to avoid breaking >> > existing use cases (lizard mode). A user-space tool to do that is >> > linked. >> > * Fully separated axes for joystick and left-pad. As it happens. >> > * Add fuzz values for left/right pad axes, they are a little wiggly. >> > >> > Changes in v2: >> > * Remove references to USB. Now the interesting interfaces are selected by >> > looking for the ones with feature reports. >> > * Feature reports buffers are allocated with hid_alloc_report_buf(). >> > * Feature report length is checked, to avoid overflows in case of >> > corrupt/malicius USB devices. >> > * Resolution added to the ABS axes. >> > * A lot of minor cleanups. >> > >> > Rodrigo Rivas Costa (4): >> > HID: add driver for Valve Steam Controller >> > HID: steam: add serial number information. >> > HID: steam: command to check wireless connection >> > HID: steam: add battery device. >> > >> > drivers/hid/Kconfig | 8 + >> > drivers/hid/Makefile | 1 + >> > drivers/hid/hid-ids.h | 4 + >> > drivers/hid/hid-steam.c | 794 ++++++++++++++++++++++++++++++++++++++++++++++++ >> > 4 files changed, 807 insertions(+) >> > create mode 100644 drivers/hid/hid-steam.c >> > >> > -- >> > 2.16.2 >> >