Made new Wiimote plugin not deinit SDL on shutdown. (Hacks, same thing old wiimote does, fixes the crash on emulation stop, refresh button still causes crash (damn SDL)) Minor new input plugin GUI changes. (left-click on rumble button opens control config dialog) Made NetPlay save/load settings to Dolphin.ini. Allow NetPlay host to adjust which/how many pads will be used in game. (more than one gamepad per Dolphin instance can be used on NetPlay) Worked on wiimote NetPlay a bit. (still nonfunctional) Improved SDL device numbering. Added some major hacks to ControllerInterface/SDL so XInput(360 controller) devices do not have their SDL interface shown in the device list on windows. (caused confusion for users)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5625 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak
2010-06-06 03:52:11 +00:00
parent 1aac546185
commit 5341bbad3a
13 changed files with 438 additions and 165 deletions

View File

@ -57,7 +57,7 @@ void ControllerInterface::Init()
//
// remove all devices/ call library cleanup functions
//
void ControllerInterface::DeInit()
void ControllerInterface::DeInit(const bool hacks_no_sdl_quit)
{
if ( false == m_is_init )
return;
@ -73,6 +73,13 @@ void ControllerInterface::DeInit()
(*d)->SetOutputState( *o, 0 );
// update output
(*d)->UpdateOutput();
// TODO: remove this
// major hacks to prevent gcpad/wiimote new from crashing eachother
if (hacks_no_sdl_quit)
if ((*d)->GetSource() == "SDL")
continue;
//delete device
delete *d;
}
@ -92,8 +99,9 @@ void ControllerInterface::DeInit()
ciface::OSX::DeInit();
#endif
#ifdef CIFACE_USE_SDL
// there seems to be some sort of memory leak with SDL, quit isn't freeing everything up
SDL_Quit();
// TODO: there seems to be some sort of memory leak with SDL, quit isn't freeing everything up
if (false == hacks_no_sdl_quit)
SDL_Quit();
#endif
m_is_init = false;

View File

@ -240,7 +240,8 @@ public:
void SetHwnd( void* const hwnd );
void Init();
void DeInit();
// TODO: remove this hack param
void DeInit(const bool hacks_no_sdl_quit = false);
bool IsInit();
void UpdateReference( ControlReference* control );

View File

@ -20,15 +20,21 @@ namespace SDL
void Init( std::vector<ControllerInterface::Device*>& devices )
{
if ( SDL_Init( SDL_INIT_FLAGS ) >= 0 )
// just a struct with an int that is set to ZERO by default
struct ZeroedInt{ZeroedInt():value(0){}unsigned int value;};
// this is used to number the joysticks
// multiple joysticks with the same name shall get unique ids starting at 0
std::map<std::string, ZeroedInt> name_counts;
if (SDL_Init( SDL_INIT_FLAGS ) >= 0)
{
// joysticks
for( int i = 0; i < SDL_NumJoysticks(); ++i )
for(int i = 0; i < SDL_NumJoysticks(); ++i)
{
SDL_Joystick* dev = SDL_JoystickOpen( i );
SDL_Joystick* dev = SDL_JoystickOpen(i);
if ( dev )
{
Joystick* js = new Joystick( dev, i );
Joystick* js = new Joystick(dev, i, name_counts[SDL_JoystickName(i)].value++);
// only add if it has some inputs/outputs
if ( js->Inputs().size() || js->Outputs().size() )
devices.push_back( js );
@ -39,8 +45,32 @@ void Init( std::vector<ControllerInterface::Device*>& devices )
}
}
Joystick::Joystick( SDL_Joystick* const joystick, const unsigned int index ) : m_joystick(joystick), m_index(index)
Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsigned int index)
: m_joystick(joystick)
, m_sdl_index(sdl_index)
, m_index(index)
{
// really bad HACKS:
// to not use SDL for an XInput device
// too many people on the forums pick the SDL device and ask:
// "why don't my 360 gamepad triggers/rumble work correctly"
#ifdef _WIN32
// checking the name is probably good (and hacky) enough
// but i'll double check with the num of buttons/axes
if (
("Controller (Xbox 360 Wireless Receiver for Windows)" == GetName())
&& (10 == SDL_JoystickNumButtons(joystick))
&& (5 == SDL_JoystickNumAxes(joystick))
&& (1 == SDL_JoystickNumHats(joystick))
&& (0 == SDL_JoystickNumBalls(joystick))
)
{
// this device won't be used
return;
}
#endif
// get buttons
for ( int i = 0; i < SDL_JoystickNumButtons( m_joystick ); ++i )
{
@ -210,7 +240,7 @@ bool Joystick::UpdateOutput()
std::string Joystick::GetName() const
{
return StripSpaces(SDL_JoystickName(m_index));
return StripSpaces(SDL_JoystickName(m_sdl_index));
}
std::string Joystick::GetSource() const

View File

@ -135,7 +135,7 @@ protected:
void SetOutputState( const ControllerInterface::Device::Output* const output, const ControlState state );
public:
Joystick( SDL_Joystick* const joystick, const unsigned int index );
Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsigned int index);
~Joystick();
std::string GetName() const;
@ -144,6 +144,7 @@ public:
private:
SDL_Joystick* const m_joystick;
const int m_sdl_index;
const unsigned int m_index;
#ifdef USE_SDL_HAPTIC