2013-04-17 21:09:55 -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-06-03 12:05:08 -06:00
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include <algorithm>
|
2010-06-13 03:26:00 -06:00
|
|
|
#include <cmath>
|
2014-02-01 15:20:35 -07:00
|
|
|
#include <memory>
|
2010-06-13 03:26:00 -06:00
|
|
|
#include <string>
|
2014-02-17 03:18:15 -07:00
|
|
|
#include <vector>
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/IniFile.h"
|
2014-07-11 08:42:44 -06:00
|
|
|
#include "Core/ConfigManager.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "InputCommon/GCPadStatus.h"
|
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
2010-06-03 12:05:08 -06:00
|
|
|
|
|
|
|
#define sign(x) ((x)?(x)<0?-1:1:0)
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
GROUP_TYPE_OTHER,
|
|
|
|
GROUP_TYPE_STICK,
|
|
|
|
GROUP_TYPE_MIXED_TRIGGERS,
|
|
|
|
GROUP_TYPE_BUTTONS,
|
|
|
|
GROUP_TYPE_FORCE,
|
|
|
|
GROUP_TYPE_EXTENSION,
|
|
|
|
GROUP_TYPE_TILT,
|
|
|
|
GROUP_TYPE_CURSOR,
|
|
|
|
GROUP_TYPE_TRIGGERS,
|
2010-10-05 15:43:51 -06:00
|
|
|
GROUP_TYPE_SLIDER,
|
2010-06-03 12:05:08 -06:00
|
|
|
};
|
|
|
|
|
2011-11-10 01:27:33 -07:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SETTING_RADIUS,
|
|
|
|
SETTING_DEADZONE,
|
|
|
|
};
|
|
|
|
|
2014-01-30 17:51:21 -07:00
|
|
|
const char* const named_directions[] =
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
|
|
|
"Up",
|
|
|
|
"Down",
|
|
|
|
"Left",
|
|
|
|
"Right"
|
|
|
|
};
|
|
|
|
|
|
|
|
class ControllerEmu
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
class ControlGroup
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
class Control
|
|
|
|
{
|
|
|
|
protected:
|
2014-03-12 13:33:41 -06:00
|
|
|
Control(ControllerInterface::ControlReference* const _ref, const std::string& _name)
|
2014-02-01 15:20:35 -07:00
|
|
|
: control_ref(_ref), name(_name) {}
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-02-01 15:20:35 -07:00
|
|
|
public:
|
|
|
|
virtual ~Control() {}
|
|
|
|
std::unique_ptr<ControllerInterface::ControlReference> const control_ref;
|
2014-03-12 13:33:41 -06:00
|
|
|
const std::string name;
|
2010-06-03 12:05:08 -06:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class Input : public Control
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
Input(const std::string& _name)
|
2011-01-13 20:05:02 -07:00
|
|
|
: Control(new ControllerInterface::InputReference, _name) {}
|
2010-06-03 12:05:08 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
class Output : public Control
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
Output(const std::string& _name)
|
2011-01-13 20:05:02 -07:00
|
|
|
: Control(new ControllerInterface::OutputReference, _name) {}
|
2010-06-03 12:05:08 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
class Setting
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
Setting(const std::string& _name, const ControlState def_value
|
2014-01-30 17:51:21 -07:00
|
|
|
, const unsigned int _low = 0, const unsigned int _high = 100)
|
2010-06-03 12:05:08 -06:00
|
|
|
: name(_name)
|
|
|
|
, value(def_value)
|
|
|
|
, default_value(def_value)
|
|
|
|
, low(_low)
|
2014-07-11 08:31:06 -06:00
|
|
|
, high(_high)
|
|
|
|
, is_virtual(false) {}
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
const std::string name;
|
2014-01-30 17:51:21 -07:00
|
|
|
ControlState value;
|
|
|
|
const ControlState default_value;
|
|
|
|
const unsigned int low, high;
|
2014-07-11 08:31:06 -06:00
|
|
|
bool is_virtual;
|
|
|
|
|
|
|
|
virtual void SetValue(ControlState new_value)
|
|
|
|
{
|
|
|
|
value = new_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ControlState GetValue()
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
2010-06-03 12:05:08 -06:00
|
|
|
};
|
|
|
|
|
2014-07-11 08:42:44 -06:00
|
|
|
class BackgroundInputSetting : public Setting
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BackgroundInputSetting(const std::string &_name) : Setting(_name, false)
|
|
|
|
{
|
|
|
|
is_virtual = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetValue(ControlState new_value) override
|
|
|
|
{
|
2014-08-19 21:19:12 -06:00
|
|
|
SConfig::GetInstance().m_BackgroundInput = !!new_value;
|
2014-07-11 08:42:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
ControlState GetValue() override
|
|
|
|
{
|
|
|
|
return SConfig::GetInstance().m_BackgroundInput;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
ControlGroup(const std::string& _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {}
|
2014-02-01 15:20:35 -07:00
|
|
|
virtual ~ControlGroup() {}
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2010-07-05 04:46:32 -06:00
|
|
|
virtual void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
|
|
|
virtual void SaveConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
const std::string name;
|
2014-01-30 17:51:21 -07:00
|
|
|
const unsigned int type;
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-02-01 15:20:35 -07:00
|
|
|
std::vector<std::unique_ptr<Control>> controls;
|
|
|
|
std::vector<std::unique_ptr<Setting>> settings;
|
2010-06-03 12:05:08 -06:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class AnalogStick : public ControlGroup
|
|
|
|
{
|
|
|
|
public:
|
2014-08-15 11:03:56 -06:00
|
|
|
// The GameCube controller and Wiimote attachments have a different default radius
|
|
|
|
AnalogStick(const char* const _name, ControlState default_radius);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 05:18:21 -06:00
|
|
|
void GetState(double* const x, double* const y)
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
|
|
|
ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
|
|
|
|
ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
|
|
|
|
|
2011-11-10 01:27:33 -07:00
|
|
|
ControlState radius = settings[SETTING_RADIUS]->value;
|
|
|
|
ControlState deadzone = settings[SETTING_DEADZONE]->value;
|
2010-06-03 12:05:08 -06:00
|
|
|
ControlState m = controls[4]->control_ref->State();
|
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
ControlState ang = atan2(yy, xx);
|
|
|
|
ControlState ang_sin = sin(ang);
|
|
|
|
ControlState ang_cos = cos(ang);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
ControlState dist = sqrt(xx*xx + yy*yy);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
// dead zone code
|
|
|
|
dist = std::max(0.0f, dist - deadzone);
|
|
|
|
dist /= (1 - deadzone);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
// radius
|
|
|
|
dist *= radius;
|
2011-11-10 01:27:33 -07:00
|
|
|
|
2014-07-11 06:11:33 -06:00
|
|
|
// The modifier halves the distance by 50%, which is useful
|
|
|
|
// for keyboard controls.
|
|
|
|
if (m)
|
|
|
|
dist *= 0.5;
|
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
yy = std::max(-1.0f, std::min(1.0f, ang_sin * dist));
|
|
|
|
xx = std::max(-1.0f, std::min(1.0f, ang_cos * dist));
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 05:18:21 -06:00
|
|
|
*y = yy;
|
|
|
|
*x = xx;
|
2010-06-03 12:05:08 -06:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class Buttons : public ControlGroup
|
|
|
|
{
|
|
|
|
public:
|
2014-03-12 13:33:41 -06:00
|
|
|
Buttons(const std::string& _name);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
|
|
|
template <typename C>
|
2011-01-13 20:05:02 -07:00
|
|
|
void GetState(C* const buttons, const C* bitmasks)
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
2014-02-01 15:20:35 -07:00
|
|
|
for (auto& control : controls)
|
2013-04-14 20:53:10 -06:00
|
|
|
{
|
2014-01-30 17:51:21 -07:00
|
|
|
if (control->control_ref->State() > settings[0]->value) // threshold
|
2010-06-03 12:05:08 -06:00
|
|
|
*buttons |= *bitmasks;
|
2014-01-30 17:51:21 -07:00
|
|
|
|
|
|
|
bitmasks++;
|
2013-04-14 20:53:10 -06:00
|
|
|
}
|
2010-06-03 12:05:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class MixedTriggers : public ControlGroup
|
|
|
|
{
|
|
|
|
public:
|
2014-06-17 14:10:23 -06:00
|
|
|
MixedTriggers(const std::string& _name);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 05:18:21 -06:00
|
|
|
void GetState(u16 *const digital, const u16* bitmasks, double* analog)
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
|
|
|
const unsigned int trig_count = ((unsigned int) (controls.size() / 2));
|
2011-01-13 20:05:02 -07:00
|
|
|
for (unsigned int i=0; i<trig_count; ++i,++bitmasks,++analog)
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
2011-01-13 20:05:02 -07:00
|
|
|
if (controls[i]->control_ref->State() > settings[0]->value) //threshold
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
2014-07-11 05:18:21 -06:00
|
|
|
*analog = 1.0;
|
2010-06-03 12:05:08 -06:00
|
|
|
*digital |= *bitmasks;
|
|
|
|
}
|
|
|
|
else
|
2013-04-14 20:53:10 -06:00
|
|
|
{
|
2014-07-11 05:18:21 -06:00
|
|
|
*analog = controls[i+trig_count]->control_ref->State();
|
2013-04-14 20:53:10 -06:00
|
|
|
}
|
2010-06-03 12:05:08 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class Triggers : public ControlGroup
|
|
|
|
{
|
|
|
|
public:
|
2014-06-17 14:10:23 -06:00
|
|
|
Triggers(const std::string& _name);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 05:18:21 -06:00
|
|
|
void GetState(double* analog)
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
|
|
|
const unsigned int trig_count = ((unsigned int) (controls.size()));
|
|
|
|
const ControlState deadzone = settings[0]->value;
|
2011-01-13 20:05:02 -07:00
|
|
|
for (unsigned int i=0; i<trig_count; ++i,++analog)
|
2014-07-11 05:18:21 -06:00
|
|
|
*analog = std::max(controls[i]->control_ref->State() - deadzone, 0.0f) / (1 - deadzone);
|
2010-06-03 12:05:08 -06:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-10-05 15:43:51 -06:00
|
|
|
class Slider : public ControlGroup
|
|
|
|
{
|
|
|
|
public:
|
2014-06-17 14:10:23 -06:00
|
|
|
Slider(const std::string& _name);
|
2010-10-05 15:43:51 -06:00
|
|
|
|
2014-07-11 05:18:21 -06:00
|
|
|
void GetState(double* const slider)
|
2010-10-05 15:43:51 -06:00
|
|
|
{
|
|
|
|
const float deadzone = settings[0]->value;
|
|
|
|
const float state = controls[1]->control_ref->State() - controls[0]->control_ref->State();
|
|
|
|
|
|
|
|
if (fabsf(state) > deadzone)
|
2014-07-11 05:18:21 -06:00
|
|
|
*slider = (state - (deadzone * sign(state))) / (1 - deadzone);
|
2010-10-05 15:43:51 -06:00
|
|
|
else
|
|
|
|
*slider = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-06-03 12:05:08 -06:00
|
|
|
class Force : public ControlGroup
|
|
|
|
{
|
|
|
|
public:
|
2014-03-12 13:33:41 -06:00
|
|
|
Force(const std::string& _name);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 05:18:21 -06:00
|
|
|
void GetState(double* axis)
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
|
|
|
const float deadzone = settings[0]->value;
|
2010-07-25 23:30:50 -06:00
|
|
|
for (unsigned int i=0; i<6; i+=2)
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
2010-07-25 23:30:50 -06:00
|
|
|
float tmpf = 0;
|
2010-06-03 12:05:08 -06:00
|
|
|
const float state = controls[i+1]->control_ref->State() - controls[i]->control_ref->State();
|
2010-07-23 17:48:04 -06:00
|
|
|
if (fabsf(state) > deadzone)
|
2010-07-25 23:30:50 -06:00
|
|
|
tmpf = ((state - (deadzone * sign(state))) / (1 - deadzone));
|
|
|
|
|
|
|
|
float &ax = m_swing[i >> 1];
|
2014-07-11 05:18:21 -06:00
|
|
|
*axis++ = (tmpf - ax);
|
2010-10-02 22:29:34 -06:00
|
|
|
ax = tmpf;
|
2010-06-03 12:05:08 -06:00
|
|
|
}
|
|
|
|
}
|
2014-01-30 17:51:21 -07:00
|
|
|
|
2010-07-25 23:30:50 -06:00
|
|
|
private:
|
2014-01-30 17:51:21 -07:00
|
|
|
float m_swing[3];
|
2010-06-03 12:05:08 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
class Tilt : public ControlGroup
|
|
|
|
{
|
|
|
|
public:
|
2014-03-12 13:33:41 -06:00
|
|
|
Tilt(const std::string& _name);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 05:18:21 -06:00
|
|
|
void GetState(double* const x, double* const y, const bool step = true)
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
|
|
|
// this is all a mess
|
|
|
|
|
|
|
|
ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
|
|
|
|
ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
|
|
|
|
|
|
|
|
ControlState deadzone = settings[0]->value;
|
|
|
|
ControlState circle = settings[1]->value;
|
2013-01-19 18:16:01 -07:00
|
|
|
auto const angle = settings[2]->value / 1.8f;
|
2010-06-03 12:05:08 -06:00
|
|
|
ControlState m = controls[4]->control_ref->State();
|
|
|
|
|
|
|
|
// deadzone / circle stick code
|
2014-07-11 06:09:39 -06:00
|
|
|
// this section might be all wrong, but its working good enough, I think
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
ControlState ang = atan2(yy, xx);
|
|
|
|
ControlState ang_sin = sin(ang);
|
|
|
|
ControlState ang_cos = cos(ang);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
// the amt a full square stick would have at current angle
|
|
|
|
ControlState square_full = std::min(ang_sin ? 1/fabsf(ang_sin) : 2, ang_cos ? 1/fabsf(ang_cos) : 2);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
// the amt a full stick would have that was (user setting circular) at current angle
|
|
|
|
// I think this is more like a pointed circle rather than a rounded square like it should be
|
|
|
|
ControlState stick_full = (square_full * (1 - circle)) + (circle);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
ControlState dist = sqrt(xx*xx + yy*yy);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
// dead zone code
|
|
|
|
dist = std::max(0.0f, dist - deadzone * stick_full);
|
|
|
|
dist /= (1 - deadzone);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
// circle stick code
|
|
|
|
ControlState amt = dist / stick_full;
|
|
|
|
dist += (square_full - 1) * amt * circle;
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 06:11:33 -06:00
|
|
|
if (m)
|
|
|
|
dist *= 0.5;
|
|
|
|
|
2014-07-11 06:09:39 -06:00
|
|
|
yy = std::max(-1.0f, std::min(1.0f, ang_sin * dist));
|
|
|
|
xx = std::max(-1.0f, std::min(1.0f, ang_cos * dist));
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2010-06-11 20:08:01 -06:00
|
|
|
// this is kinda silly here
|
|
|
|
// gui being open will make this happen 2x as fast, o well
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2010-07-10 00:48:24 -06:00
|
|
|
// silly
|
|
|
|
if (step)
|
|
|
|
{
|
|
|
|
if (xx > m_tilt[0])
|
|
|
|
m_tilt[0] = std::min(m_tilt[0] + 0.1f, xx);
|
|
|
|
else if (xx < m_tilt[0])
|
|
|
|
m_tilt[0] = std::max(m_tilt[0] - 0.1f, xx);
|
|
|
|
|
|
|
|
if (yy > m_tilt[1])
|
|
|
|
m_tilt[1] = std::min(m_tilt[1] + 0.1f, yy);
|
|
|
|
else if (yy < m_tilt[1])
|
|
|
|
m_tilt[1] = std::max(m_tilt[1] - 0.1f, yy);
|
|
|
|
}
|
2010-06-11 20:08:01 -06:00
|
|
|
|
2014-07-11 05:18:21 -06:00
|
|
|
*y = m_tilt[1] * angle;
|
|
|
|
*x = m_tilt[0] * angle;
|
2010-06-03 12:05:08 -06:00
|
|
|
}
|
2014-01-30 17:51:21 -07:00
|
|
|
|
2010-06-11 20:08:01 -06:00
|
|
|
private:
|
2014-01-30 17:51:21 -07:00
|
|
|
float m_tilt[2];
|
2010-06-03 12:05:08 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
class Cursor : public ControlGroup
|
|
|
|
{
|
|
|
|
public:
|
2014-03-12 13:33:41 -06:00
|
|
|
Cursor(const std::string& _name);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 05:18:21 -06:00
|
|
|
void GetState(double* const x, double* const y, double* const z, const bool adjusted = false)
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
2010-06-11 20:08:01 -06:00
|
|
|
const float zz = controls[4]->control_ref->State() - controls[5]->control_ref->State();
|
|
|
|
|
|
|
|
// silly being here
|
|
|
|
if (zz > m_z)
|
|
|
|
m_z = std::min(m_z + 0.1f, zz);
|
|
|
|
else if (zz < m_z)
|
|
|
|
m_z = std::max(m_z - 0.1f, zz);
|
|
|
|
|
|
|
|
*z = m_z;
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2010-06-03 12:05:08 -06:00
|
|
|
// hide
|
2010-06-11 20:08:01 -06:00
|
|
|
if (controls[6]->control_ref->State() > 0.5f)
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
2010-06-11 20:08:01 -06:00
|
|
|
*x = 10000; *y = 0;
|
2010-06-03 12:05:08 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-15 21:43:11 -06:00
|
|
|
float yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
|
|
|
|
float xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
|
2010-06-03 12:05:08 -06:00
|
|
|
|
|
|
|
// adjust cursor according to settings
|
|
|
|
if (adjusted)
|
|
|
|
{
|
2011-01-13 20:05:02 -07:00
|
|
|
xx *= (settings[1]->value * 2);
|
|
|
|
yy *= (settings[2]->value * 2);
|
|
|
|
yy += (settings[0]->value - 0.5f);
|
2010-06-03 12:05:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
*x = xx;
|
|
|
|
*y = yy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-30 17:51:21 -07:00
|
|
|
float m_z;
|
2010-06-03 12:05:08 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
class Extension : public ControlGroup
|
|
|
|
{
|
|
|
|
public:
|
2014-03-12 13:33:41 -06:00
|
|
|
Extension(const std::string& _name)
|
2011-01-13 20:05:02 -07:00
|
|
|
: ControlGroup(_name, GROUP_TYPE_EXTENSION)
|
2010-06-03 12:05:08 -06:00
|
|
|
, switch_extension(0)
|
|
|
|
, active_extension(0) {}
|
2014-02-01 15:20:35 -07:00
|
|
|
|
|
|
|
~Extension() {}
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-07-11 08:58:14 -06:00
|
|
|
void GetState(u8* const data);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-02-01 15:20:35 -07:00
|
|
|
std::vector<std::unique_ptr<ControllerEmu>> attachments;
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-01-30 17:51:21 -07:00
|
|
|
int switch_extension;
|
|
|
|
int active_extension;
|
2010-06-03 12:05:08 -06:00
|
|
|
};
|
|
|
|
|
2014-02-01 15:20:35 -07:00
|
|
|
virtual ~ControllerEmu() {}
|
2010-06-03 12:05:08 -06:00
|
|
|
|
|
|
|
virtual std::string GetName() const = 0;
|
|
|
|
|
2010-07-10 00:48:24 -06:00
|
|
|
virtual void LoadDefaults(const ControllerInterface& ciface);
|
2010-06-12 06:57:28 -06:00
|
|
|
|
2010-07-05 04:46:32 -06:00
|
|
|
virtual void LoadConfig(IniFile::Section *sec, const std::string& base = "");
|
|
|
|
virtual void SaveConfig(IniFile::Section *sec, const std::string& base = "");
|
2010-06-03 12:05:08 -06:00
|
|
|
void UpdateDefaultDevice();
|
|
|
|
|
2011-01-13 20:05:02 -07:00
|
|
|
void UpdateReferences(ControllerInterface& devi);
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-02-01 15:20:35 -07:00
|
|
|
std::vector<std::unique_ptr<ControlGroup>> groups;
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-01-30 17:51:21 -07:00
|
|
|
DeviceQualifier default_device;
|
2010-06-03 12:05:08 -06:00
|
|
|
};
|