@@ -144,11 +144,12 @@ void JoypadSDL::process_events() {
144144 print_error (" A new joypad was attached but couldn't allocate a new id for it because joypad limit was reached." );
145145 } else {
146146 SDL_Joystick *joy = nullptr ;
147+ SDL_Gamepad *gamepad = nullptr ;
147148 String device_name;
148149
149150 // Gamepads must be opened with SDL_OpenGamepad to get their special remapped events
150151 if (SDL_IsGamepad (sdl_event.jdevice .which )) {
151- SDL_Gamepad * gamepad = SDL_OpenGamepad (sdl_event.jdevice .which );
152+ gamepad = SDL_OpenGamepad (sdl_event.jdevice .which );
152153
153154 ERR_CONTINUE_MSG (!gamepad,
154155 vformat (" Error opening gamepad at index %d: %s" , sdl_event.jdevice .which , SDL_GetError ()));
@@ -180,9 +181,22 @@ void JoypadSDL::process_events() {
180181
181182 sdl_instance_id_to_joypad_id.insert (sdl_event.jdevice .which , joy_id);
182183
183- // Skip Godot's mapping system because SDL already handles the joypad's mapping
184184 Dictionary joypad_info;
185- joypad_info[" mapping_handled" ] = true ;
185+ joypad_info[" mapping_handled" ] = true ; // Skip Godot's mapping system because SDL already handles the joypad's mapping.
186+ joypad_info[" raw_name" ] = String (SDL_GetJoystickName (joy));
187+ joypad_info[" vendor_id" ] = itos (SDL_GetJoystickVendor (joy));
188+ joypad_info[" product_id" ] = itos (SDL_GetJoystickProduct (joy));
189+
190+ const uint64_t steam_handle = SDL_GetGamepadSteamHandle (gamepad);
191+ if (steam_handle != 0 ) {
192+ joypad_info[" steam_input_index" ] = itos (steam_handle);
193+ }
194+
195+ const int player_index = SDL_GetJoystickPlayerIndex (joy);
196+ if (player_index >= 0 ) {
197+ // For XInput controllers SDL_GetJoystickPlayerIndex returns the XInput user index.
198+ joypad_info[" xinput_index" ] = itos (player_index);
199+ }
186200
187201 Input::get_singleton ()->joy_connection_changed (
188202 joy_id,
0 commit comments