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