Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp960693iob; Fri, 13 May 2022 17:48:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7JiPlgEJUvxvm/r24KuFvOIi5oRFPPu6I7TXN2J69f1dnF05hmXzXvVHEplocTcLNd7J8 X-Received: by 2002:a05:600c:ad1:b0:394:1585:a164 with SMTP id c17-20020a05600c0ad100b003941585a164mr17153164wmr.101.1652489288089; Fri, 13 May 2022 17:48:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652489288; cv=none; d=google.com; s=arc-20160816; b=F5HdHpH/cyiRZjb3zS1orlj3mOGbrLyqpnYM1zl0TAg4HcmbkbDhf5A7ifqFTu2ME6 FZFFxhE3sowgZ86fl9trltMswyxR5+U47Ye3FIFSGm8F0J+Bupu+9gjuf/xG30A61aM5 2EKzMDI729OvdoKRGpEabX85CSnhoEA+vIZtZP/LySxu5sOCCgBa/EIMnlue/TIHQy6W h0fm+YUm5IbRI6yX96KwBcdlCraC8EkxcYG+Z2ZlfP8WAxM5xr/rXEMrSR+elKdus3AB fIOe3Fw0ieGZ8Z/Tqpk3drxwTXmynHg86xpl9BQCzNsynynEuxAhpbF0dbgBcciB4HFi AubA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uocv32A42nu0KZF7Yg0Y4JkBC2sf3Jsh4f2LBZHV7do=; b=MloEtngHgSWVeOMkGVky1t/iS8FGR+1C70HhJXERvsACCCBU/uHD7bV5jkpN3YPxhU 4zP2hwX3a3JrGx4FPmYZm8qQDoOqC8+zaXXw/c6JaNywG57FcwW9gSwrFVoiVyDNGzsh Js8RY7gkrojZeaybp0bP/yp79lktYVs3NMjAlznu1kDZFUuVlh0yrqD5F2RBT9uak4Sq Psj0XR4yBAw5YP5hOZS0fRev433b06CLd3RlJgfMbx8mtTWm8VNzh5ce9YZcSbhMJF8m 6v+bftuWPdrhSok3+3zbuZX8H+cJ2f24NchLcN6+hMe6BrGFdcB/bDSdIeaJV7V2NUs8 M6ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CLylvKJ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i12-20020a5d584c000000b0020cfe065a8dsi116875wrf.974.2022.05.13.17.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 17:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CLylvKJ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E58F033709E; Fri, 13 May 2022 16:26:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349605AbiELAQG (ORCPT + 99 others); Wed, 11 May 2022 20:16:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349611AbiELAPy (ORCPT ); Wed, 11 May 2022 20:15:54 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D5636586; Wed, 11 May 2022 17:15:49 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-e2fa360f6dso4861061fac.2; Wed, 11 May 2022 17:15:49 -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=uocv32A42nu0KZF7Yg0Y4JkBC2sf3Jsh4f2LBZHV7do=; b=CLylvKJ7toAIWbWncI9CKpK04030wQp7GI52qUfnWV2M9naUOsmaoJi3NBs5aIAXPy i9zG2rJqJhulsH9n3T67Sik8zTTb4fvpGXDAdJRBfXHZiXWTbCOhpOsfkfUYDfNgvOt1 uJ9/9+FVKc1YJOtAseNwxrI8KvabUHKzBzRBLGYMHE4AOquD3EAC22Cuukc4WHh+pHhq KPF7KUouHdKPgG75q7b0/MW7sKVhg1oAsaAv6p2a491qgqZdS++7/7CcRl10rkTu+hvt DFVpY3lUtRXVhtVFBSG/Bejdy3PwlfHVHrKx21me2SxS4zC61JsVz3Rby1S+L1GW4syl oyIg== 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=uocv32A42nu0KZF7Yg0Y4JkBC2sf3Jsh4f2LBZHV7do=; b=UgMZRmhLwWgcpgpeeTwnT/0LhR/eVJFm9KfQsRa+0minWTDfpW8kkL24e5sZD3x1E/ RqlZOSdIPz1RmjFa0vzx9bD6guTsEojsaC/N3r+d7QO2uwIWcmyg/kwvSH1U3OesPKF4 IfDLYI5QjI+M1HYSQSCMU8mCm+/9QS7aHwDgYAxclEQIN5pwkOEM+VYFFX+fG5t3Q+6+ kaJWKzhuNQiN2mr5SQqaoDOAn0Zk2EhQ42FQ2goNjmnsKtAxdu0oa4+GplD2GZQs6nrx vjs3GnrXcMwn+5z7Uop3iCMP4uyfW9FZvcXCEXelMvkB1sjEmdm8DlAicOSQHcvKRMHg Ra0Q== X-Gm-Message-State: AOAM531c61AzZZgYlO4Zbeq5XT4M7T4dCoButa8obBM/8Y9+WR4WGAXI Z1mzUJS7rK2qSv9/mN2wZQhwhKArwdw0vg== X-Received: by 2002:a05:6870:4341:b0:da:b3f:2b26 with SMTP id x1-20020a056870434100b000da0b3f2b26mr4359163oah.197.1652314548599; Wed, 11 May 2022 17:15:48 -0700 (PDT) Received: from max-lenovo.. (169-231-139-87.wireless.ucsb.edu. [169.231.139.87]) by smtp.gmail.com with ESMTPSA id z23-20020a9d65d7000000b0060603221235sm1392635oth.5.2022.05.11.17.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 17:15:48 -0700 (PDT) From: Max Fletcher To: djogorchock@gmail.com, jikos@kernel.org, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Max Fletcher Subject: [PATCH 2/2] HID: nintendo: add parameter to swap face buttons Date: Wed, 11 May 2022 17:15:00 -0700 Message-Id: <20220512001500.16739-2-fletcher0max@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220512001500.16739-1-fletcher0max@gmail.com> References: <20220512001500.16739-1-fletcher0max@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the module parameter "faceswap" that swaps the face (ABXY) buttons to match the printed layout. This will be helpful for people who prefer to use the Nintendo layout over the Xbox layout. Signed-off-by: Max Fletcher --- drivers/hid/hid-nintendo.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c index 7735971ede3f..925cdcd0ac77 100644 --- a/drivers/hid/hid-nintendo.c +++ b/drivers/hid/hid-nintendo.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -320,6 +321,8 @@ struct joycon_imu_cal { s16 scale[3]; }; +bool faceswap; + /* * All the controller's button values are stored in a u32. * They can be accessed with bitwise ANDs. @@ -1351,10 +1354,17 @@ static void joycon_parse_report(struct joycon_ctlr *ctlr, input_report_key(dev, BTN_START, btns & JC_BTN_PLUS); input_report_key(dev, BTN_THUMBR, btns & JC_BTN_RSTICK); input_report_key(dev, BTN_MODE, btns & JC_BTN_HOME); - input_report_key(dev, BTN_X, btns & JC_BTN_Y); - input_report_key(dev, BTN_Y, btns & JC_BTN_X); - input_report_key(dev, BTN_B, btns & JC_BTN_A); - input_report_key(dev, BTN_A, btns & JC_BTN_B); + if (!faceswap) { + input_report_key(dev, BTN_X, btns & JC_BTN_Y); + input_report_key(dev, BTN_Y, btns & JC_BTN_X); + input_report_key(dev, BTN_B, btns & JC_BTN_A); + input_report_key(dev, BTN_A, btns & JC_BTN_B); + } else { + input_report_key(dev, BTN_Y, btns & JC_BTN_Y); + input_report_key(dev, BTN_X, btns & JC_BTN_X); + input_report_key(dev, BTN_A, btns & JC_BTN_A); + input_report_key(dev, BTN_B, btns & JC_BTN_B); + } } input_sync(dev); @@ -2313,6 +2323,10 @@ static const struct hid_device_id nintendo_hid_devices[] = { }; MODULE_DEVICE_TABLE(hid, nintendo_hid_devices); +module_param(faceswap, bool, 0440); +MODULE_PARM_DESC(faceswap, + "Swaps the face buttons to match the printed layout"); + static struct hid_driver nintendo_hid_driver = { .name = "nintendo", .id_table = nintendo_hid_devices, -- 2.35.3