Check for SDL_JOYDEVICEADDED and SDL_JOYDEVICEREMOVED
This commit is contained in:
parent
b062427942
commit
abfe5601c7
2 changed files with 25 additions and 6 deletions
|
|
@ -32,6 +32,7 @@
|
|||
*/
|
||||
#include <SDL.h>
|
||||
#include "m_argv.h"
|
||||
#include "m_joy.h"
|
||||
#include "v_video.h"
|
||||
|
||||
#include "d_eventbase.h"
|
||||
|
|
@ -467,6 +468,13 @@ void MessagePump (const SDL_Event &sev)
|
|||
if(event.data1 != 0)
|
||||
D_PostEvent(&event);
|
||||
break;
|
||||
|
||||
case SDL_JOYDEVICEADDED:
|
||||
case SDL_JOYDEVICEREMOVED:
|
||||
I_UpdateDeviceList();
|
||||
event.type = EV_DeviceChange;
|
||||
D_PostEvent (&event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -281,7 +281,22 @@ class SDLInputJoystickManager
|
|||
public:
|
||||
SDLInputJoystickManager()
|
||||
{
|
||||
for(int i = 0;i < SDL_NumJoysticks();i++)
|
||||
this->UpdateDeviceList();
|
||||
}
|
||||
~SDLInputJoystickManager()
|
||||
{
|
||||
for(unsigned int i = 0;i < Joysticks.Size();i++)
|
||||
delete Joysticks[i];
|
||||
}
|
||||
|
||||
void UpdateDeviceList()
|
||||
{
|
||||
for (int i = 0; i < Joysticks.SSize(); i++)
|
||||
{
|
||||
delete Joysticks[i];
|
||||
}
|
||||
Joysticks.clear();
|
||||
for(int i = 0; i < SDL_NumJoysticks(); i++)
|
||||
{
|
||||
SDLInputJoystick *device = new SDLInputJoystick(i);
|
||||
if(device->IsValid())
|
||||
|
|
@ -290,11 +305,6 @@ public:
|
|||
delete device;
|
||||
}
|
||||
}
|
||||
~SDLInputJoystickManager()
|
||||
{
|
||||
for(unsigned int i = 0;i < Joysticks.Size();i++)
|
||||
delete Joysticks[i];
|
||||
}
|
||||
|
||||
void AddAxes(float axes[NUM_JOYAXIS])
|
||||
{
|
||||
|
|
@ -364,5 +374,6 @@ void I_ProcessJoysticks()
|
|||
|
||||
IJoystickConfig *I_UpdateDeviceList()
|
||||
{
|
||||
JoystickManager->UpdateDeviceList();
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue