diff --git a/hid-xpadneo/src/hid-xpadneo.c b/hid-xpadneo/src/hid-xpadneo.c index 3ec206d..6df4e13 100644 --- a/hid-xpadneo/src/hid-xpadneo.c +++ b/hid-xpadneo/src/hid-xpadneo.c @@ -906,6 +906,13 @@ static int xpadneo_input_configured(struct hid_device *hdev, struct hid_input *h __set_bit(BTN_PADDLES(3), xdata->gamepad->keybit); } + /* expose current profile as buttons */ + __set_bit(BTN_PROFILES(0), xdata->gamepad->keybit); + __set_bit(BTN_PROFILES(1), xdata->gamepad->keybit); + __set_bit(BTN_PROFILES(2), xdata->gamepad->keybit); + __set_bit(BTN_PROFILES(3), xdata->gamepad->keybit); + input_report_key(xdata->gamepad, BTN_PROFILES(0), 1); + return 0; } @@ -1026,6 +1033,14 @@ static int xpadneo_event(struct hid_device *hdev, struct hid_field *field, } stop_processing: + /* report the profile change */ + if (xdata->last_profile != xdata->profile) { + if (xdata->last_profile < 4) + input_report_key(gamepad, BTN_PROFILES(xdata->last_profile), 0); + input_report_key(gamepad, BTN_PROFILES(xdata->profile), 1); + xdata->last_profile = xdata->profile; + } + return 1; } diff --git a/hid-xpadneo/src/xpadneo.h b/hid-xpadneo/src/xpadneo.h index 727cbc5..152c935 100644 --- a/hid-xpadneo/src/xpadneo.h +++ b/hid-xpadneo/src/xpadneo.h @@ -48,9 +48,10 @@ do { \ } while (0) /* button aliases */ -#define BTN_PADDLES(b) (BTN_TRIGGER_HAPPY5+(b)) -#define BTN_SHARE KEY_F12 -#define BTN_XBOX BTN_MODE +#define BTN_PROFILES(b) (BTN_TRIGGER_HAPPY33+(b)) +#define BTN_PADDLES(b) (BTN_TRIGGER_HAPPY5+(b)) +#define BTN_SHARE KEY_F12 +#define BTN_XBOX BTN_MODE /* module parameter "trigger_rumble_mode" */ #define PARAM_TRIGGER_RUMBLE_PRESSURE 0 @@ -152,7 +153,7 @@ struct xpadneo_devdata { /* profile switching */ bool xbox_button_down, profile_switched; - u8 profile; + u8 last_profile, profile; /* mouse mode */ bool mouse_mode;