From dbb660ccc9f1506f87f92b51b013043b113b074a Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 3 Jul 2026 22:57:26 -0700 Subject: [PATCH] Input: maplecontrol - only enable present axes The driver was unconditionally enabling all possible analog axes and hats on the input device, even if the controller reported it did not have them in its function data. Move the input_set_abs_params() calls inside the capability check loop so that only actually present axes are enabled on the input device. Also, correct the D-pad (hat) axis limits. They were initialized with inverted limits (min=1, max=-1). Correct them to min=-1, max=1, which matches the values (-1, 0, 1) reported by the driver. Assisted-by: Antigravity:gemini-3.5-flash Link: https://patch.msgid.link/20260703-b4-maple-cleanup-v1-3-41e424964da5@gmail.com Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/maplecontrol.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/input/joystick/maplecontrol.c b/drivers/input/joystick/maplecontrol.c index 6293b6e8148b..a498fc322c4d 100644 --- a/drivers/input/joystick/maplecontrol.c +++ b/drivers/input/joystick/maplecontrol.c @@ -118,26 +118,19 @@ static int probe_maple_controller(struct device *dev) idev->close = dc_pad_close; for (i = 0; i < 32; i++) { - if (data & (1 << i)) { + if (data & BIT(i)) { if (btn_bit[i] >= 0) __set_bit(btn_bit[i], idev->keybit); - else if (abs_bit[i] >= 0) - __set_bit(abs_bit[i], idev->absbit); + else if (abs_bit[i] >= ABS_X && abs_bit[i] <= ABS_BRAKE) + input_set_abs_params(idev, abs_bit[i], 0, 255, 0, 0); + else if (abs_bit[i] >= ABS_HAT0X && abs_bit[i] <= ABS_HAT3Y) + input_set_abs_params(idev, abs_bit[i], -1, 1, 0, 0); } } if (idev->keybit[BIT_WORD(BTN_JOYSTICK)]) idev->evbit[0] |= BIT_MASK(EV_KEY); - if (idev->absbit[0]) - idev->evbit[0] |= BIT_MASK(EV_ABS); - - for (i = ABS_X; i <= ABS_BRAKE; i++) - input_set_abs_params(idev, i, 0, 255, 0, 0); - - for (i = ABS_HAT0X; i <= ABS_HAT3Y; i++) - input_set_abs_params(idev, i, 1, -1, 0, 0); - idev->dev.platform_data = pad; idev->dev.parent = &mdev->dev; idev->name = mdev->product_name;