We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents bde522d + 45be5d9 commit 170fb29Copy full SHA for 170fb29
libndofdev/ndofdev.c
@@ -261,8 +261,24 @@ int ndof_init_first(NDOF_Device *in_out_dev, void *param)
261
262
} else {
263
#ifdef USE_SDL3
264
+ if(!SDL_HasJoystick())
265
+ {
266
+ return -1;
267
+ }
268
+
269
+ int count = 0;
270
+ SDL_JoystickID *ids = SDL_GetJoysticks(&count);
271
+ if(0 >= count)
272
273
274
275
276
+ // Get ID of first device
277
+ SDL_JoystickID first_device = ids[0];
278
+ SDL_free(ids);
279
280
// SpaceNavigator not found, use SDL Joystick
- SDL_Joystick *j = SDL_OpenJoystick(0);
281
+ SDL_Joystick *j = SDL_OpenJoystick(first_device);
282
if(j)
283
{
284
in_out_dev->axes_count = SDL_GetNumJoystickAxes(j) + SDL_GetNumJoystickHats(j) * 2; // each hat has 2 axes
0 commit comments