-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Milestone
Description
This issue was found while testing a different issue here: #13913 and here: godotengine/godot#108753
I've prepared a small program to test joysticks using SDL3
#include <iostream>
#include "SDL3/SDL.h"
using std::cout;
int main()
{
cout << "SDL version: " << SDL_GetVersion() << '\n';
cout << "Before SDL_Init\n";
if (!SDL_Init(SDL_INIT_JOYSTICK)) {
cout << "SDL_Init fail: " << SDL_GetError() << '\n';
return 1;
}
cout << "SDL_Init success\n";
int joystick_count = 0;
SDL_GetJoysticks(&joystick_count);
cout << "Initial joystick count == " << joystick_count << '\n';
SDL_Event event;
bool running = true;
while (running) {
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_EVENT_QUIT:
cout << "Application closed\n";
running = false;
break;
case SDL_EVENT_JOYSTICK_ADDED: {
cout << "Joystick added, before SDL_OpenJoystick\n";
SDL_Joystick* joy = SDL_OpenJoystick(event.jdevice.which);
char guid[64];
SDL_GUIDToString(SDL_GetJoystickGUID(joy), guid, 64);
cout << "Joystick added, name: \"" << SDL_GetJoystickName(joy) << "\", GUID: " << guid
<< ", vendor ID: " << SDL_GetJoystickVendor(joy) << ", product ID: " << SDL_GetJoystickProduct(joy) << '\n';
} break;
case SDL_EVENT_JOYSTICK_REMOVED: {
SDL_CloseJoystick(SDL_GetJoystickFromID(event.jdevice.which));
cout << "Joystick removed\n";
} break;
case SDL_EVENT_JOYSTICK_AXIS_MOTION:
cout << "Joystick axis motion: axis=" << +event.jaxis.axis << " value=" << event.jaxis.value << '\n';
break;
case SDL_EVENT_JOYSTICK_BUTTON_DOWN:
cout << "Joystick button pressed: id=" << +event.jbutton.button << '\n';
break;
case SDL_EVENT_JOYSTICK_BUTTON_UP:
cout << "Joystick button released: id=" << +event.jbutton.button << '\n';
break;
}
}
}
cout << "Before SDL_Quit\n";
SDL_Quit();
cout << "After SDL_Quit\n";
}
The user with the webcam (goncalo) tested this program with both SDL3 3.2.16 (the version Godot Engine currently uses) and 3.2.22 (the latest stable release) and here's what this program outputs:
SDL3 3.2.16 output
SDL version: 3002016
Before SDL_Init
SDL_Init success
Initial joystick count == 1
Joystick added, before SDL_OpenJoystick
Joystick added, name: "HP Deluxe Webcam KQ246AA", GUID: 03006923f20400003ca1000000000000, vendor ID: 1266, product ID: 41276
Joystick button pressed: id=232
Joystick button pressed: id=233
Joystick button pressed: id=234
Joystick button pressed: id=235
Joystick button pressed: id=236
Joystick button pressed: id=237
Joystick button pressed: id=240
Joystick button pressed: id=241
Joystick button pressed: id=242
Joystick button pressed: id=243
Joystick button pressed: id=244
Joystick button pressed: id=245
Joystick button pressed: id=248
SDL3 3.2.22 output
SDL version: 3002022
Before SDL_Init
SDL_Init success
Initial joystick count == 1
Joystick added, before SDL_OpenJoystick
Joystick added, name: "HP Deluxe Webcam KQ246AA", GUID: 03006923f20400003ca1000000000000, vendor ID: 1266, product ID: 41276
Joystick button pressed: id=232
Joystick button pressed: id=233
Joystick button pressed: id=234
Joystick button pressed: id=235
Joystick button pressed: id=236
Joystick button pressed: id=237
Joystick button pressed: id=241
Joystick button pressed: id=242
Joystick button pressed: id=243
Joystick button pressed: id=244
Joystick button pressed: id=245
Joystick button pressed: id=248
(Note that the vendor and product IDs are represented here in decimal and not hexadecimal format, in hex they are 4F2 and A13C respectively)
The weird button presses bug is reported here: #13913
If any further testing is required, I can setup a building environment for SDL3 with any required changes and ask the users to test them when they're available.
Metadata
Metadata
Assignees
Labels
No labels