Send joystick added events on portable handheld platforms

The IDs on these drivers are hard-coded as device_index + 1, so that's the ID we will send during initialization.
main
Sam Lantinga 2024-03-25 07:14:00 -07:00
parent b391e6477e
commit 977285ef6a
5 changed files with 15 additions and 8 deletions

View File

@ -70,12 +70,14 @@ extern "C"
for (i = 0; (numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i) {
if (joystick.GetDeviceName(i, name) == B_OK) {
if (joystick.Open(name) != B_ERROR) {
BString stick_name;
joystick.GetControllerName(&stick_name);
SDL_joyport[numjoysticks] = SDL_strdup(name);
SDL_joyname[numjoysticks] = SDL_CreateJoystickName(0, 0, NULL, stick_name.String());
numjoysticks++;
joystick.Close();
BString stick_name;
joystick.GetControllerName(&stick_name);
SDL_joyport[numjoysticks] = SDL_strdup(name);
SDL_joyname[numjoysticks] = SDL_CreateJoystickName(0, 0, NULL, stick_name.String());
numjoysticks++;
joystick.Close();
SDL_PrivateJoystickAdded(numjoysticks);
}
}
}

View File

@ -62,6 +62,7 @@ static void UpdateN3DSCStick(Uint64 timestamp, SDL_Joystick *joystick);
static int N3DS_JoystickInit(void)
{
hidInit();
SDL_PrivateJoystickAdded(1);
return 0;
}

View File

@ -122,6 +122,7 @@ static int PS2_JoystickInit(void)
info->slot = (uint8_t)slot;
info->opened = 1;
enabled_pads++;
SDL_PrivateJoystickAdded(enabled_pads);
}
}
}

View File

@ -93,6 +93,8 @@ static int PSP_JoystickInit(void)
analog_map[127 - i] = -1 * analog_map[i + 128];
}
SDL_PrivateJoystickAdded(1);
return 1;
}

View File

@ -124,7 +124,8 @@ static int VITA_JoystickInit(void)
// after the app has already started.
SDL_numjoysticks = 1;
SDL_PrivateJoystickAdded(0);
SDL_PrivateJoystickAdded(SDL_numjoysticks);
// How many additional paired controllers are there?
sceCtrlGetControllerPortInfo(&myPortInfo);
@ -132,8 +133,8 @@ static int VITA_JoystickInit(void)
// and that is the first one, so start at port 2
for (i = 2; i <= 4; i++) {
if (myPortInfo.port[i] != SCE_CTRL_TYPE_UNPAIRED) {
++SDL_numjoysticks;
SDL_PrivateJoystickAdded(SDL_numjoysticks);
SDL_numjoysticks++;
}
}
return SDL_numjoysticks;