Received: by 10.223.185.116 with SMTP id b49csp73180wrg; Tue, 20 Feb 2018 16:10:32 -0800 (PST) X-Google-Smtp-Source: AH8x226lzSpXhWczxMYAgVn7QPLP2OsSDqHcEPjWYGQIRbDLZE7h/WSm5tc/v8g+cPKuGQRbeS+Q X-Received: by 2002:a17:902:3103:: with SMTP id w3-v6mr1215346plb.99.1519171832599; Tue, 20 Feb 2018 16:10:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519171832; cv=none; d=google.com; s=arc-20160816; b=PLnwTTe5reMZBkFZlq6XqHKwn+UW2gKaysMbE/6B/vsafMGFfjMh2bBD9Q1KFFgStf ll9j1eRxwQP8PoCMZQK4dHplPPYPTaw+RqCKor1it2mXORgTJWY1dV22vbcwh5LDvlTp G3Tj4dAMQg4kE9uhxQHJObQvZx6MCr5Gu6pmz7ogxa+4o0O7j1+HEZKoYjJ5aAaNIzjm N3U4jDmmKev6LBOJIl0OYtPyHpXSs39fys+iRXRumoRjsq2HIJWGo6KtjxKCJ4MI4neE I3aZ835EstJ6NIeR1dEefcTTSpEbTo+7khDzjGHaKCx4usFTkSLqXqRViiTVTz5S3lv0 p7Jg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=U7rOu8vMrPsi3Mhqs2829HdRXi9ObCYS/+UkVWHA1UY=; b=MIgdsIGGiLgySbJAYb9g51cy38XsC1nV5Emg4omK6r8pzxFeZ3rfRrV1ipSzvSQmIR 6HgeZH8d9OPHLbh9H12RIVSuVb62OAgqJgZ/O6o0Y6BeCAI9PAu2gUE1iU976JpReA8o 7+9mH/umxIyDc7LVOSDChF5doEL3QkgCd12mU3V0XN9nlGbrRbpfIgR16xy6vBfHeaix DWiYnD2vRPzRtfB+AWWvygiXXw3CeaUItLu1NhyzM3XyCeaxy+9nTjgrlx9s5O845KAT JQC5SO50YnM4TSTATeaX8UPwoTIioPeZsRpKJu6Ky58U0WAOOpsM574rN1EI3Qy04uXd mKaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@valvesoftware.com header.s=mc20150811 header.b=E2zR+ZAj; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9-v6si2925232plt.349.2018.02.20.16.10.17; Tue, 20 Feb 2018 16:10:32 -0800 (PST) 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; dkim=pass header.i=@valvesoftware.com header.s=mc20150811 header.b=E2zR+ZAj; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751604AbeBUAJf (ORCPT + 99 others); Tue, 20 Feb 2018 19:09:35 -0500 Received: from us-smtp-delivery-172.mimecast.com ([216.205.24.172]:25694 "EHLO us-smtp-delivery-172.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751359AbeBUAJd (ORCPT ); Tue, 20 Feb 2018 19:09:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=valvesoftware.com; s=mc20150811; t=1519171772; h=from:subject:date:message-id:to:cc:mime-version:content-type:content-transfer-encoding:in-reply-to:references; bh=U7rOu8vMrPsi3Mhqs2829HdRXi9ObCYS/+UkVWHA1UY=; b=E2zR+ZAjErheeEMgObsumvULojuN7ngPpv6Ww3lCKXvldYEqk22AU9UZk1KwQA2VguIWewsWaaRoQsH2aJxQni1SD58PBPin8HWhbLAGxrzLyHYlYVhnoern36murVW+jhHhZlIomuEqiPwfzjfLub1zZFRGo55Ss7KMAEE2SOk= Received: from smtp02.valvesoftware.com (smtp02.valvesoftware.com [208.64.203.182]) (Using TLS) by us-smtp-1.mimecast.com with ESMTP id us-mta-153-gLFN7_L9MZW-M9YnmoRj3A-1; Tue, 20 Feb 2018 19:09:31 -0500 Received: from [172.16.1.107] (helo=antispam.valvesoftware.com) by smtp02.valvesoftware.com with esmtp (Exim 4.86_2) (envelope-from ) id 1eoHyT-000ARy-U1; Tue, 20 Feb 2018 16:09:29 -0800 Received: from antispam.valvesoftware.com (127.0.0.1) id hhisbi0171sc; Tue, 20 Feb 2018 16:09:29 -0800 (envelope-from ) Received: from exchange17.valvemail.org ([172.16.144.21]) by antispam.valvesoftware.com ([172.16.1.107]) (SonicWALL 8.3.2.6535) with ESMTP id 201802210009290030196; Tue, 20 Feb 2018 16:09:29 -0800 Received: from [172.18.9.62] (172.18.9.62) by exchange17.valvemail.org (172.16.144.21) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 20 Feb 2018 16:09:29 -0800 Subject: Re: [PATCH v2 0/3] new driver for Valve Steam Controller To: Rodrigo Rivas Costa CC: Jiri Kosina , Benjamin Tissoires , , References: <20180220193306.28748-1-rodrigorivascosta@gmail.com> <673a2510-7d82-1b24-1085-9f5aa2bb9998@valvesoftware.com> <20180220232035.GA28798@casa> From: "Pierre-Loup A. Griffais" Message-ID: <52b10af3-d93b-34b2-e6ba-22621511b16f@valvesoftware.com> Date: Tue, 20 Feb 2018 16:09:39 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180220232035.GA28798@casa> Content-Language: en-US X-Mlf-Version: 8.3.2.6535 X-Mlf-UniqueId: o201802210009290030196 X-MC-Unique: gLFN7_L9MZW-M9YnmoRj3A-1 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/20/2018 03:20 PM, Rodrigo Rivas Costa wrote: > On Tue, Feb 20, 2018 at 02:29:48PM -0800, Pierre-Loup A. Griffais wrote: >> Hi Rodrigo, >> >> Thanks for working on that! I have a few questions and remarks. >> >> For the reverse-engineering part, there's a lot of existing reference in >> existing (user-space) drivers for the controllers like sc-controller, bu= t >> feel free to reach out if you have any questions. It's overall pretty si= mple >> and there's nothing secret about how it functions; there are some quirks= , >> however. Nothing secret about it, but also no documentation, so might as >> well be... Have you tried deflecting the analog stick while touching the >> left trackpad? You'll most likely need special handling there. How are y= ou >> planning to expose enabling/disabling auxiliary data like gyro over >> wireless? >=20 > Yeah, I look for information about a year when I started on this. I read > Ynsta's user-mode driver [1] (I didn't find sc-controller), but I found > that a bit incomplete, so I wrote my own named `inputmap` [2]. >=20 > About the left trackpad/joystick, currently I'm not treating them > different. I'm out of ABS axes, and anyway, it is not likely that the > left pad and the joystick be used at the same time (I only have one left > thumb). Nevertheless, if we really want to make them apart, we can use > bits 10.3 (lpad_touch) and 10.7 (lpad_and_joy) together. I described the > details in [2], but I'm not currently doing that in this driver. I didn't necessarily mean exposing it, but in the event a user is using=20 both at the same time (it happens, using claw grip with some games is=20 necessary to use the D-pad while deflecting the stick), then you'll most=20 likely run into issues unless you demux the inbound data, since we were=20 also out of left analog fields and mux them together if used at the same=20 time. Not sure if you're already handling that case, but not doing it=20 would result in the stick appearing to fully deflect every other input=20 report if the user is doing both at the same time. > About the gyroscope/acceleration/quaternion, you know the issue > that the wireless gives gyro plus quat but no accel, while the wired > gives all three. My general idea is to create an additional input device > with INPUT_PROP_ACCELEROMETER to expose what is available. Pity is that > the wireless gives no accel, maybe there is some command to enable it? It should be three neighboring bits for that setting; does this not work=20 for you? // Bitmask that define which IMU features to enable. typedef enum { =09SETTING_GYRO_MODE_OFF=09=09=09=09=3D 0x0000, =09SETTING_GYRO_MODE_STEERING=09=09=09=3D 0x0001, =09SETTING_GYRO_MODE_TILT=09=09=09=09=3D 0x0002, =09SETTING_GYRO_MODE_SEND_ORIENTATION=09=3D 0x0004, =09SETTING_GYRO_MODE_SEND_RAW_ACCEL=09=3D 0x0008, =09SETTING_GYRO_MODE_SEND_RAW_GYRO=09=09=3D 0x0010, } SettingGyroMode; >=20 > Also, ideally, we could expose the quat. data directly to userspace, but > I see no clear way to do that. Maybe defining INPUT_PROP_QUATERNION? I > also thought of computing yaw/pitch/roll from the quat. and exposing > those, but doing that requires atan2() and sin() (16-bit precision), and > that would be tricky. Any thoughts on that? I have no useful feedback on the actual shape of the data, but you'll=20 want to give careful thought to sending the setting above. The battery=20 life of the controller is going to get worse the more data you're=20 enabling to be transmitted over the radio. For this reason, Steam only=20 selectively enables the data that the current configuration demands,=20 dynamically based on what client application has focus. It might make=20 sense to expose the quaternion like you describe, but would it be doable=20 to have it exposed through a separate device node? This way, I assume=20 the driver could properly send the appropriate radio setting to the=20 device based on whether that gyro-specific device node is open by an=20 interested user or not. It would be unfortunate to enable these data=20 channels by default if they're not needed. >> Will this driver being loaded affect functionality of existing applicati= ons >> that talk to it through HID directly, like Steam or sc-controller? Will = they >> be able to keep getting the same HID data they do today? If so, the exte= nt >> of the work needed to support it in Steam might just be to ignore the >> controller device it's exposing, since Steam will expose that itself thr= ough >> its own means. >=20 > As it is, this patchset hould be pretty safe. The only command sent to > the controller is the get-serial-number, and that seems to do no harm to > Steam Client. Other than that, it only reads. Moreover, the hidraw > device is still created, so user-mode driver should keep working > (but AFAIK, Steam Client uses direct USB access, not hidraw). >=20 > Curiously, Steam Client does not show the new native Steam Controller > gamepad. That is, if I connect the Steam controller with hid-steam.ko > and an Acme HID gamepad, then in Steam Client controller settings I > see only two controllers, the managed Steam Controller (not HID) and the > Acme HID gamepad. I reckon that Steam Client recognizes that the > new HID device is a Steam Controller and ignores it in favor of its own > managed controller. OK, I can give it a spin to see what Steam thinks about that device.=20 Maybe the proper VID/PID being exposed is enough for it to ignore it. In general I'm concerned about sending of the gyro-enable message=20 potentially impairing Steam functionality if it's running at the same=20 time (eg. if gyro gets disabled over the radio while Steam still needs=20 it), or sending any stateful messages to the device. For instance, are=20 you ever sending the "blank configuration" setting? I assume you must be=20 or users would still get keyboard/mouse input over these USB endpoints=20 while trying to interact with the controller. But sending this after=20 Steam programmed a setting, or instructed the controller to go back to=20 lizard mode because it was requested by a configuration, would be=20 problematic. Thanks, - Pierre-Loup > Regards. > Rodrigo >=20 > [1]: https://github.com/ynsta/steamcontroller > [2]: https://github.com/rodrigorc/inputmap >=20 >=20