Rearranged EmuWiimote & nJoy. Wow they can share one pad at the same time, and they also can be enabled/disabled separately.

So as long as the game supports, you can toggle controller input between them on the fly.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4691 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx
2009-12-14 02:23:14 +00:00
parent 2d10a47c2b
commit 6f1efd4873
20 changed files with 271 additions and 208 deletions

View File

@ -40,25 +40,50 @@ extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteEmu
{
extern void PAD_RumbleClose();
// Close joypads
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 < 1; i++)
{
if (SDL_WasInit(0) && joyinfo.size() > (u32)PadMapping[i].ID)
if (PadState[i].joy && joyinfo.at(PadMapping[i].ID).Good)
{
INFO_LOG(WIIMOTE, "ShutDown: %i", PadState[i].joy);
if(SDL_JoystickOpened(PadMapping[i].ID))
{
SDL_JoystickClose(PadState[i].joy);
PadState[i].joy = NULL;
}
}
}
// Clear the physical device info
joyinfo.clear();
NumPads = 0;
NumGoodPads = 0;
}
// Fill joyinfo with the current connected devices
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
{
// Close opened pad first
Close_Devices();
bool WasGotten = InputCommon::SearchDevices(_joyinfo, _NumPads, _NumGoodPads);
// Warn the user if no gamepads are detected
if (_NumGoodPads == 0 && g_EmulatorRunning)
{
//PanicAlert("nJoy: No Gamepad Detected");
//return false;
}
// Load PadMapping[] etc
g_Config.Load();
if (_NumGoodPads == 0)
return false;
// Update the PadState[].joy handle
for (int i = 0; i < 1; i++)
{
if (PadMapping[i].enabled && joyinfo.size() > (u32)PadMapping[i].ID)
if (joyinfo.size() > (u32)PadMapping[i].ID)
if(joyinfo.at(PadMapping[i].ID).Good)
PadState[i].joy = SDL_JoystickOpen(PadMapping[i].ID);
}