mirror of https://github.com/PCSX2/pcsx2.git
onepad: add hot-plugging support
Note: pad to player mapping is done later v2: remove the useless print
This commit is contained in:
parent
1b369520ed
commit
c183de5662
|
@ -47,6 +47,8 @@ void JoystickInfo::EnumerateJoysticks(std::vector<std::unique_ptr<GamePad>> &vjo
|
||||||
|
|
||||||
SDL_JoystickEventState(SDL_QUERY);
|
SDL_JoystickEventState(SDL_QUERY);
|
||||||
SDL_GameControllerEventState(SDL_QUERY);
|
SDL_GameControllerEventState(SDL_QUERY);
|
||||||
|
SDL_EventState(SDL_CONTROLLERDEVICEADDED, SDL_ENABLE);
|
||||||
|
SDL_EventState(SDL_CONTROLLERDEVICEREMOVED, SDL_ENABLE);
|
||||||
|
|
||||||
{ // Support as much Joystick as possible
|
{ // Support as much Joystick as possible
|
||||||
GBytes *bytes = g_resource_lookup_data(onepad_res_get_resource(), "/onepad/res/game_controller_db.txt", G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr);
|
GBytes *bytes = g_resource_lookup_data(onepad_res_get_resource(), "/onepad/res/game_controller_db.txt", G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr);
|
||||||
|
|
|
@ -341,6 +341,21 @@ PADpoll(u8 value)
|
||||||
EXPORT_C_(keyEvent *)
|
EXPORT_C_(keyEvent *)
|
||||||
PADkeyEvent()
|
PADkeyEvent()
|
||||||
{
|
{
|
||||||
|
#ifdef SDL_BUILD
|
||||||
|
// Take the opportunity to handle hot plugging here
|
||||||
|
SDL_Event events;
|
||||||
|
while (SDL_PollEvent(&events)) {
|
||||||
|
switch (events.type) {
|
||||||
|
case SDL_CONTROLLERDEVICEADDED:
|
||||||
|
case SDL_CONTROLLERDEVICEREMOVED:
|
||||||
|
GamePad::EnumerateGamePads(s_vgamePad);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
s_event = event;
|
s_event = event;
|
||||||
event.evt = 0;
|
event.evt = 0;
|
||||||
event.key = 0;
|
event.key = 0;
|
||||||
|
|
Loading…
Reference in New Issue