From patchwork Sat Sep 11 17:36:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Ogorchock X-Patchwork-Id: 509303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07D45C433FE for ; Sat, 11 Sep 2021 17:37:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4FE961059 for ; Sat, 11 Sep 2021 17:37:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232985AbhIKRiQ (ORCPT ); Sat, 11 Sep 2021 13:38:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233074AbhIKRiP (ORCPT ); Sat, 11 Sep 2021 13:38:15 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48FF0C061756 for ; Sat, 11 Sep 2021 10:37:02 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id bk29so5797471qkb.8 for ; Sat, 11 Sep 2021 10:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=czpR2U/8SvztuRjNgqTIyIRpRJzK2hatecEATnWUBi0=; b=oXHB5dUZElbZSaEcK5w6HDwpU537VEiJOejy1DrvYJOSJtpwrMuOKgx0Gh+ZXtfMXs X4gMra6Fc8vs7Ywqpi8TXiQduitfTBlP/04X9PVankmdpooecJazfUbXD2YTmuVRFdRY g4AFRSWnCJR8hYzxrLj3A4qjI/L9tG7izi0hJPWz3LgXgIsG0i1kqMLh+QfVEiZgJAay ejl1diYLPoAyHyjeOXpYrSD7CEe9yHqm9Xq1BREJDf2C3seKuP6QXg9NesVrjdN9532a j27xiBhrJqKkPkSlqGyeqek9/eT5slduXLNIPBxNACmGdbTXToqT+EWOpjjskEWTVwMB dJyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=czpR2U/8SvztuRjNgqTIyIRpRJzK2hatecEATnWUBi0=; b=XZoMshtvjLsFe7Kuw2I7PEGf76kYoBGfZ+zr3/5jAtAD1bvQkUr2nSyJ4D6zjkjG8s Xm8sU+vipj2U2HIqvthzhZnOy0bGmu/EE4GK0TbBLAfujOhFnwNi0C8oQS6oU6R51Oib xUi2x8RhdNPfQAz34etdTortQrFdMXk2ZGW065L1mfI6rIcD9uIwyW1qUk3RR3BweqCZ 2q1PEJPoto9ylQiplZv8d36+sSO9ZNtla8g5WfX7asKMxx9wgzIHdGsCmigE8Ipd+DdX vRHEX9JoXB919oZIC4FqcQ4ZcPqwLSjW0nEZ0RtO1RtA5mbf/XqcCdoHV/LUI/Y7PcEM 9UxQ== X-Gm-Message-State: AOAM530oFXhBqDQZsj/9jbex5e9TLIjeg/ABgTYVHtO67PDpQ4UWWm7D 9XtFGgIAahtiaMeDZra+WEga6AlxGYDM/g== X-Google-Smtp-Source: ABdhPJzHKvMAY4NZ7/ljFr9tcjt5gCYKZ9tA/H0BsrQnzUGZPSErmh8rXs1GuIyAUSwQyJjt7NdRuQ== X-Received: by 2002:a37:c97:: with SMTP id 145mr2836001qkm.121.1631381821414; Sat, 11 Sep 2021 10:37:01 -0700 (PDT) Received: from Arrakis.djogorchock.com (pool-173-68-59-147.nycmny.fios.verizon.net. [173.68.59.147]) by smtp.gmail.com with ESMTPSA id m5sm1594286qkn.33.2021.09.11.10.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Sep 2021 10:37:01 -0700 (PDT) From: "Daniel J. Ogorchock" To: linux-input@vger.kernel.org Cc: thunderbird2k@gmail.com, blaws05@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org, Roderick.Colenbrander@sony.com, svv@google.com, s.jegen@gmail.com, carmueller@gmail.com, pgriffais@valvesoftware.com, hadess@hadess.net, pobrn@protonmail.com, lee.jones@linaro.org, "Daniel J. Ogorchock" Subject: [PATCH v16 09/16] HID: nintendo: patch hw version for userspace HID mappings Date: Sat, 11 Sep 2021 13:36:32 -0400 Message-Id: <20210911173639.5688-10-djogorchock@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210911173639.5688-1-djogorchock@gmail.com> References: <20210911173639.5688-1-djogorchock@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This patch sets the most significant bit of the hid hw version to allow userspace to distinguish between this driver's input mappings vs. the default hid mappings. This prevents breaking userspace applications that use SDL2 for gamepad input, allowing them to distinguish the mappings based on the version. Signed-off-by: Daniel J. Ogorchock --- drivers/hid/hid-nintendo.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c index cda0118ebd14b..ed9cf7b373067 100644 --- a/drivers/hid/hid-nintendo.c +++ b/drivers/hid/hid-nintendo.c @@ -1426,6 +1426,15 @@ static int nintendo_hid_probe(struct hid_device *hdev, goto err_wq; } + /* + * Patch the hw version of pro controller/joycons, so applications can + * distinguish between the default HID mappings and the mappings defined + * by the Linux game controller spec. This is important for the SDL2 + * library, which has a game controller database, which uses device ids + * in combination with version as a key. + */ + hdev->version |= 0x8000; + ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); if (ret) { hid_err(hdev, "HW start failed\n");