[PATCH 03/26] Input: maplecontrol - only enable present axes
Dmitry Torokhov
dmitry.torokhov at gmail.com
Fri Jul 3 22:57:26 PDT 2026
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
Signed-off-by: Dmitry Torokhov <dmitry.torokhov at gmail.com>
---
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;
--
2.55.0.rc0.799.gd6f94ed593-goog
More information about the linux-mtd
mailing list