Finally got the input common strings figured out. That pretty much finishes translations.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6843 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2011-01-14 03:05:02 +00:00
parent a747cb548c
commit d0de395a46
26 changed files with 3093 additions and 954 deletions

View file

@ -46,43 +46,50 @@ const char* const named_buttons[] =
"X",
"Y",
"Z",
"Start",
_trans("Start"),
};
const char* const named_triggers[] =
{
"L", "R", "L-Analog", "R-Analog"
// i18n: Left
_trans("L"),
// i18n: Right
_trans("R"),
// i18n: Left-Analog
_trans("L-Analog"),
// i18n: Right-Analog
_trans("R-Analog")
};
GCPad::GCPad( const unsigned int index ) : m_index(index)
GCPad::GCPad(const unsigned int index) : m_index(index)
{
// buttons
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
for ( unsigned int i=0; i < sizeof(named_buttons)/sizeof(*named_buttons); ++i )
m_buttons->controls.push_back( new ControlGroup::Input( named_buttons[i] ) );
groups.push_back(m_buttons = new Buttons(_trans("Buttons")));
for (unsigned int i=0; i < sizeof(named_buttons)/sizeof(*named_buttons); ++i)
m_buttons->controls.push_back(new ControlGroup::Input(named_buttons[i]));
// sticks
groups.push_back( m_main_stick = new AnalogStick( "Main Stick" ) );
groups.push_back( m_c_stick = new AnalogStick( "C-Stick" ) );
groups.push_back(m_main_stick = new AnalogStick(_trans("Main Stick")));
groups.push_back(m_c_stick = new AnalogStick(_trans("C-Stick")));
// triggers
groups.push_back( m_triggers = new MixedTriggers( "Triggers" ) );
for ( unsigned int i=0; i < sizeof(named_triggers)/sizeof(*named_triggers); ++i )
m_triggers->controls.push_back( new ControlGroup::Input( named_triggers[i] ) );
groups.push_back(m_triggers = new MixedTriggers(_trans("Triggers")));
for (unsigned int i=0; i < sizeof(named_triggers)/sizeof(*named_triggers); ++i)
m_triggers->controls.push_back(new ControlGroup::Input(named_triggers[i]));
// rumble
groups.push_back( m_rumble = new ControlGroup( "Rumble" ) );
m_rumble->controls.push_back( new ControlGroup::Output( "Motor" ) );
groups.push_back(m_rumble = new ControlGroup(_trans("Rumble")));
m_rumble->controls.push_back(new ControlGroup::Output(_trans("Motor")));
// dpad
groups.push_back( m_dpad = new Buttons( "D-Pad" ) );
for ( unsigned int i=0; i < 4; ++i )
m_dpad->controls.push_back( new ControlGroup::Input( named_directions[i] ) );
groups.push_back(m_dpad = new Buttons(_trans("D-Pad")));
for (unsigned int i=0; i < 4; ++i)
m_dpad->controls.push_back(new ControlGroup::Input(named_directions[i]));
// options
groups.push_back( m_options = new ControlGroup( "Options" ) );
m_options->settings.push_back( new ControlGroup::Setting( "Background Input", false ) );
groups.push_back(m_options = new ControlGroup(_trans("Options")));
m_options->settings.push_back(new ControlGroup::Setting(_trans("Background Input"), false));
}
@ -91,37 +98,37 @@ std::string GCPad::GetName() const
return std::string("GCPad") + char('1'+m_index);
}
void GCPad::GetInput( SPADStatus* const pad )
void GCPad::GetInput(SPADStatus* const pad)
{
// if window has focus or background input enabled
if (Host_RendererHasFocus() || m_options[0].settings[0]->value )
if (Host_RendererHasFocus() || m_options[0].settings[0]->value)
{
// buttons
m_buttons->GetState( &pad->button, button_bitmasks );
m_buttons->GetState(&pad->button, button_bitmasks);
// TODO: set analog A/B analog to full or w/e, prolly not needed
// dpad
m_dpad->GetState( &pad->button, dpad_bitmasks );
m_dpad->GetState(&pad->button, dpad_bitmasks);
// sticks
m_main_stick->GetState( &pad->stickX, &pad->stickY, 0x80, 127 );
m_c_stick->GetState( &pad->substickX, &pad->substickY, 0x80, 127 );
m_main_stick->GetState(&pad->stickX, &pad->stickY, 0x80, 127);
m_c_stick->GetState(&pad->substickX, &pad->substickY, 0x80, 127);
// triggers
m_triggers->GetState( &pad->button, trigger_bitmasks, &pad->triggerLeft, 0xFF );
m_triggers->GetState(&pad->button, trigger_bitmasks, &pad->triggerLeft, 0xFF);
}
else
{
// center sticks
memset( &pad->stickX, 0x80, 4 );
memset(&pad->stickX, 0x80, 4);
}
}
void GCPad::SetOutput( const bool on )
void GCPad::SetOutput(const bool on)
{
// only rumble if window has focus or background input is enabled
m_rumble->controls[0]->control_ref->State( on && (Host_RendererHasFocus() || m_options[0].settings[0]->value) );
m_rumble->controls[0]->control_ref->State(on && (Host_RendererHasFocus() || m_options[0].settings[0]->value));
}
void GCPad::LoadDefaults(const ControllerInterface& ciface)

View file

@ -26,9 +26,9 @@ class GCPad : public ControllerEmu
{
public:
GCPad( const unsigned int index );
void GetInput( SPADStatus* const pad );
void SetOutput( const bool on );
GCPad(const unsigned int index);
void GetInput(SPADStatus* const pad);
void SetOutput(const bool on);
std::string GetName() const;

View file

@ -1082,7 +1082,7 @@ void CFrame::OnPluginPAD(wxCommandEvent& WXUNUSED (event))
Pad::Initialize(GetHandle());
#endif
}
InputConfigDialog *const m_ConfigFrame = new InputConfigDialog(this, *pad_plugin, "Dolphin GCPad Configuration");
InputConfigDialog *const m_ConfigFrame = new InputConfigDialog(this, *pad_plugin, _trans("Dolphin GCPad Configuration"));
m_ConfigFrame->ShowModal();
m_ConfigFrame->Destroy();
if (!was_init) // if game isn't running

View file

@ -18,8 +18,9 @@
#include "InputConfigDiag.h"
#include "UDPConfigDiag.h"
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler(f), (wxObject*)0, (wxEvtHandler*)s)
#define WXSTR_FROM_STR(s) (wxString::From8BitData((s).c_str()))
#define WXTSTR_FROM_CSTR(s) (wxGetTranslation(wxString::From8BitData(s)))
// ToAscii was causing probs with some extended ascii characters, To8BitData seems to work
#define STR_FROM_WXSTR(w) (std::string((w).To8BitData()))
@ -32,23 +33,23 @@ void GamepadPage::ConfigUDPWii(wxCommandEvent &event)
diag->Destroy();
}
void GamepadPage::ConfigExtension( wxCommandEvent& event )
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 )
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 );
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);
const std::size_t orig_size = control_groups.size();
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
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
dlg->Center();
@ -56,12 +57,12 @@ void GamepadPage::ConfigExtension( wxCommandEvent& event )
dlg->Destroy();
// remove the new groups that were just added, now that the window closed
control_groups.resize( orig_size );
control_groups.resize(orig_size);
}
}
PadSettingExtension::PadSettingExtension( wxWindow* const parent, ControllerEmu::Extension* const ext )
: PadSetting(new wxChoice( parent, -1 ))
PadSettingExtension::PadSettingExtension(wxWindow* const parent, ControllerEmu::Extension* const ext)
: PadSetting(new wxChoice(parent, -1))
, extension(ext)
{
@ -69,7 +70,7 @@ PadSettingExtension::PadSettingExtension( wxWindow* const parent, ControllerEmu:
i = extension->attachments.begin(),
e = extension->attachments.end();
for ( ; i!=e; ++i )
for (; i!=e; ++i)
((wxChoice*)wxcontrol)->Append(WXSTR_FROM_STR((*i)->GetName()));
UpdateGUI();
@ -85,8 +86,8 @@ void PadSettingExtension::UpdateValue()
extension->switch_extension = ((wxChoice*)wxcontrol)->GetSelection();
}
PadSettingCheckBox::PadSettingCheckBox( wxWindow* const parent, ControlState& _value, const char* const label )
: PadSetting(new wxCheckBox( parent, -1, wxString::FromAscii( label ), wxDefaultPosition ))
PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const char* const label)
: PadSetting(new wxCheckBox(parent, -1, WXTSTR_FROM_CSTR(label), wxDefaultPosition))
, value(_value)
{
UpdateGUI();
@ -94,7 +95,7 @@ PadSettingCheckBox::PadSettingCheckBox( wxWindow* const parent, ControlState& _v
void PadSettingCheckBox::UpdateGUI()
{
((wxCheckBox*)wxcontrol)->SetValue( value > 0 );
((wxCheckBox*)wxcontrol)->SetValue(value > 0);
}
void PadSettingCheckBox::UpdateValue()
@ -125,28 +126,28 @@ ControlDialog::ControlDialog(GamepadPage* const parent, InputPlugin& plugin, Con
//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);
_connect_macro_( device_cbox, ControlDialog::SetDevice, wxEVT_COMMAND_COMBOBOX_SELECTED, this );
_connect_macro_( device_cbox, ControlDialog::SetDevice, wxEVT_COMMAND_TEXT_ENTER, this );
_connect_macro_(device_cbox, ControlDialog::SetDevice, wxEVT_COMMAND_COMBOBOX_SELECTED, this);
_connect_macro_(device_cbox, ControlDialog::SetDevice, wxEVT_COMMAND_TEXT_ENTER, this);
wxStaticBoxSizer* const control_chooser = CreateControlChooser( this, parent );
wxStaticBoxSizer* const control_chooser = CreateControlChooser(this, parent);
wxStaticBoxSizer* const d_szr = new wxStaticBoxSizer( wxVERTICAL, this, _("Device") );
d_szr->Add( device_cbox, 0, wxEXPAND|wxALL, 5 );
wxStaticBoxSizer* const d_szr = new wxStaticBoxSizer(wxVERTICAL, this, _("Device"));
d_szr->Add(device_cbox, 0, wxEXPAND|wxALL, 5);
wxBoxSizer* const szr = new wxBoxSizer( wxVERTICAL );
szr->Add( d_szr, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
szr->Add( control_chooser, 1, wxEXPAND|wxALL, 5 );
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
szr->Add(d_szr, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5);
szr->Add(control_chooser, 1, wxEXPAND|wxALL, 5);
SetSizerAndFit( szr ); // needed
SetSizerAndFit(szr); // needed
UpdateGUI();
}
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 )
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() )
if (label.empty())
SetLabel(WXSTR_FROM_STR(_ref->expression));
else
SetLabel(WXSTR_FROM_STR(label));
@ -154,29 +155,29 @@ ControlButton::ControlButton( wxWindow* const parent, ControllerInterface::Contr
void InputConfigDialog::UpdateProfileComboBox()
{
std::string pname( File::GetUserPath(D_CONFIG_IDX) );
std::string pname(File::GetUserPath(D_CONFIG_IDX));
pname += PROFILES_PATH;
pname += m_plugin.profile_name;
CFileSearch::XStringVector exts;
exts.push_back("*.ini");
CFileSearch::XStringVector dirs;
dirs.push_back( pname );
CFileSearch cfs( exts, 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 )
for (; si!=se; ++si)
{
std::string str( si->begin() + si->find_last_of('/') + 1 , si->end() - 4 ) ;
std::string str(si->begin() + si->find_last_of('/') + 1 , si->end() - 4) ;
strs.push_back(WXSTR_FROM_STR(str));
}
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
e = m_padpages.end();
for ( ; i != e; ++i )
for (; i != e; ++i)
{
(*i)->profile_cbox->Clear();
(*i)->profile_cbox->Append(strs);
@ -187,7 +188,7 @@ void InputConfigDialog::UpdateControlReferences()
{
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
e = m_padpages.end();
for ( ; i != e; ++i )
for (; i != e; ++i)
(*i)->controller->UpdateReferences(g_controller_interface);
}
@ -240,11 +241,7 @@ void ControlDialog::UpdateGUI()
textctrl->SetValue(WXSTR_FROM_STR(control_reference->expression));
// updates the "bound controls:" label
size_t bound = control_reference->BoundCount();
std::ostringstream ss;
ss << "Bound Controls: ";
if ( bound ) ss << bound; else ss << "None";
m_bound_label->SetLabel(WXSTR_FROM_STR(ss.str()));
m_bound_label->SetLabel(wxString::Format(_("Bound Controls: %u"), control_reference->BoundCount()));
};
void GamepadPage::UpdateGUI()
@ -253,12 +250,12 @@ void GamepadPage::UpdateGUI()
std::vector< ControlGroupBox* >::const_iterator g = control_groups.begin(),
ge = control_groups.end();
for ( ; g!=ge; ++g )
for (; g!=ge; ++g)
{
// buttons
std::vector<ControlButton*>::const_iterator i = (*g)->control_buttons.begin()
, e = (*g)->control_buttons.end();
for ( ; i!=e; ++i )
for (; i!=e; ++i)
//if (std::string::npos == (*i)->control_reference->expression.find_first_of("`|&!#"))
(*i)->SetLabel(WXSTR_FROM_STR((*i)->control_reference->expression));
//else
@ -267,7 +264,7 @@ void GamepadPage::UpdateGUI()
// cboxes
std::vector<PadSetting*>::const_iterator si = (*g)->options.begin()
, se = (*g)->options.end();
for ( ; si!=se; ++si )
for (; si!=se; ++si)
(*si)->UpdateGUI();
}
}
@ -322,7 +319,7 @@ void GamepadPage::SetDevice(wxCommandEvent&)
// update references
m_plugin.controls_crit.Enter(); // enter
controller->UpdateReferences( g_controller_interface );
controller->UpdateReferences(g_controller_interface);
m_plugin.controls_crit.Leave(); // leave
}
@ -405,7 +402,7 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
UpdateGUI();
}
void GamepadPage::AdjustSetting( wxCommandEvent& event )
void GamepadPage::AdjustSetting(wxCommandEvent& event)
{
m_plugin.controls_crit.Enter(); // enter / prolly fine not being here
((PadSetting*)((wxControl*)event.GetEventObject())->GetClientData())->UpdateValue();
@ -419,7 +416,7 @@ void GamepadPage::AdjustControlOption(wxCommandEvent&)
m_plugin.controls_crit.Leave(); // leave
}
void GamepadPage::ConfigControl( wxCommandEvent& event )
void GamepadPage::ConfigControl(wxCommandEvent& event)
{
m_control_dialog = new ControlDialog(this, m_plugin, ((ControlButton*)event.GetEventObject())->control_reference);
m_control_dialog->ShowModal();
@ -429,14 +426,14 @@ void GamepadPage::ConfigControl( wxCommandEvent& event )
UpdateGUI();
}
void GamepadPage::ClearControl( wxCommandEvent& event )
void GamepadPage::ClearControl(wxCommandEvent& event)
{
ControlButton* const btn = (ControlButton*)event.GetEventObject();
btn->control_reference->expression.clear();
btn->control_reference->range = 1.0f;
m_plugin.controls_crit.Enter(); // enter
controller->UpdateReferences( g_controller_interface );
controller->UpdateReferences(g_controller_interface);
m_plugin.controls_crit.Leave(); // leave
// update changes
@ -468,7 +465,7 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
}
}
void GamepadPage::DetectControl( wxCommandEvent& event )
void GamepadPage::DetectControl(wxCommandEvent& event)
{
ControlButton* btn = (ControlButton*)event.GetEventObject();
@ -497,21 +494,21 @@ void GamepadPage::DetectControl( wxCommandEvent& event )
}
}
wxStaticBoxSizer* ControlDialog::CreateControlChooser( wxWindow* const parent, wxWindow* const eventsink )
wxStaticBoxSizer* ControlDialog::CreateControlChooser(wxWindow* const parent, wxWindow* const eventsink)
{
wxStaticBoxSizer* const main_szr = new wxStaticBoxSizer(wxVERTICAL, parent, control_reference->is_input ? _("Input") : _("Output"));
textctrl = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxSize(-1, 48), wxTE_MULTILINE);
wxButton* const detect_button = new wxButton( parent, -1, control_reference->is_input ? _("Detect") : _("Test") );
wxButton* const detect_button = new wxButton(parent, -1, control_reference->is_input ? _("Detect") : _("Test"));
wxButton* const clear_button = new wxButton( parent, -1, _("Clear"));
wxButton* const set_button = new wxButton( parent, -1, _("Set"));
wxButton* const clear_button = new wxButton(parent, -1, _("Clear"));
wxButton* const set_button = new wxButton(parent, -1, _("Set"));
wxButton* const select_button = new wxButton( parent, -1, _("Select"));
wxButton* const select_button = new wxButton(parent, -1, _("Select"));
_connect_macro_(select_button, ControlDialog::SetSelectedControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
wxButton* const or_button = new wxButton( parent, -1, _("| OR"), wxDefaultPosition );
wxButton* const or_button = new wxButton(parent, -1, _("| OR"), wxDefaultPosition);
_connect_macro_(or_button, ControlDialog::AppendControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
control_lbox = new wxListBox(parent, -1, wxDefaultPosition, wxSize(-1, 64));
@ -524,9 +521,9 @@ wxStaticBoxSizer* ControlDialog::CreateControlChooser( wxWindow* const parent, w
if (control_reference->is_input)
{
// TODO: check if && is good on other OS
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 );
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);
_connect_macro_(and_button, ControlDialog::AppendControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
_connect_macro_(not_button, ControlDialog::AppendControl, wxEVT_COMMAND_BUTTON_CLICKED, parent);
@ -537,21 +534,21 @@ wxStaticBoxSizer* ControlDialog::CreateControlChooser( wxWindow* const parent, w
button_sizer->Add(add_button, 1, 0, 5);
}
range_slider = new wxSlider( parent, -1, SLIDER_TICK_COUNT, 0, SLIDER_TICK_COUNT * 5, wxDefaultPosition, wxDefaultSize, wxSL_TOP | wxSL_LABELS /*| wxSL_AUTOTICKS*/ );
range_slider = new wxSlider(parent, -1, SLIDER_TICK_COUNT, 0, SLIDER_TICK_COUNT * 5, wxDefaultPosition, wxDefaultSize, wxSL_TOP | wxSL_LABELS /*| wxSL_AUTOTICKS*/);
range_slider->SetValue( control_reference->range * SLIDER_TICK_COUNT );
range_slider->SetValue(control_reference->range * SLIDER_TICK_COUNT);
_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);
_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);
_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("") );
_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(""));
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 );
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);
wxBoxSizer* const ctrls_sizer = new wxBoxSizer(wxHORIZONTAL);
ctrls_sizer->Add(control_lbox, 1, wxEXPAND, 0);
@ -648,15 +645,15 @@ void InputConfigDialog::UpdateDeviceComboBox()
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
e = m_padpages.end();
ControllerInterface::DeviceQualifier dq;
for ( ; i != e; ++i )
for (; i != e; ++i)
{
(*i)->device_cbox->Clear();
std::vector<ControllerInterface::Device*>::const_iterator
di = g_controller_interface.Devices().begin(),
de = g_controller_interface.Devices().end();
for ( ; di!=de; ++di )
for (; di!=de; ++di)
{
dq.FromDevice( *di );
dq.FromDevice(*di);
(*i)->device_cbox->Append(WXSTR_FROM_STR(dq.ToString()));
}
(*i)->device_cbox->SetValue(WXSTR_FROM_STR((*i)->controller->default_device.ToString()));
@ -689,7 +686,7 @@ ControlGroupBox::~ControlGroupBox()
delete *i;
}
ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWindow* const parent, wxWindow* const eventsink )
ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, wxWindow* const eventsink)
: wxStaticBoxSizer(wxVERTICAL, parent, wxString::FromAscii(group->name))
, control_group(group)
{
@ -700,10 +697,10 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
std::vector<ControllerEmu::ControlGroup::Control*>::iterator
ci = group->controls.begin(),
ce = group->controls.end();
for ( ; ci != ce; ++ci)
for (; ci != ce; ++ci)
{
wxStaticText* const label = new wxStaticText(parent, -1, wxString::FromAscii((*ci)->name)/*.append(wxT(" :"))*/ );
wxStaticText* const label = new wxStaticText(parent, -1, WXTSTR_FROM_CSTR((*ci)->name));
ControlButton* const control_button = new ControlButton(parent, (*ci)->control_ref, 80);
control_button->SetFont(m_SmallFont);
@ -713,29 +710,29 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
if ((*ci)->control_ref->is_input)
{
control_button->SetToolTip(_("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
_connect_macro_( control_button, GamepadPage::DetectControl, wxEVT_COMMAND_BUTTON_CLICKED, eventsink );
_connect_macro_(control_button, GamepadPage::DetectControl, wxEVT_COMMAND_BUTTON_CLICKED, eventsink);
}
else
{
control_button->SetToolTip(_("Left/Right-click for more options.\nMiddle-click to clear."));
_connect_macro_( control_button, GamepadPage::ConfigControl, wxEVT_COMMAND_BUTTON_CLICKED, eventsink );
_connect_macro_(control_button, GamepadPage::ConfigControl, wxEVT_COMMAND_BUTTON_CLICKED, eventsink);
}
_connect_macro_( control_button, GamepadPage::ClearControl, wxEVT_MIDDLE_DOWN, eventsink );
_connect_macro_( control_button, GamepadPage::ConfigControl, wxEVT_RIGHT_UP, eventsink );
_connect_macro_(control_button, GamepadPage::ClearControl, wxEVT_MIDDLE_DOWN, eventsink);
_connect_macro_(control_button, GamepadPage::ConfigControl, wxEVT_RIGHT_UP, eventsink);
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 );
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);
Add( control_sizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 3 );
Add(control_sizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 3);
}
wxMemoryDC dc;
switch ( group->type )
switch (group->type)
{
case GROUP_TYPE_STICK:
case GROUP_TYPE_TILT:
@ -751,21 +748,21 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
i = group->settings.begin(),
e = group->settings.end();
wxBoxSizer* const szr = new wxBoxSizer( wxVERTICAL );
for ( ; i!=e; ++i )
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
for (; i!=e; ++i)
{
PadSettingSpin* setting = new PadSettingSpin(parent, *i);
_connect_macro_(setting->wxcontrol, GamepadPage::AdjustSetting, wxEVT_COMMAND_SPINCTRL_UPDATED, eventsink);
options.push_back(setting);
szr->Add(new wxStaticText(parent, -1, wxString::FromAscii((*i)->name)));
szr->Add(setting->wxcontrol, 0, wxLEFT, 0 );
szr->Add(new wxStaticText(parent, -1, WXTSTR_FROM_CSTR((*i)->name)));
szr->Add(setting->wxcontrol, 0, wxLEFT, 0);
}
wxBoxSizer* const h_szr = new wxBoxSizer( wxHORIZONTAL );
h_szr->Add( szr, 1, 0, 5 );
h_szr->Add( static_bitmap, 0, wxALL|wxCENTER, 3 );
wxBoxSizer* const h_szr = new wxBoxSizer(wxHORIZONTAL);
h_szr->Add(szr, 1, 0, 5);
h_szr->Add(static_bitmap, 0, wxALL|wxCENTER, 3);
Add( h_szr, 0, wxEXPAND|wxLEFT|wxCENTER|wxTOP, 3 );
Add(h_szr, 0, wxEXPAND|wxLEFT|wxCENTER|wxTOP, 3);
}
break;
case GROUP_TYPE_BUTTONS:
@ -782,8 +779,9 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
options.push_back(threshold_cbox);
wxBoxSizer* const szr = new wxBoxSizer( wxHORIZONTAL );
szr->Add(new wxStaticText(parent, -1, wxString::FromAscii(group->settings[0]->name)), 0, wxCENTER|wxRIGHT, 3);
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
szr->Add(new wxStaticText(parent, -1, WXTSTR_FROM_CSTR(group->settings[0]->name)),
0, wxCENTER|wxRIGHT, 3);
szr->Add(threshold_cbox->wxcontrol, 0, wxRIGHT, 3);
Add(szr, 0, wxALL|wxCENTER, 3);
@ -811,24 +809,24 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
i = group->settings.begin(),
e = group->settings.end();
for ( ; i!=e; ++i )
for (; i!=e; ++i)
{
PadSettingSpin* setting = new PadSettingSpin(parent, *i);
_connect_macro_(setting->wxcontrol, GamepadPage::AdjustSetting, wxEVT_COMMAND_SPINCTRL_UPDATED, eventsink);
options.push_back(setting);
wxBoxSizer* const szr = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
szr->Add(new wxStaticText(parent, -1, wxString::FromAscii((*i)->name)), 0, wxCENTER|wxRIGHT, 3);
szr->Add(setting->wxcontrol, 0, wxRIGHT, 3);
Add(szr, 0, wxALL|wxCENTER, 3);
}
Add( static_bitmap, 0, wxALL|wxCENTER, 3 );
Add(static_bitmap, 0, wxALL|wxCENTER, 3);
}
break;
case GROUP_TYPE_EXTENSION:
{
PadSettingExtension* const attachments = new PadSettingExtension( parent, (ControllerEmu::Extension*)group );
wxButton* const configure_btn = new ExtensionButton( parent, (ControllerEmu::Extension*)group );
PadSettingExtension* const attachments = new PadSettingExtension(parent, (ControllerEmu::Extension*)group);
wxButton* const configure_btn = new ExtensionButton(parent, (ControllerEmu::Extension*)group);
options.push_back(attachments);
@ -836,12 +834,12 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
_connect_macro_(configure_btn, GamepadPage::ConfigExtension, wxEVT_COMMAND_BUTTON_CLICKED, eventsink);
Add(attachments->wxcontrol, 0, wxTOP|wxLEFT|wxRIGHT|wxEXPAND, 3);
Add(configure_btn, 0, wxALL|wxEXPAND, 3 );
Add(configure_btn, 0, wxALL|wxEXPAND, 3);
}
break;
case GROUP_TYPE_UDPWII:
{
wxButton* const btn = new UDPConfigButton( parent, (UDPWrapper*)group );
wxButton* const btn = new UDPConfigButton(parent, (UDPWrapper*)group);
_connect_macro_(btn, GamepadPage::ConfigUDPWii, wxEVT_COMMAND_BUTTON_CLICKED, eventsink);
Add(btn, 0, wxALL|wxEXPAND, 3);
}
@ -853,7 +851,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
i = group->settings.begin(),
e = group->settings.end();
for ( ; i!=e; ++i )
for (; i!=e; ++i)
{
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, (*i)->value, (*i)->name);
_connect_macro_(setting_cbox->wxcontrol, GamepadPage::AdjustSetting, wxEVT_COMMAND_CHECKBOX_CLICKED, eventsink);
@ -868,56 +866,56 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
dc.SelectObject(wxNullBitmap);
//AddStretchSpacer( 0 );
//AddStretchSpacer(0);
}
ControlGroupsSizer::ControlGroupsSizer( ControllerEmu* const controller, wxWindow* const parent, wxWindow* const eventsink, std::vector<ControlGroupBox*>* groups )
: wxBoxSizer( wxHORIZONTAL )
ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow* const parent, wxWindow* const eventsink, std::vector<ControlGroupBox*>* groups)
: wxBoxSizer(wxHORIZONTAL)
{
size_t col_size = 0;
wxBoxSizer* stacked_groups = NULL;
for ( unsigned int i = 0; i < controller->groups.size(); ++i )
for (unsigned int i = 0; i < controller->groups.size(); ++i)
{
ControlGroupBox* control_group = new ControlGroupBox( controller->groups[i], parent, eventsink );
ControlGroupBox* control_group = new ControlGroupBox(controller->groups[i], parent, eventsink);
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)
{
if ( stacked_groups )
Add( stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5 );
if (stacked_groups)
Add(stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5);
stacked_groups = new wxBoxSizer( wxVERTICAL );
stacked_groups->Add( control_group, 0, wxEXPAND );
stacked_groups = new wxBoxSizer(wxVERTICAL);
stacked_groups->Add(control_group, 0, wxEXPAND);
col_size = grp_size;
}
else
stacked_groups->Add( control_group, 0, wxEXPAND );
stacked_groups->Add(control_group, 0, wxEXPAND);
if ( groups )
groups->push_back( control_group );
if (groups)
groups->push_back(control_group);
}
if ( stacked_groups )
Add( stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5 );
if (stacked_groups)
Add(stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5);
}
GamepadPage::GamepadPage( wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog )
: wxNotebookPage( parent, -1 , wxDefaultPosition, wxDefaultSize )
GamepadPage::GamepadPage(wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog)
: wxNotebookPage(parent, -1 , wxDefaultPosition, wxDefaultSize)
,controller(plugin.controllers[pad_num])
, m_config_dialog(config_dialog)
, m_plugin(plugin)
{
wxBoxSizer* control_group_sizer = new ControlGroupsSizer( m_plugin.controllers[pad_num], this, this, &control_groups );
wxBoxSizer* control_group_sizer = new ControlGroupsSizer(m_plugin.controllers[pad_num], this, this, &control_groups);
wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, _("Profile") );
wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Profile"));
// device chooser
wxStaticBoxSizer* const device_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, _("Device") );
wxStaticBoxSizer* const device_sbox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Device"));
device_cbox = new wxComboBox(this, -1, wxT(""), wxDefaultPosition, wxSize(64,-1));
#ifndef __APPLE__
@ -925,67 +923,67 @@ GamepadPage::GamepadPage( wxWindow* parent, InputPlugin& plugin, const unsigned
device_cbox->ToggleWindowStyle(wxTE_PROCESS_ENTER);
#endif
wxButton* refresh_button = new wxButton( this, -1, _("Refresh"), wxDefaultPosition, wxSize(60,-1) );
wxButton* refresh_button = new wxButton(this, -1, _("Refresh"), wxDefaultPosition, wxSize(60,-1));
_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 );
_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);
device_sbox->Add( device_cbox, 1, wxLEFT|wxRIGHT, 3 );
device_sbox->Add( refresh_button, 0, wxRIGHT|wxBOTTOM, 3 );
device_sbox->Add(device_cbox, 1, wxLEFT|wxRIGHT, 3);
device_sbox->Add(refresh_button, 0, wxRIGHT|wxBOTTOM, 3);
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));
wxStaticBoxSizer* const clear_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, _("Reset") );
wxStaticBoxSizer* const clear_sbox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Reset"));
clear_sbox->Add(default_button, 1, wxLEFT, 3);
clear_sbox->Add(clearall_button, 1, wxRIGHT, 3);
_connect_macro_(clearall_button, GamepadPage::ClearAll, wxEVT_COMMAND_BUTTON_CLICKED, this);
_connect_macro_(default_button, GamepadPage::LoadDefaults, wxEVT_COMMAND_BUTTON_CLICKED, this);
profile_cbox = new wxComboBox( this, -1, wxT(""), wxDefaultPosition, wxSize(64,-1) );
profile_cbox = new wxComboBox(this, -1, wxT(""), wxDefaultPosition, wxSize(64,-1));
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) );
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));
_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);
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 );
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);
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 );
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);
wxBoxSizer* const mapping = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* const mapping = new wxBoxSizer(wxVERTICAL);
mapping->Add( dio, 1, wxEXPAND|wxLEFT|wxTOP|wxBOTTOM, 5 );
mapping->Add( control_group_sizer, 0, wxLEFT|wxEXPAND, 5 );
mapping->Add(dio, 1, wxEXPAND|wxLEFT|wxTOP|wxBOTTOM, 5);
mapping->Add(control_group_sizer, 0, wxLEFT|wxEXPAND, 5);
UpdateGUI();
SetSizerAndFit( mapping ); // needed
SetSizerAndFit(mapping); // needed
Layout();
};
InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputPlugin& plugin, const std::string& name, const int tab_num)
: wxDialog( parent, wxID_ANY, wxString::FromAscii(name.c_str()), wxPoint(128,-1), wxDefaultSize )
: wxDialog(parent, wxID_ANY, WXTSTR_FROM_CSTR(name.c_str()), wxPoint(128,-1), wxDefaultSize)
, m_plugin(plugin)
{
m_pad_notebook = new wxNotebook( this, -1, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT );
for ( unsigned int i = 0; i < plugin.controllers.size(); ++i )
m_pad_notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT);
for (unsigned int i = 0; i < plugin.controllers.size(); ++i)
{
GamepadPage* gp = new GamepadPage( m_pad_notebook, m_plugin, i, this );
m_padpages.push_back( gp );
m_pad_notebook->AddPage( gp, wxString::FromAscii(m_plugin.gui_name) + wxT(' ') + wxChar('1'+i) );
GamepadPage* gp = new GamepadPage(m_pad_notebook, m_plugin, i, this);
m_padpages.push_back(gp);
m_pad_notebook->AddPage(gp, wxString::FromAscii(m_plugin.gui_name) + wxT(' ') + wxChar('1'+i));
}
m_pad_notebook->SetSelection(tab_num);
@ -993,20 +991,20 @@ InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputPlugin& plugin
UpdateDeviceComboBox();
UpdateProfileComboBox();
wxButton* const close_button = new wxButton( this, -1, _("Save"));
wxButton* const close_button = new wxButton(this, -1, _("Save"));
_connect_macro_(close_button, InputConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this);
_connect_macro_(close_button, InputConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxBoxSizer* btns = new wxBoxSizer( wxHORIZONTAL );
//btns->Add( new wxStaticText( this, -1, wxString::FromAscii(ver.c_str())), 0, wxLEFT|wxTOP, 5 );
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 );
btns->Add(close_button, 0, 0, 0);
wxBoxSizer* const szr = new wxBoxSizer( wxVERTICAL );
szr->Add( m_pad_notebook, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5 );
szr->Add( btns, 0, wxEXPAND|wxALL, 5 );
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
szr->Add(m_pad_notebook, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5);
szr->Add(btns, 0, wxEXPAND|wxALL, 5);
SetSizerAndFit( szr ); // needed
SetSizerAndFit(szr); // needed
// not needed here it seems, but it cant hurt
//Layout();
@ -1014,9 +1012,9 @@ InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputPlugin& plugin
Center();
// live preview update timer
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);
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);
}

View file

@ -74,7 +74,7 @@ class PadSettingSpin : public PadSetting
public:
PadSettingSpin(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const setting)
: PadSetting(new wxSpinCtrl(parent, -1, wxEmptyString, wxDefaultPosition
, wxSize( 54, -1 ), 0, setting->low, setting->high, setting->value * 100))
, wxSize(54, -1), 0, setting->low, setting->high, setting->value * 100))
, value(setting->value) {}
void UpdateGUI();
@ -100,7 +100,7 @@ class ControlDialog : public wxDialog
public:
ControlDialog(GamepadPage* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref);
wxStaticBoxSizer* CreateControlChooser(wxWindow* const parent, wxWindow* const eventsink );
wxStaticBoxSizer* CreateControlChooser(wxWindow* const parent, wxWindow* const eventsink);
void DetectControl(wxCommandEvent& event);
void ClearControl(wxCommandEvent& event);
@ -131,8 +131,8 @@ private:
class ExtensionButton : public wxButton
{
public:
ExtensionButton( wxWindow* const parent, ControllerEmu::Extension* const ext )
: wxButton( parent, -1, _("Configure"), wxDefaultPosition )
ExtensionButton(wxWindow* const parent, ControllerEmu::Extension* const ext)
: wxButton(parent, -1, _("Configure"), wxDefaultPosition)
, extension(ext) {}
ControllerEmu::Extension* const extension;
@ -141,7 +141,7 @@ public:
class ControlButton : public wxButton
{
public:
ControlButton( wxWindow* const parent, ControllerInterface::ControlReference* const _ref, const unsigned int width, const std::string& label = "" );
ControlButton(wxWindow* const parent, ControllerInterface::ControlReference* const _ref, const unsigned int width, const std::string& label = "");
ControllerInterface::ControlReference* const control_reference;
};
@ -150,8 +150,8 @@ class UDPConfigButton : public wxButton
{
public:
UDPWrapper* const wrapper;
UDPConfigButton( wxWindow* const parent, UDPWrapper * udp)
: wxButton( parent, -1, _("Configure"), wxDefaultPosition )
UDPConfigButton(wxWindow* const parent, UDPWrapper * udp)
: wxButton(parent, -1, _("Configure"), wxDefaultPosition)
, wrapper(udp)
{}
};
@ -159,7 +159,7 @@ public:
class ControlGroupBox : public wxStaticBoxSizer
{
public:
ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWindow* const parent, wxWindow* const eventsink );
ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, wxWindow* const eventsink);
~ControlGroupBox();
std::vector<PadSetting*> options;
@ -172,7 +172,7 @@ public:
class ControlGroupsSizer : public wxBoxSizer
{
public:
ControlGroupsSizer( ControllerEmu* const controller, wxWindow* const parent, wxWindow* const eventsink, std::vector<ControlGroupBox*>* const groups = NULL );
ControlGroupsSizer(ControllerEmu* const controller, wxWindow* const parent, wxWindow* const eventsink, std::vector<ControlGroupBox*>* const groups = NULL);
};
class InputConfigDialog;
@ -183,31 +183,31 @@ class GamepadPage : public wxNotebookPage
friend class ControlDialog;
public:
GamepadPage( wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog );
GamepadPage(wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog);
void UpdateGUI();
void RefreshDevices( wxCommandEvent& event );
void RefreshDevices(wxCommandEvent& event);
void LoadProfile( wxCommandEvent& event );
void SaveProfile( wxCommandEvent& event );
void DeleteProfile( wxCommandEvent& event );
void LoadProfile(wxCommandEvent& event);
void SaveProfile(wxCommandEvent& event);
void DeleteProfile(wxCommandEvent& event);
void ConfigControl( wxCommandEvent& event );
void ClearControl( wxCommandEvent& event );
void DetectControl( wxCommandEvent& event );
void ConfigControl(wxCommandEvent& event);
void ClearControl(wxCommandEvent& event);
void DetectControl(wxCommandEvent& event);
void ConfigExtension( wxCommandEvent& event );
void ConfigExtension(wxCommandEvent& event);
void ConfigUDPWii( wxCommandEvent& event );
void ConfigUDPWii(wxCommandEvent& event);
void SetDevice( wxCommandEvent& event );
void SetDevice(wxCommandEvent& event);
void ClearAll( wxCommandEvent& event );
void LoadDefaults( wxCommandEvent& event );
void ClearAll(wxCommandEvent& event);
void LoadDefaults(wxCommandEvent& event);
void AdjustControlOption( wxCommandEvent& event );
void AdjustSetting( wxCommandEvent& event );
void AdjustControlOption(wxCommandEvent& event);
void AdjustSetting(wxCommandEvent& event);
void GetProfilePath(std::string& path);
@ -230,12 +230,12 @@ private:
class InputConfigDialog : public wxDialog
{
public:
InputConfigDialog( wxWindow* const parent, InputPlugin& plugin, const std::string& name, const int tab_num = 0);
InputConfigDialog(wxWindow* const parent, InputPlugin& plugin, const std::string& name, const int tab_num = 0);
//~InputConfigDialog();
bool Destroy();
void ClickSave( wxCommandEvent& event );
void ClickSave(wxCommandEvent& event);
void UpdateDeviceComboBox();
void UpdateProfileComboBox();

View file

@ -3,7 +3,7 @@
#include "HW/Wiimote.h"
#include "Frame.h"
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler(f), (wxObject*)0, (wxEvtHandler*)s)
const wxString& ConnectedWiimotesString()
{
@ -73,7 +73,7 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin
{
WiimoteConfigPage* const wpage = new WiimoteConfigPage(m_pad_notebook, i);
//m_padpages.push_back(wpage);
m_pad_notebook->AddPage(wpage, wxString(wxT("Wiimote ")) + wxChar('1'+i));
m_pad_notebook->AddPage(wpage, wxString(_("Wiimote ")) + wxChar('1'+i));
}
wxButton* const ok_button = new wxButton(this, -1, _("OK"), wxDefaultPosition);
@ -90,7 +90,7 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin
void WiimoteConfigDiag::ConfigEmulatedWiimote(wxCommandEvent&)
{
InputConfigDialog* const m_emu_config_diag = new InputConfigDialog(this, m_plugin, "Dolphin Emulated Wiimote Configuration", m_pad_notebook->GetSelection());
InputConfigDialog* const m_emu_config_diag = new InputConfigDialog(this, m_plugin, _trans("Dolphin Emulated Wiimote Configuration"), m_pad_notebook->GetSelection());
m_emu_config_diag->ShowModal();
m_emu_config_diag->Destroy();
}
@ -137,7 +137,7 @@ void WiimoteConfigPage::SelectSource(wxCommandEvent& event)
void WiimoteConfigDiag::Save(wxCommandEvent&)
{
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + WIIMOTE_INI_NAME ".ini" );
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + WIIMOTE_INI_NAME ".ini");
IniFile inifile;
inifile.Load(ini_filename);

View file

@ -27,7 +27,7 @@ ControllerEmu::~ControllerEmu()
std::vector<ControlGroup*>::const_iterator
i = groups.begin(),
e = groups.end();
for ( ; i!=e; ++i )
for (; i!=e; ++i)
delete *i;
}
@ -37,14 +37,14 @@ ControllerEmu::ControlGroup::~ControlGroup()
std::vector<Control*>::const_iterator
ci = controls.begin(),
ce = controls.end();
for ( ; ci!=ce; ++ci )
for (; ci!=ce; ++ci)
delete *ci;
// settings
std::vector<Setting*>::const_iterator
si = settings.begin(),
se = settings.end();
for ( ; si!=se; ++si )
for (; si!=se; ++si)
delete *si;
}
@ -54,7 +54,7 @@ ControllerEmu::Extension::~Extension()
std::vector<ControllerEmu*>::const_iterator
ai = attachments.begin(),
ae = attachments.end();
for ( ; ai!=ae; ++ai )
for (; ai!=ae; ++ai)
delete *ai;
}
ControllerEmu::ControlGroup::Control::~Control()
@ -67,21 +67,21 @@ void ControllerEmu::UpdateReferences(ControllerInterface& devi)
std::vector<ControlGroup*>::const_iterator
i = groups.begin(),
e = groups.end();
for ( ; i!=e; ++i )
for (; i!=e; ++i)
{
std::vector<ControlGroup::Control*>::const_iterator
ci = (*i)->controls.begin(),
ce = (*i)->controls.end();
for ( ; ci!=ce; ++ci )
for (; ci!=ce; ++ci)
devi.UpdateReference((*ci)->control_ref, default_device);
// extension
if ( GROUP_TYPE_EXTENSION == (*i)->type )
if (GROUP_TYPE_EXTENSION == (*i)->type)
{
std::vector<ControllerEmu*>::const_iterator
ai = ((Extension*)*i)->attachments.begin(),
ae = ((Extension*)*i)->attachments.end();
for ( ; ai!=ae; ++ai )
for (; ai!=ae; ++ai)
(*ai)->UpdateReferences(devi);
}
}
@ -92,21 +92,21 @@ void ControllerEmu::UpdateDefaultDevice()
std::vector<ControlGroup*>::const_iterator
i = groups.begin(),
e = groups.end();
for ( ; i!=e; ++i )
for (; i!=e; ++i)
{
//std::vector<ControlGroup::Control*>::const_iterator
//ci = (*i)->controls.begin(),
//ce = (*i)->controls.end();
//for ( ; ci!=ce; ++ci )
//for (; ci!=ce; ++ci)
//(*ci)->control_ref->device_qualifier = default_device;
// extension
if ( GROUP_TYPE_EXTENSION == (*i)->type )
if (GROUP_TYPE_EXTENSION == (*i)->type)
{
std::vector<ControllerEmu*>::const_iterator
ai = ((Extension*)*i)->attachments.begin(),
ae = ((Extension*)*i)->attachments.end();
for ( ; ai!=ae; ++ai )
for (; ai!=ae; ++ai)
{
(*ai)->default_device = default_device;
(*ai)->UpdateDefaultDevice();
@ -115,15 +115,15 @@ void ControllerEmu::UpdateDefaultDevice()
}
}
void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::string& defdev, const std::string& base )
void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::string& defdev, const std::string& base)
{
std::string group( base + name ); group += "/";
std::string group(base + name); group += "/";
// settings
std::vector<ControlGroup::Setting*>::const_iterator
si = settings.begin(),
se = settings.end();
for ( ; si!=se; ++si )
for (; si!=se; ++si)
{
sec->Get((group+(*si)->name).c_str(), &(*si)->value, (*si)->default_value*100);
(*si)->value /= 100;
@ -133,19 +133,19 @@ void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::s
std::vector<ControlGroup::Control*>::const_iterator
ci = controls.begin(),
ce = controls.end();
for ( ; ci!=ce; ++ci )
for (; ci!=ce; ++ci)
{
// control expression
sec->Get((group + (*ci)->name).c_str(), &(*ci)->control_ref->expression, "");
// range
sec->Get( (group+(*ci)->name+"/Range").c_str(), &(*ci)->control_ref->range, 100.0f);
sec->Get((group+(*ci)->name+"/Range").c_str(), &(*ci)->control_ref->range, 100.0f);
(*ci)->control_ref->range /= 100;
}
// extensions
if ( GROUP_TYPE_EXTENSION == type )
if (GROUP_TYPE_EXTENSION == type)
{
Extension* const ex = ((Extension*)this);
@ -157,18 +157,18 @@ void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::s
std::vector<ControllerEmu*>::const_iterator
ai = ((Extension*)this)->attachments.begin(),
ae = ((Extension*)this)->attachments.end();
for ( ; ai!=ae; ++ai,++n )
for (; ai!=ae; ++ai,++n)
{
(*ai)->default_device.FromString( defdev );
(*ai)->LoadConfig( sec, base + (*ai)->GetName() + "/" );
(*ai)->default_device.FromString(defdev);
(*ai)->LoadConfig(sec, base + (*ai)->GetName() + "/");
if ( (*ai)->GetName() == extname )
if ((*ai)->GetName() == extname)
ex->switch_extension = n;
}
}
}
void ControllerEmu::LoadConfig( IniFile::Section *sec, const std::string& base )
void ControllerEmu::LoadConfig(IniFile::Section *sec, const std::string& base)
{
std::string defdev = default_device.ToString();
if (base.empty())
@ -178,36 +178,36 @@ void ControllerEmu::LoadConfig( IniFile::Section *sec, const std::string& base )
}
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
e = groups.end();
for ( ; i!=e; ++i )
for (; i!=e; ++i)
(*i)->LoadConfig(sec, defdev, base);
}
void ControllerEmu::ControlGroup::SaveConfig( IniFile::Section *sec, const std::string& defdev, const std::string& base )
void ControllerEmu::ControlGroup::SaveConfig(IniFile::Section *sec, const std::string& defdev, const std::string& base)
{
std::string group( base + name ); group += "/";
std::string group(base + name); group += "/";
// settings
std::vector<ControlGroup::Setting*>::const_iterator
si = settings.begin(),
se = settings.end();
for ( ; si!=se; ++si )
sec->Set( (group+(*si)->name).c_str(), (*si)->value*100.0f, (*si)->default_value*100.0f);
for (; si!=se; ++si)
sec->Set((group+(*si)->name).c_str(), (*si)->value*100.0f, (*si)->default_value*100.0f);
// controls
std::vector<ControlGroup::Control*>::const_iterator
ci = controls.begin(),
ce = controls.end();
for ( ; ci!=ce; ++ci )
for (; ci!=ce; ++ci)
{
// control expression
sec->Set( (group+(*ci)->name).c_str(), (*ci)->control_ref->expression, "");
sec->Set((group+(*ci)->name).c_str(), (*ci)->control_ref->expression, "");
// range
sec->Set( (group+(*ci)->name+"/Range").c_str(), (*ci)->control_ref->range*100.0f, 100.0f);
sec->Set((group+(*ci)->name+"/Range").c_str(), (*ci)->control_ref->range*100.0f, 100.0f);
}
// extensions
if ( GROUP_TYPE_EXTENSION == type )
if (GROUP_TYPE_EXTENSION == type)
{
Extension* const ext = ((Extension*)this);
sec->Set((base + name).c_str(), ext->attachments[ext->switch_extension]->GetName(), "None");
@ -215,48 +215,48 @@ void ControllerEmu::ControlGroup::SaveConfig( IniFile::Section *sec, const std::
std::vector<ControllerEmu*>::const_iterator
ai = ((Extension*)this)->attachments.begin(),
ae = ((Extension*)this)->attachments.end();
for ( ; ai!=ae; ++ai )
(*ai)->SaveConfig( sec, base + (*ai)->GetName() + "/" );
for (; ai!=ae; ++ai)
(*ai)->SaveConfig(sec, base + (*ai)->GetName() + "/");
}
}
void ControllerEmu::SaveConfig( IniFile::Section *sec, const std::string& base )
void ControllerEmu::SaveConfig(IniFile::Section *sec, const std::string& base)
{
const std::string defdev = default_device.ToString();
if ( base.empty() )
sec->Set( (/*std::string(" ") +*/ base + "Device").c_str(), defdev, "");
if (base.empty())
sec->Set((/*std::string(" ") +*/ base + "Device").c_str(), defdev, "");
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
e = groups.end();
for ( ; i!=e; ++i )
(*i)->SaveConfig( sec, defdev, base );
for (; i!=e; ++i)
(*i)->SaveConfig(sec, defdev, base);
}
ControllerEmu::AnalogStick::AnalogStick( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_STICK )
ControllerEmu::AnalogStick::AnalogStick(const char* const _name) : ControlGroup(_name, GROUP_TYPE_STICK)
{
for ( unsigned int i = 0; i < 4; ++i )
controls.push_back( new Input( named_directions[i] ) );
for (unsigned int i = 0; i < 4; ++i)
controls.push_back(new Input(named_directions[i]));
controls.push_back( new Input( "Modifier" ) );
controls.push_back(new Input(_trans("Modifier")));
settings.push_back( new Setting("Dead Zone", 0, 0, 50 ) );
settings.push_back( new Setting("Square Stick", 0 ) );
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
settings.push_back(new Setting(_trans("Square Stick"), 0));
}
ControllerEmu::Buttons::Buttons( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_BUTTONS )
ControllerEmu::Buttons::Buttons(const char* const _name) : ControlGroup(_name, GROUP_TYPE_BUTTONS)
{
settings.push_back( new Setting("Threshold", 0.5f ) );
settings.push_back(new Setting(_trans("Threshold"), 0.5f));
}
ControllerEmu::MixedTriggers::MixedTriggers( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_MIXED_TRIGGERS )
ControllerEmu::MixedTriggers::MixedTriggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_MIXED_TRIGGERS)
{
settings.push_back( new Setting("Threshold", 0.9f ) );
settings.push_back(new Setting(_trans("Threshold"), 0.9f));
}
ControllerEmu::Triggers::Triggers( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_TRIGGERS )
ControllerEmu::Triggers::Triggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_TRIGGERS)
{
settings.push_back( new Setting("Dead Zone", 0, 0, 50 ) );
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
}
ControllerEmu::Slider::Slider(const char* const _name) : ControlGroup(_name, GROUP_TYPE_SLIDER)
@ -264,53 +264,52 @@ ControllerEmu::Slider::Slider(const char* const _name) : ControlGroup(_name, GRO
controls.push_back(new Input("Left"));
controls.push_back(new Input("Right"));
settings.push_back(new Setting("Dead Zone", 0, 0, 50));
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
}
ControllerEmu::Force::Force( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_FORCE )
ControllerEmu::Force::Force(const char* const _name) : ControlGroup(_name, GROUP_TYPE_FORCE)
{
memset(m_swing, 0, sizeof(m_swing));
controls.push_back( new Input( "Up" ) );
controls.push_back( new Input( "Down" ) );
controls.push_back( new Input( "Left" ) );
controls.push_back( new Input( "Right" ) );
controls.push_back( new Input( "Forward" ) );
controls.push_back( new Input( "Backward" ) );
//controls.push_back( new Input( "Modifier" ) );
controls.push_back(new Input(_trans("Up")));
controls.push_back(new Input(_trans("Down")));
controls.push_back(new Input(_trans("Left")));
controls.push_back(new Input(_trans("Right")));
controls.push_back(new Input(_trans("Forward")));
controls.push_back(new Input(_trans("Backward")));
settings.push_back( new Setting("Dead Zone", 0, 0, 50 ) );
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
}
ControllerEmu::Tilt::Tilt( const char* const _name )
: ControlGroup( _name, GROUP_TYPE_TILT )
ControllerEmu::Tilt::Tilt(const char* const _name)
: ControlGroup(_name, GROUP_TYPE_TILT)
{
memset(m_tilt, 0, sizeof(m_tilt));
controls.push_back( new Input( "Forward" ) );
controls.push_back( new Input( "Backward" ) );
controls.push_back( new Input( "Left" ) );
controls.push_back( new Input( "Right" ) );
controls.push_back(new Input("Forward"));
controls.push_back(new Input("Backward"));
controls.push_back(new Input("Left"));
controls.push_back(new Input("Right"));
controls.push_back( new Input( "Modifier" ) );
controls.push_back(new Input(_trans("Modifier")));
settings.push_back( new Setting("Dead Zone", 0, 0, 50 ) );
settings.push_back( new Setting("Circle Stick", 0 ) );
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
settings.push_back(new Setting(_trans("Circle Stick"), 0));
}
ControllerEmu::Cursor::Cursor(const char* const _name)
: ControlGroup(_name, GROUP_TYPE_CURSOR)
, m_z(0)
{
for ( unsigned int i = 0; i < 4; ++i )
controls.push_back( new Input( named_directions[i] ) );
controls.push_back( new Input( "Forward" ) );
controls.push_back( new Input( "Backward" ) );
controls.push_back( new Input( "Hide" ) );
for (unsigned int i = 0; i < 4; ++i)
controls.push_back(new Input(named_directions[i]));
controls.push_back(new Input("Forward"));
controls.push_back(new Input("Backward"));
controls.push_back(new Input(_trans("Hide")));
settings.push_back( new Setting("Center", 0.5f ) );
settings.push_back( new Setting("Width", 0.5f ) );
settings.push_back( new Setting("Height", 0.5f ) );
settings.push_back(new Setting(_trans("Center"), 0.5f));
settings.push_back(new Setting(_trans("Width"), 0.5f));
settings.push_back(new Setting(_trans("Height"), 0.5f));
}

View file

@ -67,7 +67,7 @@ public:
class Control
{
protected:
Control( ControllerInterface::ControlReference* const _ref, const char * const _name )
Control(ControllerInterface::ControlReference* const _ref, const char * const _name)
: control_ref(_ref), name(_name){}
public:
@ -81,8 +81,8 @@ public:
{
public:
Input( const char * const _name )
: Control( new ControllerInterface::InputReference, _name ) {}
Input(const char * const _name)
: Control(new ControllerInterface::InputReference, _name) {}
};
@ -90,8 +90,8 @@ public:
{
public:
Output( const char * const _name )
: Control( new ControllerInterface::OutputReference, _name ) {}
Output(const char * const _name)
: Control(new ControllerInterface::OutputReference, _name) {}
};
@ -113,7 +113,7 @@ public:
const unsigned int low, high;
};
ControlGroup( const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER ) : name(_name), type(_type) {}
ControlGroup(const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {}
virtual ~ControlGroup();
virtual void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
@ -132,7 +132,7 @@ public:
public:
template <typename C>
void GetState( C* const x, C* const y, const unsigned int base, const unsigned int range )
void GetState(C* const x, C* const y, const unsigned int base, const unsigned int range)
{
// this is all a mess
@ -144,62 +144,62 @@ public:
ControlState m = controls[4]->control_ref->State();
// modifier code
if ( m )
if (m)
{
yy = (fabsf(yy)>deadzone) * sign(yy) * (m + deadzone/2);
xx = (fabsf(xx)>deadzone) * sign(xx) * (m + deadzone/2);
}
// deadzone / square stick code
if ( deadzone || square )
if (deadzone || square)
{
// this section might be all wrong, but its working good enough, i think
ControlState ang = atan2( yy, xx );
ControlState ang = atan2(yy, xx);
ControlState ang_sin = sin(ang);
ControlState ang_cos = cos(ang);
// the amt a full square stick would have at current angle
ControlState square_full = std::min( ang_sin ? 1/fabsf(ang_sin) : 2, ang_cos ? 1/fabsf(ang_cos) : 2 );
ControlState square_full = std::min(ang_sin ? 1/fabsf(ang_sin) : 2, ang_cos ? 1/fabsf(ang_cos) : 2);
// the amt a full stick would have that was ( user setting squareness) at current angle
// i think this is more like a pointed circle rather than a rounded square like it should be
ControlState stick_full = ( 1 + ( square_full - 1 ) * square );
ControlState stick_full = (1 + (square_full - 1) * square);
ControlState dist = sqrt(xx*xx + yy*yy);
// dead zone code
dist = std::max( 0.0f, dist - deadzone * stick_full );
dist /= ( 1 - deadzone );
dist = std::max(0.0f, dist - deadzone * stick_full);
dist /= (1 - deadzone);
// square stick code
ControlState amt = dist / stick_full;
dist -= ((square_full - 1) * amt * square);
yy = std::max( -1.0f, std::min( 1.0f, ang_sin * dist ) );
xx = std::max( -1.0f, std::min( 1.0f, ang_cos * dist ) );
yy = std::max(-1.0f, std::min(1.0f, ang_sin * dist));
xx = std::max(-1.0f, std::min(1.0f, ang_cos * dist));
}
*y = C( yy * range + base );
*x = C( xx * range + base );
*y = C(yy * range + base);
*x = C(xx * range + base);
}
AnalogStick( const char* const _name );
AnalogStick(const char* const _name);
};
class Buttons : public ControlGroup
{
public:
Buttons( const char* const _name );
Buttons(const char* const _name);
template <typename C>
void GetState( C* const buttons, const C* bitmasks )
void GetState(C* const buttons, const C* bitmasks)
{
std::vector<Control*>::iterator i = controls.begin(),
e = controls.end();
for ( ; i!=e; ++i, ++bitmasks )
if ( (*i)->control_ref->State() > settings[0]->value ) // threshold
for (; i!=e; ++i, ++bitmasks)
if ((*i)->control_ref->State() > settings[0]->value) // threshold
*buttons |= *bitmasks;
}
@ -210,12 +210,12 @@ public:
public:
template <typename C, typename S>
void GetState( C* const digital, const C* bitmasks, S* analog, const unsigned int range )
void GetState(C* const digital, const C* bitmasks, S* analog, const unsigned int range)
{
const unsigned int trig_count = ((unsigned int) (controls.size() / 2));
for ( unsigned int i=0; i<trig_count; ++i,++bitmasks,++analog )
for (unsigned int i=0; i<trig_count; ++i,++bitmasks,++analog)
{
if ( controls[i]->control_ref->State() > settings[0]->value ) //threshold
if (controls[i]->control_ref->State() > settings[0]->value) //threshold
{
*analog = range;
*digital |= *bitmasks;
@ -226,7 +226,7 @@ public:
}
}
MixedTriggers( const char* const _name );
MixedTriggers(const char* const _name);
};
@ -235,15 +235,15 @@ public:
public:
template <typename S>
void GetState( S* analog, const unsigned int range )
void GetState(S* analog, const unsigned int range)
{
const unsigned int trig_count = ((unsigned int) (controls.size()));
const ControlState deadzone = settings[0]->value;
for ( unsigned int i=0; i<trig_count; ++i,++analog )
*analog = S( std::max(controls[i]->control_ref->State() - deadzone, 0.0f) / (1 - deadzone) * range );
for (unsigned int i=0; i<trig_count; ++i,++analog)
*analog = S(std::max(controls[i]->control_ref->State() - deadzone, 0.0f) / (1 - deadzone) * range);
}
Triggers( const char* const _name );
Triggers(const char* const _name);
};
@ -270,7 +270,7 @@ public:
class Force : public ControlGroup
{
public:
Force( const char* const _name );
Force(const char* const _name);
template <typename C, typename R>
void GetState(C* axis, const u8 base, const R range)
@ -295,7 +295,7 @@ public:
class Tilt : public ControlGroup
{
public:
Tilt( const char* const _name );
Tilt(const char* const _name);
template <typename C, typename R>
void GetState(C* const x, C* const y, const unsigned int base, const R range, const bool step = true)
@ -310,40 +310,40 @@ public:
ControlState m = controls[4]->control_ref->State();
// modifier code
if ( m )
if (m)
{
yy = (fabsf(yy)>deadzone) * sign(yy) * (m + deadzone/2);
xx = (fabsf(xx)>deadzone) * sign(xx) * (m + deadzone/2);
}
// deadzone / circle stick code
if ( deadzone || circle )
if (deadzone || circle)
{
// this section might be all wrong, but its working good enough, i think
ControlState ang = atan2( yy, xx );
ControlState ang = atan2(yy, xx);
ControlState ang_sin = sin(ang);
ControlState ang_cos = cos(ang);
// the amt a full square stick would have at current angle
ControlState square_full = std::min( ang_sin ? 1/fabsf(ang_sin) : 2, ang_cos ? 1/fabsf(ang_cos) : 2 );
ControlState square_full = std::min(ang_sin ? 1/fabsf(ang_sin) : 2, ang_cos ? 1/fabsf(ang_cos) : 2);
// the amt a full stick would have that was ( user setting circular ) at current angle
// the amt a full stick would have that was (user setting circular) at current angle
// i think this is more like a pointed circle rather than a rounded square like it should be
ControlState stick_full = (square_full * (1 - circle)) + (circle);
ControlState dist = sqrt(xx*xx + yy*yy);
// dead zone code
dist = std::max( 0.0f, dist - deadzone * stick_full );
dist = std::max(0.0f, dist - deadzone * stick_full);
dist /= (1 - deadzone);
// circle stick code
ControlState amt = dist / stick_full;
dist += (square_full - 1) * amt * circle;
yy = std::max( -1.0f, std::min( 1.0f, ang_sin * dist ) );
xx = std::max( -1.0f, std::min( 1.0f, ang_cos * dist ) );
yy = std::max(-1.0f, std::min(1.0f, ang_sin * dist));
xx = std::max(-1.0f, std::min(1.0f, ang_cos * dist));
}
// this is kinda silly here
@ -363,8 +363,8 @@ public:
m_tilt[1] = std::max(m_tilt[1] - 0.1f, yy);
}
*y = C( m_tilt[1] * range + base );
*x = C( m_tilt[0] * range + base );
*y = C(m_tilt[1] * range + base);
*x = C(m_tilt[0] * range + base);
}
private:
float m_tilt[2];
@ -376,7 +376,7 @@ public:
Cursor(const char* const _name);
template <typename C>
void GetState( C* const x, C* const y, C* const z, const bool adjusted = false )
void GetState(C* const x, C* const y, C* const z, const bool adjusted = false)
{
const float zz = controls[4]->control_ref->State() - controls[5]->control_ref->State();
@ -401,9 +401,9 @@ public:
// adjust cursor according to settings
if (adjusted)
{
xx *= ( settings[1]->value * 2 );
yy *= ( settings[2]->value * 2 );
yy += ( settings[0]->value - 0.5f );
xx *= (settings[1]->value * 2);
yy *= (settings[2]->value * 2);
yy += (settings[0]->value - 0.5f);
}
*x = xx;
@ -417,13 +417,13 @@ public:
class Extension : public ControlGroup
{
public:
Extension( const char* const _name )
: ControlGroup( _name, GROUP_TYPE_EXTENSION )
Extension(const char* const _name)
: ControlGroup(_name, GROUP_TYPE_EXTENSION)
, switch_extension(0)
, active_extension(0) {}
~Extension();
void GetState( u8* const data, const bool focus = true );
void GetState(u8* const data, const bool focus = true);
std::vector<ControllerEmu*> attachments;
@ -441,7 +441,7 @@ public:
virtual void SaveConfig(IniFile::Section *sec, const std::string& base = "");
void UpdateDefaultDevice();
void UpdateReferences( ControllerInterface& devi );
void UpdateReferences(ControllerInterface& devi);
std::vector< ControlGroup* > groups;