Skip to content

Commit abe3275

Browse files
committed
xpadneo, profiles: Report current profile as depressed button
This way, user-space can figure out which profile currently is configured. Take note that this may also involve a different button mapping, and only profile 0 has paddles forcibly reported as their distinct events (otherwise mapped to A, B, X, and Y by default). Link: atar-axis#428 Signed-off-by: Kai Krakow <kai@kaishome.de>
1 parent 1b409b1 commit abe3275

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

hid-xpadneo/src/hid-xpadneo.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,13 @@ static int xpadneo_input_configured(struct hid_device *hdev, struct hid_input *h
900900
__set_bit(BTN_PADDLES(3), xdata->gamepad->keybit);
901901
}
902902

903+
/* expose current profile as buttons */
904+
__set_bit(BTN_PROFILES(0), xdata->gamepad->keybit);
905+
__set_bit(BTN_PROFILES(1), xdata->gamepad->keybit);
906+
__set_bit(BTN_PROFILES(2), xdata->gamepad->keybit);
907+
__set_bit(BTN_PROFILES(3), xdata->gamepad->keybit);
908+
input_report_key(xdata->gamepad, BTN_PROFILES(0), 1);
909+
903910
return 0;
904911
}
905912

@@ -1019,6 +1026,14 @@ static int xpadneo_event(struct hid_device *hdev, struct hid_field *field,
10191026
}
10201027

10211028
stop_processing:
1029+
/* report the profile change */
1030+
if (xdata->last_profile != xdata->profile) {
1031+
if (xdata->last_profile < 4)
1032+
input_report_key(gamepad, BTN_PROFILES(xdata->last_profile), 0);
1033+
input_report_key(gamepad, BTN_PROFILES(xdata->profile), 1);
1034+
xdata->last_profile = xdata->profile;
1035+
}
1036+
10221037
return 1;
10231038
}
10241039

hid-xpadneo/src/xpadneo.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ do { \
4848
} while (0)
4949

5050
/* button aliases */
51-
#define BTN_PADDLES(b) (BTN_TRIGGER_HAPPY5+(b))
52-
#define BTN_SHARE KEY_F12
53-
#define BTN_XBOX BTN_MODE
51+
#define BTN_PROFILES(b) (BTN_TRIGGER_HAPPY33+(b))
52+
#define BTN_PADDLES(b) (BTN_TRIGGER_HAPPY5+(b))
53+
#define BTN_SHARE KEY_F12
54+
#define BTN_XBOX BTN_MODE
5455

5556
/* module parameter "trigger_rumble_mode" */
5657
#define PARAM_TRIGGER_RUMBLE_PRESSURE 0
@@ -152,7 +153,7 @@ struct xpadneo_devdata {
152153

153154
/* profile switching */
154155
bool xbox_button_down, profile_switched;
155-
u8 profile;
156+
u8 last_profile, profile;
156157

157158
/* mouse mode */
158159
bool mouse_mode;

0 commit comments

Comments
 (0)