Skip to content

Commit

Permalink
xpadneo, fixups: Adapt SDL fixup to fix the Xbox button
Browse files Browse the repository at this point in the history
A new SDL gamecontrollerdb entry allows us to get rid of the Xbox
button fixup we are carrying around. While this button is still not
exactly a button for games, all software expects it to be part of the
gamepad mapping anyways.

This leaves only the Share button left in the consumer control bits
which doesn't have an jsdev equivalent.

Affects: #286
Maybe-affects: #283
Fixes: #362
Fixes: #359
Closes: #301
Signed-off-by: Kai Krakow <[email protected]>
  • Loading branch information
kakra committed May 30, 2022
1 parent c65477f commit d5ad475
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
18 changes: 7 additions & 11 deletions hid-xpadneo/src/hid-xpadneo.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,11 +929,9 @@ static int xpadneo_input_configured(struct hid_device *hdev, struct hid_input *h
input_set_abs_params(xdata->gamepad, ABS_MISC, -1023, 1023, 3, 63);

/* do not report the consumer control buttons as part of the gamepad */
__clear_bit(BTN_XBOX, xdata->gamepad->keybit);
__clear_bit(BTN_SHARE, xdata->gamepad->keybit);

/* add paddles as part of the gamepad */
__set_bit(BTN_TRIGGER_HAPPY, xdata->gamepad->keybit); /* workaround for Steam */
__set_bit(BTN_PADDLES(0), xdata->gamepad->keybit);
__set_bit(BTN_PADDLES(1), xdata->gamepad->keybit);
__set_bit(BTN_PADDLES(2), xdata->gamepad->keybit);
Expand Down Expand Up @@ -992,17 +990,15 @@ static int xpadneo_event(struct hid_device *hdev, struct hid_field *field,
xdata->xbox_button_down = false;
if (xdata->profile_switched) {
xdata->profile_switched = false;
} else if (consumer) {
} else {
/* replay cached event */
input_report_key(consumer, BTN_XBOX, 1);
input_sync(consumer);
input_report_key(gamepad, BTN_XBOX, 1);
input_sync(gamepad);
/* synthesize the release to remove the scan code */
input_report_key(consumer, BTN_XBOX, 0);
input_sync(consumer);
input_report_key(gamepad, BTN_XBOX, 0);
input_sync(gamepad);
}
}
if (!consumer)
goto consumer_missing;
goto stop_processing;
} else if ((usage->type == EV_KEY) && (usage->code == BTN_SHARE)) {
/* move the Share button to the consumer control device */
Expand Down Expand Up @@ -1201,8 +1197,8 @@ static int xpadneo_probe(struct hid_device *hdev, const struct hid_device_id *id
*/
xdata->original_product = hdev->product;
xdata->original_version = hdev->version;
hdev->product = 0x02E0;
hdev->version = 0x00000903;
hdev->product = 0x02FD;
hdev->version = 0x00001130;

if (hdev->product != xdata->original_product)
hid_info(hdev,
Expand Down
2 changes: 1 addition & 1 deletion hid-xpadneo/src/xpadneo.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ do { \
/* button aliases */
#define BTN_PADDLES(b) (BTN_TRIGGER_HAPPY37+(b))
#define BTN_SHARE KEY_RECORD
#define BTN_XBOX KEY_MODE
#define BTN_XBOX BTN_MODE

/* module parameter "trigger_rumble_mode" */
#define PARAM_TRIGGER_RUMBLE_PRESSURE 0
Expand Down
1 change: 0 additions & 1 deletion hid-xpadneo/src/xpadneo/consumer.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ extern int xpadneo_init_consumer(struct xpadneo_devdata *xdata)
}

/* enable key events for consumer control */
input_set_capability(xdata->consumer, EV_KEY, BTN_XBOX);
input_set_capability(xdata->consumer, EV_KEY, BTN_SHARE);

if (synth) {
Expand Down

0 comments on commit d5ad475

Please sign in to comment.