Wiimote and nJoy > Gamepad changes

1. Added LiveUpdates, while the configuration window is open nJoy and Wiimote will check for connected/disconnected pads
2. Removed the 'Nintendo RVL-CNT-01' device from the device list, and other SDL devices with no axes/buttons
3. Added SDL (from the current SVN) to get debugging information for SDL.dll
4. Added 'Upright Wiimote' option to emulated Wiimote options

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4534 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson
2009-11-12 18:57:35 +00:00
parent b858befba2
commit 71506bc0f7
590 changed files with 197210 additions and 17135 deletions

View File

@ -30,36 +30,15 @@
is only used the first time the pads are checked. */
void WiimotePadConfigDialog::DoChangeJoystick()
{
// Close the current pad, unless it's used by another slot
//if (PadMapping[notebookpage].enabled) PadClose(notebookpage);
WARN_LOG(WIIMOTE, "---- DoChangeJoystick ----");
// Before changing the pad we save potential changes to the current pad
DoSave(true);
// Load the settings for the new Id
g_Config.Load(true);
UpdateGUI(Page); // Update the GUI
// Open the new pad
if (WiiMoteEmu::PadMapping[Page].enabled) PadOpen(Page);
}
void WiimotePadConfigDialog::PadOpen(int Open) // Open for slot 1, 2, 3 or 4
{
// Check that we got a good pad
if (!WiiMoteEmu::joyinfo.at(WiiMoteEmu::PadMapping[Open].ID).Good)
{
DEBUG_LOG(WIIMOTE, "A bad pad was selected");
WiiMoteEmu::PadState[Open].joy = NULL;
return;
}
DEBUG_LOG(WIIMOTE, "Update the Slot %i handle to Id %i", Page, WiiMoteEmu::PadMapping[Open].ID);
WiiMoteEmu::PadState[Open].joy = SDL_JoystickOpen(WiiMoteEmu::PadMapping[Open].ID);
}
void WiimotePadConfigDialog::PadClose(int _Close) // Close for slot 1, 2, 3 or 4
{
if (SDL_JoystickOpened(WiiMoteEmu::PadMapping[_Close].ID)) SDL_JoystickClose(WiiMoteEmu::PadState[_Close].joy);
WiiMoteEmu::PadState[_Close].joy = NULL;
// Update the GUI
UpdateGUI(Page);
}
void WiimotePadConfigDialog::DoChangeDeadZone(bool Left)
@ -90,30 +69,29 @@ void WiimotePadConfigDialog::DoChangeDeadZone(bool Left)
// Set the button text for all four Wiimotes
void WiimotePadConfigDialog::SetButtonTextAll(int id, char text[128])
{
for (int i = 0; i < 1; i++)
for (int i = 0; i < MAX_WIIMOTES; i++)
{
// Safety check to avoid crash
if ((int)WiiMoteEmu::joyinfo.size() > WiiMoteEmu::PadMapping[i].ID)
if (WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name == WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[Page].ID].Name)
SetButtonText(id, text, i);
if (WiiMoteEmu::IDToName(WiiMoteEmu::PadMapping[i].ID) == WiiMoteEmu::IDToName(WiiMoteEmu::PadMapping[Page].ID))
{
SetButtonText(id, text, i);
DEBUG_LOG(PAD, "Updated button text for slot %i", i);
}
};
}
void WiimotePadConfigDialog::SaveButtonMappingAll(int Slot)
{
for (int i = 0; i < 4; i++)
{
// This can occur when no gamepad is detected
if ((int)WiiMoteEmu::joyinfo.size() > WiiMoteEmu::PadMapping[i].ID && WiiMoteEmu::PadMapping[i].ID >= 0)
if (WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name == WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[Slot].ID].Name)
SaveButtonMapping(i, false, Slot);
for (int i = 0; i < MAX_WIIMOTES; i++)
{
if (WiiMoteEmu::IDToName(WiiMoteEmu::PadMapping[i].ID) == WiiMoteEmu::IDToName(WiiMoteEmu::PadMapping[Slot].ID))
SaveButtonMapping(i, false, Slot);
}
}
// Set dialog items from saved values
void WiimotePadConfigDialog::UpdateGUIButtonMapping(int controller)
{
NOTICE_LOG(WIIMOTE, "Load ButtonMapping | controller:%i", controller);
// Temporary storage
wxString tmp;
@ -204,12 +182,19 @@ void WiimotePadConfigDialog::UpdateGUIButtonMapping(int controller)
void WiimotePadConfigDialog::SaveButtonMapping(int controller, bool DontChangeId, int FromSlot)
{
// Log
NOTICE_LOG(WIIMOTE, "SaveButtonMapping | controller:%i FromSlot:%i", controller, FromSlot);
// Temporary storage
wxString tmp;
long value;
// Save from or to the same or different slots
if (FromSlot == -1) FromSlot = controller;
// TEMPORARY
// There is only one slot at the moment
if (FromSlot > MAX_WIIMOTES-1) FromSlot = MAX_WIIMOTES-1;
// Replace "" with "-1" in the GUI controls
ToBlank(false);
@ -218,7 +203,10 @@ void WiimotePadConfigDialog::SaveButtonMapping(int controller, bool DontChangeId
-1 that's a bug that should be fixed. Because the m_Joyname[] combo box should always show <No Gamepad Detected>, or a gamepad name, not a
a blank selection. */
if (!DontChangeId)
WiiMoteEmu::PadMapping[controller].ID = m_Joyname[FromSlot]->GetSelection();
{
WiiMoteEmu::PadMapping[controller].ID = WiiMoteEmu::joyinfo.at(m_Joyname[FromSlot]->GetSelection()).ID;
WiiMoteEmu::PadMapping[controller].Name = m_Joyname[FromSlot]->GetValue().mb_str();
}
// Set enabled or disable status
if (FromSlot == controller)
WiiMoteEmu::PadMapping[controller].enabled = true; //m_Joyattach[FromSlot]->GetValue(); // Only enable one
@ -372,6 +360,11 @@ void WiimotePadConfigDialog::GetButtons(wxCommandEvent& event)
void WiimotePadConfigDialog::DoGetButtons(int _GetId)
{
DEBUG_LOG(WIIMOTE, "DoGetButtons");
bool _LiveUpdates = LiveUpdates;
LiveUpdates = false;
// Collect the starting values
// Get the current controller
@ -399,7 +392,7 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId)
// Values used in this function
char format[128];
int Seconds = 4; // Seconds to wait for
int TimesPerSecond = 40; // How often to run the check
int TimesPerSecond = 60; // How often to run the check
// Values returned from InputCommon::GetButton()
int value; // Axis value
@ -438,7 +431,7 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId)
m_ButtonMappingTimer->Start( floor((double)(1000 / TimesPerSecond)) );
#endif
DEBUG_LOG(WIIMOTE, "Timer Started for Pad:%i _GetId:%i"
"Allowed input is Axis:%i LeftRight:%i XInput:%i Button:%i Hat:%i\n",
" Allowed input is Axis:%i LeftRight:%i XInput:%i Button:%i Hat:%i\n",
WiiMoteEmu::PadMapping[Controller].ID, _GetId,
Axis, LeftRight, XInput, Button, Hat);
}
@ -449,7 +442,7 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId)
else
{
InputCommon::GetButton(
WiiMoteEmu::joyinfo[PadID].joy, PadID, WiiMoteEmu::joyinfo[PadID].NumButtons, WiiMoteEmu::joyinfo[PadID].NumAxes, WiiMoteEmu::joyinfo[PadID].NumHats,
WiiMoteEmu::PadState[Page].joy, PadID,
g_Pressed, value, type, pressed, Succeed, Stop,
LeftRight, Axis, XInput, Button, Hat, NoTriggerFilter);
}
@ -482,7 +475,7 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId)
}
// If we got a button
if(Succeed)
if (Succeed)
{
Stop = true;
// Write the number of the pressed button to the text box
@ -491,10 +484,11 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId)
}
// Stop the timer
if(Stop)
if (Stop)
{
m_ButtonMappingTimer->Stop();
GetButtonWaitingTimer = 0;
LiveUpdates = _LiveUpdates;
/* Update the button mapping for all slots that use this device. (It
doesn't make sense to have several slots controlled by the same
@ -545,12 +539,12 @@ void WiimotePadConfigDialog::Convert2Box(int &x)
// Update the input status boxes
void WiimotePadConfigDialog::PadGetStatus()
{
//DEBUG_LOG(WIIMOTE, "SDL_WasInit: %i", SDL_WasInit(0));
//DEBUG_LOG(WIIMOTE, "PadGetStatus");
/* Return if it's not detected. The ID should never be less than zero here,
it can only be that because of a manual ini file change, but we make
that check anway. */
if(WiiMoteEmu::PadMapping[Page].ID < 0 || WiiMoteEmu::PadMapping[Page].ID >= SDL_NumJoysticks())
if (WiiMoteEmu::PadMapping[Page].ID < 0 || WiiMoteEmu::PadMapping[Page].ID >= SDL_NumJoysticks())
{
m_TStatusLeftIn[Page]->SetLabel(wxT("Not connected"));
m_TStatusLeftOut[Page]->SetLabel(wxT("Not connected"));
@ -574,15 +568,13 @@ void WiimotePadConfigDialog::PadGetStatus()
}
// Get physical device status
int PhysicalDevice = WiiMoteEmu::PadMapping[Page].ID;
int ID = WiiMoteEmu::PadMapping[Page].ID;
int TriggerType = WiiMoteEmu::PadMapping[Page].triggertype;
// Check that Dolphin is in focus, otherwise don't update the pad status
//if (IsFocus())
WiiMoteEmu::GetJoyState(WiiMoteEmu::PadState[Page], WiiMoteEmu::PadMapping[Page], Page, WiiMoteEmu::joyinfo.at(WiiMoteEmu::PadMapping[Page].ID).NumButtons);
WiiMoteEmu::GetJoyState(WiiMoteEmu::PadState[Page], WiiMoteEmu::PadMapping[Page], Page);
// Analog stick
// Set Deadzones perhaps out of function
//int deadzone = (int)(((float)(128.00/100.00)) * (float)(PadMapping[_numPAD].deadzone+1));
@ -695,16 +687,40 @@ void WiimotePadConfigDialog::PadGetStatus()
wxT("%03i"), TriggerRight));
}
// Slow timer, once a second
void WiimotePadConfigDialog::Update(wxTimerEvent& WXUNUSED(event))
{
if (!LiveUpdates) return;
// Search for connected devices and update dialog
int OldNumDIDevices = WiiMoteEmu::NumDIDevices;
WiiMoteEmu::NumDIDevices = InputCommon::SearchDIDevices();
// Update if a pad has been connected/disconnected. Todo: Add a better check that also takes into consideration the pad id
// and other things to ensure nothing has changed
//DEBUG_LOG(WIIMOTE, "Found %i devices", WiiMoteEmu::NumDIDevices);
//DEBUG_LOG(WIIMOTE, "Update: %i %i", OldNumPads, WiiMoteEmu::NumPads);
if (OldNumDIDevices != WiiMoteEmu::NumDIDevices)
{
WiiMoteEmu::LocalSearchDevicesReset(WiiMoteEmu::joyinfo, WiiMoteEmu::NumPads);
WiimotePadConfigDialog::UpdateDeviceList();
}
}
// Populate the advanced tab
void WiimotePadConfigDialog::UpdatePad(wxTimerEvent& WXUNUSED(event))
{
if (!WiiMoteEmu::IsPolling()) return;
//DEBUG_LOG(WIIMOTE, "UpdatePad");
// Show the current status
/*
#ifdef SHOW_PAD_STATUS
m_pStatusBar->SetLabel(wxString::Format(
"%s", ShowStatus(notebookpage).c_str()
));
#endif*/
m_pStatusBar->SetLabel(wxString::FromAscii(InputCommon::DoShowStatus(
Page, m_Joyname[Page]->GetSelection(),
WiiMoteEmu::PadMapping, WiiMoteEmu::PadState, WiiMoteEmu::joyinfo
).c_str()));
#endif
//LogMsg("Abc%s\n", ShowStatus(notebookpage).c_str());