This should fix Issue 1982 & Issue 2042

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4908 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx 2010-01-20 17:01:38 +00:00
parent 2eeb3d5e9d
commit 1426a5c768
4 changed files with 31 additions and 20 deletions

View File

@ -103,7 +103,7 @@ bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_
_joyinfo.push_back(Tmp);
// We have now read the values we need so we close the device
if (SDL_JoystickOpened(i)) SDL_JoystickClose(_joyinfo[i].joy);
// if (SDL_JoystickOpened(i)) SDL_JoystickClose(_joyinfo[i].joy);
}
_NumPads = (int)_joyinfo.size();

View File

@ -320,7 +320,7 @@ void Config::Load()
iniFile.Get(SectionName, "DeadZoneR", &WiiMoteEmu::WiiMapping[i].DeadZoneR, 0);
iniFile.Get(SectionName, "Diagonal", &WiiMoteEmu::WiiMapping[i].Diagonal, "100%");
iniFile.Get(SectionName, "Circle2Square", &WiiMoteEmu::WiiMapping[i].bCircle2Square, false);
iniFile.Get(SectionName, "Rumble", &WiiMoteEmu::WiiMapping[i].Rumble, true);
iniFile.Get(SectionName, "Rumble", &WiiMoteEmu::WiiMapping[i].Rumble, false);
iniFile.Get(SectionName, "RumbleStrength", &WiiMoteEmu::WiiMapping[i].RumbleStrength, 8); // x10
iniFile.Get(SectionName, "TriggerType", &WiiMoteEmu::WiiMapping[i].TriggerType, 0);
}

View File

@ -48,20 +48,24 @@ void Close_Devices()
PAD_RumbleClose();
// Close all devices carefully. We must check that we are not accessing any
// undefined vector elements or any bad devices
for (int i = 0; i < MAX_WIIMOTES; i++)
if (SDL_WasInit(0))
{
if (SDL_WasInit(0) && joyinfo.size() > (u32)WiiMapping[i].ID)
if (WiiMapping[i].joy && joyinfo.at(WiiMapping[i].ID).Good)
for (int i = 0; i < NumPads; i++)
{
if (joyinfo.at(i).joy)
{
INFO_LOG(WIIMOTE, "ShutDown: %i", WiiMapping[i].ID);
if(SDL_JoystickOpened(WiiMapping[i].ID))
if(SDL_JoystickOpened(i))
{
SDL_JoystickClose(WiiMapping[i].joy);
WiiMapping[i].joy = NULL;
INFO_LOG(WIIMOTE, "Shut down Joypad: %i", i);
SDL_JoystickClose(joyinfo.at(i).joy);
}
}
}
}
for (int i = 0; i < MAX_WIIMOTES; i++)
WiiMapping[i].joy = NULL;
// Clear the physical device info
joyinfo.clear();
NumPads = 0;
@ -83,9 +87,9 @@ bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_N
// Update the PadState[].joy handle
for (int i = 0; i < MAX_WIIMOTES; i++)
{
if (joyinfo.size() > (u32)WiiMapping[i].ID)
if(joyinfo.at(WiiMapping[i].ID).Good)
WiiMapping[i].joy = SDL_JoystickOpen(WiiMapping[i].ID);
if (_NumPads > (u32)WiiMapping[i].ID)
if(_joyinfo.at(WiiMapping[i].ID).Good)
WiiMapping[i].joy = _joyinfo.at(WiiMapping[i].ID).joy;
}
return WasGotten;

View File

@ -211,17 +211,24 @@ void Close_Devices()
PAD_RumbleClose();
/* Close all devices carefully. We must check that we are not accessing any undefined
vector elements or any bad devices */
for (int i = 0; i < 4; i++)
if (SDL_WasInit(0))
{
if (SDL_WasInit(0) && joyinfo.size() > (u32)PadMapping[i].ID)
if (PadState[i].joy && joyinfo.at(PadMapping[i].ID).Good)
if(SDL_JoystickOpened(PadMapping[i].ID))
for (int i = 0; i < NumPads; i++)
{
if (joyinfo.at(i).joy)
{
if(SDL_JoystickOpened(i))
{
SDL_JoystickClose(PadState[i].joy);
PadState[i].joy = NULL;
INFO_LOG(WIIMOTE, "Shut down Joypad: %i", i);
SDL_JoystickClose(joyinfo.at(i).joy);
}
}
}
}
for (int i = 0; i < 4; i++)
PadState[i].joy = NULL;
// Clear the physical device info
joyinfo.clear();
NumPads = 0;
@ -478,9 +485,9 @@ bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_N
// Update the PadState[].joy handle
for (int i = 0; i < 4; i++)
{
if (joyinfo.size() > (u32)PadMapping[i].ID)
if (_NumPads > (u32)PadMapping[i].ID)
if(joyinfo.at(PadMapping[i].ID).Good)
PadState[i].joy = SDL_JoystickOpen(PadMapping[i].ID);
PadState[i].joy = joyinfo.at(PadMapping[i].ID).joy;
}
return Success;