From patchwork Thu May 12 00:14:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxwell Fletcher X-Patchwork-Id: 12846757 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA077C433EF for ; Thu, 12 May 2022 00:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349603AbiELAPo (ORCPT ); Wed, 11 May 2022 20:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349600AbiELAPm (ORCPT ); Wed, 11 May 2022 20:15:42 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4A0213CA0A; Wed, 11 May 2022 17:15:37 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id q10so4598533oia.9; Wed, 11 May 2022 17:15:37 -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:mime-version :content-transfer-encoding; bh=CwF4OHVvt2/W8/fWhl2zbk3bkx19u2MZi1kJ5541uj8=; b=JIOiyWZp/G5JC4MWsBffctuOOWbvvZpQxuBEL1q05eK4/n5arHlfQI0dgpQYFXagFO AGxJciNUa3sMLRnzViH+R8Cbq/83+YWxfNczaP+mVf2qpuUtNX4WX1U/l0VX9TnRA74z p6iqrXrcBReuwguPUHHmziVPRmDFwLdQhLVLqeFYBct0L4D8NCz/YLWA6H8kFaC/II7c XmcQflRpoyrrXQSv1mtDlVFlJiwgsYhzW7VQMu6xCNnNOv5UDqtAx2D96PunTDSfb536 iep6iTDECao6sxbIxIxVUH7WKP/A0JcK+ArhU/uwGDSF3ade5f113mt4fQ5UxRWlYcvz I3OQ== 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:mime-version :content-transfer-encoding; bh=CwF4OHVvt2/W8/fWhl2zbk3bkx19u2MZi1kJ5541uj8=; b=VXtdFbr+SjfRfKuQ8PWTQn+QE8Z5fqQxA4sEpnqZF9u/uzpAzNoZztoiUVlCcknOC8 /zD5DjuBodwlp/HMs2uieka5AJfrtap/L7+9BhEekTZp8CtfHQe56pfYVogUpnk6+7C7 hfppzDCSRJFom8UbY69H4UiFzqiDu1aJFKHm+/O1TJVU2bLONh+JSk8yiSn1i1SDgdKH 8iAukM+wYMJkzWJ+uVoLbEYgSNny0WW9NAjcufjjXKfT9gYHQN8LSQsY1pLe2zcrHWra hpdl3KD/+BTxAskYKWx8GV5WCHBOxqURsTgbPRA9yXyMypLeCkR/E2Dgp25GmqUs+E8h V5Vw== X-Gm-Message-State: AOAM533biIUiPvZp1718NdDvV4xE5KrdlUcrtjyq1jFMXy8eba00hd/3 pL5VudMZkUE0V4/dnPemf+I= X-Google-Smtp-Source: ABdhPJy97TB8m3Ng26yRdFYL14QRXz+1D9b+EYJPwKHn/73E8WX4UKBWyK3qcKt0sHTt91kOb7OC4A== X-Received: by 2002:aca:a996:0:b0:326:9197:4b41 with SMTP id s144-20020acaa996000000b0032691974b41mr3694555oie.221.1652314537212; Wed, 11 May 2022 17:15:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 17:15:36 -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 1/2] HID: nintendo: fix face button mappings Date: Wed, 11 May 2022 17:14:59 -0700 Message-Id: <20220512001500.16739-1-fletcher0max@gmail.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Previously, A and B would match the Xbox layout, but X and Y were incorrectly swapped. This corrects it so that X and Y match the Xbox layout. Signed-off-by: Max Fletcher --- drivers/hid/hid-nintendo.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c index 2204de889739..7735971ede3f 100644 --- a/drivers/hid/hid-nintendo.c +++ b/drivers/hid/hid-nintendo.c @@ -1351,10 +1351,10 @@ 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_WEST, btns & JC_BTN_Y); - input_report_key(dev, BTN_NORTH, btns & JC_BTN_X); - input_report_key(dev, BTN_EAST, btns & JC_BTN_A); - input_report_key(dev, BTN_SOUTH, btns & JC_BTN_B); + 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); } input_sync(dev); @@ -1578,7 +1578,7 @@ static const unsigned int joycon_button_inputs_l[] = { static const unsigned int joycon_button_inputs_r[] = { BTN_START, BTN_MODE, BTN_THUMBR, - BTN_SOUTH, BTN_EAST, BTN_NORTH, BTN_WEST, + BTN_A, BTN_B, BTN_Y, BTN_X, BTN_TR, BTN_TR2, 0 /* 0 signals end of array */ }; From patchwork Thu May 12 00:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxwell Fletcher X-Patchwork-Id: 12846758 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65AADC433F5 for ; Thu, 12 May 2022 00:16:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239985AbiELAQF (ORCPT ); Wed, 11 May 2022 20:16:05 -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-Google-Smtp-Source: ABdhPJwoDecLr2WXu80NgjTEUn84SQe11nQvDvepCnDLJCLW5E0woMI4dASTPgEEhcQZl/Gn4kWyVg== 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 Precedence: bulk List-ID: X-Mailing-List: linux-input@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,