Introduce the usage of unique_ptr into the InputCommon ControlEmu.h class. Allows for the automatic handling of resource deallocation.
This commit is contained in:
parent
825c5f689b
commit
557015626a
|
@ -55,31 +55,31 @@ GCPad::GCPad(const unsigned int index) : m_index(index)
|
|||
int const mic_hax = index > 1;
|
||||
|
||||
// buttons
|
||||
groups.push_back(m_buttons = new Buttons(_trans("Buttons")));
|
||||
groups.emplace_back(m_buttons = new Buttons(_trans("Buttons")));
|
||||
for (unsigned int i=0; i < sizeof(named_buttons)/sizeof(*named_buttons) - mic_hax; ++i)
|
||||
m_buttons->controls.push_back(new ControlGroup::Input(named_buttons[i]));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input(named_buttons[i]));
|
||||
|
||||
// sticks
|
||||
groups.push_back(m_main_stick = new AnalogStick(_trans("Main Stick")));
|
||||
groups.push_back(m_c_stick = new AnalogStick(_trans("C-Stick")));
|
||||
groups.emplace_back(m_main_stick = new AnalogStick(_trans("Main Stick")));
|
||||
groups.emplace_back(m_c_stick = new AnalogStick(_trans("C-Stick")));
|
||||
|
||||
// triggers
|
||||
groups.push_back(m_triggers = new MixedTriggers(_trans("Triggers")));
|
||||
groups.emplace_back(m_triggers = new MixedTriggers(_trans("Triggers")));
|
||||
for (auto& named_trigger : named_triggers)
|
||||
m_triggers->controls.push_back(new ControlGroup::Input(named_trigger));
|
||||
m_triggers->controls.emplace_back(new ControlGroup::Input(named_trigger));
|
||||
|
||||
// rumble
|
||||
groups.push_back(m_rumble = new ControlGroup(_trans("Rumble")));
|
||||
m_rumble->controls.push_back(new ControlGroup::Output(_trans("Motor")));
|
||||
groups.emplace_back(m_rumble = new ControlGroup(_trans("Rumble")));
|
||||
m_rumble->controls.emplace_back(new ControlGroup::Output(_trans("Motor")));
|
||||
|
||||
// dpad
|
||||
groups.push_back(m_dpad = new Buttons(_trans("D-Pad")));
|
||||
groups.emplace_back(m_dpad = new Buttons(_trans("D-Pad")));
|
||||
for (auto& named_direction : named_directions)
|
||||
m_dpad->controls.push_back(new ControlGroup::Input(named_direction));
|
||||
m_dpad->controls.emplace_back(new ControlGroup::Input(named_direction));
|
||||
|
||||
// options
|
||||
groups.push_back(m_options = new ControlGroup(_trans("Options")));
|
||||
m_options->settings.push_back(new ControlGroup::Setting(_trans("Background Input"), false));
|
||||
groups.emplace_back(m_options = new ControlGroup(_trans("Options")));
|
||||
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Background Input"), false));
|
||||
}
|
||||
|
||||
std::string GCPad::GetName() const
|
||||
|
|
|
@ -43,5 +43,5 @@ void Attachment::Reset()
|
|||
|
||||
void ControllerEmu::Extension::GetState( u8* const data, const bool focus )
|
||||
{
|
||||
((WiimoteEmu::Attachment*)attachments[ active_extension ])->GetState( data, focus );
|
||||
((WiimoteEmu::Attachment*)attachments[active_extension].get())->GetState( data, focus );
|
||||
}
|
||||
|
|
|
@ -56,23 +56,23 @@ static const u16 classic_dpad_bitmasks[] =
|
|||
Classic::Classic(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Classic"), _reg)
|
||||
{
|
||||
// buttons
|
||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
for (auto& classic_button_name : classic_button_names)
|
||||
m_buttons->controls.push_back(new ControlGroup::Input(classic_button_name));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input(classic_button_name));
|
||||
|
||||
// sticks
|
||||
groups.push_back(m_left_stick = new AnalogStick(_trans("Left Stick")));
|
||||
groups.push_back(m_right_stick = new AnalogStick(_trans("Right Stick")));
|
||||
groups.emplace_back(m_left_stick = new AnalogStick(_trans("Left Stick")));
|
||||
groups.emplace_back(m_right_stick = new AnalogStick(_trans("Right Stick")));
|
||||
|
||||
// triggers
|
||||
groups.push_back(m_triggers = new MixedTriggers("Triggers"));
|
||||
groups.emplace_back(m_triggers = new MixedTriggers("Triggers"));
|
||||
for (auto& classic_trigger_name : classic_trigger_names)
|
||||
m_triggers->controls.push_back(new ControlGroup::Input(classic_trigger_name));
|
||||
m_triggers->controls.emplace_back(new ControlGroup::Input(classic_trigger_name));
|
||||
|
||||
// dpad
|
||||
groups.push_back(m_dpad = new Buttons("D-Pad"));
|
||||
groups.emplace_back(m_dpad = new Buttons("D-Pad"));
|
||||
for (auto& named_direction : named_directions)
|
||||
m_dpad->controls.push_back(new ControlGroup::Input(named_direction));
|
||||
m_dpad->controls.emplace_back(new ControlGroup::Input(named_direction));
|
||||
|
||||
// set up register
|
||||
// calibration
|
||||
|
|
|
@ -35,17 +35,17 @@ static const u16 drum_button_bitmasks[] =
|
|||
Drums::Drums(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Drums"), _reg)
|
||||
{
|
||||
// pads
|
||||
groups.push_back(m_pads = new Buttons(_trans("Pads")));
|
||||
groups.emplace_back(m_pads = new Buttons(_trans("Pads")));
|
||||
for (auto& drum_pad_name : drum_pad_names)
|
||||
m_pads->controls.push_back(new ControlGroup::Input(drum_pad_name));
|
||||
m_pads->controls.emplace_back(new ControlGroup::Input(drum_pad_name));
|
||||
|
||||
// stick
|
||||
groups.push_back(m_stick = new AnalogStick("Stick"));
|
||||
groups.emplace_back(m_stick = new AnalogStick("Stick"));
|
||||
|
||||
// buttons
|
||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
||||
m_buttons->controls.push_back(new ControlGroup::Input("-"));
|
||||
m_buttons->controls.push_back(new ControlGroup::Input("+"));
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("-"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("+"));
|
||||
|
||||
// set up register
|
||||
// id
|
||||
|
|
|
@ -39,26 +39,26 @@ static const u16 guitar_strum_bitmasks[] =
|
|||
Guitar::Guitar(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Guitar"), _reg)
|
||||
{
|
||||
// frets
|
||||
groups.push_back(m_frets = new Buttons(_trans("Frets")));
|
||||
groups.emplace_back(m_frets = new Buttons(_trans("Frets")));
|
||||
for (auto& guitar_fret_name : guitar_fret_names)
|
||||
m_frets->controls.push_back(new ControlGroup::Input(guitar_fret_name));
|
||||
m_frets->controls.emplace_back(new ControlGroup::Input(guitar_fret_name));
|
||||
|
||||
// strum
|
||||
groups.push_back(m_strum = new Buttons(_trans("Strum")));
|
||||
m_strum->controls.push_back(new ControlGroup::Input("Up"));
|
||||
m_strum->controls.push_back(new ControlGroup::Input("Down"));
|
||||
groups.emplace_back(m_strum = new Buttons(_trans("Strum")));
|
||||
m_strum->controls.emplace_back(new ControlGroup::Input("Up"));
|
||||
m_strum->controls.emplace_back(new ControlGroup::Input("Down"));
|
||||
|
||||
// buttons
|
||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
||||
m_buttons->controls.push_back(new ControlGroup::Input("-"));
|
||||
m_buttons->controls.push_back(new ControlGroup::Input("+"));
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("-"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("+"));
|
||||
|
||||
// stick
|
||||
groups.push_back(m_stick = new AnalogStick(_trans("Stick")));
|
||||
groups.emplace_back(m_stick = new AnalogStick(_trans("Stick")));
|
||||
|
||||
// whammy
|
||||
groups.push_back(m_whammy = new Triggers(_trans("Whammy")));
|
||||
m_whammy->controls.push_back(new ControlGroup::Input(_trans("Bar")));
|
||||
groups.emplace_back(m_whammy = new Triggers(_trans("Whammy")));
|
||||
m_whammy->controls.emplace_back(new ControlGroup::Input(_trans("Bar")));
|
||||
|
||||
// set up register
|
||||
// id
|
||||
|
|
|
@ -35,24 +35,24 @@ Nunchuk::Nunchuk(UDPWrapper *wrp, WiimoteEmu::ExtensionReg& _reg)
|
|||
: Attachment(_trans("Nunchuk"), _reg) , m_udpWrap(wrp)
|
||||
{
|
||||
// buttons
|
||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
||||
m_buttons->controls.push_back(new ControlGroup::Input("C"));
|
||||
m_buttons->controls.push_back(new ControlGroup::Input("Z"));
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("C"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("Z"));
|
||||
|
||||
// stick
|
||||
groups.push_back(m_stick = new AnalogStick("Stick"));
|
||||
groups.emplace_back(m_stick = new AnalogStick("Stick"));
|
||||
|
||||
// swing
|
||||
groups.push_back(m_swing = new Force("Swing"));
|
||||
groups.emplace_back(m_swing = new Force("Swing"));
|
||||
|
||||
// tilt
|
||||
groups.push_back(m_tilt = new Tilt("Tilt"));
|
||||
groups.emplace_back(m_tilt = new Tilt("Tilt"));
|
||||
|
||||
// shake
|
||||
groups.push_back(m_shake = new Buttons("Shake"));
|
||||
m_shake->controls.push_back(new ControlGroup::Input("X"));
|
||||
m_shake->controls.push_back(new ControlGroup::Input("Y"));
|
||||
m_shake->controls.push_back(new ControlGroup::Input("Z"));
|
||||
groups.emplace_back(m_shake = new Buttons("Shake"));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("X"));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("Y"));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("Z"));
|
||||
|
||||
// set up register
|
||||
// calibration
|
||||
|
|
|
@ -33,23 +33,23 @@ static const char* const turntable_button_names[] =
|
|||
Turntable::Turntable(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Turntable"), _reg)
|
||||
{
|
||||
// buttons
|
||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
for (auto& turntable_button_name : turntable_button_names)
|
||||
m_buttons->controls.push_back(new ControlGroup::Input(turntable_button_name));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input(turntable_button_name));
|
||||
|
||||
// turntables
|
||||
groups.push_back(m_left_table = new Slider(_trans("Table Left")));
|
||||
groups.push_back(m_right_table = new Slider(_trans("Table Right")));
|
||||
groups.emplace_back(m_left_table = new Slider(_trans("Table Left")));
|
||||
groups.emplace_back(m_right_table = new Slider(_trans("Table Right")));
|
||||
|
||||
// stick
|
||||
groups.push_back(m_stick = new AnalogStick("Stick"));
|
||||
groups.emplace_back(m_stick = new AnalogStick("Stick"));
|
||||
|
||||
// effect dial
|
||||
groups.push_back(m_effect_dial = new Triggers(_trans("Effect")));
|
||||
m_effect_dial->controls.push_back(new ControlGroup::Input(_trans("Dial")));
|
||||
groups.emplace_back(m_effect_dial = new Triggers(_trans("Effect")));
|
||||
m_effect_dial->controls.emplace_back(new ControlGroup::Input(_trans("Dial")));
|
||||
|
||||
// crossfade
|
||||
groups.push_back(m_crossfade = new Slider(_trans("Crossfade")));
|
||||
groups.emplace_back(m_crossfade = new Slider(_trans("Crossfade")));
|
||||
|
||||
// set up register
|
||||
// id
|
||||
|
|
|
@ -852,7 +852,7 @@ void Wiimote::HandleExtensionSwap()
|
|||
m_extension->active_extension = m_extension->switch_extension;
|
||||
|
||||
// reset register
|
||||
((WiimoteEmu::Attachment*)m_extension->attachments[m_extension->active_extension])->Reset();
|
||||
((WiimoteEmu::Attachment*)m_extension->attachments[m_extension->active_extension].get())->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -268,53 +268,53 @@ Wiimote::Wiimote( const unsigned int index )
|
|||
// ---- set up all the controls ----
|
||||
|
||||
// buttons
|
||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
for (auto& named_button : named_buttons)
|
||||
m_buttons->controls.push_back(new ControlGroup::Input( named_button));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input( named_button));
|
||||
|
||||
// udp
|
||||
groups.push_back(m_udp = new UDPWrapper(m_index, _trans("UDP Wiimote")));
|
||||
groups.emplace_back(m_udp = new UDPWrapper(m_index, _trans("UDP Wiimote")));
|
||||
|
||||
// ir
|
||||
groups.push_back(m_ir = new Cursor(_trans("IR")));
|
||||
groups.emplace_back(m_ir = new Cursor(_trans("IR")));
|
||||
|
||||
// swing
|
||||
groups.push_back(m_swing = new Force(_trans("Swing")));
|
||||
groups.emplace_back(m_swing = new Force(_trans("Swing")));
|
||||
|
||||
// tilt
|
||||
groups.push_back(m_tilt = new Tilt(_trans("Tilt")));
|
||||
groups.emplace_back(m_tilt = new Tilt(_trans("Tilt")));
|
||||
|
||||
// shake
|
||||
groups.push_back(m_shake = new Buttons(_trans("Shake")));
|
||||
m_shake->controls.push_back(new ControlGroup::Input("X"));
|
||||
m_shake->controls.push_back(new ControlGroup::Input("Y"));
|
||||
m_shake->controls.push_back(new ControlGroup::Input("Z"));
|
||||
groups.emplace_back(m_shake = new Buttons(_trans("Shake")));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("X"));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("Y"));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("Z"));
|
||||
|
||||
// extension
|
||||
groups.push_back(m_extension = new Extension(_trans("Extension")));
|
||||
m_extension->attachments.push_back(new WiimoteEmu::None(m_reg_ext));
|
||||
m_extension->attachments.push_back(new WiimoteEmu::Nunchuk(m_udp, m_reg_ext));
|
||||
m_extension->attachments.push_back(new WiimoteEmu::Classic(m_reg_ext));
|
||||
m_extension->attachments.push_back(new WiimoteEmu::Guitar(m_reg_ext));
|
||||
m_extension->attachments.push_back(new WiimoteEmu::Drums(m_reg_ext));
|
||||
m_extension->attachments.push_back(new WiimoteEmu::Turntable(m_reg_ext));
|
||||
groups.emplace_back(m_extension = new Extension(_trans("Extension")));
|
||||
m_extension->attachments.emplace_back(new WiimoteEmu::None(m_reg_ext));
|
||||
m_extension->attachments.emplace_back(new WiimoteEmu::Nunchuk(m_udp, m_reg_ext));
|
||||
m_extension->attachments.emplace_back(new WiimoteEmu::Classic(m_reg_ext));
|
||||
m_extension->attachments.emplace_back(new WiimoteEmu::Guitar(m_reg_ext));
|
||||
m_extension->attachments.emplace_back(new WiimoteEmu::Drums(m_reg_ext));
|
||||
m_extension->attachments.emplace_back(new WiimoteEmu::Turntable(m_reg_ext));
|
||||
|
||||
m_extension->settings.push_back(new ControlGroup::Setting(_trans("Motion Plus"), 0, 0, 1));
|
||||
m_extension->settings.emplace_back(new ControlGroup::Setting(_trans("Motion Plus"), 0, 0, 1));
|
||||
|
||||
// rumble
|
||||
groups.push_back(m_rumble = new ControlGroup(_trans("Rumble")));
|
||||
m_rumble->controls.push_back(new ControlGroup::Output(_trans("Motor")));
|
||||
groups.emplace_back(m_rumble = new ControlGroup(_trans("Rumble")));
|
||||
m_rumble->controls.emplace_back(new ControlGroup::Output(_trans("Motor")));
|
||||
|
||||
// dpad
|
||||
groups.push_back(m_dpad = new Buttons("D-Pad"));
|
||||
groups.emplace_back(m_dpad = new Buttons("D-Pad"));
|
||||
for (auto& named_direction : named_directions)
|
||||
m_dpad->controls.push_back(new ControlGroup::Input(named_direction));
|
||||
m_dpad->controls.emplace_back(new ControlGroup::Input(named_direction));
|
||||
|
||||
// options
|
||||
groups.push_back( m_options = new ControlGroup(_trans("Options")));
|
||||
m_options->settings.push_back(new ControlGroup::Setting(_trans("Background Input"), false));
|
||||
m_options->settings.push_back(new ControlGroup::Setting(_trans("Sideways Wiimote"), false));
|
||||
m_options->settings.push_back(new ControlGroup::Setting(_trans("Upright Wiimote"), false));
|
||||
groups.emplace_back( m_options = new ControlGroup(_trans("Options")));
|
||||
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Background Input"), false));
|
||||
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Sideways Wiimote"), false));
|
||||
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Upright Wiimote"), false));
|
||||
|
||||
// TODO: This value should probably be re-read if SYSCONF gets changed
|
||||
m_sensor_bar_on_top = SConfig::GetInstance().m_SYSCONF->GetData<u8>("BT.BAR") != 0;
|
||||
|
|
|
@ -31,8 +31,7 @@ void GamepadPage::ConfigExtension(wxCommandEvent& event)
|
|||
wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
|
||||
const std::size_t orig_size = control_groups.size();
|
||||
|
||||
ControlGroupsSizer* const szr =
|
||||
new ControlGroupsSizer(ex->attachments[ex->switch_extension], &dlg, this, &control_groups);
|
||||
ControlGroupsSizer* const szr = new ControlGroupsSizer(ex->attachments[ex->switch_extension].get(), &dlg, this, &control_groups);
|
||||
main_szr->Add(szr, 0, wxLEFT, 5);
|
||||
main_szr->Add(dlg.CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
||||
dlg.SetSizerAndFit(main_szr);
|
||||
|
@ -49,13 +48,10 @@ PadSettingExtension::PadSettingExtension(wxWindow* const parent, ControllerEmu::
|
|||
: PadSetting(new wxChoice(parent, -1))
|
||||
, extension(ext)
|
||||
{
|
||||
|
||||
std::vector<ControllerEmu*>::const_iterator
|
||||
i = extension->attachments.begin(),
|
||||
e = extension->attachments.end();
|
||||
|
||||
for (; i!=e; ++i)
|
||||
((wxChoice*)wxcontrol)->Append(wxGetTranslation(StrToWxStr((*i)->GetName())));
|
||||
for (auto& attachment : extension->attachments)
|
||||
{
|
||||
((wxChoice*)wxcontrol)->Append(wxGetTranslation(StrToWxStr(attachment->GetName())));
|
||||
}
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
@ -724,20 +720,16 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
|||
static_bitmap = NULL;
|
||||
|
||||
wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
std::vector<ControllerEmu::ControlGroup::Control*>::iterator
|
||||
ci = group->controls.begin(),
|
||||
ce = group->controls.end();
|
||||
for (; ci != ce; ++ci)
|
||||
for (auto& control : group->controls)
|
||||
{
|
||||
wxStaticText* const label = new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr(control->name)));
|
||||
|
||||
wxStaticText* const label = new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr((*ci)->name)));
|
||||
|
||||
ControlButton* const control_button = new ControlButton(parent, (*ci)->control_ref, 80);
|
||||
ControlButton* const control_button = new ControlButton(parent, control->control_ref.get(), 80);
|
||||
control_button->SetFont(m_SmallFont);
|
||||
|
||||
control_buttons.push_back(control_button);
|
||||
|
||||
if ((*ci)->control_ref->is_input)
|
||||
if (control->control_ref->is_input)
|
||||
{
|
||||
control_button->SetToolTip(_("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
|
||||
control_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::DetectControl, eventsink);
|
||||
|
@ -774,17 +766,13 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
|||
dc.Clear();
|
||||
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
||||
|
||||
std::vector< ControllerEmu::ControlGroup::Setting* >::const_iterator
|
||||
i = group->settings.begin(),
|
||||
e = group->settings.end();
|
||||
|
||||
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
|
||||
for (; i!=e; ++i)
|
||||
for (auto& groupSetting : group->settings)
|
||||
{
|
||||
PadSettingSpin* setting = new PadSettingSpin(parent, *i);
|
||||
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
|
||||
setting->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
|
||||
options.push_back(setting);
|
||||
szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr((*i)->name))));
|
||||
szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr(groupSetting->name))));
|
||||
szr->Add(setting->wxcontrol, 0, wxLEFT, 0);
|
||||
}
|
||||
|
||||
|
@ -802,7 +790,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
|||
dc.Clear();
|
||||
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
||||
|
||||
PadSettingSpin* const threshold_cbox = new PadSettingSpin(parent, group->settings[0]);
|
||||
PadSettingSpin* const threshold_cbox = new PadSettingSpin(parent, group->settings[0].get());
|
||||
threshold_cbox->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
|
||||
|
||||
threshold_cbox->wxcontrol->SetToolTip(_("Adjust the analog control pressure required to activate buttons."));
|
||||
|
@ -836,16 +824,13 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
|||
dc.Clear();
|
||||
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
||||
|
||||
std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
|
||||
i = group->settings.begin(),
|
||||
e = group->settings.end();
|
||||
for (; i!=e; ++i)
|
||||
for (auto& groupSetting : group->settings)
|
||||
{
|
||||
PadSettingSpin* setting = new PadSettingSpin(parent, *i);
|
||||
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
|
||||
setting->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
|
||||
options.push_back(setting);
|
||||
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr((*i)->name))), 0, wxCENTER|wxRIGHT, 3);
|
||||
szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr(groupSetting->name))), 0, wxCENTER|wxRIGHT, 3);
|
||||
szr->Add(setting->wxcontrol, 0, wxRIGHT, 3);
|
||||
Add(szr, 0, wxALL|wxCENTER, 3);
|
||||
}
|
||||
|
@ -877,18 +862,13 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
|||
default:
|
||||
{
|
||||
//options
|
||||
|
||||
std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
|
||||
i = group->settings.begin(),
|
||||
e = group->settings.end();
|
||||
for (; i!=e; ++i)
|
||||
for (auto& groupSetting : group->settings)
|
||||
{
|
||||
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, (*i)->value, (*i)->name);
|
||||
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, groupSetting->value, groupSetting->name);
|
||||
setting_cbox->wxcontrol->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &GamepadPage::AdjustSetting, eventsink);
|
||||
options.push_back(setting_cbox);
|
||||
|
||||
Add(setting_cbox->wxcontrol, 0, wxALL|wxLEFT, 5);
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -905,9 +885,9 @@ ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow
|
|||
size_t col_size = 0;
|
||||
|
||||
wxBoxSizer* stacked_groups = NULL;
|
||||
for (ControllerEmu::ControlGroup* group : controller->groups)
|
||||
for (auto& group : controller->groups)
|
||||
{
|
||||
ControlGroupBox* control_group_box = new ControlGroupBox(group, parent, eventsink);
|
||||
ControlGroupBox* control_group_box = new ControlGroupBox(group.get(), parent, eventsink);
|
||||
wxStaticBoxSizer *control_group =
|
||||
new wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->name)));
|
||||
control_group->Add(control_group_box);
|
||||
|
|
|
@ -8,55 +8,30 @@
|
|||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
|
||||
ControllerEmu::~ControllerEmu()
|
||||
{
|
||||
for (ControlGroup* cg : groups)
|
||||
delete cg;
|
||||
}
|
||||
|
||||
ControllerEmu::ControlGroup::~ControlGroup()
|
||||
{
|
||||
for (Control* c : controls)
|
||||
delete c;
|
||||
|
||||
for (Setting* s : settings)
|
||||
delete s;
|
||||
}
|
||||
|
||||
ControllerEmu::Extension::~Extension()
|
||||
{
|
||||
for (ControllerEmu* ai : attachments)
|
||||
delete ai;
|
||||
}
|
||||
ControllerEmu::ControlGroup::Control::~Control()
|
||||
{
|
||||
delete control_ref;
|
||||
}
|
||||
|
||||
void ControllerEmu::UpdateReferences(ControllerInterface& devi)
|
||||
{
|
||||
for (ControlGroup* cg : groups)
|
||||
for (auto& ctrlGroup : groups)
|
||||
{
|
||||
for (ControlGroup::Control* control : cg->controls)
|
||||
devi.UpdateReference(control->control_ref, default_device);
|
||||
for (auto& control : ctrlGroup->controls)
|
||||
devi.UpdateReference(control->control_ref.get(), default_device);
|
||||
|
||||
// extension
|
||||
if (GROUP_TYPE_EXTENSION == cg->type)
|
||||
if (ctrlGroup->type == GROUP_TYPE_EXTENSION)
|
||||
{
|
||||
for (ControllerEmu* ai : ((Extension*)cg)->attachments)
|
||||
ai->UpdateReferences(devi);
|
||||
for (auto& attachment : ((Extension*)ctrlGroup.get())->attachments)
|
||||
attachment->UpdateReferences(devi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerEmu::UpdateDefaultDevice()
|
||||
{
|
||||
for (ControlGroup* cg : groups)
|
||||
for (auto& ctrlGroup : groups)
|
||||
{
|
||||
// extension
|
||||
if (GROUP_TYPE_EXTENSION == cg->type)
|
||||
if (ctrlGroup->type == GROUP_TYPE_EXTENSION)
|
||||
{
|
||||
for (ControllerEmu* ai : ((Extension*)cg)->attachments)
|
||||
for (auto& ai : ((Extension*)ctrlGroup.get())->attachments)
|
||||
{
|
||||
ai->default_device = default_device;
|
||||
ai->UpdateDefaultDevice();
|
||||
|
@ -70,13 +45,13 @@ void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::s
|
|||
std::string group(base + name); group += "/";
|
||||
|
||||
// settings
|
||||
for (Setting* s : settings)
|
||||
for (auto& s : settings)
|
||||
{
|
||||
sec->Get((group + s->name).c_str(), &s->value, s->default_value * 100);
|
||||
s->value /= 100;
|
||||
}
|
||||
|
||||
for (Control* c : controls)
|
||||
for (auto& c : controls)
|
||||
{
|
||||
// control expression
|
||||
sec->Get((group + c->name).c_str(), &c->control_ref->expression, "");
|
||||
|
@ -88,7 +63,7 @@ void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::s
|
|||
}
|
||||
|
||||
// extensions
|
||||
if (GROUP_TYPE_EXTENSION == type)
|
||||
if (type == GROUP_TYPE_EXTENSION)
|
||||
{
|
||||
Extension* const ext = ((Extension*)this);
|
||||
|
||||
|
@ -97,7 +72,7 @@ void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::s
|
|||
std::string extname;
|
||||
sec->Get((base + name).c_str(), &extname, "");
|
||||
|
||||
for (ControllerEmu* ai : ext->attachments)
|
||||
for (auto& ai : ext->attachments)
|
||||
{
|
||||
ai->default_device.FromString(defdev);
|
||||
ai->LoadConfig(sec, base + ai->GetName() + "/");
|
||||
|
@ -119,7 +94,7 @@ void ControllerEmu::LoadConfig(IniFile::Section *sec, const std::string& base)
|
|||
default_device.FromString(defdev);
|
||||
}
|
||||
|
||||
for (ControlGroup* cg : groups)
|
||||
for (auto& cg : groups)
|
||||
cg->LoadConfig(sec, defdev, base);
|
||||
}
|
||||
|
||||
|
@ -127,10 +102,10 @@ void ControllerEmu::ControlGroup::SaveConfig(IniFile::Section *sec, const std::s
|
|||
{
|
||||
std::string group(base + name); group += "/";
|
||||
|
||||
for (Setting* s : settings)
|
||||
for (auto& s : settings)
|
||||
sec->Set((group + s->name).c_str(), s->value*100.0f, s->default_value*100.0f);
|
||||
|
||||
for (Control* c : controls)
|
||||
for (auto& c : controls)
|
||||
{
|
||||
// control expression
|
||||
sec->Set((group + c->name).c_str(), c->control_ref->expression, "");
|
||||
|
@ -140,12 +115,12 @@ void ControllerEmu::ControlGroup::SaveConfig(IniFile::Section *sec, const std::s
|
|||
}
|
||||
|
||||
// extensions
|
||||
if (GROUP_TYPE_EXTENSION == type)
|
||||
if (type == GROUP_TYPE_EXTENSION)
|
||||
{
|
||||
Extension* const ext = ((Extension*)this);
|
||||
sec->Set((base + name).c_str(), ext->attachments[ext->switch_extension]->GetName(), "None");
|
||||
|
||||
for (ControllerEmu* ai : ext->attachments)
|
||||
for (auto& ai : ext->attachments)
|
||||
ai->SaveConfig(sec, base + ai->GetName() + "/");
|
||||
}
|
||||
}
|
||||
|
@ -156,58 +131,58 @@ void ControllerEmu::SaveConfig(IniFile::Section *sec, const std::string& base)
|
|||
if (base.empty())
|
||||
sec->Set((/*std::string(" ") +*/ base + "Device").c_str(), defdev, "");
|
||||
|
||||
for (ControlGroup* cg : groups)
|
||||
cg->SaveConfig(sec, defdev, base);
|
||||
for (auto& ctrlGroup : groups)
|
||||
ctrlGroup->SaveConfig(sec, defdev, base);
|
||||
}
|
||||
|
||||
ControllerEmu::AnalogStick::AnalogStick(const char* const _name) : ControlGroup(_name, GROUP_TYPE_STICK)
|
||||
{
|
||||
for (auto& named_direction : named_directions)
|
||||
controls.push_back(new Input(named_direction));
|
||||
controls.emplace_back(new Input(named_direction));
|
||||
|
||||
controls.push_back(new Input(_trans("Modifier")));
|
||||
controls.emplace_back(new Input(_trans("Modifier")));
|
||||
|
||||
settings.push_back(new Setting(_trans("Radius"), 0.7f, 0, 100));
|
||||
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
settings.push_back(new Setting(_trans("Square Stick"), 0));
|
||||
settings.emplace_back(new Setting(_trans("Radius"), 0.7f, 0, 100));
|
||||
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
settings.emplace_back(new Setting(_trans("Square Stick"), 0));
|
||||
|
||||
}
|
||||
|
||||
ControllerEmu::Buttons::Buttons(const char* const _name) : ControlGroup(_name, GROUP_TYPE_BUTTONS)
|
||||
{
|
||||
settings.push_back(new Setting(_trans("Threshold"), 0.5f));
|
||||
settings.emplace_back(new Setting(_trans("Threshold"), 0.5f));
|
||||
}
|
||||
|
||||
ControllerEmu::MixedTriggers::MixedTriggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_MIXED_TRIGGERS)
|
||||
{
|
||||
settings.push_back(new Setting(_trans("Threshold"), 0.9f));
|
||||
settings.emplace_back(new Setting(_trans("Threshold"), 0.9f));
|
||||
}
|
||||
|
||||
ControllerEmu::Triggers::Triggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_TRIGGERS)
|
||||
{
|
||||
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
ControllerEmu::Slider::Slider(const char* const _name) : ControlGroup(_name, GROUP_TYPE_SLIDER)
|
||||
{
|
||||
controls.push_back(new Input("Left"));
|
||||
controls.push_back(new Input("Right"));
|
||||
controls.emplace_back(new Input("Left"));
|
||||
controls.emplace_back(new Input("Right"));
|
||||
|
||||
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
ControllerEmu::Force::Force(const char* const _name) : ControlGroup(_name, GROUP_TYPE_FORCE)
|
||||
{
|
||||
memset(m_swing, 0, sizeof(m_swing));
|
||||
|
||||
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")));
|
||||
controls.emplace_back(new Input(_trans("Up")));
|
||||
controls.emplace_back(new Input(_trans("Down")));
|
||||
controls.emplace_back(new Input(_trans("Left")));
|
||||
controls.emplace_back(new Input(_trans("Right")));
|
||||
controls.emplace_back(new Input(_trans("Forward")));
|
||||
controls.emplace_back(new Input(_trans("Backward")));
|
||||
|
||||
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
ControllerEmu::Tilt::Tilt(const char* const _name)
|
||||
|
@ -215,16 +190,16 @@ ControllerEmu::Tilt::Tilt(const char* const _name)
|
|||
{
|
||||
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.emplace_back(new Input("Forward"));
|
||||
controls.emplace_back(new Input("Backward"));
|
||||
controls.emplace_back(new Input("Left"));
|
||||
controls.emplace_back(new Input("Right"));
|
||||
|
||||
controls.push_back(new Input(_trans("Modifier")));
|
||||
controls.emplace_back(new Input(_trans("Modifier")));
|
||||
|
||||
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
settings.push_back(new Setting(_trans("Circle Stick"), 0));
|
||||
settings.push_back(new Setting(_trans("Angle"), 0.9f, 0, 180));
|
||||
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
settings.emplace_back(new Setting(_trans("Circle Stick"), 0));
|
||||
settings.emplace_back(new Setting(_trans("Angle"), 0.9f, 0, 180));
|
||||
}
|
||||
|
||||
ControllerEmu::Cursor::Cursor(const char* const _name)
|
||||
|
@ -232,14 +207,14 @@ ControllerEmu::Cursor::Cursor(const char* const _name)
|
|||
, m_z(0)
|
||||
{
|
||||
for (auto& named_direction : named_directions)
|
||||
controls.push_back(new Input(named_direction));
|
||||
controls.push_back(new Input("Forward"));
|
||||
controls.push_back(new Input("Backward"));
|
||||
controls.push_back(new Input(_trans("Hide")));
|
||||
controls.emplace_back(new Input(named_direction));
|
||||
controls.emplace_back(new Input("Forward"));
|
||||
controls.emplace_back(new Input("Backward"));
|
||||
controls.emplace_back(new Input(_trans("Hide")));
|
||||
|
||||
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));
|
||||
settings.emplace_back(new Setting(_trans("Center"), 0.5f));
|
||||
settings.emplace_back(new Setting(_trans("Width"), 0.5f));
|
||||
settings.emplace_back(new Setting(_trans("Height"), 0.5f));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define NOMINMAX
|
||||
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
@ -62,11 +63,11 @@ public:
|
|||
{
|
||||
protected:
|
||||
Control(ControllerInterface::ControlReference* const _ref, const char* const _name)
|
||||
: control_ref(_ref), name(_name){}
|
||||
public:
|
||||
: control_ref(_ref), name(_name) {}
|
||||
|
||||
virtual ~Control();
|
||||
ControllerInterface::ControlReference* const control_ref;
|
||||
public:
|
||||
virtual ~Control() {}
|
||||
std::unique_ptr<ControllerInterface::ControlReference> const control_ref;
|
||||
const char* const name;
|
||||
|
||||
};
|
||||
|
@ -77,7 +78,6 @@ public:
|
|||
|
||||
Input(const char* const _name)
|
||||
: Control(new ControllerInterface::InputReference, _name) {}
|
||||
|
||||
};
|
||||
|
||||
class Output : public Control
|
||||
|
@ -86,7 +86,6 @@ public:
|
|||
|
||||
Output(const char* const _name)
|
||||
: Control(new ControllerInterface::OutputReference, _name) {}
|
||||
|
||||
};
|
||||
|
||||
class Setting
|
||||
|
@ -108,7 +107,7 @@ public:
|
|||
};
|
||||
|
||||
ControlGroup(const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {}
|
||||
virtual ~ControlGroup();
|
||||
virtual ~ControlGroup() {}
|
||||
|
||||
virtual void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
||||
virtual void SaveConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
||||
|
@ -116,8 +115,8 @@ public:
|
|||
const char* const name;
|
||||
const unsigned int type;
|
||||
|
||||
std::vector<Control*> controls;
|
||||
std::vector<Setting*> settings;
|
||||
std::vector<std::unique_ptr<Control>> controls;
|
||||
std::vector<std::unique_ptr<Setting>> settings;
|
||||
|
||||
};
|
||||
|
||||
|
@ -194,7 +193,7 @@ public:
|
|||
template <typename C>
|
||||
void GetState(C* const buttons, const C* bitmasks)
|
||||
{
|
||||
for (Control* control : controls)
|
||||
for (auto& control : controls)
|
||||
{
|
||||
if (control->control_ref->State() > settings[0]->value) // threshold
|
||||
*buttons |= *bitmasks;
|
||||
|
@ -425,17 +424,18 @@ public:
|
|||
: ControlGroup(_name, GROUP_TYPE_EXTENSION)
|
||||
, switch_extension(0)
|
||||
, active_extension(0) {}
|
||||
~Extension();
|
||||
|
||||
~Extension() {}
|
||||
|
||||
void GetState(u8* const data, const bool focus = true);
|
||||
|
||||
std::vector<ControllerEmu*> attachments;
|
||||
std::vector<std::unique_ptr<ControllerEmu>> attachments;
|
||||
|
||||
int switch_extension;
|
||||
int active_extension;
|
||||
};
|
||||
|
||||
virtual ~ControllerEmu();
|
||||
virtual ~ControllerEmu() {}
|
||||
|
||||
virtual std::string GetName() const = 0;
|
||||
|
||||
|
@ -447,7 +447,7 @@ public:
|
|||
|
||||
void UpdateReferences(ControllerInterface& devi);
|
||||
|
||||
std::vector<ControlGroup*> groups;
|
||||
std::vector<std::unique_ptr<ControlGroup>> groups;
|
||||
|
||||
DeviceQualifier default_device;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue