2013-04-18 03:43:35 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2010-06-12 17:15:16 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
#define SLIDER_TICK_COUNT 100
|
|
|
|
#define DETECT_WAIT_TIME 1500
|
|
|
|
#define PREVIEW_UPDATE_TIME 25
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
// might have to change this setup for wiimote
|
2014-02-17 04:51:41 +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() {}
|
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
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();
|
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
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)))
|
2014-02-17 04:51:41 +00:00
|
|
|
, value(setting->value) {}
|
2010-06-05 05:30:23 +00:00
|
|
|
|
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();
|
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
ControlState& value;
|
2010-04-13 05:15:38 +00:00
|
|
|
};
|
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);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-01-13 08:28:12 +00:00
|
|
|
wxStaticBoxSizer* CreateControlChooser(GamepadPage* const parent);
|
2010-06-21 03:12:16 +00:00
|
|
|
|
2013-07-22 06:48:07 +00:00
|
|
|
virtual bool Validate();
|
|
|
|
|
2010-06-21 03:12:16 +00:00
|
|
|
void DetectControl(wxCommandEvent& event);
|
|
|
|
void ClearControl(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
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
ControllerInterface::ControlReference* const control_reference;
|
|
|
|
InputPlugin& m_plugin;
|
|
|
|
wxComboBox* device_cbox;
|
2010-06-21 03:12:16 +00:00
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
wxTextCtrl* textctrl;
|
|
|
|
wxListBox* control_lbox;
|
|
|
|
wxSlider* range_slider;
|
2010-06-21 03:12:16 +00:00
|
|
|
|
|
|
|
private:
|
2014-02-17 04:51:41 +00:00
|
|
|
GamepadPage* const m_parent;
|
|
|
|
wxStaticText* m_bound_label;
|
|
|
|
wxStaticText* m_error_label;
|
|
|
|
DeviceQualifier m_devq;
|
2013-06-17 09:55:21 +00:00
|
|
|
bool GetExpressionForSelectedControl(wxString &expr);
|
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) {}
|
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
ControllerEmu::Extension* const extension;
|
2010-04-13 05:15:38 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
ControllerInterface::ControlReference* const control_reference;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2011-01-31 22:19:30 +00:00
|
|
|
class ControlGroupBox : public wxBoxSizer
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-01-13 08:28:12 +00:00
|
|
|
ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, GamepadPage* const eventsink);
|
2010-08-15 20:33:07 +00:00
|
|
|
~ControlGroupBox();
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
std::vector<PadSetting*> options;
|
2010-08-15 20:33:07 +00:00
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
ControllerEmu::ControlGroup* const control_group;
|
|
|
|
wxStaticBitmap* static_bitmap;
|
|
|
|
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:
|
2013-01-13 08:28:12 +00:00
|
|
|
ControlGroupsSizer(ControllerEmu* const controller, wxWindow* const parent, GamepadPage* 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
|
|
|
|
2012-03-23 07:27:54 +00:00
|
|
|
class GamepadPage : public wxPanel
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
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
|
|
|
|
2013-01-13 08:28:12 +00:00
|
|
|
void ConfigControl(wxEvent& event);
|
|
|
|
void ClearControl(wxEvent& event);
|
2011-01-14 03:05:02 +00:00
|
|
|
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);
|
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
wxComboBox* profile_cbox;
|
|
|
|
wxComboBox* device_cbox;
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
std::vector<ControlGroupBox*> control_groups;
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
protected:
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
ControllerEmu* const controller;
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
ControlDialog* m_control_dialog;
|
|
|
|
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:
|
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
wxNotebook* m_pad_notebook;
|
|
|
|
std::vector<GamepadPage*> m_padpages;
|
|
|
|
InputPlugin& m_plugin;
|
|
|
|
wxTimer* m_update_timer;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|