2010-06-12 17:15:16 +00:00
|
|
|
// Copyright (C) 2010 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
#ifndef _CONFIGBOX_H_
|
|
|
|
#define _CONFIGBOX_H_
|
|
|
|
|
|
|
|
#define SLIDER_TICK_COUNT 100
|
|
|
|
#define DETECT_WAIT_TIME 1500
|
|
|
|
#define PREVIEW_UPDATE_TIME 25
|
|
|
|
|
|
|
|
// might have to change this setup for wiimote
|
2010-04-13 05:15:38 +00:00
|
|
|
#define PROFILES_PATH "Profiles/"
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
#include <wx/wx.h>
|
|
|
|
#include <wx/listbox.h>
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <wx/combobox.h>
|
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/notebook.h>
|
|
|
|
#include <wx/panel.h>
|
2010-06-05 05:30:23 +00:00
|
|
|
#include <wx/spinctrl.h>
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <vector>
|
|
|
|
|
2010-06-12 17:39:33 +00:00
|
|
|
#include "ControllerInterface/ControllerInterface.h"
|
|
|
|
#include "ControllerEmu.h"
|
|
|
|
#include "InputConfig.h"
|
2010-04-02 02:48:24 +00:00
|
|
|
#include "FileSearch.h"
|
2010-07-06 01:37:34 +00:00
|
|
|
#include "UDPWrapper.h"
|
2010-07-05 10:46:32 +00:00
|
|
|
|
2010-04-08 03:33:16 +00:00
|
|
|
class PadSetting
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-04-08 03:33:16 +00:00
|
|
|
protected:
|
2010-07-03 08:04:10 +00:00
|
|
|
PadSetting(wxControl* const _control) : wxcontrol(_control) { wxcontrol->SetClientData(this); }
|
2010-04-08 03:33:16 +00:00
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
public:
|
2010-04-08 03:33:16 +00:00
|
|
|
virtual void UpdateGUI() = 0;
|
|
|
|
virtual void UpdateValue() = 0;
|
2010-07-03 08:04:10 +00:00
|
|
|
|
|
|
|
virtual ~PadSetting() {}
|
|
|
|
|
|
|
|
wxControl* const wxcontrol;
|
2010-04-13 05:15:38 +00:00
|
|
|
};
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
class PadSettingExtension : public PadSetting
|
2010-04-13 05:15:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-07-03 08:04:10 +00:00
|
|
|
PadSettingExtension(wxWindow* const parent, ControllerEmu::Extension* const ext);
|
2010-04-13 05:15:38 +00:00
|
|
|
void UpdateGUI();
|
|
|
|
void UpdateValue();
|
|
|
|
|
|
|
|
ControllerEmu::Extension* const extension;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
class PadSettingSpin : public PadSetting
|
2010-04-08 03:33:16 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-07-03 08:04:10 +00:00
|
|
|
PadSettingSpin(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const setting)
|
|
|
|
: PadSetting(new wxSpinCtrl(parent, -1, wxEmptyString, wxDefaultPosition
|
2011-01-30 01:58:54 +00:00
|
|
|
, wxSize(54, -1), 0, setting->low, setting->high, (int)(setting->value * 100)))
|
2010-06-05 05:30:23 +00:00
|
|
|
, value(setting->value) {}
|
|
|
|
|
2010-04-08 03:33:16 +00:00
|
|
|
void UpdateGUI();
|
|
|
|
void UpdateValue();
|
2010-04-13 05:15:38 +00:00
|
|
|
|
2010-06-12 17:39:33 +00:00
|
|
|
ControlState& value;
|
2010-04-08 03:33:16 +00:00
|
|
|
};
|
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
class PadSettingCheckBox : public PadSetting
|
2010-04-08 03:33:16 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-07-03 08:04:10 +00:00
|
|
|
PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const char* const label);
|
2010-04-08 03:33:16 +00:00
|
|
|
void UpdateGUI();
|
|
|
|
void UpdateValue();
|
|
|
|
|
2010-04-13 05:15:38 +00:00
|
|
|
ControlState& value;
|
|
|
|
};
|
2010-04-08 03:33:16 +00:00
|
|
|
|
2010-06-16 02:57:50 +00:00
|
|
|
class GamepadPage;
|
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
class ControlDialog : public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
2010-06-16 02:57:50 +00:00
|
|
|
ControlDialog(GamepadPage* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref);
|
2010-04-14 23:50:33 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
wxStaticBoxSizer* CreateControlChooser(wxWindow* const parent, wxWindow* const eventsink);
|
2010-06-21 03:12:16 +00:00
|
|
|
|
|
|
|
void DetectControl(wxCommandEvent& event);
|
|
|
|
void ClearControl(wxCommandEvent& event);
|
|
|
|
void SetControl(wxCommandEvent& event);
|
|
|
|
void SetDevice(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void UpdateGUI();
|
|
|
|
void UpdateListContents();
|
|
|
|
void SelectControl(const std::string& name);
|
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
void SetSelectedControl(wxCommandEvent& event);
|
2010-06-21 03:12:16 +00:00
|
|
|
void AppendControl(wxCommandEvent& event);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
ControllerInterface::ControlReference* const control_reference;
|
2010-06-12 18:45:39 +00:00
|
|
|
InputPlugin& m_plugin;
|
2010-04-02 02:48:24 +00:00
|
|
|
wxComboBox* device_cbox;
|
2010-06-21 03:12:16 +00:00
|
|
|
|
|
|
|
wxTextCtrl* textctrl;
|
|
|
|
wxListBox* control_lbox;
|
|
|
|
wxSlider* range_slider;
|
|
|
|
|
|
|
|
private:
|
|
|
|
GamepadPage* const m_parent;
|
|
|
|
wxStaticText* m_bound_label;
|
|
|
|
ControllerInterface::DeviceQualifier m_devq;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
|
|
|
|
2010-04-13 05:15:38 +00:00
|
|
|
class ExtensionButton : public wxButton
|
|
|
|
{
|
|
|
|
public:
|
2011-01-14 03:05:02 +00:00
|
|
|
ExtensionButton(wxWindow* const parent, ControllerEmu::Extension* const ext)
|
|
|
|
: wxButton(parent, -1, _("Configure"), wxDefaultPosition)
|
2010-04-13 05:15:38 +00:00
|
|
|
, extension(ext) {}
|
|
|
|
|
|
|
|
ControllerEmu::Extension* const extension;
|
|
|
|
};
|
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
class ControlButton : public wxButton
|
|
|
|
{
|
|
|
|
public:
|
2011-01-14 03:05:02 +00:00
|
|
|
ControlButton(wxWindow* const parent, ControllerInterface::ControlReference* const _ref, const unsigned int width, const std::string& label = "");
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
ControllerInterface::ControlReference* const control_reference;
|
|
|
|
};
|
|
|
|
|
2010-07-05 10:46:32 +00:00
|
|
|
class UDPConfigButton : public wxButton
|
|
|
|
{
|
|
|
|
public:
|
2010-07-09 22:11:12 +00:00
|
|
|
UDPWrapper* const wrapper;
|
2011-01-14 03:05:02 +00:00
|
|
|
UDPConfigButton(wxWindow* const parent, UDPWrapper * udp)
|
|
|
|
: wxButton(parent, -1, _("Configure"), wxDefaultPosition)
|
2010-07-09 22:11:12 +00:00
|
|
|
, wrapper(udp)
|
2010-07-05 10:46:32 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
class ControlGroupBox : public wxStaticBoxSizer
|
|
|
|
{
|
|
|
|
public:
|
2011-01-14 03:05:02 +00:00
|
|
|
ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, wxWindow* const eventsink);
|
2010-08-15 20:33:07 +00:00
|
|
|
~ControlGroupBox();
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-08-15 20:33:07 +00:00
|
|
|
std::vector<PadSetting*> options;
|
|
|
|
|
|
|
|
ControllerEmu::ControlGroup* const control_group;
|
2010-04-02 02:48:24 +00:00
|
|
|
wxStaticBitmap* static_bitmap;
|
2010-08-15 20:33:07 +00:00
|
|
|
std::vector<ControlButton*> control_buttons;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
|
|
|
|
2010-04-13 05:15:38 +00:00
|
|
|
class ControlGroupsSizer : public wxBoxSizer
|
|
|
|
{
|
|
|
|
public:
|
2011-01-14 03:05:02 +00:00
|
|
|
ControlGroupsSizer(ControllerEmu* const controller, wxWindow* const parent, wxWindow* const eventsink, std::vector<ControlGroupBox*>* const groups = NULL);
|
2010-04-13 05:15:38 +00:00
|
|
|
};
|
|
|
|
|
2010-06-12 18:45:39 +00:00
|
|
|
class InputConfigDialog;
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
class GamepadPage : public wxNotebookPage
|
|
|
|
{
|
2010-06-12 18:45:39 +00:00
|
|
|
friend class InputConfigDialog;
|
2010-06-21 03:12:16 +00:00
|
|
|
friend class ControlDialog;
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
public:
|
2011-01-14 03:05:02 +00:00
|
|
|
GamepadPage(wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
void UpdateGUI();
|
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void RefreshDevices(wxCommandEvent& event);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void LoadProfile(wxCommandEvent& event);
|
|
|
|
void SaveProfile(wxCommandEvent& event);
|
|
|
|
void DeleteProfile(wxCommandEvent& event);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void ConfigControl(wxCommandEvent& event);
|
|
|
|
void ClearControl(wxCommandEvent& event);
|
|
|
|
void DetectControl(wxCommandEvent& event);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void ConfigExtension(wxCommandEvent& event);
|
2010-04-13 05:15:38 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void ConfigUDPWii(wxCommandEvent& event);
|
2010-07-05 10:46:32 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void SetDevice(wxCommandEvent& event);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void ClearAll(wxCommandEvent& event);
|
|
|
|
void LoadDefaults(wxCommandEvent& event);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void AdjustControlOption(wxCommandEvent& event);
|
|
|
|
void AdjustSetting(wxCommandEvent& event);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
void GetProfilePath(std::string& path);
|
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
wxComboBox* profile_cbox;
|
|
|
|
wxComboBox* device_cbox;
|
|
|
|
|
|
|
|
std::vector<ControlGroupBox*> control_groups;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
ControllerEmu* const controller;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
ControlDialog* m_control_dialog;
|
2010-06-21 03:12:16 +00:00
|
|
|
InputConfigDialog* const m_config_dialog;
|
2010-06-12 18:45:39 +00:00
|
|
|
InputPlugin &m_plugin;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
|
|
|
|
2010-06-12 18:45:39 +00:00
|
|
|
class InputConfigDialog : public wxDialog
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-01-14 03:05:02 +00:00
|
|
|
InputConfigDialog(wxWindow* const parent, InputPlugin& plugin, const std::string& name, const int tab_num = 0);
|
2010-06-21 03:12:16 +00:00
|
|
|
//~InputConfigDialog();
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-06-13 14:49:49 +00:00
|
|
|
bool Destroy();
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2011-01-14 03:05:02 +00:00
|
|
|
void ClickSave(wxCommandEvent& event);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
void UpdateDeviceComboBox();
|
|
|
|
void UpdateProfileComboBox();
|
|
|
|
|
|
|
|
void UpdateControlReferences();
|
|
|
|
void UpdateBitmaps(wxTimerEvent&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
wxNotebook* m_pad_notebook;
|
|
|
|
std::vector<GamepadPage*> m_padpages;
|
2010-06-12 18:45:39 +00:00
|
|
|
InputPlugin& m_plugin;
|
2010-04-02 02:48:24 +00:00
|
|
|
wxTimer* m_update_timer;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|