GCPad/New Wiimote: Fixed issue 2848 (profiles not saving). Renamed DInput mouse axes to "Axis [XYZ][-+]" from "Mouse XYZ...". Minor cleanup/warning removal.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5767 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak 2010-06-22 08:30:33 +00:00
parent 1b670a9825
commit 25aca8cc4a
5 changed files with 38 additions and 54 deletions

View File

@ -372,7 +372,8 @@ u8 CSIDevice_GCController::NetPlay_GetPadNum(u8 numPAD)
// called from ---CPU--- thread // called from ---CPU--- thread
// wiimote update / used for frame counting // wiimote update / used for frame counting
void CWII_IPC_HLE_Device_usb_oh1_57e_305::NetPlay_WiimoteUpdate(int _number) //void CWII_IPC_HLE_Device_usb_oh1_57e_305::NetPlay_WiimoteUpdate(int _number)
void CWII_IPC_HLE_Device_usb_oh1_57e_305::NetPlay_WiimoteUpdate(int)
{ {
//CritLocker crit(::crit_netplay_ptr); //CritLocker crit(::crit_netplay_ptr);
@ -394,7 +395,8 @@ int CWII_IPC_HLE_WiiMote::NetPlay_GetWiimoteNum(int _number)
// called from ---CPU--- thread // called from ---CPU--- thread
// intercept wiimote input callback // intercept wiimote input callback
bool CWII_IPC_HLE_WiiMote::NetPlay_WiimoteInput(int _number, u16 _channelID, const void* _pData, u32& _Size) //bool CWII_IPC_HLE_WiiMote::NetPlay_WiimoteInput(int _number, u16 _channelID, const void* _pData, u32& _Size)
bool CWII_IPC_HLE_WiiMote::NetPlay_WiimoteInput(int, u16, const void*, u32&)
{ {
CritLocker crit(::crit_netplay_ptr); CritLocker crit(::crit_netplay_ptr);

View File

@ -327,11 +327,11 @@ void ControllerInterface::DeviceQualifier::FromDevice(const ControllerInterface:
source= dev->GetSource(); source= dev->GetSource();
} }
bool ControllerInterface::Device::operator==(const ControllerInterface::DeviceQualifier& devq) const bool ControllerInterface::DeviceQualifier::operator==(const ControllerInterface::Device* const dev) const
{ {
if (GetId() == devq.cid) if (dev->GetId() == cid)
if (GetName() == devq.name) if (dev->GetName() == name)
if (GetSource() == devq.source) if (dev->GetSource() == source)
return true; return true;
return false; return false;
} }
@ -390,11 +390,7 @@ void ControllerInterface::UpdateReference(ControllerInterface::ControlReference*
devq.FromString(dev_str); devq.FromString(dev_str);
// find device // find device
std::vector<Device*>::const_iterator di = FindDevice(m_devices, devq); devc.device = FindDevice(devq);
if (m_devices.end() != di)
devc.device = *di;
if (devc.device) if (devc.device)
{ {
@ -407,10 +403,9 @@ void ControllerInterface::UpdateReference(ControllerInterface::ControlReference*
// FIXME: Use std::find instead of a for loop // FIXME: Use std::find instead of a for loop
// i = std::find(devc.device->Inputs().begin(), devc.device->Inputs().end(), ctrl_str); // i = std::find(devc.device->Inputs().begin(), devc.device->Inputs().end(), ctrl_str);
for(i = devc.device->Inputs().begin(); i < devc.device->Inputs().end(); ++i) { for(i = devc.device->Inputs().begin(); i < devc.device->Inputs().end(); ++i)
if(*(*i) == ctrl_str) if(*(*i) == ctrl_str)
break; break;
}
if (devc.device->Inputs().end() != i) if (devc.device->Inputs().end() != i)
{ {
@ -424,11 +419,9 @@ void ControllerInterface::UpdateReference(ControllerInterface::ControlReference*
// FIXME: Use std::find instead of a for loop // FIXME: Use std::find instead of a for loop
// i = std::find(devc.device->Outputs().begin(), devc.device->Outputs().end(), ctrl_str); // i = std::find(devc.device->Outputs().begin(), devc.device->Outputs().end(), ctrl_str);
for(i = devc.device->Outputs().begin(); i < devc.device->Outputs().end(); ++i) { for(i = devc.device->Outputs().begin(); i < devc.device->Outputs().end(); ++i)
if(*(*i) == ctrl_str) if(*(*i) == ctrl_str)
break; break;
}
if (devc.device->Outputs().end() != i) if (devc.device->Outputs().end() != i)
{ {
@ -455,19 +448,16 @@ void ControllerInterface::UpdateReference(ControllerInterface::ControlReference*
} }
} }
std::vector<ControllerInterface::Device*>::const_iterator FindDevice( ControllerInterface::Device* ControllerInterface::FindDevice(const ControllerInterface::DeviceQualifier& devq) const
const std::vector<ControllerInterface::Device*>& devices, const ControllerInterface::DeviceQualifier& devq) { {
std::vector<ControllerInterface::Device*>::const_iterator
di = m_devices.begin(),
de = m_devices.end();
for (; di!=de; ++di)
if (devq == *di)
return *di;
std::vector<ControllerInterface::Device*>::const_iterator di; return NULL;
// FIXME: Use std::find instead of a for loop
// di = std::find(m_devices.begin(), m_devices.end(), devq);
for(di = devices.begin(); di < devices.end(); ++di) {
if(*(*di) == devq)
break;
}
return di;
} }
// //

View File

@ -64,7 +64,7 @@ public:
public: public:
virtual std::string GetName() const = 0; virtual std::string GetName() const = 0;
virtual ~Control() {} virtual ~Control() {}
virtual bool operator==(const std::string& name) const; bool operator==(const std::string& name) const;
}; };
// //
@ -104,8 +104,6 @@ public:
virtual void ClearInputState(); virtual void ClearInputState();
virtual bool operator==(const DeviceQualifier& devq) const;
const std::vector<Input*>& Inputs() const { return m_inputs; } const std::vector<Input*>& Inputs() const { return m_inputs; }
const std::vector<Output*>& Outputs() const { return m_outputs; } const std::vector<Output*>& Outputs() const { return m_outputs; }
@ -135,6 +133,7 @@ public:
void FromString(const std::string& str); void FromString(const std::string& str);
std::string ToString() const; std::string ToString() const;
bool operator==(const DeviceQualifier& devq) const; bool operator==(const DeviceQualifier& devq) const;
bool operator==(const Device* const dev) const;
std::string source; std::string source;
int cid; int cid;
@ -220,6 +219,7 @@ public:
bool UpdateOutput(); bool UpdateOutput();
const std::vector<Device*>& Devices() const { return m_devices; } const std::vector<Device*>& Devices() const { return m_devices; }
Device* FindDevice(const DeviceQualifier& devq) const;
private: private:
bool m_is_init; bool m_is_init;
@ -227,7 +227,4 @@ private:
void* m_hwnd; void* m_hwnd;
}; };
std::vector<ControllerInterface::Device*>::const_iterator FindDevice(
const std::vector<ControllerInterface::Device*>& devices, const ControllerInterface::DeviceQualifier& devq);
#endif #endif

View File

@ -153,7 +153,7 @@ std::string Mouse::Button::GetName() const
std::string Mouse::Axis::GetName() const std::string Mouse::Axis::GetName() const
{ {
std::string tmpstr("Mouse "); std::string tmpstr("Axis ");
tmpstr += "XYZ"[m_index]; tmpstr += ( m_range>0 ? '+' : '-' ); tmpstr += "XYZ"[m_index]; tmpstr += ( m_range>0 ? '+' : '-' );
return tmpstr; return tmpstr;
} }

View File

@ -192,17 +192,15 @@ void ControlDialog::UpdateListContents()
{ {
control_lbox->Clear(); control_lbox->Clear();
std::vector<ControllerInterface::Device*>::const_iterator di = ControllerInterface::Device* const dev = m_plugin.controller_interface.FindDevice(m_devq);
FindDevice(m_plugin.controller_interface.Devices(), m_devq); if (dev)
if (m_plugin.controller_interface.Devices().end() != di)
{ {
if (control_reference->is_input) if (control_reference->is_input)
{ {
// for inputs // for inputs
std::vector<ControllerInterface::Device::Input*>::const_iterator std::vector<ControllerInterface::Device::Input*>::const_iterator
i = (*di)->Inputs().begin(), i = dev->Inputs().begin(),
e = (*di)->Inputs().end(); e = dev->Inputs().end();
for (; i!=e; ++i) for (; i!=e; ++i)
control_lbox->Append(WXSTR_FROM_STR((*i)->GetName())); control_lbox->Append(WXSTR_FROM_STR((*i)->GetName()));
} }
@ -210,8 +208,8 @@ void ControlDialog::UpdateListContents()
{ {
// for outputs // for outputs
std::vector<ControllerInterface::Device::Output*>::const_iterator std::vector<ControllerInterface::Device::Output*>::const_iterator
i = (*di)->Outputs().begin(), i = dev->Outputs().begin(),
e = (*di)->Outputs().end(); e = dev->Outputs().end();
for (; i!=e; ++i) for (; i!=e; ++i)
control_lbox->Append(WXSTR_FROM_STR((*i)->GetName())); control_lbox->Append(WXSTR_FROM_STR((*i)->GetName()));
} }
@ -411,15 +409,13 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
wxButton* const btn = (wxButton*)event.GetEventObject(); wxButton* const btn = (wxButton*)event.GetEventObject();
const wxString lbl = btn->GetLabel(); const wxString lbl = btn->GetLabel();
std::vector<ControllerInterface::Device*>::const_iterator di = ControllerInterface::Device* const dev = m_plugin.controller_interface.FindDevice(m_devq);
FindDevice(m_plugin.controller_interface.Devices(), m_devq); if (dev)
if (m_plugin.controller_interface.Devices().end() != di)
{ {
btn->SetLabel(wxT("[ waiting ]")); btn->SetLabel(wxT("[ waiting ]"));
m_plugin.controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
ControllerInterface::Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, *di); ControllerInterface::Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev);
// if we got input, select it in the list // if we got input, select it in the list
if (ctrl) if (ctrl)
@ -436,15 +432,13 @@ void GamepadPage::DetectControl( wxCommandEvent& event )
ControlButton* btn = (ControlButton*)event.GetEventObject(); ControlButton* btn = (ControlButton*)event.GetEventObject();
// find device :/ // find device :/
const std::vector<ControllerInterface::Device*>::const_iterator di = ControllerInterface::Device* const dev = m_plugin.controller_interface.FindDevice(controller->default_device);
FindDevice(m_plugin.controller_interface.Devices(), controller->default_device); if (dev)
if (m_plugin.controller_interface.Devices().end() != di)
{ {
btn->SetLabel(wxT("[ waiting ]")); btn->SetLabel(wxT("[ waiting ]"));
m_plugin.controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
ControllerInterface::Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, *di); ControllerInterface::Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);
// if we got input, update expression and reference // if we got input, update expression and reference
if (ctrl) if (ctrl)
@ -561,6 +555,7 @@ void GamepadPage::SaveProfile( wxCommandEvent& event )
{ {
std::string fname; std::string fname;
GamepadPage::GetProfilePath(fname); GamepadPage::GetProfilePath(fname);
File::CreateFullPath(fname.c_str());
if (false == fname.empty()) if (false == fname.empty())
{ {