2010-06-12 17:15:16 +00:00
|
|
|
// Copyright (C) 2010 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
#include "InputConfigDiag.h"
|
2010-11-14 13:30:57 +00:00
|
|
|
#include "UDPConfigDiag.h"
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler(f), (wxObject*)0, (wxEvtHandler*)s)
|
2011-01-15 21:16:13 +00:00
|
|
|
#define WXSTR_FROM_STR(s) (wxString::FromUTF8((s).c_str()))
|
|
|
|
#define WXTSTR_FROM_CSTR(s) (wxGetTranslation(wxString::FromUTF8(s)))
|
|
|
|
#define STR_FROM_WXSTR(w) (std::string((w).ToUTF8()))
|
2010-06-21 03:12:16 +00:00
|
|
|
|
2010-07-05 10:46:32 +00:00
|
|
|
void GamepadPage::ConfigUDPWii(wxCommandEvent &event)
|
|
|
|
{
|
|
|
|
UDPWrapper* const wrp = ((UDPConfigButton*)event.GetEventObject())->wrapper;
|
2010-11-14 13:30:57 +00:00
|
|
|
wxDialog * diag = new UDPConfigDiag(this, wrp);
|
|
|
|
diag->Center();
|
|
|
|
diag->ShowModal();
|
|
|
|
diag->Destroy();
|
2010-07-05 10:46:32 +00:00
|
|
|
}
|
2010-04-13 05:15:38 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void GamepadPage::ConfigExtension(wxCommandEvent& event)
|
2010-04-13 05:15:38 +00:00
|
|
|
{
|
|
|
|
ControllerEmu::Extension* const ex = ((ExtensionButton*)event.GetEventObject())->extension;
|
|
|
|
|
|
|
|
// show config diag, if "none" isn't selected
|
2011-01-14 03:05:02 +00:00
|
|
|
if (ex->switch_extension)
|
2010-04-13 05:15:38 +00:00
|
|
|
{
|
2011-01-14 03:05:02 +00:00
|
|
|
wxDialog* const dlg = new wxDialog(this, -1, WXTSTR_FROM_CSTR(ex->attachments[ex->switch_extension]->GetName().c_str()), wxDefaultPosition);
|
|
|
|
wxPanel* const pnl = new wxPanel(dlg, -1, wxDefaultPosition);
|
|
|
|
wxBoxSizer* const pnl_szr = new wxBoxSizer(wxHORIZONTAL);
|
2010-04-13 05:15:38 +00:00
|
|
|
|
|
|
|
const std::size_t orig_size = control_groups.size();
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
ControlGroupsSizer* const szr = new ControlGroupsSizer(ex->attachments[ex->switch_extension], pnl, this, &control_groups);
|
|
|
|
pnl->SetSizerAndFit(szr); // needed
|
|
|
|
pnl_szr->Add(pnl, 0, wxLEFT, 5);
|
|
|
|
dlg->SetSizerAndFit(pnl_szr); // needed
|
2010-04-13 05:15:38 +00:00
|
|
|
|
|
|
|
dlg->Center();
|
|
|
|
|
|
|
|
dlg->ShowModal();
|
|
|
|
dlg->Destroy();
|
|
|
|
|
|
|
|
// remove the new groups that were just added, now that the window closed
|
2011-01-14 03:05:02 +00:00
|
|
|
control_groups.resize(orig_size);
|
2010-04-13 05:15:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
PadSettingExtension::PadSettingExtension(wxWindow* const parent, ControllerEmu::Extension* const ext)
|
|
|
|
: PadSetting(new wxChoice(parent, -1))
|
2010-04-13 05:15:38 +00:00
|
|
|
, extension(ext)
|
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<ControllerEmu*>::const_iterator
|
|
|
|
i = extension->attachments.begin(),
|
|
|
|
e = extension->attachments.end();
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; i!=e; ++i)
|
2011-01-14 18:25:25 +00:00
|
|
|
((wxChoice*)wxcontrol)->Append(WXTSTR_FROM_CSTR((*i)->GetName().c_str()));
|
2010-04-13 05:15:38 +00:00
|
|
|
|
|
|
|
UpdateGUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PadSettingExtension::UpdateGUI()
|
|
|
|
{
|
2010-07-03 08:04:10 +00:00
|
|
|
((wxChoice*)wxcontrol)->Select(extension->switch_extension);
|
2010-04-13 05:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PadSettingExtension::UpdateValue()
|
|
|
|
{
|
2010-07-03 08:04:10 +00:00
|
|
|
extension->switch_extension = ((wxChoice*)wxcontrol)->GetSelection();
|
2010-04-13 05:15:38 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const char* const label)
|
|
|
|
: PadSetting(new wxCheckBox(parent, -1, WXTSTR_FROM_CSTR(label), wxDefaultPosition))
|
2010-04-13 05:15:38 +00:00
|
|
|
, value(_value)
|
2010-04-08 03:33:16 +00:00
|
|
|
{
|
|
|
|
UpdateGUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PadSettingCheckBox::UpdateGUI()
|
|
|
|
{
|
2011-01-14 03:05:02 +00:00
|
|
|
((wxCheckBox*)wxcontrol)->SetValue(value > 0);
|
2010-04-08 03:33:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PadSettingCheckBox::UpdateValue()
|
|
|
|
{
|
|
|
|
// 0.01 so its saved to the ini file as just 1. :(
|
2010-07-03 08:04:10 +00:00
|
|
|
value = 0.01 * ((wxCheckBox*)wxcontrol)->GetValue();
|
2010-04-08 03:33:16 +00:00
|
|
|
}
|
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
void PadSettingSpin::UpdateGUI()
|
2010-04-08 03:33:16 +00:00
|
|
|
{
|
2011-01-30 01:58:54 +00:00
|
|
|
((wxSpinCtrl*)wxcontrol)->SetValue((int)(value * 100));
|
2010-04-08 03:33:16 +00:00
|
|
|
}
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
void PadSettingSpin::UpdateValue()
|
2010-04-08 03:33:16 +00:00
|
|
|
{
|
2010-07-03 08:04:10 +00:00
|
|
|
value = float(((wxSpinCtrl*)wxcontrol)->GetValue()) / 100;
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-06-16 02:57:50 +00:00
|
|
|
ControlDialog::ControlDialog(GamepadPage* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref)
|
2011-01-05 04:35:46 +00:00
|
|
|
: wxDialog(parent, -1, _("Configure Control"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
2010-06-21 03:12:16 +00:00
|
|
|
, control_reference(ref)
|
|
|
|
, m_plugin(plugin)
|
|
|
|
, m_parent(parent)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
m_devq = m_parent->controller->default_device;
|
|
|
|
|
2010-06-16 02:57:50 +00:00
|
|
|
// GetStrings() sounds slow :/
|
2010-06-21 03:12:16 +00:00
|
|
|
//device_cbox = new wxComboBox(this, -1, WXSTR_FROM_STR(ref->device_qualifier.ToString()), wxDefaultPosition, wxSize(256,-1), parent->device_cbox->GetStrings(), wxTE_PROCESS_ENTER);
|
|
|
|
device_cbox = new wxComboBox(this, -1, WXSTR_FROM_STR(m_devq.ToString()), wxDefaultPosition, wxSize(256,-1), parent->device_cbox->GetStrings(), wxTE_PROCESS_ENTER);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
_connect_macro_(device_cbox, ControlDialog::SetDevice, wxEVT_COMMAND_COMBOBOX_SELECTED, this);
|
|
|
|
_connect_macro_(device_cbox, ControlDialog::SetDevice, wxEVT_COMMAND_TEXT_ENTER, this);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxStaticBoxSizer* const control_chooser = CreateControlChooser(this, parent);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxStaticBoxSizer* const d_szr = new wxStaticBoxSizer(wxVERTICAL, this, _("Device"));
|
|
|
|
d_szr->Add(device_cbox, 0, wxEXPAND|wxALL, 5);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
|
|
|
|
szr->Add(d_szr, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5);
|
|
|
|
szr->Add(control_chooser, 1, wxEXPAND|wxALL, 5);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
SetSizerAndFit(szr); // needed
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
UpdateGUI();
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
ControlButton::ControlButton(wxWindow* const parent, ControllerInterface::ControlReference* const _ref, const unsigned int width, const std::string& label)
|
|
|
|
: wxButton(parent, -1, wxT(""), wxDefaultPosition, wxSize(width,20))
|
|
|
|
, control_reference(_ref)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2011-01-14 03:05:02 +00:00
|
|
|
if (label.empty())
|
2010-06-21 03:12:16 +00:00
|
|
|
SetLabel(WXSTR_FROM_STR(_ref->expression));
|
2010-04-02 02:48:24 +00:00
|
|
|
else
|
2010-06-21 03:12:16 +00:00
|
|
|
SetLabel(WXSTR_FROM_STR(label));
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-06-12 18:45:39 +00:00
|
|
|
void InputConfigDialog::UpdateProfileComboBox()
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2011-01-14 03:05:02 +00:00
|
|
|
std::string pname(File::GetUserPath(D_CONFIG_IDX));
|
2010-06-12 18:45:39 +00:00
|
|
|
pname += PROFILES_PATH;
|
|
|
|
pname += m_plugin.profile_name;
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
CFileSearch::XStringVector exts;
|
|
|
|
exts.push_back("*.ini");
|
|
|
|
CFileSearch::XStringVector dirs;
|
2011-01-14 03:05:02 +00:00
|
|
|
dirs.push_back(pname);
|
|
|
|
CFileSearch cfs(exts, dirs);
|
2010-04-02 02:48:24 +00:00
|
|
|
const CFileSearch::XStringVector& sv = cfs.GetFileNames();
|
|
|
|
|
|
|
|
wxArrayString strs;
|
|
|
|
CFileSearch::XStringVector::const_iterator si = sv.begin(),
|
|
|
|
se = sv.end();
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; si!=se; ++si)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2011-01-14 03:05:02 +00:00
|
|
|
std::string str(si->begin() + si->find_last_of('/') + 1 , si->end() - 4) ;
|
2010-07-03 08:04:10 +00:00
|
|
|
strs.push_back(WXSTR_FROM_STR(str));
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
|
|
|
|
e = m_padpages.end();
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; i != e; ++i)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
(*i)->profile_cbox->Clear();
|
|
|
|
(*i)->profile_cbox->Append(strs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-12 18:45:39 +00:00
|
|
|
void InputConfigDialog::UpdateControlReferences()
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
|
|
|
|
e = m_padpages.end();
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; i != e; ++i)
|
2010-10-12 19:42:29 +00:00
|
|
|
(*i)->controller->UpdateReferences(g_controller_interface);
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void InputConfigDialog::ClickSave(wxCommandEvent&)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.SaveConfig();
|
2010-04-02 02:48:24 +00:00
|
|
|
Close();
|
2010-04-14 23:50:33 +00:00
|
|
|
}
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
void ControlDialog::UpdateListContents()
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
control_lbox->Clear();
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
ControllerInterface::Device* const dev = g_controller_interface.FindDevice(m_devq);
|
2010-06-22 08:30:33 +00:00
|
|
|
if (dev)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
if (control_reference->is_input)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
// for inputs
|
|
|
|
std::vector<ControllerInterface::Device::Input*>::const_iterator
|
2010-07-06 13:14:51 +00:00
|
|
|
i = dev->Inputs().begin(),
|
2010-06-22 08:30:33 +00:00
|
|
|
e = dev->Inputs().end();
|
2010-06-21 03:12:16 +00:00
|
|
|
for (; i!=e; ++i)
|
|
|
|
control_lbox->Append(WXSTR_FROM_STR((*i)->GetName()));
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// for outputs
|
|
|
|
std::vector<ControllerInterface::Device::Output*>::const_iterator
|
2010-07-06 13:14:51 +00:00
|
|
|
i = dev->Outputs().begin(),
|
2010-06-22 08:30:33 +00:00
|
|
|
e = dev->Outputs().end();
|
2010-06-21 03:12:16 +00:00
|
|
|
for (; i!=e; ++i)
|
|
|
|
control_lbox->Append(WXSTR_FROM_STR((*i)->GetName()));
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
2010-04-14 23:50:33 +00:00
|
|
|
}
|
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
void ControlDialog::SelectControl(const std::string& name)
|
2010-04-14 23:50:33 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
//UpdateGUI();
|
2010-04-14 23:50:33 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
const int f = control_lbox->FindString(WXSTR_FROM_STR(name));
|
|
|
|
if (f >= 0)
|
|
|
|
control_lbox->Select(f);
|
2010-04-14 23:50:33 +00:00
|
|
|
}
|
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
void ControlDialog::UpdateGUI()
|
2010-04-14 23:50:33 +00:00
|
|
|
{
|
|
|
|
// update textbox
|
2010-06-21 03:12:16 +00:00
|
|
|
textctrl->SetValue(WXSTR_FROM_STR(control_reference->expression));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-04-14 23:50:33 +00:00
|
|
|
// updates the "bound controls:" label
|
2011-01-16 17:56:26 +00:00
|
|
|
m_bound_label->SetLabel(wxString::Format(_("Bound Controls: %lu"),
|
|
|
|
(unsigned long)control_reference->BoundCount()));
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void GamepadPage::UpdateGUI()
|
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
device_cbox->SetValue(WXSTR_FROM_STR(controller->default_device.ToString()));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-04-13 05:15:38 +00:00
|
|
|
std::vector< ControlGroupBox* >::const_iterator g = control_groups.begin(),
|
2010-04-02 02:48:24 +00:00
|
|
|
ge = control_groups.end();
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; g!=ge; ++g)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
// buttons
|
2010-04-13 05:15:38 +00:00
|
|
|
std::vector<ControlButton*>::const_iterator i = (*g)->control_buttons.begin()
|
|
|
|
, e = (*g)->control_buttons.end();
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; i!=e; ++i)
|
2010-06-21 03:12:16 +00:00
|
|
|
//if (std::string::npos == (*i)->control_reference->expression.find_first_of("`|&!#"))
|
|
|
|
(*i)->SetLabel(WXSTR_FROM_STR((*i)->control_reference->expression));
|
|
|
|
//else
|
|
|
|
//(*i)->SetLabel(wxT("..."));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-04-13 05:15:38 +00:00
|
|
|
// cboxes
|
|
|
|
std::vector<PadSetting*>::const_iterator si = (*g)->options.begin()
|
|
|
|
, se = (*g)->options.end();
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; si!=se; ++si)
|
2010-04-08 03:33:16 +00:00
|
|
|
(*si)->UpdateGUI();
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void GamepadPage::ClearAll(wxCommandEvent&)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
// just load an empty ini section to clear everything :P
|
2010-06-04 20:03:03 +00:00
|
|
|
IniFile::Section section;
|
|
|
|
controller->LoadConfig(§ion);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
// no point in using the real ControllerInterface i guess
|
2010-04-13 05:15:38 +00:00
|
|
|
ControllerInterface face;
|
2010-07-03 08:04:10 +00:00
|
|
|
|
|
|
|
m_plugin.controls_crit.Enter(); // enter
|
2010-06-04 20:03:03 +00:00
|
|
|
controller->UpdateReferences(face);
|
2010-07-03 08:04:10 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
UpdateGUI();
|
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void GamepadPage::LoadDefaults(wxCommandEvent&)
|
2010-07-10 06:48:24 +00:00
|
|
|
{
|
2010-10-12 19:42:29 +00:00
|
|
|
controller->LoadDefaults(g_controller_interface);
|
2010-07-10 06:48:24 +00:00
|
|
|
|
|
|
|
m_plugin.controls_crit.Enter(); // enter
|
2010-10-12 19:42:29 +00:00
|
|
|
controller->UpdateReferences(g_controller_interface);
|
2010-07-10 06:48:24 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
|
|
|
|
|
|
|
UpdateGUI();
|
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void ControlDialog::SetControl(wxCommandEvent&)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
control_reference->expression = STR_FROM_WXSTR(textctrl->GetValue());
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.controls_crit.Enter(); // enter
|
2010-10-12 19:42:29 +00:00
|
|
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
UpdateGUI();
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void GamepadPage::SetDevice(wxCommandEvent&)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-16 02:57:50 +00:00
|
|
|
controller->default_device.FromString(STR_FROM_WXSTR(device_cbox->GetValue()));
|
2010-04-14 23:50:33 +00:00
|
|
|
|
|
|
|
// show user what it was validated as
|
2010-06-16 02:57:50 +00:00
|
|
|
device_cbox->SetValue(WXSTR_FROM_STR(controller->default_device.ToString()));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-04-14 23:50:33 +00:00
|
|
|
// this will set all the controls to this default device
|
|
|
|
controller->UpdateDefaultDevice();
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-04-14 23:50:33 +00:00
|
|
|
// update references
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.controls_crit.Enter(); // enter
|
2011-01-14 03:05:02 +00:00
|
|
|
controller->UpdateReferences(g_controller_interface);
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
2010-04-14 23:50:33 +00:00
|
|
|
}
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void ControlDialog::SetDevice(wxCommandEvent&)
|
2010-04-14 23:50:33 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
m_devq.FromString(STR_FROM_WXSTR(device_cbox->GetValue()));
|
2010-04-14 23:50:33 +00:00
|
|
|
|
|
|
|
// show user what it was validated as
|
2010-06-21 03:12:16 +00:00
|
|
|
device_cbox->SetValue(WXSTR_FROM_STR(m_devq.ToString()));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
// update gui
|
|
|
|
UpdateListContents();
|
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void ControlDialog::ClearControl(wxCommandEvent&)
|
2010-06-21 03:12:16 +00:00
|
|
|
{
|
|
|
|
control_reference->expression.clear();
|
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
m_plugin.controls_crit.Enter(); // enter
|
2010-10-12 19:42:29 +00:00
|
|
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
2010-07-03 08:04:10 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
|
|
|
|
|
|
|
UpdateGUI();
|
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void ControlDialog::SetSelectedControl(wxCommandEvent&)
|
2010-07-03 08:04:10 +00:00
|
|
|
{
|
|
|
|
const int num = control_lbox->GetSelection();
|
|
|
|
|
|
|
|
if (num < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString expr;
|
|
|
|
|
|
|
|
// non-default device
|
|
|
|
if (false == (m_devq == m_parent->controller->default_device))
|
|
|
|
expr.append(wxT('`')).append(WXSTR_FROM_STR(m_devq.ToString())).append(wxT('`'));
|
|
|
|
|
|
|
|
// append the control name
|
|
|
|
expr += control_lbox->GetString(num);
|
|
|
|
|
|
|
|
control_reference->expression = STR_FROM_WXSTR(expr);
|
|
|
|
|
|
|
|
m_plugin.controls_crit.Enter(); // enter
|
2010-10-12 19:42:29 +00:00
|
|
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
UpdateGUI();
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
void ControlDialog::AppendControl(wxCommandEvent& event)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
const int num = control_lbox->GetSelection();
|
|
|
|
|
|
|
|
if (num < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// o boy!, hax
|
|
|
|
const wxString lbl = ((wxButton*)event.GetEventObject())->GetLabel();
|
|
|
|
|
2010-07-16 03:43:11 +00:00
|
|
|
wxString expr = textctrl->GetValue();
|
2010-06-21 03:12:16 +00:00
|
|
|
|
|
|
|
// append the operator to the expression
|
|
|
|
if (wxT('!') == lbl[0] || false == expr.empty())
|
|
|
|
expr += lbl[0];
|
|
|
|
|
|
|
|
// non-default device
|
|
|
|
if (false == (m_devq == m_parent->controller->default_device))
|
|
|
|
expr.append(wxT('`')).append(WXSTR_FROM_STR(m_devq.ToString())).append(wxT('`'));
|
|
|
|
|
|
|
|
// append the control name
|
|
|
|
expr += control_lbox->GetString(num);
|
|
|
|
|
|
|
|
control_reference->expression = STR_FROM_WXSTR(expr);
|
2010-04-14 23:50:33 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
m_plugin.controls_crit.Enter(); // enter
|
2010-10-12 19:42:29 +00:00
|
|
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
2010-04-14 23:50:33 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
UpdateGUI();
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void GamepadPage::AdjustSetting(wxCommandEvent& event)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-07-03 08:04:10 +00:00
|
|
|
m_plugin.controls_crit.Enter(); // enter / prolly fine not being here
|
|
|
|
((PadSetting*)((wxControl*)event.GetEventObject())->GetClientData())->UpdateValue();
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void GamepadPage::AdjustControlOption(wxCommandEvent&)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
m_plugin.controls_crit.Enter(); // enter / prolly fine not being here
|
|
|
|
m_control_dialog->control_reference->range = (ControlState)(m_control_dialog->range_slider->GetValue()) / SLIDER_TICK_COUNT;
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void GamepadPage::ConfigControl(wxCommandEvent& event)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-16 02:57:50 +00:00
|
|
|
m_control_dialog = new ControlDialog(this, m_plugin, ((ControlButton*)event.GetEventObject())->control_reference);
|
2010-04-02 02:48:24 +00:00
|
|
|
m_control_dialog->ShowModal();
|
|
|
|
m_control_dialog->Destroy();
|
2010-04-14 23:50:33 +00:00
|
|
|
|
|
|
|
// update changes that were made in the dialog
|
|
|
|
UpdateGUI();
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void GamepadPage::ClearControl(wxCommandEvent& event)
|
2010-06-05 05:30:23 +00:00
|
|
|
{
|
|
|
|
ControlButton* const btn = (ControlButton*)event.GetEventObject();
|
2010-06-21 03:12:16 +00:00
|
|
|
btn->control_reference->expression.clear();
|
2010-07-26 05:30:50 +00:00
|
|
|
btn->control_reference->range = 1.0f;
|
2010-06-05 05:30:23 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
m_plugin.controls_crit.Enter(); // enter
|
2011-01-14 03:05:02 +00:00
|
|
|
controller->UpdateReferences(g_controller_interface);
|
2010-07-03 08:04:10 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
2010-06-05 05:30:23 +00:00
|
|
|
|
|
|
|
// update changes
|
|
|
|
UpdateGUI();
|
|
|
|
}
|
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
void ControlDialog::DetectControl(wxCommandEvent& event)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-12 02:08:01 +00:00
|
|
|
wxButton* const btn = (wxButton*)event.GetEventObject();
|
|
|
|
const wxString lbl = btn->GetLabel();
|
2010-06-21 03:12:16 +00:00
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
ControllerInterface::Device* const dev = g_controller_interface.FindDevice(m_devq);
|
2010-06-22 08:30:33 +00:00
|
|
|
if (dev)
|
2010-06-12 02:08:01 +00:00
|
|
|
{
|
2011-01-05 04:35:46 +00:00
|
|
|
btn->SetLabel(_("[ waiting ]"));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-07-16 03:43:11 +00:00
|
|
|
// apparently, this makes the "waiting" text work on Linux
|
2010-11-10 23:23:12 +00:00
|
|
|
wxTheApp->Yield();
|
2010-07-16 03:43:11 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
m_plugin.controls_crit.Enter(); // enter
|
2010-06-22 08:30:33 +00:00
|
|
|
ControllerInterface::Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev);
|
2010-07-03 08:04:10 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
2010-06-21 03:12:16 +00:00
|
|
|
|
|
|
|
// if we got input, select it in the list
|
|
|
|
if (ctrl)
|
|
|
|
SelectControl(ctrl->GetName());
|
2010-06-12 02:08:01 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
btn->SetLabel(lbl);
|
|
|
|
}
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void GamepadPage::DetectControl(wxCommandEvent& event)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
ControlButton* btn = (ControlButton*)event.GetEventObject();
|
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
// find device :/
|
2010-10-12 19:42:29 +00:00
|
|
|
ControllerInterface::Device* const dev = g_controller_interface.FindDevice(controller->default_device);
|
2010-06-22 08:30:33 +00:00
|
|
|
if (dev)
|
2010-06-21 03:12:16 +00:00
|
|
|
{
|
2011-01-05 04:35:46 +00:00
|
|
|
btn->SetLabel(_("[ waiting ]"));
|
2010-04-14 23:50:33 +00:00
|
|
|
|
2010-07-16 03:43:11 +00:00
|
|
|
// apparently, this makes the "waiting" text work on Linux
|
2010-11-10 23:23:12 +00:00
|
|
|
wxTheApp->Yield();
|
2010-07-16 03:43:11 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
m_plugin.controls_crit.Enter(); // enter
|
2010-06-22 08:30:33 +00:00
|
|
|
ControllerInterface::Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
// if we got input, update expression and reference
|
|
|
|
if (ctrl)
|
|
|
|
{
|
|
|
|
btn->control_reference->expression = ctrl->GetName();
|
2010-10-12 19:42:29 +00:00
|
|
|
g_controller_interface.UpdateReference(btn->control_reference, controller->default_device);
|
2010-06-21 03:12:16 +00:00
|
|
|
}
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
btn->SetLabel(WXSTR_FROM_STR(btn->control_reference->expression));
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxStaticBoxSizer* ControlDialog::CreateControlChooser(wxWindow* const parent, wxWindow* const eventsink)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2011-01-05 04:35:46 +00:00
|
|
|
wxStaticBoxSizer* const main_szr = new wxStaticBoxSizer(wxVERTICAL, parent, control_reference->is_input ? _("Input") : _("Output"));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
textctrl = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxSize(-1, 48), wxTE_MULTILINE);
|
2010-06-21 03:12:16 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxButton* const detect_button = new wxButton(parent, -1, control_reference->is_input ? _("Detect") : _("Test"));
|
2010-04-22 07:11:49 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxButton* const clear_button = new wxButton(parent, -1, _("Clear"));
|
|
|
|
wxButton* const set_button = new wxButton(parent, -1, _("Set"));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxButton* const select_button = new wxButton(parent, -1, _("Select"));
|
2010-07-03 08:04:10 +00:00
|
|
|
_connect_macro_(select_button, ControlDialog::SetSelectedControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxButton* const or_button = new wxButton(parent, -1, _("| OR"), wxDefaultPosition);
|
2010-06-21 03:12:16 +00:00
|
|
|
_connect_macro_(or_button, ControlDialog::AppendControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
control_lbox = new wxListBox(parent, -1, wxDefaultPosition, wxSize(-1, 64));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
wxBoxSizer* const button_sizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
button_sizer->Add(detect_button, 1, 0, 5);
|
2010-07-03 08:04:10 +00:00
|
|
|
button_sizer->Add(select_button, 1, 0, 5);
|
2010-06-21 03:12:16 +00:00
|
|
|
button_sizer->Add(or_button, 1, 0, 5);
|
2010-07-03 08:04:10 +00:00
|
|
|
|
|
|
|
if (control_reference->is_input)
|
|
|
|
{
|
|
|
|
// TODO: check if && is good on other OS
|
2011-01-14 03:05:02 +00:00
|
|
|
wxButton* const and_button = new wxButton(parent, -1, _("&& AND"), wxDefaultPosition);
|
|
|
|
wxButton* const not_button = new wxButton(parent, -1, _("! NOT"), wxDefaultPosition);
|
|
|
|
wxButton* const add_button = new wxButton(parent, -1, _("^ ADD"), wxDefaultPosition);
|
2010-07-03 08:04:10 +00:00
|
|
|
|
|
|
|
_connect_macro_(and_button, ControlDialog::AppendControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
|
|
|
|
_connect_macro_(not_button, ControlDialog::AppendControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
|
|
|
|
_connect_macro_(add_button, ControlDialog::AppendControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
|
|
|
|
|
|
|
|
button_sizer->Add(and_button, 1, 0, 5);
|
|
|
|
button_sizer->Add(not_button, 1, 0, 5);
|
|
|
|
button_sizer->Add(add_button, 1, 0, 5);
|
|
|
|
}
|
2010-06-21 03:12:16 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
range_slider = new wxSlider(parent, -1, SLIDER_TICK_COUNT, 0, SLIDER_TICK_COUNT * 5, wxDefaultPosition, wxDefaultSize, wxSL_TOP | wxSL_LABELS /*| wxSL_AUTOTICKS*/);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-30 01:58:54 +00:00
|
|
|
range_slider->SetValue((int)(control_reference->range * SLIDER_TICK_COUNT));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
_connect_macro_(detect_button, ControlDialog::DetectControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
|
|
|
|
_connect_macro_(clear_button, ControlDialog::ClearControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
|
|
|
|
_connect_macro_(set_button, ControlDialog::SetControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
_connect_macro_(range_slider, GamepadPage::AdjustControlOption, wxEVT_SCROLL_CHANGED, eventsink);
|
|
|
|
wxStaticText* const range_label = new wxStaticText(parent, -1, _("Range"));
|
|
|
|
m_bound_label = new wxStaticText(parent, -1, wxT(""));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* const range_sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
range_sizer->Add(range_label, 0, wxCENTER|wxLEFT, 5);
|
|
|
|
range_sizer->Add(range_slider, 1, wxEXPAND|wxLEFT, 5);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
wxBoxSizer* const ctrls_sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
ctrls_sizer->Add(control_lbox, 1, wxEXPAND, 0);
|
|
|
|
ctrls_sizer->Add(button_sizer, 0, wxEXPAND, 0);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
wxBoxSizer* const bottom_btns_sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
bottom_btns_sizer->Add(clear_button, 0, wxLEFT, 5);
|
|
|
|
bottom_btns_sizer->AddStretchSpacer(1);
|
|
|
|
bottom_btns_sizer->Add(set_button, 0, wxRIGHT, 5);
|
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
main_szr->Add(range_sizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 5);
|
|
|
|
main_szr->Add(ctrls_sizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 5);
|
|
|
|
main_szr->Add(textctrl, 1, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 5);
|
2010-07-03 08:04:10 +00:00
|
|
|
main_szr->Add(bottom_btns_sizer, 0, wxEXPAND|wxBOTTOM, 5);
|
2010-06-21 03:12:16 +00:00
|
|
|
main_szr->Add(m_bound_label, 0, wxCENTER, 0);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
UpdateListContents();
|
2010-04-22 07:11:49 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
return main_szr;
|
|
|
|
}
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
void GamepadPage::GetProfilePath(std::string& path)
|
|
|
|
{
|
|
|
|
const wxString& name = profile_cbox->GetValue();
|
|
|
|
if (false == name.empty())
|
|
|
|
{
|
|
|
|
// TODO: check for dumb characters maybe
|
|
|
|
|
|
|
|
path = File::GetUserPath(D_CONFIG_IDX);
|
|
|
|
path += PROFILES_PATH;
|
|
|
|
path += m_plugin.profile_name;
|
|
|
|
path += '/';
|
|
|
|
path += STR_FROM_WXSTR(profile_cbox->GetValue());
|
|
|
|
path += ".ini";
|
2010-04-22 07:11:49 +00:00
|
|
|
}
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void GamepadPage::LoadProfile(wxCommandEvent&)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
std::string fname;
|
|
|
|
GamepadPage::GetProfilePath(fname);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
if (false == File::Exists(fname.c_str()))
|
2010-04-02 02:48:24 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
IniFile inifile;
|
2010-06-04 20:03:03 +00:00
|
|
|
inifile.Load(fname);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
m_plugin.controls_crit.Enter();
|
|
|
|
controller->LoadConfig(inifile.GetOrCreateSection("Profile"));
|
2010-10-12 19:42:29 +00:00
|
|
|
controller->UpdateReferences(g_controller_interface);
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.controls_crit.Leave();
|
2010-06-21 03:12:16 +00:00
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
UpdateGUI();
|
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void GamepadPage::SaveProfile(wxCommandEvent&)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
std::string fname;
|
|
|
|
GamepadPage::GetProfilePath(fname);
|
2010-06-22 08:30:33 +00:00
|
|
|
File::CreateFullPath(fname.c_str());
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
if (false == fname.empty())
|
|
|
|
{
|
|
|
|
IniFile inifile;
|
|
|
|
controller->SaveConfig(inifile.GetOrCreateSection("Profile"));
|
|
|
|
inifile.Save(fname);
|
2010-08-15 23:03:15 +00:00
|
|
|
|
|
|
|
m_config_dialog->UpdateProfileComboBox();
|
2010-06-21 03:12:16 +00:00
|
|
|
}
|
2010-08-15 23:03:15 +00:00
|
|
|
else
|
2011-01-13 02:05:58 +00:00
|
|
|
PanicAlertT("You must enter a valid profile name.");
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void GamepadPage::DeleteProfile(wxCommandEvent&)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
std::string fname;
|
|
|
|
GamepadPage::GetProfilePath(fname);
|
|
|
|
|
|
|
|
const char* const fnamecstr = fname.c_str();
|
|
|
|
|
2011-01-12 13:14:50 +00:00
|
|
|
if (File::Exists(fnamecstr) &&
|
2011-01-13 02:05:58 +00:00
|
|
|
AskYesNoT("Are you sure you want to delete \"%s\"?",
|
2011-01-12 13:14:50 +00:00
|
|
|
STR_FROM_WXSTR(profile_cbox->GetValue()).c_str()))
|
2010-08-15 23:03:15 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
File::Delete(fnamecstr);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-08-15 23:03:15 +00:00
|
|
|
m_config_dialog->UpdateProfileComboBox();
|
|
|
|
}
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-06-12 18:45:39 +00:00
|
|
|
void InputConfigDialog::UpdateDeviceComboBox()
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
|
2010-04-02 02:48:24 +00:00
|
|
|
e = m_padpages.end();
|
|
|
|
ControllerInterface::DeviceQualifier dq;
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; i != e; ++i)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
(*i)->device_cbox->Clear();
|
2010-08-15 23:03:15 +00:00
|
|
|
std::vector<ControllerInterface::Device*>::const_iterator
|
2010-10-12 19:42:29 +00:00
|
|
|
di = g_controller_interface.Devices().begin(),
|
|
|
|
de = g_controller_interface.Devices().end();
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; di!=de; ++di)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2011-01-14 03:05:02 +00:00
|
|
|
dq.FromDevice(*di);
|
2010-06-16 02:57:50 +00:00
|
|
|
(*i)->device_cbox->Append(WXSTR_FROM_STR(dq.ToString()));
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
2010-06-16 02:57:50 +00:00
|
|
|
(*i)->device_cbox->SetValue(WXSTR_FROM_STR((*i)->controller->default_device.ToString()));
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void GamepadPage::RefreshDevices(wxCommandEvent&)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.controls_crit.Enter(); // enter
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
// refresh devices
|
2010-10-12 19:42:29 +00:00
|
|
|
g_controller_interface.Shutdown();
|
|
|
|
g_controller_interface.Initialize();
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
// update all control references
|
|
|
|
m_config_dialog->UpdateControlReferences();
|
|
|
|
|
|
|
|
// update device cbox
|
|
|
|
m_config_dialog->UpdateDeviceComboBox();
|
|
|
|
|
2010-06-12 18:45:39 +00:00
|
|
|
m_plugin.controls_crit.Leave(); // leave
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-08-15 20:33:07 +00:00
|
|
|
ControlGroupBox::~ControlGroupBox()
|
|
|
|
{
|
|
|
|
std::vector<PadSetting*>::const_iterator
|
|
|
|
i = options.begin(),
|
|
|
|
e = options.end();
|
|
|
|
for (; i!=e; ++i)
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, wxWindow* const eventsink)
|
2011-01-31 22:19:30 +00:00
|
|
|
: wxBoxSizer(wxVERTICAL)
|
2010-08-15 20:33:07 +00:00
|
|
|
, control_group(group)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
static_bitmap = NULL;
|
|
|
|
|
2010-04-12 20:41:38 +00:00
|
|
|
wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
2010-06-06 03:52:11 +00:00
|
|
|
std::vector<ControllerEmu::ControlGroup::Control*>::iterator
|
|
|
|
ci = group->controls.begin(),
|
|
|
|
ce = group->controls.end();
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; ci != ce; ++ci)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxStaticText* const label = new wxStaticText(parent, -1, WXTSTR_FROM_CSTR((*ci)->name));
|
2010-04-13 05:15:38 +00:00
|
|
|
|
2010-06-06 03:52:11 +00:00
|
|
|
ControlButton* const control_button = new ControlButton(parent, (*ci)->control_ref, 80);
|
2010-04-12 20:41:38 +00:00
|
|
|
control_button->SetFont(m_SmallFont);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-06 03:52:11 +00:00
|
|
|
control_buttons.push_back(control_button);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-06 03:52:11 +00:00
|
|
|
if ((*ci)->control_ref->is_input)
|
|
|
|
{
|
2011-01-05 04:35:46 +00:00
|
|
|
control_button->SetToolTip(_("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
|
2011-01-14 03:05:02 +00:00
|
|
|
_connect_macro_(control_button, GamepadPage::DetectControl, wxEVT_COMMAND_BUTTON_CLICKED, eventsink);
|
2010-06-06 03:52:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-05 04:35:46 +00:00
|
|
|
control_button->SetToolTip(_("Left/Right-click for more options.\nMiddle-click to clear."));
|
2011-01-14 03:05:02 +00:00
|
|
|
_connect_macro_(control_button, GamepadPage::ConfigControl, wxEVT_COMMAND_BUTTON_CLICKED, eventsink);
|
2010-06-06 03:52:11 +00:00
|
|
|
}
|
2010-06-05 05:30:23 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
_connect_macro_(control_button, GamepadPage::ClearControl, wxEVT_MIDDLE_DOWN, eventsink);
|
|
|
|
_connect_macro_(control_button, GamepadPage::ConfigControl, wxEVT_RIGHT_UP, eventsink);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* const control_sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
control_sizer->AddStretchSpacer(1);
|
|
|
|
control_sizer->Add(label, 0, wxCENTER | wxRIGHT, 3);
|
|
|
|
control_sizer->Add(control_button, 0, 0, 0);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
Add(control_sizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 3);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-06-05 05:30:23 +00:00
|
|
|
wxMemoryDC dc;
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
switch (group->type)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-07-06 13:14:51 +00:00
|
|
|
case GROUP_TYPE_STICK:
|
|
|
|
case GROUP_TYPE_TILT:
|
|
|
|
case GROUP_TYPE_CURSOR:
|
|
|
|
case GROUP_TYPE_FORCE:
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
wxBitmap bitmap(64, 64);
|
|
|
|
dc.SelectObject(bitmap);
|
|
|
|
dc.Clear();
|
2010-07-03 08:04:10 +00:00
|
|
|
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-04-22 07:11:49 +00:00
|
|
|
std::vector< ControllerEmu::ControlGroup::Setting* >::const_iterator
|
|
|
|
i = group->settings.begin(),
|
|
|
|
e = group->settings.end();
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
|
|
|
|
for (; i!=e; ++i)
|
2010-04-22 07:11:49 +00:00
|
|
|
{
|
2010-07-03 08:04:10 +00:00
|
|
|
PadSettingSpin* setting = new PadSettingSpin(parent, *i);
|
|
|
|
_connect_macro_(setting->wxcontrol, GamepadPage::AdjustSetting, wxEVT_COMMAND_SPINCTRL_UPDATED, eventsink);
|
|
|
|
options.push_back(setting);
|
2011-01-14 03:05:02 +00:00
|
|
|
szr->Add(new wxStaticText(parent, -1, WXTSTR_FROM_CSTR((*i)->name)));
|
|
|
|
szr->Add(setting->wxcontrol, 0, wxLEFT, 0);
|
2010-04-22 07:11:49 +00:00
|
|
|
}
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* const h_szr = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
h_szr->Add(szr, 1, 0, 5);
|
|
|
|
h_szr->Add(static_bitmap, 0, wxALL|wxCENTER, 3);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
Add(h_szr, 0, wxEXPAND|wxLEFT|wxCENTER|wxTOP, 3);
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-07-06 13:14:51 +00:00
|
|
|
case GROUP_TYPE_BUTTONS:
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
wxBitmap bitmap(int(12*group->controls.size()+1), 12);
|
|
|
|
dc.SelectObject(bitmap);
|
|
|
|
dc.Clear();
|
2010-07-03 08:04:10 +00:00
|
|
|
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
PadSettingSpin* const threshold_cbox = new PadSettingSpin(parent, group->settings[0]);
|
|
|
|
_connect_macro_(threshold_cbox->wxcontrol, GamepadPage::AdjustSetting, wxEVT_COMMAND_SPINCTRL_UPDATED, eventsink);
|
2010-06-05 05:30:23 +00:00
|
|
|
|
2011-01-05 04:35:46 +00:00
|
|
|
threshold_cbox->wxcontrol->SetToolTip(_("Adjust the analog control pressure required to activate buttons."));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
options.push_back(threshold_cbox);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
szr->Add(new wxStaticText(parent, -1, WXTSTR_FROM_CSTR(group->settings[0]->name)),
|
|
|
|
0, wxCENTER|wxRIGHT, 3);
|
2010-07-03 08:04:10 +00:00
|
|
|
szr->Add(threshold_cbox->wxcontrol, 0, wxRIGHT, 3);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
Add(szr, 0, wxALL|wxCENTER, 3);
|
|
|
|
Add(static_bitmap, 0, wxALL|wxCENTER, 3);
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-07-06 13:14:51 +00:00
|
|
|
case GROUP_TYPE_MIXED_TRIGGERS:
|
|
|
|
case GROUP_TYPE_TRIGGERS:
|
2010-10-05 21:43:51 +00:00
|
|
|
case GROUP_TYPE_SLIDER:
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-10-05 21:43:51 +00:00
|
|
|
int height = (int)(12 * group->controls.size());
|
|
|
|
int width = 64;
|
|
|
|
|
|
|
|
if (GROUP_TYPE_MIXED_TRIGGERS == group->type)
|
|
|
|
width = 64+12+1;
|
|
|
|
|
|
|
|
if (GROUP_TYPE_TRIGGERS != group->type)
|
|
|
|
height /= 2;
|
|
|
|
|
2010-04-24 00:44:10 +00:00
|
|
|
wxBitmap bitmap(width, height+1);
|
2010-04-02 02:48:24 +00:00
|
|
|
dc.SelectObject(bitmap);
|
|
|
|
dc.Clear();
|
2010-07-03 08:04:10 +00:00
|
|
|
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-04-24 00:44:10 +00:00
|
|
|
std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
|
|
|
|
i = group->settings.begin(),
|
|
|
|
e = group->settings.end();
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; i!=e; ++i)
|
2010-04-24 00:44:10 +00:00
|
|
|
{
|
2010-07-03 08:04:10 +00:00
|
|
|
PadSettingSpin* setting = new PadSettingSpin(parent, *i);
|
|
|
|
_connect_macro_(setting->wxcontrol, GamepadPage::AdjustSetting, wxEVT_COMMAND_SPINCTRL_UPDATED, eventsink);
|
|
|
|
options.push_back(setting);
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
|
2011-01-14 15:09:30 +00:00
|
|
|
szr->Add(new wxStaticText(parent, -1, WXTSTR_FROM_CSTR((*i)->name)), 0, wxCENTER|wxRIGHT, 3);
|
2010-07-03 08:04:10 +00:00
|
|
|
szr->Add(setting->wxcontrol, 0, wxRIGHT, 3);
|
|
|
|
Add(szr, 0, wxALL|wxCENTER, 3);
|
2010-04-24 00:44:10 +00:00
|
|
|
}
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
Add(static_bitmap, 0, wxALL|wxCENTER, 3);
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-07-06 13:14:51 +00:00
|
|
|
case GROUP_TYPE_EXTENSION:
|
2010-04-13 05:15:38 +00:00
|
|
|
{
|
2011-01-14 03:05:02 +00:00
|
|
|
PadSettingExtension* const attachments = new PadSettingExtension(parent, (ControllerEmu::Extension*)group);
|
|
|
|
wxButton* const configure_btn = new ExtensionButton(parent, (ControllerEmu::Extension*)group);
|
2010-04-13 05:15:38 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
options.push_back(attachments);
|
2010-04-13 05:15:38 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
_connect_macro_(attachments->wxcontrol, GamepadPage::AdjustSetting, wxEVT_COMMAND_CHOICE_SELECTED, eventsink);
|
|
|
|
_connect_macro_(configure_btn, GamepadPage::ConfigExtension, wxEVT_COMMAND_BUTTON_CLICKED, eventsink);
|
2010-04-13 05:15:38 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
Add(attachments->wxcontrol, 0, wxTOP|wxLEFT|wxRIGHT|wxEXPAND, 3);
|
2011-01-14 03:05:02 +00:00
|
|
|
Add(configure_btn, 0, wxALL|wxEXPAND, 3);
|
2010-04-13 05:15:38 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-07-05 10:46:32 +00:00
|
|
|
case GROUP_TYPE_UDPWII:
|
|
|
|
{
|
2011-01-14 03:05:02 +00:00
|
|
|
wxButton* const btn = new UDPConfigButton(parent, (UDPWrapper*)group);
|
2010-07-05 10:46:32 +00:00
|
|
|
_connect_macro_(btn, GamepadPage::ConfigUDPWii, wxEVT_COMMAND_BUTTON_CLICKED, eventsink);
|
|
|
|
Add(btn, 0, wxALL|wxEXPAND, 3);
|
|
|
|
}
|
|
|
|
break;
|
2010-07-06 13:14:51 +00:00
|
|
|
default:
|
2010-04-08 03:33:16 +00:00
|
|
|
{
|
2010-04-13 05:15:38 +00:00
|
|
|
//options
|
|
|
|
|
2010-04-08 03:33:16 +00:00
|
|
|
std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
|
|
|
|
i = group->settings.begin(),
|
|
|
|
e = group->settings.end();
|
2011-01-14 03:05:02 +00:00
|
|
|
for (; i!=e; ++i)
|
2010-04-08 03:33:16 +00:00
|
|
|
{
|
2010-07-03 08:04:10 +00:00
|
|
|
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, (*i)->value, (*i)->name);
|
|
|
|
_connect_macro_(setting_cbox->wxcontrol, GamepadPage::AdjustSetting, wxEVT_COMMAND_CHECKBOX_CLICKED, eventsink);
|
|
|
|
options.push_back(setting_cbox);
|
2010-04-08 03:33:16 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
Add(setting_cbox->wxcontrol, 0, wxALL|wxLEFT, 5);
|
2010-04-08 03:33:16 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2010-04-02 02:48:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-06-05 05:30:23 +00:00
|
|
|
dc.SelectObject(wxNullBitmap);
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
//AddStretchSpacer(0);
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow* const parent, wxWindow* const eventsink, std::vector<ControlGroupBox*>* groups)
|
|
|
|
: wxBoxSizer(wxHORIZONTAL)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-10-05 21:43:51 +00:00
|
|
|
size_t col_size = 0;
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
wxBoxSizer* stacked_groups = NULL;
|
2011-01-14 03:05:02 +00:00
|
|
|
for (unsigned int i = 0; i < controller->groups.size(); ++i)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2011-01-31 22:19:30 +00:00
|
|
|
ControlGroupBox* control_group_box = new ControlGroupBox(controller->groups[i], parent, eventsink);
|
|
|
|
wxStaticBoxSizer *control_group =
|
|
|
|
new wxStaticBoxSizer(wxVERTICAL, parent, WXTSTR_FROM_CSTR(controller->groups[i]->name));
|
|
|
|
control_group->Add(control_group_box);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-10-05 21:43:51 +00:00
|
|
|
const size_t grp_size = controller->groups[i]->controls.size() + controller->groups[i]->settings.size();
|
|
|
|
col_size += grp_size;
|
|
|
|
if (col_size > 8 || NULL == stacked_groups)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2011-01-14 03:05:02 +00:00
|
|
|
if (stacked_groups)
|
|
|
|
Add(stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
stacked_groups = new wxBoxSizer(wxVERTICAL);
|
|
|
|
stacked_groups->Add(control_group, 0, wxEXPAND);
|
2010-10-05 21:43:51 +00:00
|
|
|
|
|
|
|
col_size = grp_size;
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
else
|
2011-01-14 03:05:02 +00:00
|
|
|
stacked_groups->Add(control_group, 0, wxEXPAND);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
if (groups)
|
2011-01-31 22:19:30 +00:00
|
|
|
groups->push_back(control_group_box);
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
if (stacked_groups)
|
|
|
|
Add(stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5);
|
2010-04-13 05:15:38 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
GamepadPage::GamepadPage(wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog)
|
|
|
|
: wxNotebookPage(parent, -1 , wxDefaultPosition, wxDefaultSize)
|
2010-06-12 18:45:39 +00:00
|
|
|
,controller(plugin.controllers[pad_num])
|
2010-07-03 08:04:10 +00:00
|
|
|
, m_config_dialog(config_dialog)
|
|
|
|
, m_plugin(plugin)
|
2010-04-13 05:15:38 +00:00
|
|
|
{
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* control_group_sizer = new ControlGroupsSizer(m_plugin.controllers[pad_num], this, this, &control_groups);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Profile"));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
// device chooser
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxStaticBoxSizer* const device_sbox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Device"));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-08-29 03:45:56 +00:00
|
|
|
device_cbox = new wxComboBox(this, -1, wxT(""), wxDefaultPosition, wxSize(64,-1));
|
|
|
|
device_cbox->ToggleWindowStyle(wxTE_PROCESS_ENTER);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxButton* refresh_button = new wxButton(this, -1, _("Refresh"), wxDefaultPosition, wxSize(60,-1));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
_connect_macro_(device_cbox, GamepadPage::SetDevice, wxEVT_COMMAND_COMBOBOX_SELECTED, this);
|
|
|
|
_connect_macro_(device_cbox, GamepadPage::SetDevice, wxEVT_COMMAND_TEXT_ENTER, this);
|
|
|
|
_connect_macro_(refresh_button, GamepadPage::RefreshDevices, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
device_sbox->Add(device_cbox, 1, wxLEFT|wxRIGHT, 3);
|
|
|
|
device_sbox->Add(refresh_button, 0, wxRIGHT|wxBOTTOM, 3);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-05 04:35:46 +00:00
|
|
|
wxButton* const default_button = new wxButton(this, -1, _("Default"), wxDefaultPosition, wxSize(48,-1));
|
|
|
|
wxButton* const clearall_button = new wxButton(this, -1, _("Clear"), wxDefaultPosition, wxSize(58,-1));
|
2010-07-10 06:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxStaticBoxSizer* const clear_sbox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Reset"));
|
2010-07-10 06:48:24 +00:00
|
|
|
clear_sbox->Add(default_button, 1, wxLEFT, 3);
|
|
|
|
clear_sbox->Add(clearall_button, 1, wxRIGHT, 3);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-07-10 06:48:24 +00:00
|
|
|
_connect_macro_(clearall_button, GamepadPage::ClearAll, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
|
|
|
_connect_macro_(default_button, GamepadPage::LoadDefaults, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
profile_cbox = new wxComboBox(this, -1, wxT(""), wxDefaultPosition, wxSize(64,-1));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxButton* const pload_btn = new wxButton(this, -1, _("Load"), wxDefaultPosition, wxSize(48,-1));
|
|
|
|
wxButton* const psave_btn = new wxButton(this, -1, _("Save"), wxDefaultPosition, wxSize(48,-1));
|
|
|
|
wxButton* const pdelete_btn = new wxButton(this, -1, _("Delete"), wxDefaultPosition, wxSize(60,-1));
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-04-14 23:50:33 +00:00
|
|
|
_connect_macro_(pload_btn, GamepadPage::LoadProfile, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
|
|
|
_connect_macro_(psave_btn, GamepadPage::SaveProfile, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
|
|
|
_connect_macro_(pdelete_btn, GamepadPage::DeleteProfile, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
profile_sbox->Add(profile_cbox, 1, wxLEFT, 3);
|
|
|
|
profile_sbox->Add(pload_btn, 0, wxLEFT, 3);
|
|
|
|
profile_sbox->Add(psave_btn, 0, 0, 3);
|
|
|
|
profile_sbox->Add(pdelete_btn, 0, wxRIGHT|wxBOTTOM, 3);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* const dio = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
dio->Add(device_sbox, 1, wxEXPAND|wxRIGHT, 5);
|
|
|
|
dio->Add(clear_sbox, 0, wxEXPAND|wxRIGHT, 5);
|
|
|
|
dio->Add(profile_sbox, 1, wxEXPAND|wxRIGHT, 5);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* const mapping = new wxBoxSizer(wxVERTICAL);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
mapping->Add(dio, 1, wxEXPAND|wxLEFT|wxTOP|wxBOTTOM, 5);
|
|
|
|
mapping->Add(control_group_sizer, 0, wxLEFT|wxEXPAND, 5);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
UpdateGUI();
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
SetSizerAndFit(mapping); // needed
|
2010-04-02 02:48:24 +00:00
|
|
|
Layout();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputPlugin& plugin, const std::string& name, const int tab_num)
|
2011-01-14 03:05:02 +00:00
|
|
|
: wxDialog(parent, wxID_ANY, WXTSTR_FROM_CSTR(name.c_str()), wxPoint(128,-1), wxDefaultSize)
|
2010-04-02 02:48:24 +00:00
|
|
|
, m_plugin(plugin)
|
|
|
|
{
|
2011-01-14 03:05:02 +00:00
|
|
|
m_pad_notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT);
|
|
|
|
for (unsigned int i = 0; i < plugin.controllers.size(); ++i)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2011-01-14 03:05:02 +00:00
|
|
|
GamepadPage* gp = new GamepadPage(m_pad_notebook, m_plugin, i, this);
|
|
|
|
m_padpages.push_back(gp);
|
2011-01-14 19:27:18 +00:00
|
|
|
m_pad_notebook->AddPage(gp, wxString::Format(wxT("%s %u"), WXTSTR_FROM_CSTR(m_plugin.gui_name), 1+i));
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
m_pad_notebook->SetSelection(tab_num);
|
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
UpdateDeviceComboBox();
|
|
|
|
UpdateProfileComboBox();
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxButton* const close_button = new wxButton(this, -1, _("Save"));
|
2010-06-12 18:45:39 +00:00
|
|
|
_connect_macro_(close_button, InputConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
|
|
|
_connect_macro_(close_button, InputConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* btns = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
//btns->Add(new wxStaticText(this, -1, wxString::FromAscii(ver.c_str())), 0, wxLEFT|wxTOP, 5);
|
2010-04-02 02:48:24 +00:00
|
|
|
btns->AddStretchSpacer();
|
2011-01-14 03:05:02 +00:00
|
|
|
btns->Add(close_button, 0, 0, 0);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
|
|
|
|
szr->Add(m_pad_notebook, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5);
|
|
|
|
szr->Add(btns, 0, wxEXPAND|wxALL, 5);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
SetSizerAndFit(szr); // needed
|
2010-04-29 18:51:04 +00:00
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
// not needed here it seems, but it cant hurt
|
|
|
|
//Layout();
|
|
|
|
|
|
|
|
Center();
|
|
|
|
|
|
|
|
// live preview update timer
|
2011-01-14 03:05:02 +00:00
|
|
|
m_update_timer = new wxTimer(this, -1);
|
|
|
|
Connect(wxID_ANY, wxEVT_TIMER, wxTimerEventHandler(InputConfigDialog::UpdateBitmaps), (wxObject*)0, this);
|
|
|
|
m_update_timer->Start(PREVIEW_UPDATE_TIME, wxTIMER_CONTINUOUS);
|
2010-04-02 02:48:24 +00:00
|
|
|
}
|
2010-06-12 18:45:39 +00:00
|
|
|
|
2010-06-13 14:49:49 +00:00
|
|
|
bool InputConfigDialog::Destroy()
|
2010-06-12 18:45:39 +00:00
|
|
|
{
|
|
|
|
m_update_timer->Stop();
|
2010-06-13 14:49:49 +00:00
|
|
|
return true;
|
2010-06-12 23:27:39 +00:00
|
|
|
}
|