From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0522233C199 for ; Tue, 24 Feb 2026 21:10:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771967458; cv=none; b=LYPt8mLMvKeUZc5Zpq68wWmfJhl172QE1OJPs26JDm1O76I9TK8XnPR25qUARsltkbn9T/YvQhT3DVb0hAFswm1ivPoYwxoBZi3edxnaLQQf6qpFzaaZPdW1pLmUZ1fvEMsZCIlexSEfrtnjOWqAXZTe/2lk/DKOkizGDvjVwUE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771967458; c=relaxed/simple; bh=C+YKbMIg+dCWCiO5+yHLe3GBpe8roAq2g62ABCRHIKg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ot8M77hO3ne7z2vXa1bXkP2U7Y/huCtMcN6ho2ICAGLs3Gb5T17GcWPMzUL3OcL/SasuuHCnpIDNuNmJrMruUy2UnAfXserNnVGa5oDXSs4M/Z206uJkUFRaLoAnLvztOEFYUWvph1hGlr9cCMy3c+VdqJu/CLTjE0DP1JMBkmc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=e6sHPJj4; arc=none smtp.client-ip=74.125.82.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e6sHPJj4" Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-2bdbe434b47so683065eec.1 for ; Tue, 24 Feb 2026 13:10:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771967456; x=1772572256; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=sMXb01L8QgoCBtEDBRsVtf1TuUoR4a0hS1+b6eQlnTk=; b=e6sHPJj413kRgR5U5yiu97GOpjJp5vyTYF+6VTXYpa/TOwj9mJ5Gk97Fm5uLr5cXbd niS1JsHPXzScZLl7sygLiu0NRjiC1Go+RDnpqFtO+M1qsdVzwCKGD4fSbfFs9IHsOAAR ut2fFZPk4IK27PDrkORgVai9HxoEIj7RbMB7lUv2j/Y2/3ruu2L/GguZ++JQP8iIEQrk jRrjhtWzxepzq+n5kPLPEj8PBKQjmVHtqaIHRp9EEyqva20SBqmjQerh6NIgJO69rNpr 2fs5vVrq8hcbWP1LKD2d6/UDT4WwFnPRuZ3uYveM3RHztj/9ZAZ3lWiRuLYwANniXCCJ K2cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771967456; x=1772572256; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=sMXb01L8QgoCBtEDBRsVtf1TuUoR4a0hS1+b6eQlnTk=; b=O7EEL9mFaJUn8G0MTY0gYXy03W37VYwIgNTJbh5MV5nqa1QjaTT9ETyTIVoUC9+Ou/ wd8Qf9rf/4/pcHM81r7uoS8mf8J6h4dPJuVYI2GM12Y+MGkxCF33nFy1YEHyd+zVu/F6 nKrZVRUGXN9m10x8upurGORwFeg30kiRv/DyprSSx8V0YIidwD6fSztsAlkh1CtEabln iF7r+NaFP0E5mW92HdpjtuN8NSUrh6lwya3fx0qh+WXnX5Ymqi//Pl8BvHcMQnTSzDT/ lNyXfrX34VYpX+r1lb1oFqNJAqltz4EgXEylCz72ApnwF5bXwPyHgQ7qEvYwtF5jxa4d 7VcQ== X-Forwarded-Encrypted: i=1; AJvYcCW3a6QTXK2A7csAk3lCnw8HgiUe9Qg/n2VrQ/+UW2wMUBUBIJWSa6uilb8n+vbLZJRfSMj2KP7S9yyAYKA=@vger.kernel.org X-Gm-Message-State: AOJu0YzVEq7EfQX8WvFARVIvzOlwUzPHfBq+dZgWWRg0K/NG0YckMa1q aYEc8ULLO2xJBS6V9WtKrwTLwHLMuqMqquyThOdpqJ6FD2AvoUCeBjN/ X-Gm-Gg: ATEYQzzU+xF7moxNPEMUMg1iPTk0fmEKuL4V76aIqgfT2quzqcxr499btdWuz3Mqzyf rF2Ekb7fFYYh4abMWAQJyHj00Fxy5UNFGMJNGPUzpPBCc8kYdlL/aH/PG5fNa8QKv6G4P9vtpd1 NrlgH+PzMAYTEWLrcVyTC/5ti/p33mdbEBUt6EPMycqLb/Zgaur9Y0FY55JkQCaoly24Mpnfw3Z Xmv+6iLd3FVkDBcmXxGF8UVZ/zzaKrthq3L9b0SY1X43Wn0qB1bRNLxNMsaj4WKeL1ofSGqp1z0 Emto7N/EOej6igBjOhXNprfCfGUAtuq7UnPbRayo4SWS29o3G7OJ/OuxBR7E/gwgMw95S5r9J0m 8cRxNQSFbsTrfvgkiobCkluUDwRZnT0NsZB9xuRaz/KnYkkd4jHJqURuqeBwTqQv/KufCJBTR4e 4Mkr1mVynFdpcVoTLHOrQaAkhTI/9JC+IAeckYVQJA3IUYt+g= X-Received: by 2002:a05:7300:cd43:b0:2b7:f28d:c8c1 with SMTP id 5a478bee46e88-2bd7b906d62mr5595398eec.0.1771967455969; Tue, 24 Feb 2026 13:10:55 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:da43:aeff:fecc:bfd5]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2bd7dbe8304sm7540824eec.17.2026.02.24.13.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 13:10:55 -0800 (PST) Sender: Guenter Roeck Date: Tue, 24 Feb 2026 13:10:53 -0800 From: Guenter Roeck To: Siarhei Vishniakou Cc: Jiri Kosina , Benjamin Tissoires , Roderick Colenbrander , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] HID: playstation: Center initial joystick axes to prevent spurious events Message-ID: References: <20251111234519.369652-1-svv@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251111234519.369652-1-svv@google.com> On Tue, Nov 11, 2025 at 03:45:19PM -0800, Siarhei Vishniakou wrote: > When a new PlayStation gamepad (DualShock 4 or DualSense) is initialized, > the input subsystem sets the default value for its absolute axes (e.g., > ABS_X, ABS_Y) to 0. > > However, the hardware's actual neutral/resting state for these joysticks > is 128 (0x80). This creates a mismatch. > > When the first HID report arrives from the device, the driver sees the > resting value of 128. The kernel compares this to its initial state of 0 > and incorrectly interprets this as a delta (0 -> 128). Consequently, it > generates EV_ABS events for this initial, non-existent movement. > > This behavior can fail userspace 'sanity check' tests (e.g., in > Android CTS) that correctly assert no motion events should be generated > from a device that is already at rest. > > This patch fixes the issue by explicitly setting the initial value of the > main joystick axes (e.g., ABS_X, ABS_Y, ABS_RX, ABS_RY) to 128 (0x80) > in the common ps_gamepad_create() function. > > This aligns the kernel's initial state with the hardware's expected > neutral state, ensuring that the first report (at 128) produces no > delta and thus, no spurious event. > > Signed-off-by: Siarhei Vishniakou > Reviewed-by: Benjamin Tissoires > --- > drivers/hid/hid-playstation.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c > index 1468fb11e39d..a145b5ea4405 100644 > --- a/drivers/hid/hid-playstation.c > +++ b/drivers/hid/hid-playstation.c > @@ -718,11 +718,16 @@ static struct input_dev *ps_gamepad_create(struct hid_device *hdev, > if (IS_ERR(gamepad)) > return ERR_CAST(gamepad); > > + /* Set initial resting state for joysticks to 128 (center) */ > input_set_abs_params(gamepad, ABS_X, 0, 255, 0, 0); > + gamepad->absinfo[ABS_X].value = 128; input_set_abs_params() can fail to allocate absinfo. If that happens, this will crash. AI suggests setting the value with input_abs_set_val() to ensure that the value is checked before dereferencing. Guenter > input_set_abs_params(gamepad, ABS_Y, 0, 255, 0, 0); > + gamepad->absinfo[ABS_Y].value = 128; > input_set_abs_params(gamepad, ABS_Z, 0, 255, 0, 0); > input_set_abs_params(gamepad, ABS_RX, 0, 255, 0, 0); > + gamepad->absinfo[ABS_RX].value = 128; > input_set_abs_params(gamepad, ABS_RY, 0, 255, 0, 0); > + gamepad->absinfo[ABS_RY].value = 128; > input_set_abs_params(gamepad, ABS_RZ, 0, 255, 0, 0); > > input_set_abs_params(gamepad, ABS_HAT0X, -1, 1, 0, 0); > -- > 2.51.2.1041.gc1ab5b90ca-goo