Re: [PATCH 1/2] xpad: XTYPE_XBOX: Report analog buttons

From: Max Staudt
Date: Sun Aug 27 2023 - 11:14:26 EST


On 8/27/23 01:52, Rahul Rameshbabu wrote:
You will want to update the commit message subject to use the prefix
"Input: xpad -" instead of "xpad:".

Thanks, will do!


+/* used for analog face buttons mapped to axes */
+static const signed short xpad_abs_analog_face_buttons[] = {
+ ABS_MISC + 0, ABS_MISC + 1, /* A, B */
+ ABS_MISC + 3, ABS_MISC + 4, /* X, Y */
+ ABS_MISC + 2, ABS_MISC + 5, /* C, Z */
+ -1
+};

Would it make more sense to use an enum for this?
Something like the below enum.

enum xpad_abs_analog_face_btn {
XPAD_ABS_ANALOG_FACE_BTN_A = ABS_MISC,
XPAD_ABS_ANALOG_FACE_BTN_B,
XPAD_ABS_ANALOG_FACE_BTN_C,
XPAD_ABS_ANALOG_FACE_BTN_X,
XPAD_ABS_ANALOG_FACE_BTN_Y,
XPAD_ABS_ANALOG_FACE_BTN_Z,
XPAD_ABS_ANALOG_FACE_BTN_END, /* Must remain as the last element */
};

This would clean up both xpad_process_packet and xpad_set_up_abs a bit
in my opinion. Your loop for xpad_set_up_abs would look like the
following.

enum xpad_abs_analog_face_btn btn;

...

for (btn = XPAD_ABS_ANALOG_FACE_BTN_A; btn != XPAD_ABS_ANALOG_FACE_BTN_END; ++btn)
xpad_set_up_abs(input_dev, btn);

I agree, that looks cleaner.

Since it's a step closer to standardising a mapping for those analog buttons, I'd like to wait and see whether there is a consensus across drivers and maintainers. Maybe we can include something like this enum in input-event-codes.h and have a really clean solution.



Thanks!

Max