Previously `joypad_count` was used as the index into the d_joypads array when initializing a new gamepad.
This caused the accidental override of an already connected device when a gamepad with a lower id was disconnected and connected again.
fixes #17566
(cherry picked from commit 802a0316c56c954d10c0d7f0c7bb44f3298d2c8f)