@@ -144,11 +144,12 @@ void JoypadSDL::process_events() {
144
144
print_error (" A new joypad was attached but couldn't allocate a new id for it because joypad limit was reached." );
145
145
} else {
146
146
SDL_Joystick *joy = nullptr ;
147
+ SDL_Gamepad *gamepad = nullptr ;
147
148
String device_name;
148
149
149
150
// Gamepads must be opened with SDL_OpenGamepad to get their special remapped events
150
151
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 );
152
153
153
154
ERR_CONTINUE_MSG (!gamepad,
154
155
vformat (" Error opening gamepad at index %d: %s" , sdl_event.jdevice .which , SDL_GetError ()));
@@ -180,9 +181,22 @@ void JoypadSDL::process_events() {
180
181
181
182
sdl_instance_id_to_joypad_id.insert (sdl_event.jdevice .which , joy_id);
182
183
183
- // Skip Godot's mapping system because SDL already handles the joypad's mapping
184
184
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
+ }
186
200
187
201
Input::get_singleton ()->joy_connection_changed (
188
202
joy_id,
0 commit comments