2013-04-17 21:43:35 -06:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2010-06-12 11:15:16 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
#define SLIDER_TICK_COUNT 100
|
2014-09-02 10:53:03 -06:00
|
|
|
#define DETECT_WAIT_TIME 2500
|
2014-02-16 21:51:41 -07:00
|
|
|
#define PREVIEW_UPDATE_TIME 25
|
2014-09-06 22:25:06 -06:00
|
|
|
#define DEFAULT_HIGH_VALUE 100
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
// might have to change this setup for wiimote
|
2014-02-16 21:51:41 -07:00
|
|
|
#define PROFILES_PATH "Profiles/"
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <cstddef>
|
|
|
|
#include <string>
|
2014-02-17 03:18:15 -07:00
|
|
|
#include <vector>
|
2010-04-01 20:48:24 -06:00
|
|
|
#include <wx/button.h>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <wx/control.h>
|
|
|
|
#include <wx/dialog.h>
|
|
|
|
#include <wx/gdicmn.h>
|
2010-04-01 20:48:24 -06:00
|
|
|
#include <wx/panel.h>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <wx/sizer.h>
|
2010-06-04 23:30:23 -06:00
|
|
|
#include <wx/spinctrl.h>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/translation.h>
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "InputCommon/ControllerEmu.h"
|
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
|
|
|
|
2014-08-30 22:04:15 -06:00
|
|
|
class InputConfig;
|
2014-02-22 15:36:30 -07:00
|
|
|
class wxComboBox;
|
|
|
|
class wxCommandEvent;
|
|
|
|
class wxEvent;
|
|
|
|
class wxListBox;
|
|
|
|
class wxNotebook;
|
|
|
|
class wxSlider;
|
|
|
|
class wxStaticBitmap;
|
|
|
|
class wxStaticText;
|
|
|
|
class wxTextCtrl;
|
|
|
|
class wxTimer;
|
|
|
|
class wxTimerEvent;
|
|
|
|
class wxWindow;
|
2010-07-05 04:46:32 -06:00
|
|
|
|
2010-04-07 21:33:16 -06:00
|
|
|
class PadSetting
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
2010-04-07 21:33:16 -06:00
|
|
|
protected:
|
2010-07-03 02:04:10 -06:00
|
|
|
PadSetting(wxControl* const _control) : wxcontrol(_control) { wxcontrol->SetClientData(this); }
|
2010-04-07 21:33:16 -06:00
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
public:
|
2010-04-07 21:33:16 -06:00
|
|
|
virtual void UpdateGUI() = 0;
|
|
|
|
virtual void UpdateValue() = 0;
|
2010-07-03 02:04:10 -06:00
|
|
|
|
|
|
|
virtual ~PadSetting() {}
|
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
wxControl* const wxcontrol;
|
2010-04-12 23:15:38 -06:00
|
|
|
};
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-07-03 02:04:10 -06:00
|
|
|
class PadSettingExtension : public PadSetting
|
2010-04-12 23:15:38 -06:00
|
|
|
{
|
|
|
|
public:
|
2010-07-03 02:04:10 -06:00
|
|
|
PadSettingExtension(wxWindow* const parent, ControllerEmu::Extension* const ext);
|
2014-03-07 17:54:44 -07:00
|
|
|
void UpdateGUI() override;
|
|
|
|
void UpdateValue() override;
|
2010-04-12 23:15:38 -06:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
ControllerEmu::Extension* const extension;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
|
|
|
|
2010-07-03 02:04:10 -06:00
|
|
|
class PadSettingSpin : public PadSetting
|
2010-04-07 21:33:16 -06:00
|
|
|
{
|
|
|
|
public:
|
2014-07-11 08:31:06 -06:00
|
|
|
PadSettingSpin(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const _setting)
|
|
|
|
: PadSetting(new wxSpinCtrl(parent, -1, wxEmptyString, wxDefaultPosition,
|
|
|
|
wxSize(54, -1), 0, _setting->low, _setting->high, (int)(_setting->value * 100)))
|
|
|
|
, setting(_setting) {}
|
2010-06-04 23:30:23 -06:00
|
|
|
|
2014-03-07 17:54:44 -07:00
|
|
|
void UpdateGUI() override;
|
|
|
|
void UpdateValue() override;
|
2010-04-12 23:15:38 -06:00
|
|
|
|
2014-07-11 08:31:06 -06:00
|
|
|
ControllerEmu::ControlGroup::Setting* const setting;
|
2010-04-07 21:33:16 -06:00
|
|
|
};
|
|
|
|
|
2010-07-03 02:04:10 -06:00
|
|
|
class PadSettingCheckBox : public PadSetting
|
2010-04-07 21:33:16 -06:00
|
|
|
{
|
|
|
|
public:
|
2014-07-11 08:31:06 -06:00
|
|
|
PadSettingCheckBox(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const setting);
|
2014-03-07 17:54:44 -07:00
|
|
|
void UpdateGUI() override;
|
|
|
|
void UpdateValue() override;
|
2010-04-07 21:33:16 -06:00
|
|
|
|
2014-07-11 08:31:06 -06:00
|
|
|
ControllerEmu::ControlGroup::Setting* const setting;
|
2010-04-12 23:15:38 -06:00
|
|
|
};
|
2010-04-07 21:33:16 -06:00
|
|
|
|
2010-06-15 20:57:50 -06:00
|
|
|
class GamepadPage;
|
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
class ControlDialog : public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
2014-08-30 22:04:15 -06:00
|
|
|
ControlDialog(GamepadPage* const parent, InputConfig& config, ControllerInterface::ControlReference* const ref);
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-01-13 01:28:12 -07:00
|
|
|
wxStaticBoxSizer* CreateControlChooser(GamepadPage* const parent);
|
2010-06-20 21:12:16 -06:00
|
|
|
|
2014-03-07 17:54:44 -07:00
|
|
|
virtual bool Validate() override;
|
2013-07-22 00:48:07 -06:00
|
|
|
|
2010-06-20 21:12:16 -06: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 02:04:10 -06:00
|
|
|
void SetSelectedControl(wxCommandEvent& event);
|
2010-06-20 21:12:16 -06:00
|
|
|
void AppendControl(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
ControllerInterface::ControlReference* const control_reference;
|
2014-08-30 22:04:15 -06:00
|
|
|
InputConfig& m_config;
|
2014-02-16 21:51:41 -07:00
|
|
|
wxComboBox* device_cbox;
|
2010-06-20 21:12:16 -06:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
wxTextCtrl* textctrl;
|
|
|
|
wxListBox* control_lbox;
|
|
|
|
wxSlider* range_slider;
|
2010-06-20 21:12:16 -06:00
|
|
|
|
|
|
|
private:
|
2014-02-16 21:51:41 -07:00
|
|
|
GamepadPage* const m_parent;
|
|
|
|
wxStaticText* m_bound_label;
|
|
|
|
wxStaticText* m_error_label;
|
2014-09-04 18:41:42 -06:00
|
|
|
ciface::Core::DeviceQualifier m_devq;
|
2013-06-17 03:55:21 -06:00
|
|
|
bool GetExpressionForSelectedControl(wxString &expr);
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
class ExtensionButton : public wxButton
|
|
|
|
{
|
|
|
|
public:
|
2011-01-13 20:05:02 -07:00
|
|
|
ExtensionButton(wxWindow* const parent, ControllerEmu::Extension* const ext)
|
|
|
|
: wxButton(parent, -1, _("Configure"), wxDefaultPosition)
|
2010-04-12 23:15:38 -06:00
|
|
|
, extension(ext) {}
|
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
ControllerEmu::Extension* const extension;
|
2010-04-12 23:15:38 -06:00
|
|
|
};
|
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
class ControlButton : public wxButton
|
|
|
|
{
|
|
|
|
public:
|
2011-01-13 20:05:02 -07:00
|
|
|
ControlButton(wxWindow* const parent, ControllerInterface::ControlReference* const _ref, const unsigned int width, const std::string& label = "");
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
ControllerInterface::ControlReference* const control_reference;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
|
|
|
|
2011-01-31 15:19:30 -07:00
|
|
|
class ControlGroupBox : public wxBoxSizer
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
public:
|
2013-01-13 01:28:12 -07:00
|
|
|
ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, GamepadPage* const eventsink);
|
2010-08-15 14:33:07 -06:00
|
|
|
~ControlGroupBox();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
std::vector<PadSetting*> options;
|
2010-08-15 14:33:07 -06:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
ControllerEmu::ControlGroup* const control_group;
|
|
|
|
wxStaticBitmap* static_bitmap;
|
|
|
|
std::vector<ControlButton*> control_buttons;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
class ControlGroupsSizer : public wxBoxSizer
|
|
|
|
{
|
|
|
|
public:
|
2014-03-09 14:14:26 -06:00
|
|
|
ControlGroupsSizer(ControllerEmu* const controller, wxWindow* const parent, GamepadPage* const eventsink, std::vector<ControlGroupBox*>* const groups = nullptr);
|
2010-04-12 23:15:38 -06:00
|
|
|
};
|
|
|
|
|
2010-06-12 12:45:39 -06:00
|
|
|
class InputConfigDialog;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2012-03-23 01:27:54 -06:00
|
|
|
class GamepadPage : public wxPanel
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
2010-06-12 12:45:39 -06:00
|
|
|
friend class InputConfigDialog;
|
2010-06-20 21:12:16 -06:00
|
|
|
friend class ControlDialog;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
public:
|
2014-08-30 22:04:15 -06:00
|
|
|
GamepadPage(wxWindow* parent, InputConfig& config, const unsigned int pad_num, InputConfigDialog* const config_dialog);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
void UpdateGUI();
|
|
|
|
|
2011-01-13 20:05:02 -07:00
|
|
|
void RefreshDevices(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2011-01-13 20:05:02 -07:00
|
|
|
void LoadProfile(wxCommandEvent& event);
|
|
|
|
void SaveProfile(wxCommandEvent& event);
|
|
|
|
void DeleteProfile(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2013-01-13 01:28:12 -07:00
|
|
|
void ConfigControl(wxEvent& event);
|
|
|
|
void ClearControl(wxEvent& event);
|
2011-01-13 20:05:02 -07:00
|
|
|
void DetectControl(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2011-01-13 20:05:02 -07:00
|
|
|
void ConfigExtension(wxCommandEvent& event);
|
2010-04-12 23:15:38 -06:00
|
|
|
|
2011-01-13 20:05:02 -07:00
|
|
|
void SetDevice(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2011-01-13 20:05:02 -07:00
|
|
|
void ClearAll(wxCommandEvent& event);
|
|
|
|
void LoadDefaults(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2011-01-13 20:05:02 -07:00
|
|
|
void AdjustControlOption(wxCommandEvent& event);
|
|
|
|
void AdjustSetting(wxCommandEvent& event);
|
2014-09-02 10:53:03 -06:00
|
|
|
void AdjustSettingUI(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2010-06-20 21:12:16 -06:00
|
|
|
void GetProfilePath(std::string& path);
|
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
wxComboBox* profile_cbox;
|
|
|
|
wxComboBox* device_cbox;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
std::vector<ControlGroupBox*> control_groups;
|
2014-06-14 17:15:41 -06:00
|
|
|
std::vector<ControlButton*> control_buttons;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
protected:
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
ControllerEmu* const controller;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
ControlDialog* m_control_dialog;
|
|
|
|
InputConfigDialog* const m_config_dialog;
|
2014-08-30 22:04:15 -06:00
|
|
|
InputConfig& m_config;
|
2014-06-14 17:15:41 -06:00
|
|
|
bool DetectButton(ControlButton* button);
|
2014-09-02 10:53:03 -06:00
|
|
|
bool m_iterate = false;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
|
|
|
|
2010-06-12 12:45:39 -06:00
|
|
|
class InputConfigDialog : public wxDialog
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
public:
|
2014-08-30 22:04:15 -06:00
|
|
|
InputConfigDialog(wxWindow* const parent, InputConfig& config, const std::string& name, const int tab_num = 0);
|
2010-06-20 21:12:16 -06:00
|
|
|
//~InputConfigDialog();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-03-07 17:54:44 -07:00
|
|
|
bool Destroy() override;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2011-01-13 20:05:02 -07:00
|
|
|
void ClickSave(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
void UpdateDeviceComboBox();
|
|
|
|
void UpdateProfileComboBox();
|
|
|
|
|
|
|
|
void UpdateControlReferences();
|
|
|
|
void UpdateBitmaps(wxTimerEvent&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
wxNotebook* m_pad_notebook;
|
|
|
|
std::vector<GamepadPage*> m_padpages;
|
2014-08-30 22:04:15 -06:00
|
|
|
InputConfig& m_config;
|
2014-02-16 21:51:41 -07:00
|
|
|
wxTimer* m_update_timer;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|