2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:43:35 -06:00
|
|
|
// 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
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
#define SLIDER_TICK_COUNT 100
|
|
|
|
#define DETECT_WAIT_TIME 2500
|
|
|
|
#define PREVIEW_UPDATE_TIME 25
|
|
|
|
#define DEFAULT_HIGH_VALUE 100
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2015-01-12 20:28:12 -07:00
|
|
|
// might have to change this setup for Wiimote
|
2016-06-24 02:43:46 -06: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/dialog.h>
|
2015-09-19 19:36:24 -06:00
|
|
|
#include <wx/eventfilter.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>
|
2015-02-11 07:07:16 -07:00
|
|
|
#include <wx/timer.h>
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
|
|
|
|
2017-02-08 20:15:43 -07:00
|
|
|
class ControlReference;
|
2016-08-02 00:22:48 -06:00
|
|
|
class DolphinSlider;
|
2014-08-30 22:04:15 -06:00
|
|
|
class InputConfig;
|
2017-04-04 13:37:31 -06:00
|
|
|
class InputConfigDialog;
|
2014-02-22 15:36:30 -07:00
|
|
|
class wxComboBox;
|
|
|
|
class wxListBox;
|
|
|
|
class wxStaticBitmap;
|
|
|
|
class wxStaticText;
|
|
|
|
class wxTextCtrl;
|
2010-07-05 04:46:32 -06:00
|
|
|
|
2017-02-08 20:15:43 -07:00
|
|
|
namespace ControllerEmu
|
|
|
|
{
|
2017-04-04 13:37:31 -06:00
|
|
|
class BooleanSetting;
|
|
|
|
class ControlGroup;
|
2017-02-08 20:15:43 -07:00
|
|
|
class EmulatedController;
|
|
|
|
class Extension;
|
2017-04-04 13:37:31 -06:00
|
|
|
class NumericSetting;
|
2017-02-08 20:15:43 -07: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:
|
2016-12-31 16:46:56 -07:00
|
|
|
PadSetting(wxControl* const _control);
|
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
public:
|
2016-06-24 02:43:46 -06:00
|
|
|
virtual void UpdateGUI() = 0;
|
|
|
|
virtual void UpdateValue() = 0;
|
2010-07-03 02:04:10 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
virtual ~PadSetting() {}
|
|
|
|
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:
|
2016-06-24 02:43:46 -06:00
|
|
|
PadSettingExtension(wxWindow* const parent, ControllerEmu::Extension* const ext);
|
|
|
|
void UpdateGUI() override;
|
|
|
|
void UpdateValue() override;
|
2010-04-12 23:15:38 -06:00
|
|
|
|
2016-06-24 02:43:46 -06: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:
|
2017-02-26 13:00:24 -07:00
|
|
|
PadSettingSpin(wxWindow* const parent, ControllerEmu::NumericSetting* const setting);
|
2016-06-24 02:43:46 -06:00
|
|
|
void UpdateGUI() override;
|
|
|
|
void UpdateValue() override;
|
|
|
|
|
2017-02-26 13:00:24 -07:00
|
|
|
ControllerEmu::NumericSetting* 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:
|
2017-02-26 13:00:24 -07:00
|
|
|
PadSettingCheckBox(wxWindow* const parent, ControllerEmu::BooleanSetting* const setting);
|
2016-06-24 02:43:46 -06:00
|
|
|
void UpdateGUI() override;
|
|
|
|
void UpdateValue() override;
|
2010-04-07 21:33:16 -06:00
|
|
|
|
2017-02-26 13:00:24 -07:00
|
|
|
ControllerEmu::BooleanSetting* const setting;
|
2010-04-12 23:15:38 -06:00
|
|
|
};
|
2010-04-07 21:33:16 -06:00
|
|
|
|
2015-09-19 19:36:24 -06:00
|
|
|
class InputEventFilter : public wxEventFilter
|
|
|
|
{
|
|
|
|
public:
|
2016-12-31 16:46:56 -07:00
|
|
|
InputEventFilter();
|
|
|
|
~InputEventFilter();
|
2016-06-24 02:43:46 -06:00
|
|
|
int FilterEvent(wxEvent& event) override;
|
2015-09-19 19:36:24 -06:00
|
|
|
|
2016-12-31 16:46:56 -07:00
|
|
|
void BlockEvents(bool block);
|
|
|
|
|
2015-09-19 19:36:24 -06:00
|
|
|
private:
|
2016-12-31 16:46:56 -07:00
|
|
|
static bool ShouldCatchEventType(wxEventType type);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
bool m_block = false;
|
2015-09-19 19:36:24 -06:00
|
|
|
};
|
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
class ControlDialog : public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
2016-10-11 18:48:38 -06:00
|
|
|
ControlDialog(InputConfigDialog* const parent, InputConfig& config, ControlReference* const ref);
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
bool Validate() override;
|
2010-06-20 21:12:16 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
int GetRangeSliderValue() const;
|
2013-07-22 00:48:07 -06:00
|
|
|
|
2016-10-11 18:48:38 -06:00
|
|
|
ControlReference* const control_reference;
|
2016-06-24 02:43:46 -06:00
|
|
|
InputConfig& m_config;
|
2015-04-27 18:48:04 -06:00
|
|
|
|
|
|
|
private:
|
2016-11-18 00:03:06 -07:00
|
|
|
wxStaticBoxSizer* CreateControlChooser(InputConfigDialog* parent);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
void UpdateGUI();
|
|
|
|
void UpdateListContents();
|
|
|
|
void SelectControl(const std::string& name);
|
|
|
|
|
|
|
|
void DetectControl(wxCommandEvent& event);
|
|
|
|
void ClearControl(wxCommandEvent& event);
|
|
|
|
void SetDevice(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void SetSelectedControl(wxCommandEvent& event);
|
|
|
|
void AppendControl(wxCommandEvent& event);
|
2016-08-02 00:22:48 -06:00
|
|
|
void OnRangeSlide(wxScrollEvent&);
|
|
|
|
void OnRangeSpin(wxSpinEvent&);
|
|
|
|
void OnRangeThumbtrack(wxScrollEvent&);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
bool GetExpressionForSelectedControl(wxString& expr);
|
|
|
|
|
2016-11-18 00:03:06 -07:00
|
|
|
InputConfigDialog* m_parent;
|
2016-06-24 02:43:46 -06:00
|
|
|
wxComboBox* device_cbox;
|
|
|
|
wxTextCtrl* textctrl;
|
|
|
|
wxListBox* control_lbox;
|
2016-08-02 00:22:48 -06:00
|
|
|
DolphinSlider* m_range_slider;
|
|
|
|
wxSpinCtrl* m_range_spinner;
|
2016-06-24 02:43:46 -06:00
|
|
|
wxStaticText* m_bound_label;
|
|
|
|
wxStaticText* m_error_label;
|
|
|
|
InputEventFilter m_event_filter;
|
|
|
|
ciface::Core::DeviceQualifier m_devq;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
|
|
|
|
2010-04-12 23:15:38 -06:00
|
|
|
class ExtensionButton : public wxButton
|
|
|
|
{
|
|
|
|
public:
|
2016-12-31 16:46:56 -07:00
|
|
|
ExtensionButton(wxWindow* const parent, ControllerEmu::Extension* const ext);
|
2016-06-24 02:43:46 -06: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:
|
2016-10-11 18:48:38 -06:00
|
|
|
ControlButton(wxWindow* const parent, ControlReference* const _ref, const std::string& name,
|
|
|
|
const unsigned int width, const std::string& label = {});
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-10-11 18:48:38 -06:00
|
|
|
ControlReference* const control_reference;
|
2016-07-17 06:32:06 -06:00
|
|
|
const std::string m_name;
|
2016-08-02 00:22:48 -06:00
|
|
|
|
|
|
|
protected:
|
|
|
|
wxSize DoGetBestSize() const override;
|
|
|
|
|
|
|
|
int m_configured_width = wxDefaultCoord;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
|
|
|
|
2016-11-18 00:03:06 -07:00
|
|
|
class ControlGroupBox : public wxStaticBoxSizer
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
public:
|
2016-06-24 02:43:46 -06:00
|
|
|
ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent,
|
2016-11-18 00:03:06 -07:00
|
|
|
InputConfigDialog* eventsink);
|
2016-06-24 02:43:46 -06:00
|
|
|
~ControlGroupBox();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-12-31 16:46:56 -07:00
|
|
|
bool HasBitmapHeading() const;
|
2016-08-02 00:22:48 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
std::vector<PadSetting*> options;
|
2010-08-15 14:33:07 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
ControllerEmu::ControlGroup* const control_group;
|
|
|
|
wxStaticBitmap* static_bitmap;
|
|
|
|
std::vector<ControlButton*> control_buttons;
|
2016-08-02 00:22:48 -06:00
|
|
|
double m_scale;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
|
|
|
|
2016-11-18 00:03:06 -07:00
|
|
|
class InputConfigDialog : public wxDialog
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
public:
|
2016-11-18 00:03:06 -07:00
|
|
|
InputConfigDialog(wxWindow* const parent, InputConfig& config, const wxString& name,
|
|
|
|
const int port_num = 0);
|
|
|
|
virtual ~InputConfigDialog() = default;
|
|
|
|
|
|
|
|
void OnClose(wxCloseEvent& event);
|
|
|
|
void OnCloseButton(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void UpdateDeviceComboBox();
|
|
|
|
void UpdateProfileComboBox();
|
|
|
|
|
|
|
|
void UpdateControlReferences();
|
|
|
|
void UpdateBitmaps(wxTimerEvent&);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void UpdateGUI();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void RefreshDevices(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void LoadProfile(wxCommandEvent& event);
|
|
|
|
void SaveProfile(wxCommandEvent& event);
|
|
|
|
void DeleteProfile(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void ConfigControl(wxEvent& event);
|
|
|
|
void ClearControl(wxEvent& event);
|
|
|
|
void DetectControl(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void ConfigExtension(wxCommandEvent& event);
|
2010-04-12 23:15:38 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void SetDevice(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void ClearAll(wxCommandEvent& event);
|
|
|
|
void LoadDefaults(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void AdjustControlOption(wxCommandEvent& event);
|
2016-07-17 06:32:06 -06:00
|
|
|
void EnablePadSetting(const std::string& group_name, const std::string& name, bool enabled);
|
|
|
|
void EnableControlButton(const std::string& group_name, const std::string& name, bool enabled);
|
2016-06-24 02:43:46 -06:00
|
|
|
void AdjustSetting(wxCommandEvent& event);
|
2016-07-13 04:49:28 -06:00
|
|
|
void AdjustBooleanSetting(wxCommandEvent& event);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void GetProfilePath(std::string& path);
|
2017-02-08 20:15:43 -07:00
|
|
|
ControllerEmu::EmulatedController* GetController() const;
|
2010-06-20 21:12:16 -06:00
|
|
|
|
2016-11-18 00:03:06 -07:00
|
|
|
wxComboBox* profile_cbox = nullptr;
|
|
|
|
wxComboBox* device_cbox = nullptr;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
std::vector<ControlGroupBox*> control_groups;
|
|
|
|
std::vector<ControlButton*> control_buttons;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
protected:
|
2016-11-18 00:03:06 -07:00
|
|
|
wxBoxSizer* CreateDeviceChooserGroupBox();
|
|
|
|
wxBoxSizer* CreaterResetGroupBox(wxOrientation orientation);
|
|
|
|
wxBoxSizer* CreateProfileChooserGroupBox();
|
|
|
|
|
2017-02-08 20:15:43 -07:00
|
|
|
ControllerEmu::EmulatedController* const controller;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2017-02-07 19:24:07 -07:00
|
|
|
bool m_iterate = false;
|
2016-11-18 00:03:06 -07:00
|
|
|
wxTimer m_update_timer;
|
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
private:
|
2016-06-24 02:43:46 -06:00
|
|
|
InputConfig& m_config;
|
2016-11-18 00:03:06 -07:00
|
|
|
int m_port_num;
|
|
|
|
ControlDialog* m_control_dialog;
|
2016-06-24 02:43:46 -06:00
|
|
|
InputEventFilter m_event_filter;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
bool DetectButton(ControlButton* button);
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|