2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
#include "ConfigDiag.h"
|
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
#define _connect_macro_( b, f, c, s ) (b)->Connect( wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s );
|
|
|
|
|
2010-06-02 22:55:39 -06:00
|
|
|
static Plugin* g_plugin;//WTF?TODOSHUFFLE
|
2010-04-14 17:50:33 -06:00
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
void GamepadPage::ConfigExtension( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
ControllerEmu::Extension* const ex = ((ExtensionButton*)event.GetEventObject())->extension;
|
|
|
|
|
|
|
|
// show config diag, if "none" isn't selected
|
|
|
|
if ( ex->switch_extension )
|
|
|
|
{
|
|
|
|
wxDialog* const dlg = new wxDialog( this, -1, wxString::FromAscii(ex->attachments[ex->switch_extension]->GetName().c_str()), wxDefaultPosition );
|
|
|
|
wxPanel* const pnl = new wxPanel( dlg, -1, wxDefaultPosition );
|
|
|
|
wxBoxSizer* const pnl_szr = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
|
|
|
|
const std::size_t orig_size = control_groups.size();
|
|
|
|
|
|
|
|
ControlGroupsSizer* const szr = new ControlGroupsSizer( ex->attachments[ex->switch_extension], pnl, this, &control_groups );
|
2010-04-29 12:51:04 -06:00
|
|
|
pnl->SetSizerAndFit( szr ); // needed
|
2010-04-12 23:15:38 -06:00
|
|
|
pnl_szr->Add( pnl, 0, wxLEFT, 5 );
|
2010-04-29 12:51:04 -06:00
|
|
|
dlg->SetSizerAndFit( pnl_szr ); // needed
|
2010-04-12 23:15:38 -06:00
|
|
|
|
|
|
|
dlg->Center();
|
|
|
|
|
|
|
|
dlg->ShowModal();
|
|
|
|
dlg->Destroy();
|
|
|
|
|
|
|
|
// remove the new groups that were just added, now that the window closed
|
|
|
|
control_groups.resize( orig_size );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PadSettingExtension::PadSettingExtension( wxWindow* const parent, ControllerEmu::Extension* const ext )
|
|
|
|
: wxChoice( parent, -1 )
|
|
|
|
, extension(ext)
|
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<ControllerEmu*>::const_iterator
|
|
|
|
i = extension->attachments.begin(),
|
|
|
|
e = extension->attachments.end();
|
|
|
|
|
|
|
|
for ( ; i!=e; ++i )
|
|
|
|
Append( wxString::FromAscii( (*i)->GetName().c_str() ) );
|
|
|
|
|
|
|
|
UpdateGUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PadSettingExtension::UpdateGUI()
|
|
|
|
{
|
|
|
|
Select( extension->switch_extension );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PadSettingExtension::UpdateValue()
|
|
|
|
{
|
|
|
|
extension->switch_extension = GetSelection();
|
|
|
|
}
|
|
|
|
|
2010-04-07 21:33:16 -06:00
|
|
|
PadSettingCheckBox::PadSettingCheckBox( wxWindow* const parent, ControlState& _value, const char* const label )
|
2010-04-12 23:15:38 -06:00
|
|
|
: wxCheckBox( parent, -1, wxString::FromAscii( label ), wxDefaultPosition )
|
|
|
|
, value(_value)
|
2010-04-07 21:33:16 -06:00
|
|
|
{
|
|
|
|
UpdateGUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PadSettingCheckBox::UpdateGUI()
|
|
|
|
{
|
|
|
|
SetValue( value > 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PadSettingCheckBox::UpdateValue()
|
|
|
|
{
|
|
|
|
// 0.01 so its saved to the ini file as just 1. :(
|
|
|
|
value = 0.01 * GetValue();
|
|
|
|
}
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
PadSettingChoice::PadSettingChoice( wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const setting )
|
2010-04-12 23:15:38 -06:00
|
|
|
: wxChoice( parent, -1, wxDefaultPosition, wxSize( 54, -1 ) )
|
2010-04-22 01:11:49 -06:00
|
|
|
, value(setting->value)
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
Append( wxT("0") );
|
2010-04-22 01:11:49 -06:00
|
|
|
for ( unsigned int i = setting->low; i<=setting->high; ++i )
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
std::ostringstream ss;
|
2010-04-22 01:11:49 -06:00
|
|
|
ss << i;
|
2010-04-01 20:48:24 -06:00
|
|
|
Append( wxString::FromAscii( ss.str().c_str() ) );
|
|
|
|
}
|
|
|
|
|
2010-04-07 21:33:16 -06:00
|
|
|
UpdateGUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PadSettingChoice::UpdateGUI()
|
|
|
|
{
|
2010-04-01 20:48:24 -06:00
|
|
|
std::ostringstream ss;
|
|
|
|
ss << int(value * 100);
|
|
|
|
SetSelection( FindString( wxString::FromAscii( ss.str().c_str() ) ) );
|
2010-04-07 21:33:16 -06:00
|
|
|
}
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-07 21:33:16 -06:00
|
|
|
void PadSettingChoice::UpdateValue()
|
|
|
|
{
|
|
|
|
value = float( atoi( GetStringSelection().mb_str() ) ) / 100;
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
ControlDialog::ControlDialog( wxWindow* const parent, ControllerInterface::ControlReference* const ref, const std::vector<ControllerInterface::Device*>& devs )
|
|
|
|
:wxDialog( parent, -1, wxT("Configure Control"), wxDefaultPosition )
|
|
|
|
,control_reference(ref)
|
|
|
|
{
|
|
|
|
|
|
|
|
device_cbox = new wxComboBox( this, -1, wxString::FromAscii( ref->device_qualifier.ToString().c_str() ), wxDefaultPosition, wxSize(256,-1), wxArrayString(), wxTE_PROCESS_ENTER );
|
|
|
|
|
2010-04-14 17:50:33 -06: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-01 20:48:24 -06:00
|
|
|
|
|
|
|
std::vector< ControllerInterface::Device* >::const_iterator i = devs.begin(),
|
|
|
|
e = devs.end();
|
|
|
|
ControllerInterface::DeviceQualifier dq;
|
|
|
|
for ( ; i!=e; ++i )
|
|
|
|
{
|
|
|
|
dq.FromDevice( *i );
|
|
|
|
device_cbox->Append( wxString::FromAscii( dq.ToString().c_str() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
control_chooser = new ControlChooser( this, ref, parent );
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxStaticBoxSizer* const d_szr = new wxStaticBoxSizer( wxVERTICAL, this, wxT("Device") );
|
2010-04-01 20:48:24 -06:00
|
|
|
d_szr->Add( device_cbox, 0, wxEXPAND|wxALL, 5 );
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const szr = new wxBoxSizer( wxVERTICAL );
|
2010-04-01 20:48:24 -06:00
|
|
|
szr->Add( d_szr, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
|
|
|
|
szr->Add( control_chooser, 0, wxEXPAND|wxALL, 5 );
|
|
|
|
|
2010-04-29 12:51:04 -06:00
|
|
|
SetSizerAndFit( szr ); // needed
|
2010-04-01 20:48:24 -06: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 )
|
|
|
|
{
|
|
|
|
if ( label.empty() )
|
|
|
|
SetLabel( wxString::FromAscii( _ref->control_qualifier.name.c_str() ) );
|
|
|
|
else
|
|
|
|
SetLabel( wxString::FromAscii( label.c_str() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigDialog::UpdateProfileComboBox()
|
|
|
|
{
|
|
|
|
std::string pname( File::GetUserPath(D_CONFIG_IDX) );
|
2010-04-14 17:50:33 -06:00
|
|
|
pname += PROFILES_PATH; pname += g_plugin->profile_name;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
CFileSearch::XStringVector exts;
|
|
|
|
exts.push_back("*.ini");
|
|
|
|
CFileSearch::XStringVector dirs;
|
|
|
|
dirs.push_back( pname );
|
|
|
|
CFileSearch cfs( exts, dirs );
|
|
|
|
const CFileSearch::XStringVector& sv = cfs.GetFileNames();
|
|
|
|
|
|
|
|
wxArrayString strs;
|
|
|
|
CFileSearch::XStringVector::const_iterator si = sv.begin(),
|
|
|
|
se = sv.end();
|
|
|
|
for ( ; si!=se; ++si )
|
|
|
|
{
|
|
|
|
std::string str( si->begin() + si->find_last_of('/') + 1 , si->end() - 4 ) ;
|
|
|
|
strs.push_back( wxString::FromAscii( str.c_str() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
|
|
|
|
e = m_padpages.end();
|
|
|
|
for ( ; i != e; ++i )
|
|
|
|
{
|
|
|
|
(*i)->profile_cbox->Clear();
|
|
|
|
(*i)->profile_cbox->Append(strs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigDialog::UpdateControlReferences()
|
|
|
|
{
|
|
|
|
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
|
|
|
|
e = m_padpages.end();
|
|
|
|
for ( ; i != e; ++i )
|
2010-04-14 17:50:33 -06:00
|
|
|
(*i)->controller->UpdateReferences( g_plugin->controller_interface );
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigDialog::ClickSave( wxCommandEvent& event )
|
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->SaveConfig();
|
2010-04-01 20:48:24 -06:00
|
|
|
Close();
|
2010-04-14 17:50:33 -06:00
|
|
|
}
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
void ControlChooser::UpdateListContents()
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
control_lbox->Clear();
|
|
|
|
|
|
|
|
// make sure it's a valid device
|
|
|
|
if ( control_reference->device )
|
|
|
|
{
|
|
|
|
if ( control_reference->is_input )
|
|
|
|
{
|
|
|
|
// for inputs
|
|
|
|
std::vector<ControllerInterface::Device::Input*>::const_iterator
|
|
|
|
i = control_reference->device->Inputs().begin(),
|
|
|
|
e = control_reference->device->Inputs().end();
|
|
|
|
for ( ; i!=e; ++i )
|
|
|
|
control_lbox->Append( wxString::FromAscii( (*i)->GetName().c_str() ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// for outputs
|
|
|
|
std::vector<ControllerInterface::Device::Output*>::const_iterator
|
|
|
|
i = control_reference->device->Outputs().begin(),
|
|
|
|
e = control_reference->device->Outputs().end();
|
|
|
|
for ( ; i!=e; ++i )
|
|
|
|
control_lbox->Append( wxString::FromAscii( (*i)->GetName().c_str() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
UpdateListSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControlChooser::UpdateListSelection()
|
|
|
|
{
|
|
|
|
UpdateGUI();
|
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
wxArrayString control_names = control_lbox->GetStrings();
|
|
|
|
const std::string cname = control_reference->control_qualifier.name;
|
2010-04-14 17:50:33 -06:00
|
|
|
|
|
|
|
control_lbox->DeselectAll();
|
|
|
|
|
|
|
|
// if text starts and ends with '|' it's multiple controls, otherwise just single one
|
|
|
|
if (cname.size() ? ((*cname.rbegin()=='|') && (*cname.begin()=='|')) : false)
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
for (int i = int(control_names.size()) - 1; i >= 0; --i)
|
|
|
|
if (cname.find( control_names[i].Prepend(wxT('|')).Append(wxT('|')).ToAscii()) != cname.npos)
|
|
|
|
control_lbox->Select( i );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const int n = control_lbox->FindString(wxString::FromAscii(cname.c_str()));
|
|
|
|
if (n >= 0)
|
|
|
|
control_lbox->Select(n);
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
2010-04-14 17:50:33 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void ControlChooser::UpdateGUI()
|
|
|
|
{
|
|
|
|
// update textbox
|
|
|
|
textctrl->SetValue(wxString::FromAscii(control_reference->control_qualifier.name.c_str()));
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
// updates the "bound controls:" label
|
2010-04-01 20:48:24 -06:00
|
|
|
size_t bound = control_reference->controls.size();
|
|
|
|
std::ostringstream ss;
|
|
|
|
ss << "Bound Controls: ";
|
|
|
|
if ( bound ) ss << bound; else ss << "None";
|
|
|
|
m_bound_label->SetLabel( wxString::FromAscii(ss.str().c_str()) );
|
|
|
|
};
|
|
|
|
|
|
|
|
void GamepadPage::UpdateGUI()
|
|
|
|
{
|
2010-04-12 23:15:38 -06:00
|
|
|
device_cbox->SetValue( wxString::FromAscii( controller->default_device.ToString().c_str() ) );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
std::vector< ControlGroupBox* >::const_iterator g = control_groups.begin(),
|
2010-04-01 20:48:24 -06:00
|
|
|
ge = control_groups.end();
|
|
|
|
for ( ; g!=ge; ++g )
|
|
|
|
{
|
|
|
|
// buttons
|
2010-04-12 23:15:38 -06:00
|
|
|
std::vector<ControlButton*>::const_iterator i = (*g)->control_buttons.begin()
|
|
|
|
, e = (*g)->control_buttons.end();
|
2010-04-01 20:48:24 -06:00
|
|
|
for ( ; i!=e; ++i )
|
|
|
|
(*i)->SetLabel( wxString::FromAscii( (*i)->control_reference->control_qualifier.name.c_str() ) );
|
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
// cboxes
|
|
|
|
std::vector<PadSetting*>::const_iterator si = (*g)->options.begin()
|
|
|
|
, se = (*g)->options.end();
|
2010-04-01 20:48:24 -06:00
|
|
|
for ( ; si!=se; ++si )
|
2010-04-07 21:33:16 -06:00
|
|
|
(*si)->UpdateGUI();
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GamepadPage::ClearAll( wxCommandEvent& event )
|
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Enter(); // enter
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
// just load an empty ini section to clear everything :P
|
2010-06-02 22:55:39 -06:00
|
|
|
Section section;
|
2010-04-12 23:15:38 -06:00
|
|
|
controller->LoadConfig( section );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
// no point in using the real ControllerInterface i guess
|
2010-04-12 23:15:38 -06:00
|
|
|
ControllerInterface face;
|
|
|
|
controller->UpdateReferences( face );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
UpdateGUI();
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Leave(); // leave
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
void ControlDialog::SetControl( wxCommandEvent& event )
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
control_reference->control_qualifier.name =
|
|
|
|
std::string( control_chooser->textctrl->GetValue().ToAscii() );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Enter(); // enter
|
|
|
|
control_reference->UpdateControls();
|
|
|
|
g_plugin->controls_crit.Leave(); // leave
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
control_chooser->UpdateListSelection();
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GamepadPage::SetDevice( wxCommandEvent& event )
|
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
controller->default_device.FromString( std::string( device_cbox->GetValue().ToAscii() ) );
|
|
|
|
|
|
|
|
// show user what it was validated as
|
|
|
|
device_cbox->SetValue( wxString::FromAscii( controller->default_device.ToString().c_str() ) );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
// this will set all the controls to this default device
|
|
|
|
controller->UpdateDefaultDevice();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
// update references
|
|
|
|
g_plugin->controls_crit.Enter(); // enter
|
|
|
|
controller->UpdateReferences( g_plugin->controller_interface );
|
|
|
|
g_plugin->controls_crit.Leave(); // leave
|
|
|
|
}
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
void ControlDialog::SetDevice( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
control_reference->device_qualifier.FromString( std::string( device_cbox->GetValue().ToAscii() ) );
|
|
|
|
|
|
|
|
// show user what it was validated as
|
|
|
|
device_cbox->SetValue( wxString::FromAscii( control_reference->device_qualifier.ToString().c_str() ) );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
// update references
|
|
|
|
g_plugin->controls_crit.Enter(); // enter
|
|
|
|
g_plugin->controller_interface.UpdateReference( control_reference );
|
|
|
|
g_plugin->controls_crit.Leave(); // leave
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
// update gui
|
|
|
|
control_chooser->UpdateListContents();
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
void ControlDialog::ClearControl( wxCommandEvent& event )
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
control_reference->control_qualifier.name.clear();
|
|
|
|
|
|
|
|
g_plugin->controls_crit.Leave(); // enter
|
|
|
|
control_reference->UpdateControls();
|
|
|
|
g_plugin->controls_crit.Leave(); // leave
|
|
|
|
|
|
|
|
control_chooser->UpdateListSelection();
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GamepadPage::AdjustSetting( wxCommandEvent& event )
|
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Enter(); // enter
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-07 21:33:16 -06:00
|
|
|
// updates the setting value from the GUI control
|
|
|
|
(dynamic_cast<PadSetting*>(event.GetEventObject()))->UpdateValue();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Leave(); // leave
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GamepadPage::AdjustControlOption( wxCommandEvent& event )
|
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Enter(); // enter
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
m_control_dialog->control_reference->range = ControlState( m_control_dialog->control_chooser->range_slider->GetValue() ) / SLIDER_TICK_COUNT;
|
|
|
|
|
|
|
|
if ( m_control_dialog->control_reference->is_input )
|
2010-04-14 17:50:33 -06:00
|
|
|
((ControllerInterface::InputReference*)m_control_dialog->control_reference)->mode =
|
|
|
|
m_control_dialog->control_chooser->mode_cbox->GetSelection();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Leave(); // leave
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GamepadPage::ConfigControl( wxCommandEvent& event )
|
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
m_control_dialog = new ControlDialog( this, ((ControlButton*)event.GetEventObject())->control_reference, g_plugin->controller_interface.Devices() );
|
2010-04-01 20:48:24 -06:00
|
|
|
m_control_dialog->ShowModal();
|
|
|
|
m_control_dialog->Destroy();
|
2010-04-14 17:50:33 -06:00
|
|
|
|
|
|
|
// update changes that were made in the dialog
|
|
|
|
UpdateGUI();
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
void ControlDialog::DetectControl( wxCommandEvent& event )
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
// some hacks
|
2010-04-01 20:48:24 -06:00
|
|
|
wxChar num = ((wxButton*)event.GetEventObject())->GetLabel()[0];
|
|
|
|
if ( num > '9' )
|
|
|
|
num = 1;
|
|
|
|
else
|
|
|
|
num -= 0x30;
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Enter(); // enter
|
|
|
|
if ( control_reference->Detect( DETECT_WAIT_TIME, num ) ) // if we got input, update gui
|
|
|
|
control_chooser->UpdateListSelection();
|
|
|
|
g_plugin->controls_crit.Leave(); // leave
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GamepadPage::DetectControl( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
ControlButton* btn = (ControlButton*)event.GetEventObject();
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Enter(); // enter
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
btn->control_reference->Detect( DETECT_WAIT_TIME );
|
|
|
|
btn->SetLabel( wxString::FromAscii( btn->control_reference->control_qualifier.name.c_str() ) );
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Leave(); // leave
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void ControlDialog::SelectControl( wxCommandEvent& event )
|
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
// needed for linux
|
|
|
|
if (IsBeingDeleted())
|
|
|
|
return;
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxListBox* const lb = (wxListBox*)event.GetEventObject();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
wxArrayInt sels;
|
|
|
|
lb->GetSelections( sels );
|
|
|
|
wxArrayString names = lb->GetStrings();
|
|
|
|
|
|
|
|
wxString final_label;
|
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
if (sels.GetCount() == 1)
|
2010-04-01 20:48:24 -06:00
|
|
|
final_label = names[ sels[0] ];
|
|
|
|
else
|
|
|
|
{
|
2010-04-12 23:15:38 -06:00
|
|
|
final_label = wxT('|');
|
|
|
|
for ( unsigned int i=0; i<sels.GetCount(); ++i )
|
|
|
|
final_label += names[ sels[i] ] + wxT('|');
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
control_reference->control_qualifier.name =
|
|
|
|
std::string( final_label.ToAscii() );
|
|
|
|
|
|
|
|
g_plugin->controls_crit.Enter(); // enter
|
|
|
|
control_reference->UpdateControls();
|
|
|
|
g_plugin->controls_crit.Leave(); // leave
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
control_chooser->UpdateGUI();
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
ControlChooser::ControlChooser( wxWindow* const parent, ControllerInterface::ControlReference* const ref, wxWindow* const eventsink )
|
|
|
|
: wxStaticBoxSizer( wxVERTICAL, parent, ref->is_input ? wxT("Input") : wxT("Output") )
|
|
|
|
, control_reference(ref)
|
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
textctrl = new wxTextCtrl( parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
|
|
|
_connect_macro_( textctrl, ControlDialog::SetControl, wxEVT_COMMAND_TEXT_ENTER, parent);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxButton* const detect_button = new wxButton( parent, -1, ref->is_input ? wxT("Detect 1") : wxT("Test") );
|
|
|
|
wxButton* const clear_button = new wxButton( parent, -1, wxT("Clear"), wxDefaultPosition );
|
|
|
|
wxButton* const set_button = new wxButton( parent, -1, wxT("Set")/*, wxDefaultPosition, wxSize( 32, -1 )*/ );
|
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
control_lbox = new wxListBox( parent, -1, wxDefaultPosition, wxSize( 256, 128 ), wxArrayString(), wxLB_EXTENDED );
|
2010-04-14 17:50:33 -06:00
|
|
|
_connect_macro_( control_lbox, ControlDialog::SelectControl, wxEVT_COMMAND_LISTBOX_SELECTED, parent);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const button_sizer = new wxBoxSizer( wxHORIZONTAL );
|
2010-04-01 20:48:24 -06:00
|
|
|
button_sizer->Add( detect_button, 1, 0, 5 );
|
|
|
|
if ( ref->is_input )
|
|
|
|
for ( unsigned int i = 2; i<5; ++i )
|
|
|
|
{
|
2010-04-12 14:41:38 -06:00
|
|
|
wxButton* d_btn = new wxButton( parent, -1, wxChar( '0'+i ), wxDefaultPosition, wxSize(20,-1) );
|
2010-04-14 17:50:33 -06:00
|
|
|
_connect_macro_( d_btn, ControlDialog::DetectControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
|
2010-04-01 20:48:24 -06:00
|
|
|
button_sizer->Add( d_btn );
|
|
|
|
}
|
|
|
|
button_sizer->Add( clear_button, 1, 0, 5 );
|
|
|
|
button_sizer->Add( set_button, 1, 0, 5 );
|
|
|
|
|
|
|
|
range_slider = new wxSlider( parent, -1, SLIDER_TICK_COUNT, 0, SLIDER_TICK_COUNT, wxDefaultPosition, wxDefaultSize, wxSL_TOP | wxSL_LABELS /*| wxSL_AUTOTICKS*/ );
|
|
|
|
|
|
|
|
range_slider->SetValue( control_reference->range * SLIDER_TICK_COUNT );
|
|
|
|
|
2010-04-14 17:50:33 -06: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-01 20:48:24 -06:00
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
_connect_macro_( range_slider, GamepadPage::AdjustControlOption, wxEVT_SCROLL_CHANGED, eventsink);
|
2010-04-22 01:11:49 -06:00
|
|
|
wxStaticText* const range_label = new wxStaticText( parent, -1, wxT("Range"));
|
2010-04-01 20:48:24 -06:00
|
|
|
m_bound_label = new wxStaticText( parent, -1, wxT("") );
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const range_sizer = new wxBoxSizer( wxHORIZONTAL );
|
2010-04-01 20:48:24 -06:00
|
|
|
range_sizer->Add( range_label, 0, wxCENTER|wxLEFT, 5 );
|
|
|
|
range_sizer->Add( range_slider, 1, wxEXPAND|wxLEFT, 5 );
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const txtbox_szr = new wxBoxSizer( wxHORIZONTAL );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
txtbox_szr->Add( textctrl, 1, wxEXPAND, 0 );
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
|
|
|
|
Add( range_sizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
|
2010-04-01 20:48:24 -06:00
|
|
|
if ( control_reference->is_input )
|
|
|
|
{
|
|
|
|
mode_cbox = new wxChoice( parent, -1 );
|
|
|
|
mode_cbox->Append( wxT("OR") );
|
|
|
|
mode_cbox->Append( wxT("AND") );
|
|
|
|
mode_cbox->Append( wxT("NOT") );
|
|
|
|
mode_cbox->Select( ((ControllerInterface::InputReference*)control_reference)->mode );
|
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
_connect_macro_( mode_cbox, GamepadPage::AdjustControlOption, wxEVT_COMMAND_CHOICE_SELECTED, eventsink );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const mode_szr = new wxBoxSizer( wxHORIZONTAL );
|
2010-04-01 20:48:24 -06:00
|
|
|
mode_szr->Add( new wxStaticText( parent, -1, wxT("Mode") ), 0, wxCENTER|wxLEFT|wxRIGHT, 5 );
|
|
|
|
mode_szr->Add( mode_cbox, 0, wxLEFT, 5 );
|
2010-04-22 01:11:49 -06:00
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
Add( mode_szr, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
|
2010-04-22 01:11:49 -06:00
|
|
|
}
|
2010-04-01 20:48:24 -06:00
|
|
|
Add( txtbox_szr, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5 );
|
|
|
|
Add( button_sizer, 0, wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT, 5 );
|
|
|
|
Add( control_lbox, 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
|
|
|
|
Add( m_bound_label, 0, wxEXPAND|wxLEFT, 80 );
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
UpdateListContents();
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
2010-06-02 22:55:39 -06:00
|
|
|
void GamepadPage::LoadProfile(wxCommandEvent& event)
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
// TODO: check for dumb characters maybe
|
2010-06-02 22:55:39 -06:00
|
|
|
if (profile_cbox->GetValue().empty())
|
2010-04-01 20:48:24 -06:00
|
|
|
return;
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Enter();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
std::string fname( File::GetUserPath(D_CONFIG_IDX) );
|
2010-04-14 17:50:33 -06:00
|
|
|
fname += PROFILES_PATH; fname += g_plugin->profile_name; fname += '/';
|
2010-04-12 23:15:38 -06:00
|
|
|
fname += profile_cbox->GetValue().ToAscii(); fname += ".ini";
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-06-02 22:55:39 -06:00
|
|
|
if (false == File::Exists(fname.c_str()))
|
2010-04-01 20:48:24 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
IniFile inifile;
|
2010-06-02 22:55:39 -06:00
|
|
|
inifile.Load(fname);
|
|
|
|
controller->LoadConfig(inifile["Profile"]);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-06-02 22:55:39 -06:00
|
|
|
controller->UpdateReferences(g_plugin->controller_interface);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Leave();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
UpdateGUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GamepadPage::SaveProfile( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// TODO: check for dumb characters
|
|
|
|
if ( profile_cbox->GetValue().empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// don't need lock
|
|
|
|
IniFile inifile;
|
|
|
|
controller->SaveConfig( inifile["Profile"] );
|
|
|
|
std::ofstream file;
|
|
|
|
std::string fname( File::GetUserPath(D_CONFIG_IDX) );
|
2010-04-14 17:50:33 -06:00
|
|
|
fname += PROFILES_PATH; fname += g_plugin->profile_name; fname += '/';
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
if ( false == File::Exists( fname.c_str() ) )
|
|
|
|
File::CreateFullPath( fname.c_str() );
|
|
|
|
|
|
|
|
fname += profile_cbox->GetValue().ToAscii(); fname += ".ini";
|
|
|
|
|
2010-06-02 22:55:39 -06:00
|
|
|
inifile.Save(fname);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
m_config_dialog->UpdateProfileComboBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GamepadPage::DeleteProfile( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// TODO: check for dumb characters maybe
|
|
|
|
if ( profile_cbox->GetValue().empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// don't need lock
|
|
|
|
std::string fname( File::GetUserPath(D_CONFIG_IDX) );
|
2010-04-14 17:50:33 -06:00
|
|
|
fname += PROFILES_PATH; fname += g_plugin->profile_name; fname += '/';
|
2010-04-12 23:15:38 -06:00
|
|
|
fname += profile_cbox->GetValue().ToAscii(); fname += ".ini";
|
2010-04-01 20:48:24 -06:00
|
|
|
if ( File::Exists( fname.c_str() ) )
|
|
|
|
File::Delete( fname.c_str() );
|
|
|
|
|
|
|
|
m_config_dialog->UpdateProfileComboBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigDialog::UpdateDeviceComboBox()
|
|
|
|
{
|
|
|
|
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
|
|
|
|
e = m_padpages.end();
|
|
|
|
ControllerInterface::DeviceQualifier dq;
|
|
|
|
for ( ; i != e; ++i )
|
|
|
|
{
|
|
|
|
(*i)->device_cbox->Clear();
|
2010-04-14 17:50:33 -06:00
|
|
|
std::vector<ControllerInterface::Device*>::const_iterator di = g_plugin->controller_interface.Devices().begin(),
|
|
|
|
de = g_plugin->controller_interface.Devices().end();
|
2010-04-01 20:48:24 -06:00
|
|
|
for ( ; di!=de; ++di )
|
|
|
|
{
|
|
|
|
dq.FromDevice( *di );
|
|
|
|
(*i)->device_cbox->Append( wxString::FromAscii( dq.ToString().c_str() ) );
|
|
|
|
}
|
|
|
|
(*i)->device_cbox->SetValue( wxString::FromAscii( (*i)->controller->default_device.ToString().c_str() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GamepadPage::RefreshDevices( wxCommandEvent& event )
|
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Enter(); // enter
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
// refresh devices
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controller_interface.DeInit();
|
|
|
|
g_plugin->controller_interface.Init();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
// update all control references
|
|
|
|
m_config_dialog->UpdateControlReferences();
|
|
|
|
|
|
|
|
// update device cbox
|
|
|
|
m_config_dialog->UpdateDeviceComboBox();
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin->controls_crit.Leave(); // leave
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWindow* const parent, wxWindow* const eventsink )
|
2010-04-01 20:48:24 -06:00
|
|
|
: wxStaticBoxSizer( wxVERTICAL, parent, wxString::FromAscii( group->name ) )
|
|
|
|
{
|
|
|
|
|
|
|
|
control_group = group;
|
|
|
|
static_bitmap = NULL;
|
|
|
|
|
2010-04-12 14:41:38 -06:00
|
|
|
wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
2010-04-01 20:48:24 -06:00
|
|
|
for ( unsigned int c = 0; c < group->controls.size(); ++c )
|
|
|
|
{
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxStaticText* const label = new wxStaticText( parent, -1, wxString::FromAscii( group->controls[c]->name )/*.append(wxT(" :"))*/ );
|
2010-04-12 23:15:38 -06:00
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
ControlButton* const control_button = new ControlButton( parent, group->controls[c]->control_ref, 80 );
|
2010-04-12 14:41:38 -06:00
|
|
|
control_button->SetFont(m_SmallFont);
|
|
|
|
ControlButton* adv_button = new ControlButton( parent, group->controls[c]->control_ref, 18, "+" );
|
|
|
|
adv_button->SetFont(m_SmallFont);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
controls.push_back( control_button );
|
2010-04-01 20:48:24 -06:00
|
|
|
control_buttons.push_back( control_button );
|
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
_connect_macro_( control_button, GamepadPage::DetectControl, wxEVT_COMMAND_BUTTON_CLICKED, eventsink );
|
|
|
|
_connect_macro_( adv_button, GamepadPage::ConfigControl, wxEVT_COMMAND_BUTTON_CLICKED, eventsink );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const control_sizer = new wxBoxSizer( wxHORIZONTAL );
|
2010-04-01 20:48:24 -06:00
|
|
|
control_sizer->AddStretchSpacer( 1 );
|
|
|
|
control_sizer->Add( label, 0, wxCENTER | wxRIGHT, 5 );
|
|
|
|
control_sizer->Add( control_button, 0, 0, 0 );
|
|
|
|
control_sizer->Add( adv_button, 0, 0, 5 );
|
|
|
|
|
|
|
|
Add( control_sizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ( group->type )
|
|
|
|
{
|
|
|
|
case GROUP_TYPE_STICK :
|
2010-04-12 23:15:38 -06:00
|
|
|
case GROUP_TYPE_TILT :
|
2010-04-22 01:11:49 -06:00
|
|
|
case GROUP_TYPE_CURSOR :
|
2010-04-29 12:51:04 -06:00
|
|
|
case GROUP_TYPE_FORCE :
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
wxBitmap bitmap(64, 64);
|
|
|
|
wxMemoryDC dc;
|
|
|
|
dc.SelectObject(bitmap);
|
|
|
|
dc.Clear();
|
|
|
|
dc.SelectObject(wxNullBitmap);
|
|
|
|
|
|
|
|
static_bitmap = new wxStaticBitmap( parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP );
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
std::vector< ControllerEmu::ControlGroup::Setting* >::const_iterator
|
|
|
|
i = group->settings.begin(),
|
|
|
|
e = group->settings.end();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const szr = new wxBoxSizer( wxVERTICAL );
|
|
|
|
for ( ; i!=e; ++i )
|
|
|
|
{
|
|
|
|
PadSettingChoice* cbox = new PadSettingChoice( parent, *i );
|
|
|
|
_connect_macro_( cbox, GamepadPage::AdjustSetting, wxEVT_COMMAND_CHOICE_SELECTED, eventsink );
|
|
|
|
options.push_back( cbox );
|
|
|
|
szr->Add( new wxStaticText( parent, -1, wxString::FromAscii( (*i)->name ) ) );
|
|
|
|
szr->Add( cbox, 0, wxLEFT, 0 );
|
|
|
|
}
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const h_szr = new wxBoxSizer( wxHORIZONTAL );
|
2010-04-01 20:48:24 -06:00
|
|
|
h_szr->Add( szr, 1, 0, 5 );
|
|
|
|
h_szr->Add( static_bitmap, 0, wxALL|wxCENTER, 5 );
|
|
|
|
|
|
|
|
Add( h_szr, 0, wxEXPAND|wxLEFT|wxCENTER|wxTOP, 5 );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GROUP_TYPE_BUTTONS :
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(int(12*group->controls.size()+1), 12);
|
|
|
|
wxMemoryDC dc;
|
|
|
|
dc.SelectObject(bitmap);
|
|
|
|
dc.Clear();
|
|
|
|
dc.SelectObject(wxNullBitmap);
|
|
|
|
static_bitmap = new wxStaticBitmap( parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP );
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
PadSettingChoice* const threshold_cbox = new PadSettingChoice( parent, group->settings[0] );
|
2010-04-12 23:15:38 -06:00
|
|
|
_connect_macro_( threshold_cbox, GamepadPage::AdjustSetting, wxEVT_COMMAND_CHOICE_SELECTED, eventsink );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
options.push_back( threshold_cbox );
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const szr = new wxBoxSizer( wxHORIZONTAL );
|
2010-04-01 20:48:24 -06:00
|
|
|
szr->Add( new wxStaticText( parent, -1, wxString::FromAscii( group->settings[0]->name ) ), 0, wxCENTER|wxRIGHT, 5 );
|
|
|
|
szr->Add( threshold_cbox, 0, wxRIGHT, 5 );
|
|
|
|
|
|
|
|
Add( szr, 0, wxALL|wxCENTER, 5 );
|
|
|
|
Add( static_bitmap, 0, wxALL|wxCENTER, 5 );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GROUP_TYPE_MIXED_TRIGGERS :
|
2010-04-23 18:44:10 -06:00
|
|
|
case GROUP_TYPE_TRIGGERS :
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
2010-04-23 18:44:10 -06:00
|
|
|
int height = (int)(6 * group->controls.size());
|
|
|
|
int width = 64+12+1;
|
|
|
|
if (GROUP_TYPE_TRIGGERS == group->type)
|
|
|
|
{
|
|
|
|
height *= 2;
|
|
|
|
width = 64;
|
|
|
|
}
|
|
|
|
wxBitmap bitmap(width, height+1);
|
2010-04-01 20:48:24 -06:00
|
|
|
wxMemoryDC dc;
|
|
|
|
dc.SelectObject(bitmap);
|
|
|
|
dc.Clear();
|
|
|
|
dc.SelectObject(wxNullBitmap);
|
|
|
|
static_bitmap = new wxStaticBitmap( parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP );
|
|
|
|
|
2010-04-23 18:44:10 -06:00
|
|
|
std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
|
|
|
|
i = group->settings.begin(),
|
|
|
|
e = group->settings.end();
|
|
|
|
for ( ; i!=e; ++i )
|
|
|
|
{
|
|
|
|
PadSettingChoice* cbox = new PadSettingChoice( parent, *i );
|
|
|
|
_connect_macro_( cbox, GamepadPage::AdjustSetting, wxEVT_COMMAND_CHOICE_SELECTED, eventsink );
|
|
|
|
options.push_back( cbox );
|
|
|
|
wxBoxSizer* const szr = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
szr->Add( new wxStaticText( parent, -1, wxString::FromAscii( (*i)->name ) ), 0, wxCENTER|wxRIGHT, 5 );
|
|
|
|
szr->Add( cbox, 0, wxRIGHT, 5 );
|
|
|
|
Add( szr, 0, wxALL|wxCENTER, 5 );
|
|
|
|
}
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
Add( static_bitmap, 0, wxALL|wxCENTER, 5 );
|
|
|
|
}
|
|
|
|
break;
|
2010-04-12 23:15:38 -06:00
|
|
|
case GROUP_TYPE_EXTENSION :
|
|
|
|
{
|
|
|
|
PadSettingExtension* const attachments = new PadSettingExtension( parent, (ControllerEmu::Extension*)group );
|
|
|
|
wxButton* const configure = new ExtensionButton( parent, (ControllerEmu::Extension*)group );
|
|
|
|
|
|
|
|
options.push_back( attachments );
|
|
|
|
|
|
|
|
_connect_macro_( attachments, GamepadPage::AdjustSetting, wxEVT_COMMAND_CHOICE_SELECTED, eventsink );
|
|
|
|
_connect_macro_( configure, GamepadPage::ConfigExtension, wxEVT_COMMAND_BUTTON_CLICKED, eventsink );
|
|
|
|
|
|
|
|
Add( attachments, 0, wxTOP|wxLEFT|wxRIGHT|wxEXPAND, 5 );
|
|
|
|
Add( configure, 0, wxALL|wxEXPAND, 5 );
|
|
|
|
}
|
|
|
|
break;
|
2010-04-01 20:48:24 -06:00
|
|
|
default :
|
2010-04-07 21:33:16 -06:00
|
|
|
{
|
2010-04-12 23:15:38 -06:00
|
|
|
//options
|
|
|
|
|
2010-04-07 21:33:16 -06:00
|
|
|
std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
|
|
|
|
i = group->settings.begin(),
|
|
|
|
e = group->settings.end();
|
|
|
|
for ( ; i!=e; ++i )
|
|
|
|
{
|
|
|
|
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox( parent, (*i)->value, (*i)->name );
|
2010-04-12 23:15:38 -06:00
|
|
|
_connect_macro_( setting_cbox, GamepadPage::AdjustSetting, wxEVT_COMMAND_CHECKBOX_CLICKED, eventsink );
|
2010-04-07 21:33:16 -06:00
|
|
|
options.push_back( setting_cbox );
|
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
Add( setting_cbox, 0, wxALL|wxLEFT, 5 );
|
2010-04-07 21:33:16 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2010-04-01 20:48:24 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//AddStretchSpacer( 0 );
|
|
|
|
}
|
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
ControlGroupsSizer::ControlGroupsSizer( ControllerEmu* const controller, wxWindow* const parent, wxWindow* const eventsink, std::vector<ControlGroupBox*>* groups )
|
|
|
|
: wxBoxSizer( wxHORIZONTAL )
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
|
|
|
|
wxBoxSizer* stacked_groups = NULL;
|
2010-04-12 23:15:38 -06:00
|
|
|
for ( unsigned int i = 0; i < controller->groups.size(); ++i )
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
2010-04-12 23:15:38 -06:00
|
|
|
ControlGroupBox* control_group = new ControlGroupBox( controller->groups[i], parent, eventsink );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
if ( control_group->control_buttons.size() > 1 )
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
if ( stacked_groups )
|
2010-04-12 23:15:38 -06:00
|
|
|
Add( stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5 );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
stacked_groups = new wxBoxSizer( wxVERTICAL );
|
2010-04-07 21:33:16 -06:00
|
|
|
stacked_groups->Add( control_group, 0, wxEXPAND );
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
else
|
2010-04-07 21:33:16 -06:00
|
|
|
stacked_groups->Add( control_group, 0, wxEXPAND );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
if ( groups )
|
|
|
|
groups->push_back( control_group );
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( stacked_groups )
|
2010-04-12 23:15:38 -06:00
|
|
|
Add( stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5 );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
GamepadPage::GamepadPage( wxWindow* parent, const unsigned int pad_num, ConfigDialog* const config_dialog )
|
2010-04-12 23:15:38 -06:00
|
|
|
: wxNotebookPage( parent, -1 , wxDefaultPosition, wxDefaultSize )
|
2010-04-14 17:50:33 -06:00
|
|
|
,controller(g_plugin->controllers[pad_num])
|
2010-04-12 23:15:38 -06:00
|
|
|
,m_config_dialog(config_dialog)
|
|
|
|
{
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
wxBoxSizer* control_group_sizer = new ControlGroupsSizer( g_plugin->controllers[pad_num], this, this, &control_groups );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, wxT("Profile") );
|
|
|
|
|
|
|
|
// device chooser
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxStaticBoxSizer* const device_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, wxT("Device") );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
device_cbox = new wxComboBox( this, -1, wxT(""), wxDefaultPosition, wxSize(128,-1), 0, 0, wxTE_PROCESS_ENTER );
|
|
|
|
|
2010-04-12 14:41:38 -06:00
|
|
|
wxButton* refresh_button = new wxButton( this, -1, wxT("Refresh"), wxDefaultPosition, wxSize(60,-1) );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-12 23:15:38 -06: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-01 20:48:24 -06:00
|
|
|
|
|
|
|
device_sbox->Add( device_cbox, 1, wxLEFT|wxRIGHT, 5 );
|
|
|
|
device_sbox->Add( refresh_button, 0, wxRIGHT|wxBOTTOM, 5 );
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxStaticBoxSizer* const clear_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, wxT("Clear") );
|
2010-04-01 20:48:24 -06:00
|
|
|
wxButton* all_button = new wxButton( this, -1, wxT("All"), wxDefaultPosition, wxSize(48,-1) );
|
|
|
|
clear_sbox->Add( all_button, 1, wxLEFT|wxRIGHT, 5 );
|
|
|
|
|
2010-04-14 17:50:33 -06:00
|
|
|
_connect_macro_(all_button, GamepadPage::ClearAll, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
profile_cbox = new wxComboBox( this, -1, wxT(""), wxDefaultPosition, wxSize(128,-1) );
|
|
|
|
|
|
|
|
wxButton* const pload_btn = new wxButton( this, -1, wxT("Load"), wxDefaultPosition, wxSize(48,-1) );
|
|
|
|
wxButton* const psave_btn = new wxButton( this, -1, wxT("Save"), wxDefaultPosition, wxSize(48,-1) );
|
2010-04-12 14:41:38 -06:00
|
|
|
wxButton* const pdelete_btn = new wxButton( this, -1, wxT("Delete"), wxDefaultPosition, wxSize(60,-1) );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-04-14 17:50:33 -06: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-01 20:48:24 -06:00
|
|
|
|
|
|
|
profile_sbox->Add( profile_cbox, 1, wxLEFT, 5 );
|
|
|
|
profile_sbox->Add( pload_btn, 0, wxLEFT, 5 );
|
|
|
|
profile_sbox->Add( psave_btn, 0, 0, 5 );
|
|
|
|
profile_sbox->Add( pdelete_btn, 0, wxRIGHT|wxBOTTOM, 5 );
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const dio = new wxBoxSizer( wxHORIZONTAL );
|
2010-04-01 20:48:24 -06:00
|
|
|
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-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const mapping = new wxBoxSizer( wxVERTICAL );
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
mapping->Add( dio, 1, wxEXPAND|wxLEFT|wxTOP|wxBOTTOM, 5 );
|
|
|
|
mapping->Add( control_group_sizer, 0, wxLEFT|wxEXPAND, 5 );
|
|
|
|
|
|
|
|
UpdateGUI();
|
|
|
|
|
2010-04-29 12:51:04 -06:00
|
|
|
SetSizerAndFit( mapping ); // needed
|
2010-04-01 20:48:24 -06:00
|
|
|
Layout();
|
|
|
|
};
|
|
|
|
|
|
|
|
ConfigDialog::~ConfigDialog()
|
|
|
|
{
|
|
|
|
m_update_timer->Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfigDialog::ConfigDialog( wxWindow* const parent, Plugin& plugin, const std::string& name, const bool _is_game_running )
|
|
|
|
: wxDialog( parent, wxID_ANY, wxString::FromAscii(name.c_str()), wxPoint(128,-1), wxDefaultSize )
|
|
|
|
, is_game_running(_is_game_running)
|
|
|
|
, m_plugin(plugin)
|
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
g_plugin = &plugin;
|
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
m_pad_notebook = new wxNotebook( this, -1, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT );
|
|
|
|
for ( unsigned int i = 0; i < plugin.controllers.size(); ++i )
|
|
|
|
{
|
2010-04-14 17:50:33 -06:00
|
|
|
GamepadPage* gp = new GamepadPage( m_pad_notebook, i, this );
|
2010-04-01 20:48:24 -06:00
|
|
|
m_padpages.push_back( gp );
|
2010-04-14 17:50:33 -06:00
|
|
|
m_pad_notebook->AddPage( gp, wxString::FromAscii( g_plugin->gui_name ) + wxT(' ') + wxChar('1'+i) );
|
2010-04-01 20:48:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
UpdateDeviceComboBox();
|
|
|
|
UpdateProfileComboBox();
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxButton* const close_button = new wxButton( this, -1, wxT("Save"));
|
|
|
|
_connect_macro_(close_button, ConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
2010-04-14 17:50:33 -06:00
|
|
|
_connect_macro_(close_button, ConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
wxBoxSizer* btns = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
//btns->Add( new wxStaticText( this, -1, wxString::FromAscii(ver.c_str())), 0, wxLEFT|wxTOP, 5 );
|
|
|
|
btns->AddStretchSpacer();
|
|
|
|
btns->Add( close_button, 0, 0, 0 );
|
|
|
|
|
2010-04-22 01:11:49 -06:00
|
|
|
wxBoxSizer* const szr = new wxBoxSizer( wxVERTICAL );
|
2010-04-01 20:48:24 -06:00
|
|
|
szr->Add( m_pad_notebook, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5 );
|
|
|
|
szr->Add( btns, 0, wxEXPAND|wxALL, 5 );
|
|
|
|
|
2010-04-29 12:51:04 -06:00
|
|
|
SetSizerAndFit( szr ); // needed
|
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
// not needed here it seems, but it cant hurt
|
|
|
|
//Layout();
|
|
|
|
|
|
|
|
Center();
|
|
|
|
|
|
|
|
// live preview update timer
|
|
|
|
m_update_timer = new wxTimer( this, -1 );
|
|
|
|
Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( ConfigDialog::UpdateBitmaps ), (wxObject*)0, this );
|
|
|
|
m_update_timer->Start( PREVIEW_UPDATE_TIME, wxTIMER_CONTINUOUS);
|
|
|
|
|
|
|
|
|
|
|
|
}
|