Skip to content

Commit

Permalink
xpadneo, init: Do not report paddles unconditionally
Browse files Browse the repository at this point in the history
SDL2 author @slouken pointed out that the bitmap cannot be properly
tested for the existence of the XBE2 paddles. This commit fixes that by
first testing if the paddles exist in the bitmap, and only then enable
the remaining three paddles. The underlying problem is that the HID
descriptor does not have a properly defined bitmap for the paddles but
a single 4-bit value instead.

See-also: atar-axis#428
Signed-off-by: Kai Krakow <kai@kaishome.de>
  • Loading branch information
kakra committed Jun 14, 2023
1 parent 0675cb3 commit 17bac26
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions hid-xpadneo/src/hid-xpadneo.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,11 +906,12 @@ static int xpadneo_input_configured(struct hid_device *hdev, struct hid_input *h
/* do not report the consumer control buttons as part of the gamepad */
__clear_bit(BTN_SHARE, xdata->idev->keybit);

/* add paddles as part of the gamepad */
__set_bit(BTN_PADDLES(0), xdata->idev->keybit);
__set_bit(BTN_PADDLES(1), xdata->idev->keybit);
__set_bit(BTN_PADDLES(2), xdata->idev->keybit);
__set_bit(BTN_PADDLES(3), xdata->idev->keybit);
/* ensure all four paddles exist as part of the gamepad */
if (test_bit(BTN_PADDLES(0), xdata->idev->keybit)) {
__set_bit(BTN_PADDLES(1), xdata->idev->keybit);
__set_bit(BTN_PADDLES(2), xdata->idev->keybit);
__set_bit(BTN_PADDLES(3), xdata->idev->keybit);
}

return 0;
}
Expand Down

0 comments on commit 17bac26

Please sign in to comment.