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