Repository navigation
Commit 16fdccf
Fix SDL3 joystick enumeration using device indices as instance IDs (#182)
* Fix SDL3 joystick enumeration using device indices as instance IDs
get_joysticks/get_controllers/_get_all passed range(count) indices into
SDL_OpenJoystick/SDL_OpenGamepad/SDL_IsGamepad, which on SDL3 take an
SDL_JoystickID instance ID. _get_number discarded the instance-ID array
that SDL_GetJoysticks returns, so enumeration opened the wrong device or
failed once instance IDs diverged from device indices (e.g. after a pad
was reconnected).
Replace _get_number with _get_instance_ids, which keeps and frees the
SDL_GetJoysticks array, and enumerate by instance ID.
Fixes #181
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kyle Benesch <4b796c65+github@gmail.com>1 parent efb077c commit 16fdccf
2 files changed
Lines changed: 23 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
188 | | - | |
| 187 | + | |
| 188 | + | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
350 | | - | |
351 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
352 | 357 | | |
353 | 358 | | |
354 | | - | |
355 | | - | |
| 359 | + | |
| 360 | + | |
356 | 361 | | |
357 | 362 | | |
358 | 363 | | |
359 | 364 | | |
360 | | - | |
| 365 | + | |
361 | 366 | | |
362 | 367 | | |
363 | 368 | | |
364 | 369 | | |
365 | 370 | | |
366 | 371 | | |
367 | 372 | | |
368 | | - | |
| 373 | + | |
369 | 374 | | |
370 | 375 | | |
371 | 376 | | |
| |||
374 | 379 | | |
375 | 380 | | |
376 | 381 | | |
377 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
378 | 386 | | |
379 | 387 | | |
380 | 388 | | |
| |||
0 commit comments