From patchwork Sun Nov 26 00:15:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Koskovich X-Patchwork-Id: 13468697 X-Patchwork-Delegate: jikos@jikos.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="YFIGQbOZ" Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12324133; Sat, 25 Nov 2023 16:16:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1700957767; x=1701216967; bh=P1pnzMB33pcjyYnWs1uOpWPQE6zW15EcToOjweNN8qU=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=YFIGQbOZGbogg9ojHIfruFn7qEDtyi7Sb3c8jwg8ulDZiC28C6w9MLBVeCemhVFZT diOT6Cb/nnUsL+wNTiLuVTdO+51ijhS6amaQLM2EpMY+jXbFAaR7tF0wUHb+GJ2EsZ QqaCTRhV+2DjtDTDmt/osTdl8FEfKzZW4q6VyoYnWkp6TkC/nKP1Y7hpfuzYtOMmf9 pphoOBMmWUb1yJ2Slkd9i1z4elzTqd78G5+gXzyMJLnhhhSqqaX6Un/lxiJzGo8I4p myDQfXY1ANJZ1/PRcNEcCnSWk5rHZ9/E29P5JQhpDmZJ84YXDaDzM+JxsukjaQs4wO T+PT2GBJasRTw== Date: Sun, 26 Nov 2023 00:15:49 +0000 To: roderick.colenbrander@sony.com, jikos@kernel.org, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org From: Alexander Koskovich Cc: Alexander Koskovich Subject: [PATCH 1/1] hid-playstation: Fix button maps for the DualSense Edge controller Message-ID: <20231126001544.747151-1-akoskovich@pm.me> Feedback-ID: 37836894:user:proton Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This brings functionality of the DualSense Edge controller inline with the stock PS5 controller. Signed-off-by: Alexander Koskovich --- drivers/hid/hid-playstation.c | 60 ++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 8ac8f7b8e317..fc42003cc0eb 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -1344,10 +1344,18 @@ static int dualsense_parse_report(struct ps_device *ps_dev, struct hid_report *r input_report_abs(ds->gamepad, ABS_X, ds_report->x); input_report_abs(ds->gamepad, ABS_Y, ds_report->y); - input_report_abs(ds->gamepad, ABS_RX, ds_report->rx); - input_report_abs(ds->gamepad, ABS_RY, ds_report->ry); - input_report_abs(ds->gamepad, ABS_Z, ds_report->z); - input_report_abs(ds->gamepad, ABS_RZ, ds_report->rz); + + if (hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) { + input_report_abs(ds->gamepad, ABS_RX, ds_report->z); + input_report_abs(ds->gamepad, ABS_RY, ds_report->rz); + input_report_abs(ds->gamepad, ABS_Z, ds_report->rx); + input_report_abs(ds->gamepad, ABS_RZ, ds_report->ry); + } else { + input_report_abs(ds->gamepad, ABS_RX, ds_report->rx); + input_report_abs(ds->gamepad, ABS_RY, ds_report->ry); + input_report_abs(ds->gamepad, ABS_Z, ds_report->z); + input_report_abs(ds->gamepad, ABS_RZ, ds_report->rz); + } value = ds_report->buttons[0] & DS_BUTTONS0_HAT_SWITCH; if (value >= ARRAY_SIZE(ps_gamepad_hat_mapping)) @@ -1355,19 +1363,49 @@ static int dualsense_parse_report(struct ps_device *ps_dev, struct hid_report *r input_report_abs(ds->gamepad, ABS_HAT0X, ps_gamepad_hat_mapping[value].x); input_report_abs(ds->gamepad, ABS_HAT0Y, ps_gamepad_hat_mapping[value].y); - input_report_key(ds->gamepad, BTN_WEST, ds_report->buttons[0] & DS_BUTTONS0_SQUARE); - input_report_key(ds->gamepad, BTN_SOUTH, ds_report->buttons[0] & DS_BUTTONS0_CROSS); - input_report_key(ds->gamepad, BTN_EAST, ds_report->buttons[0] & DS_BUTTONS0_CIRCLE); - input_report_key(ds->gamepad, BTN_NORTH, ds_report->buttons[0] & DS_BUTTONS0_TRIANGLE); + if (hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) { + input_report_key(ds->gamepad, BTN_WEST, + ds_report->buttons[0] & DS_BUTTONS0_TRIANGLE); + input_report_key(ds->gamepad, BTN_SOUTH, + ds_report->buttons[0] & DS_BUTTONS0_SQUARE); + input_report_key(ds->gamepad, BTN_EAST, + ds_report->buttons[0] & DS_BUTTONS0_CROSS); + input_report_key(ds->gamepad, BTN_NORTH, + ds_report->buttons[0] & DS_BUTTONS0_CIRCLE); + } else { + input_report_key(ds->gamepad, BTN_WEST, + ds_report->buttons[0] & DS_BUTTONS0_SQUARE); + input_report_key(ds->gamepad, BTN_SOUTH, + ds_report->buttons[0] & DS_BUTTONS0_CROSS); + input_report_key(ds->gamepad, BTN_EAST, + ds_report->buttons[0] & DS_BUTTONS0_CIRCLE); + input_report_key(ds->gamepad, BTN_NORTH, + ds_report->buttons[0] & DS_BUTTONS0_TRIANGLE); + } + input_report_key(ds->gamepad, BTN_TL, ds_report->buttons[1] & DS_BUTTONS1_L1); input_report_key(ds->gamepad, BTN_TR, ds_report->buttons[1] & DS_BUTTONS1_R1); input_report_key(ds->gamepad, BTN_TL2, ds_report->buttons[1] & DS_BUTTONS1_L2); input_report_key(ds->gamepad, BTN_TR2, ds_report->buttons[1] & DS_BUTTONS1_R2); input_report_key(ds->gamepad, BTN_SELECT, ds_report->buttons[1] & DS_BUTTONS1_CREATE); input_report_key(ds->gamepad, BTN_START, ds_report->buttons[1] & DS_BUTTONS1_OPTIONS); - input_report_key(ds->gamepad, BTN_THUMBL, ds_report->buttons[1] & DS_BUTTONS1_L3); - input_report_key(ds->gamepad, BTN_THUMBR, ds_report->buttons[1] & DS_BUTTONS1_R3); - input_report_key(ds->gamepad, BTN_MODE, ds_report->buttons[2] & DS_BUTTONS2_PS_HOME); + + if (hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) { + input_report_key(ds->gamepad, BTN_THUMBL, + ds_report->buttons[1] & DS_BUTTONS1_R3); + input_report_key(ds->gamepad, BTN_THUMBR, + ds_report->buttons[2] & DS_BUTTONS2_PS_HOME); + input_report_key(ds->gamepad, BTN_MODE, + ds_report->buttons[1] & DS_BUTTONS1_L3); + } else { + input_report_key(ds->gamepad, BTN_THUMBL, + ds_report->buttons[1] & DS_BUTTONS1_L3); + input_report_key(ds->gamepad, BTN_THUMBR, + ds_report->buttons[1] & DS_BUTTONS1_R3); + input_report_key(ds->gamepad, BTN_MODE, + ds_report->buttons[2] & DS_BUTTONS2_PS_HOME); + } + input_sync(ds->gamepad); /*