AntiMicroX / AntiMicroX/antimicrox

Invalid number of gamepad buttons is showed

Đang mở
#582 1 bình luận 2 reaction 0 người được giao Xem trên GitHub
bug low-priotity refactor
Ngôn ngữ chính
C++
Star
4k
Fork
249
Merge trung bình
13 phút
Pull request đã merge (30 ngày)
1

Mô tả

All of the gamepads in AntiMicroX show wrong number of buttons.

![](https://user-images.githubusercontent.com/889881/144520351-da1e2b02-b997-4ebe-8371-6d6e9b6e8615.png)

This is caused by hardcoded value of button number for every device recognized as GamePad.

```cpp
int GameController::getNumberRawButtons() { return SDL_CONTROLLER_BUTTON_MAX; }
```

Fixing attempt https://github.com/AntiMicroX/antimicrox/pull/555
```cpp
int GameController::getNumberRawButtons() { return SDL_JoystickNumButtons(m_device); }
```
caused sudden crashes for some controllers https://github.com/AntiMicroX/antimicrox/issues/579 caused smaller than expected number of buttons (and lack of proper handling of this case)

At first glance, it seems, that SDL API `SDL_JoystickNumButtons` is broken, because in some cases it shows invalid number of buttons.

`Button numbers for gamepad: PS5 Controller SDL_JoystickNumButtons: 13`

SDL version: 2.24.0

Example log from this kind of situation:
[antimicrox.log](https://github.com/AntiMicroX/antimicrox/files/9859603/antimicrox.log)

Reported to SDL https://github.com/libsdl-org/SDL/issues/6442

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.