mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-25 18:35:37 +00:00
ControllerEmu: Separate ControlGroup from ControllerEmu
ControllerEmu, the class, is essentially acting like a namespace for ControlGroup. This makes it impossible to forward declare any of the internals. It also globs a bunch of classes together which is kind of a pain to manage. This splits ControlGroup and the classes it contains into their own source files and situates them all within a namespace, which gets them out of global scope. Since this allows forward declarations for the once-internal classes, it now requires significantly less files to be rebuilt if anything is changed in the ControllerEmu portion of code. It does not split out the settings classes yet, however, as it would be preferable to make a settings base class that all settings derive from, but this would be a functional change -- this commit only intends to move around existing code. Extracting the settings class will be done in another commit.
This commit is contained in:
parent
1385a012d9
commit
6a75ea5653
@ -1,3 +1,5 @@
|
||||
#include "Core/Analytics.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <mbedtls/sha1.h>
|
||||
#include <memory>
|
||||
@ -16,12 +18,10 @@
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/Analytics.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/HW/GCPad.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/NetPlayProto.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/GCAdapter.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Analytics.h"
|
||||
|
||||
|
@ -2,12 +2,16 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/HW/GCKeyboard.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/HW/GCKeyboard.h"
|
||||
|
||||
#include "Core/HW/GCKeyboardEmu.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
#include "InputCommon/KeyboardStatus.h"
|
||||
|
@ -5,12 +5,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
|
||||
class InputConfig;
|
||||
enum class KeyboardGroup;
|
||||
struct KeyboardStatus;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class ControlGroup;
|
||||
}
|
||||
|
||||
namespace Keyboard
|
||||
{
|
||||
void Shutdown();
|
||||
|
@ -3,7 +3,12 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/HW/GCKeyboardEmu.h"
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/KeyboardStatus.h"
|
||||
|
||||
@ -48,36 +53,38 @@ static const char* const named_keys5[] = {"LEFT", "DOWN", "UP", "RIGHT", "ENTER"
|
||||
GCKeyboard::GCKeyboard(const unsigned int index) : m_index(index)
|
||||
{
|
||||
// buttons
|
||||
groups.emplace_back(m_keys0x = new Buttons(_trans("Keys")));
|
||||
groups.emplace_back(m_keys0x = new ControllerEmu::Buttons(_trans("Keys")));
|
||||
for (const char* key : named_keys0)
|
||||
m_keys0x->controls.emplace_back(new ControlGroup::Input(key));
|
||||
m_keys0x->controls.emplace_back(new ControllerEmu::Input(key));
|
||||
|
||||
groups.emplace_back(m_keys1x = new Buttons(_trans("Keys")));
|
||||
groups.emplace_back(m_keys1x = new ControllerEmu::Buttons(_trans("Keys")));
|
||||
for (const char* key : named_keys1)
|
||||
m_keys1x->controls.emplace_back(new ControlGroup::Input(key));
|
||||
m_keys1x->controls.emplace_back(new ControllerEmu::Input(key));
|
||||
|
||||
groups.emplace_back(m_keys2x = new Buttons(_trans("Keys")));
|
||||
groups.emplace_back(m_keys2x = new ControllerEmu::Buttons(_trans("Keys")));
|
||||
for (const char* key : named_keys2)
|
||||
m_keys2x->controls.emplace_back(new ControlGroup::Input(key));
|
||||
m_keys2x->controls.emplace_back(new ControllerEmu::Input(key));
|
||||
|
||||
groups.emplace_back(m_keys3x = new Buttons(_trans("Keys")));
|
||||
groups.emplace_back(m_keys3x = new ControllerEmu::Buttons(_trans("Keys")));
|
||||
for (const char* key : named_keys3)
|
||||
m_keys3x->controls.emplace_back(new ControlGroup::Input(key));
|
||||
m_keys3x->controls.emplace_back(new ControllerEmu::Input(key));
|
||||
|
||||
groups.emplace_back(m_keys4x = new Buttons(_trans("Keys")));
|
||||
groups.emplace_back(m_keys4x = new ControllerEmu::Buttons(_trans("Keys")));
|
||||
for (const char* key : named_keys4)
|
||||
m_keys4x->controls.emplace_back(new ControlGroup::Input(key));
|
||||
m_keys4x->controls.emplace_back(new ControllerEmu::Input(key));
|
||||
|
||||
groups.emplace_back(m_keys5x = new Buttons(_trans("Keys")));
|
||||
groups.emplace_back(m_keys5x = new ControllerEmu::Buttons(_trans("Keys")));
|
||||
for (const char* key : named_keys5)
|
||||
m_keys5x->controls.emplace_back(new ControlGroup::Input(key));
|
||||
m_keys5x->controls.emplace_back(new ControllerEmu::Input(key));
|
||||
|
||||
// options
|
||||
groups.emplace_back(m_options = new ControlGroup(_trans("Options")));
|
||||
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
std::make_unique<ControlGroup::BackgroundInputSetting>(_trans("Background Input")));
|
||||
m_options->boolean_settings.emplace_back(std::make_unique<ControlGroup::BooleanSetting>(
|
||||
_trans("Iterative Input"), false, ControlGroup::SettingType::VIRTUAL));
|
||||
std::make_unique<ControllerEmu::ControlGroup::BackgroundInputSetting>(
|
||||
_trans("Background Input")));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
std::make_unique<ControllerEmu::ControlGroup::BooleanSetting>(
|
||||
_trans("Iterative Input"), false, ControllerEmu::ControlGroup::SettingType::VIRTUAL));
|
||||
}
|
||||
|
||||
std::string GCKeyboard::GetName() const
|
||||
@ -110,7 +117,7 @@ ControllerEmu::ControlGroup* GCKeyboard::GetGroup(KeyboardGroup group)
|
||||
|
||||
KeyboardStatus GCKeyboard::GetInput() const
|
||||
{
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = GetStateLock();
|
||||
|
||||
KeyboardStatus kb = {};
|
||||
|
||||
@ -126,7 +133,7 @@ KeyboardStatus GCKeyboard::GetInput() const
|
||||
|
||||
void GCKeyboard::LoadDefaults(const ControllerInterface& ciface)
|
||||
{
|
||||
ControllerEmu::LoadDefaults(ciface);
|
||||
EmulatedController::LoadDefaults(ciface);
|
||||
|
||||
// Buttons
|
||||
m_keys0x->SetControlExpression(5, "A");
|
||||
|
@ -10,6 +10,12 @@
|
||||
|
||||
struct KeyboardStatus;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class ControlGroup;
|
||||
class Buttons;
|
||||
}
|
||||
|
||||
enum class KeyboardGroup
|
||||
{
|
||||
Kb0x,
|
||||
@ -22,23 +28,23 @@ enum class KeyboardGroup
|
||||
Options
|
||||
};
|
||||
|
||||
class GCKeyboard : public ControllerEmu
|
||||
class GCKeyboard : public ControllerEmu::EmulatedController
|
||||
{
|
||||
public:
|
||||
explicit GCKeyboard(unsigned int index);
|
||||
KeyboardStatus GetInput() const;
|
||||
std::string GetName() const override;
|
||||
ControlGroup* GetGroup(KeyboardGroup group);
|
||||
ControllerEmu::ControlGroup* GetGroup(KeyboardGroup group);
|
||||
void LoadDefaults(const ControllerInterface& ciface) override;
|
||||
|
||||
private:
|
||||
Buttons* m_keys0x;
|
||||
Buttons* m_keys1x;
|
||||
Buttons* m_keys2x;
|
||||
Buttons* m_keys3x;
|
||||
Buttons* m_keys4x;
|
||||
Buttons* m_keys5x;
|
||||
ControlGroup* m_options;
|
||||
ControllerEmu::Buttons* m_keys0x;
|
||||
ControllerEmu::Buttons* m_keys1x;
|
||||
ControllerEmu::Buttons* m_keys2x;
|
||||
ControllerEmu::Buttons* m_keys3x;
|
||||
ControllerEmu::Buttons* m_keys4x;
|
||||
ControllerEmu::Buttons* m_keys5x;
|
||||
ControllerEmu::ControlGroup* m_options;
|
||||
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
@ -2,11 +2,14 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/HW/GCPad.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Core/HW/GCPad.h"
|
||||
#include "Core/HW/GCPadEmu.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
|
||||
|
@ -5,13 +5,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerInterface/Device.h"
|
||||
|
||||
class InputConfig;
|
||||
enum class PadGroup;
|
||||
struct GCPadStatus;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class ControlGroup;
|
||||
}
|
||||
|
||||
namespace Pad
|
||||
{
|
||||
void Shutdown();
|
||||
|
@ -3,9 +3,17 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/HW/GCPadEmu.h"
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/Host.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Output.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h"
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
|
||||
static const u16 button_bitmasks[] = {
|
||||
PAD_BUTTON_A,
|
||||
@ -39,40 +47,42 @@ static const char* const named_triggers[] = {
|
||||
GCPad::GCPad(const unsigned int index) : m_index(index)
|
||||
{
|
||||
// buttons
|
||||
groups.emplace_back(m_buttons = new Buttons(_trans("Buttons")));
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons")));
|
||||
for (unsigned int i = 0; i < sizeof(named_buttons) / sizeof(*named_buttons); ++i)
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input(named_buttons[i]));
|
||||
m_buttons->controls.emplace_back(new ControllerEmu::Input(named_buttons[i]));
|
||||
|
||||
// sticks
|
||||
groups.emplace_back(m_main_stick = new AnalogStick("Main Stick", _trans("Control Stick"),
|
||||
DEFAULT_PAD_STICK_RADIUS));
|
||||
groups.emplace_back(m_c_stick =
|
||||
new AnalogStick("C-Stick", _trans("C Stick"), DEFAULT_PAD_STICK_RADIUS));
|
||||
groups.emplace_back(m_main_stick = new ControllerEmu::AnalogStick(
|
||||
"Main Stick", _trans("Control Stick"), DEFAULT_PAD_STICK_RADIUS));
|
||||
groups.emplace_back(m_c_stick = new ControllerEmu::AnalogStick("C-Stick", _trans("C Stick"),
|
||||
DEFAULT_PAD_STICK_RADIUS));
|
||||
|
||||
// triggers
|
||||
groups.emplace_back(m_triggers = new MixedTriggers(_trans("Triggers")));
|
||||
groups.emplace_back(m_triggers = new ControllerEmu::MixedTriggers(_trans("Triggers")));
|
||||
for (auto& named_trigger : named_triggers)
|
||||
m_triggers->controls.emplace_back(new ControlGroup::Input(named_trigger));
|
||||
m_triggers->controls.emplace_back(new ControllerEmu::Input(named_trigger));
|
||||
|
||||
// rumble
|
||||
groups.emplace_back(m_rumble = new ControlGroup(_trans("Rumble")));
|
||||
m_rumble->controls.emplace_back(new ControlGroup::Output(_trans("Motor")));
|
||||
groups.emplace_back(m_rumble = new ControllerEmu::ControlGroup(_trans("Rumble")));
|
||||
m_rumble->controls.emplace_back(new ControllerEmu::Output(_trans("Motor")));
|
||||
|
||||
// Microphone
|
||||
groups.emplace_back(m_mic = new Buttons(_trans("Microphone")));
|
||||
m_mic->controls.emplace_back(new ControlGroup::Input(_trans("Button")));
|
||||
groups.emplace_back(m_mic = new ControllerEmu::Buttons(_trans("Microphone")));
|
||||
m_mic->controls.emplace_back(new ControllerEmu::Input(_trans("Button")));
|
||||
|
||||
// dpad
|
||||
groups.emplace_back(m_dpad = new Buttons(_trans("D-Pad")));
|
||||
groups.emplace_back(m_dpad = new ControllerEmu::Buttons(_trans("D-Pad")));
|
||||
for (auto& named_direction : named_directions)
|
||||
m_dpad->controls.emplace_back(new ControlGroup::Input(named_direction));
|
||||
m_dpad->controls.emplace_back(new ControllerEmu::Input(named_direction));
|
||||
|
||||
// options
|
||||
groups.emplace_back(m_options = new ControlGroup(_trans("Options")));
|
||||
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
std::make_unique<ControlGroup::BackgroundInputSetting>(_trans("Background Input")));
|
||||
m_options->boolean_settings.emplace_back(std::make_unique<ControlGroup::BooleanSetting>(
|
||||
_trans("Iterative Input"), false, ControlGroup::SettingType::VIRTUAL));
|
||||
std::make_unique<ControllerEmu::ControlGroup::BackgroundInputSetting>(
|
||||
_trans("Background Input")));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
std::make_unique<ControllerEmu::ControlGroup::BooleanSetting>(
|
||||
_trans("Iterative Input"), false, ControllerEmu::ControlGroup::SettingType::VIRTUAL));
|
||||
}
|
||||
|
||||
std::string GCPad::GetName() const
|
||||
@ -107,7 +117,7 @@ ControllerEmu::ControlGroup* GCPad::GetGroup(PadGroup group)
|
||||
|
||||
GCPadStatus GCPad::GetInput() const
|
||||
{
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = GetStateLock();
|
||||
|
||||
ControlState x, y, triggers[2];
|
||||
GCPadStatus pad = {};
|
||||
@ -147,13 +157,13 @@ GCPadStatus GCPad::GetInput() const
|
||||
|
||||
void GCPad::SetOutput(const ControlState strength)
|
||||
{
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = GetStateLock();
|
||||
m_rumble->controls[0]->control_ref->State(strength);
|
||||
}
|
||||
|
||||
void GCPad::LoadDefaults(const ControllerInterface& ciface)
|
||||
{
|
||||
ControllerEmu::LoadDefaults(ciface);
|
||||
EmulatedController::LoadDefaults(ciface);
|
||||
|
||||
// Buttons
|
||||
m_buttons->SetControlExpression(0, "X"); // A
|
||||
@ -222,6 +232,6 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
|
||||
|
||||
bool GCPad::GetMicButton() const
|
||||
{
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = GetStateLock();
|
||||
return (0.0f != m_mic->controls.back()->control_ref->State());
|
||||
}
|
||||
|
@ -8,7 +8,15 @@
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
|
||||
struct GCPadStatus;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class AnalogStick;
|
||||
class Buttons;
|
||||
class ControlGroup;
|
||||
class MixedTriggers;
|
||||
}
|
||||
|
||||
enum class PadGroup
|
||||
{
|
||||
@ -22,7 +30,7 @@ enum class PadGroup
|
||||
Options
|
||||
};
|
||||
|
||||
class GCPad : public ControllerEmu
|
||||
class GCPad : public ControllerEmu::EmulatedController
|
||||
{
|
||||
public:
|
||||
explicit GCPad(unsigned int index);
|
||||
@ -33,19 +41,19 @@ public:
|
||||
|
||||
std::string GetName() const override;
|
||||
|
||||
ControlGroup* GetGroup(PadGroup group);
|
||||
ControllerEmu::ControlGroup* GetGroup(PadGroup group);
|
||||
|
||||
void LoadDefaults(const ControllerInterface& ciface) override;
|
||||
|
||||
private:
|
||||
Buttons* m_buttons;
|
||||
AnalogStick* m_main_stick;
|
||||
AnalogStick* m_c_stick;
|
||||
Buttons* m_dpad;
|
||||
MixedTriggers* m_triggers;
|
||||
ControlGroup* m_rumble;
|
||||
Buttons* m_mic;
|
||||
ControlGroup* m_options;
|
||||
ControllerEmu::Buttons* m_buttons;
|
||||
ControllerEmu::AnalogStick* m_main_stick;
|
||||
ControllerEmu::AnalogStick* m_c_stick;
|
||||
ControllerEmu::Buttons* m_dpad;
|
||||
ControllerEmu::MixedTriggers* m_triggers;
|
||||
ControllerEmu::ControlGroup* m_rumble;
|
||||
ControllerEmu::Buttons* m_mic;
|
||||
ControllerEmu::ControlGroup* m_options;
|
||||
|
||||
const unsigned int m_index;
|
||||
|
||||
|
@ -3,10 +3,15 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/HW/Wiimote.h"
|
||||
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||
#include "Core/Movie.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
|
||||
|
@ -6,10 +6,15 @@
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
|
||||
class InputConfig;
|
||||
class PointerWrap;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class ControlGroup;
|
||||
}
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
enum class WiimoteGroup;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Extension.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
@ -53,12 +54,14 @@ void Attachment::Reset()
|
||||
}
|
||||
} // namespace WiimoteEmu
|
||||
|
||||
void ControllerEmu::Extension::GetState(u8* const data)
|
||||
namespace ControllerEmu
|
||||
{
|
||||
void Extension::GetState(u8* const data)
|
||||
{
|
||||
((WiimoteEmu::Attachment*)attachments[active_extension].get())->GetState(data);
|
||||
}
|
||||
|
||||
bool ControllerEmu::Extension::IsButtonPressed() const
|
||||
bool Extension::IsButtonPressed() const
|
||||
{
|
||||
// Extension == 0 means no Extension, > 0 means one is connected
|
||||
// Since we want to use this to know if disconnected Wiimotes want to be connected, and
|
||||
@ -71,3 +74,4 @@ bool ControllerEmu::Extension::IsButtonPressed() const
|
||||
return ((WiimoteEmu::Attachment*)attachments[switch_extension].get())->IsButtonPressed();
|
||||
return false;
|
||||
}
|
||||
} // namespace ControllerEmu
|
||||
|
@ -13,7 +13,7 @@ namespace WiimoteEmu
|
||||
{
|
||||
struct ExtensionReg;
|
||||
|
||||
class Attachment : public ControllerEmu
|
||||
class Attachment : public ControllerEmu::EmulatedController
|
||||
{
|
||||
public:
|
||||
Attachment(const char* const name, ExtensionReg& reg);
|
||||
|
@ -11,6 +11,12 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
constexpr std::array<u8, 6> classic_id{{0x00, 0x00, 0xa4, 0x20, 0x01, 0x01}};
|
||||
@ -49,25 +55,25 @@ constexpr std::array<u16, 4> classic_dpad_bitmasks{{
|
||||
Classic::Classic(ExtensionReg& reg) : Attachment(_trans("Classic"), reg)
|
||||
{
|
||||
// buttons
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons("Buttons"));
|
||||
for (auto& classic_button_name : classic_button_names)
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input(classic_button_name));
|
||||
m_buttons->controls.emplace_back(new ControllerEmu::Input(classic_button_name));
|
||||
|
||||
// sticks
|
||||
groups.emplace_back(m_left_stick =
|
||||
new AnalogStick(_trans("Left Stick"), DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
groups.emplace_back(m_right_stick =
|
||||
new AnalogStick(_trans("Right Stick"), DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
groups.emplace_back(m_left_stick = new ControllerEmu::AnalogStick(
|
||||
_trans("Left Stick"), DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
groups.emplace_back(m_right_stick = new ControllerEmu::AnalogStick(
|
||||
_trans("Right Stick"), DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
|
||||
// triggers
|
||||
groups.emplace_back(m_triggers = new MixedTriggers("Triggers"));
|
||||
groups.emplace_back(m_triggers = new ControllerEmu::MixedTriggers("Triggers"));
|
||||
for (auto& classic_trigger_name : classic_trigger_names)
|
||||
m_triggers->controls.emplace_back(new ControlGroup::Input(classic_trigger_name));
|
||||
m_triggers->controls.emplace_back(new ControllerEmu::Input(classic_trigger_name));
|
||||
|
||||
// dpad
|
||||
groups.emplace_back(m_dpad = new Buttons("D-Pad"));
|
||||
groups.emplace_back(m_dpad = new ControllerEmu::Buttons("D-Pad"));
|
||||
for (auto& named_direction : named_directions)
|
||||
m_dpad->controls.emplace_back(new ControlGroup::Input(named_direction));
|
||||
m_dpad->controls.emplace_back(new ControllerEmu::Input(named_direction));
|
||||
|
||||
// Set up register
|
||||
m_calibration = classic_calibration;
|
||||
|
@ -6,6 +6,14 @@
|
||||
|
||||
#include "Core/HW/WiimoteEmu/Attachment/Attachment.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class AnalogStick;
|
||||
class Buttons;
|
||||
class ControlGroup;
|
||||
class MixedTriggers;
|
||||
}
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
enum class ClassicGroup;
|
||||
@ -18,7 +26,7 @@ public:
|
||||
void GetState(u8* const data) override;
|
||||
bool IsButtonPressed() const override;
|
||||
|
||||
ControlGroup* GetGroup(ClassicGroup group);
|
||||
ControllerEmu::ControlGroup* GetGroup(ClassicGroup group);
|
||||
|
||||
enum
|
||||
{
|
||||
@ -52,10 +60,10 @@ public:
|
||||
static const u8 RIGHT_TRIGGER_RANGE = 0x1F;
|
||||
|
||||
private:
|
||||
Buttons* m_buttons;
|
||||
MixedTriggers* m_triggers;
|
||||
Buttons* m_dpad;
|
||||
AnalogStick* m_left_stick;
|
||||
AnalogStick* m_right_stick;
|
||||
ControllerEmu::Buttons* m_buttons;
|
||||
ControllerEmu::MixedTriggers* m_triggers;
|
||||
ControllerEmu::Buttons* m_dpad;
|
||||
ControllerEmu::AnalogStick* m_left_stick;
|
||||
ControllerEmu::AnalogStick* m_right_stick;
|
||||
};
|
||||
}
|
||||
|
@ -11,6 +11,10 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
constexpr std::array<u8, 6> drums_id{{0x01, 0x00, 0xa4, 0x20, 0x01, 0x03}};
|
||||
@ -32,17 +36,18 @@ constexpr std::array<u16, 2> drum_button_bitmasks{{
|
||||
Drums::Drums(ExtensionReg& reg) : Attachment(_trans("Drums"), reg)
|
||||
{
|
||||
// pads
|
||||
groups.emplace_back(m_pads = new Buttons(_trans("Pads")));
|
||||
groups.emplace_back(m_pads = new ControllerEmu::Buttons(_trans("Pads")));
|
||||
for (auto& drum_pad_name : drum_pad_names)
|
||||
m_pads->controls.emplace_back(new ControlGroup::Input(drum_pad_name));
|
||||
m_pads->controls.emplace_back(new ControllerEmu::Input(drum_pad_name));
|
||||
|
||||
// stick
|
||||
groups.emplace_back(m_stick = new AnalogStick("Stick", DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
groups.emplace_back(m_stick =
|
||||
new ControllerEmu::AnalogStick("Stick", DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
|
||||
// buttons
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("-"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("+"));
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons("Buttons"));
|
||||
m_buttons->controls.emplace_back(new ControllerEmu::Input("-"));
|
||||
m_buttons->controls.emplace_back(new ControllerEmu::Input("+"));
|
||||
|
||||
// set up register
|
||||
m_id = drums_id;
|
||||
|
@ -6,6 +6,13 @@
|
||||
|
||||
#include "Core/HW/WiimoteEmu/Attachment/Attachment.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class AnalogStick;
|
||||
class Buttons;
|
||||
class ControlGroup;
|
||||
}
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
enum class DrumsGroup;
|
||||
@ -18,7 +25,7 @@ public:
|
||||
void GetState(u8* const data) override;
|
||||
bool IsButtonPressed() const override;
|
||||
|
||||
ControlGroup* GetGroup(DrumsGroup group);
|
||||
ControllerEmu::ControlGroup* GetGroup(DrumsGroup group);
|
||||
|
||||
enum
|
||||
{
|
||||
@ -34,8 +41,8 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
Buttons* m_buttons;
|
||||
Buttons* m_pads;
|
||||
AnalogStick* m_stick;
|
||||
ControllerEmu::Buttons* m_buttons;
|
||||
ControllerEmu::Buttons* m_pads;
|
||||
ControllerEmu::AnalogStick* m_stick;
|
||||
};
|
||||
}
|
||||
|
@ -11,6 +11,12 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Triggers.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
constexpr std::array<u8, 6> guitar_id{{0x00, 0x00, 0xa4, 0x20, 0x01, 0x03}};
|
||||
@ -35,26 +41,27 @@ constexpr std::array<u16, 2> guitar_strum_bitmasks{{
|
||||
Guitar::Guitar(ExtensionReg& reg) : Attachment(_trans("Guitar"), reg)
|
||||
{
|
||||
// frets
|
||||
groups.emplace_back(m_frets = new Buttons(_trans("Frets")));
|
||||
groups.emplace_back(m_frets = new ControllerEmu::Buttons(_trans("Frets")));
|
||||
for (auto& guitar_fret_name : guitar_fret_names)
|
||||
m_frets->controls.emplace_back(new ControlGroup::Input(guitar_fret_name));
|
||||
m_frets->controls.emplace_back(new ControllerEmu::Input(guitar_fret_name));
|
||||
|
||||
// strum
|
||||
groups.emplace_back(m_strum = new Buttons(_trans("Strum")));
|
||||
m_strum->controls.emplace_back(new ControlGroup::Input("Up"));
|
||||
m_strum->controls.emplace_back(new ControlGroup::Input("Down"));
|
||||
groups.emplace_back(m_strum = new ControllerEmu::Buttons(_trans("Strum")));
|
||||
m_strum->controls.emplace_back(new ControllerEmu::Input("Up"));
|
||||
m_strum->controls.emplace_back(new ControllerEmu::Input("Down"));
|
||||
|
||||
// buttons
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("-"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("+"));
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons("Buttons"));
|
||||
m_buttons->controls.emplace_back(new ControllerEmu::Input("-"));
|
||||
m_buttons->controls.emplace_back(new ControllerEmu::Input("+"));
|
||||
|
||||
// stick
|
||||
groups.emplace_back(m_stick = new AnalogStick(_trans("Stick"), DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
groups.emplace_back(
|
||||
m_stick = new ControllerEmu::AnalogStick(_trans("Stick"), DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
|
||||
// whammy
|
||||
groups.emplace_back(m_whammy = new Triggers(_trans("Whammy")));
|
||||
m_whammy->controls.emplace_back(new ControlGroup::Input(_trans("Bar")));
|
||||
groups.emplace_back(m_whammy = new ControllerEmu::Triggers(_trans("Whammy")));
|
||||
m_whammy->controls.emplace_back(new ControllerEmu::Input(_trans("Bar")));
|
||||
|
||||
// set up register
|
||||
m_id = guitar_id;
|
||||
|
@ -6,6 +6,14 @@
|
||||
|
||||
#include "Core/HW/WiimoteEmu/Attachment/Attachment.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class AnalogStick;
|
||||
class Buttons;
|
||||
class ControlGroup;
|
||||
class Triggers;
|
||||
}
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
enum class GuitarGroup;
|
||||
@ -18,7 +26,7 @@ public:
|
||||
void GetState(u8* const data) override;
|
||||
bool IsButtonPressed() const override;
|
||||
|
||||
ControlGroup* GetGroup(GuitarGroup group);
|
||||
ControllerEmu::ControlGroup* GetGroup(GuitarGroup group);
|
||||
|
||||
enum
|
||||
{
|
||||
@ -35,10 +43,10 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
Buttons* m_buttons;
|
||||
Buttons* m_frets;
|
||||
Buttons* m_strum;
|
||||
Triggers* m_whammy;
|
||||
AnalogStick* m_stick;
|
||||
ControllerEmu::Buttons* m_buttons;
|
||||
ControllerEmu::Buttons* m_frets;
|
||||
ControllerEmu::Buttons* m_strum;
|
||||
ControllerEmu::Triggers* m_whammy;
|
||||
ControllerEmu::AnalogStick* m_stick;
|
||||
};
|
||||
}
|
||||
|
@ -12,6 +12,13 @@
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Force.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Tilt.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
constexpr std::array<u8, 6> nunchuk_id{{0x00, 0x00, 0xa4, 0x20, 0x00, 0x00}};
|
||||
@ -23,24 +30,25 @@ constexpr std::array<u8, 2> nunchuk_button_bitmasks{{
|
||||
Nunchuk::Nunchuk(ExtensionReg& reg) : Attachment(_trans("Nunchuk"), reg)
|
||||
{
|
||||
// buttons
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("C"));
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input("Z"));
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons("Buttons"));
|
||||
m_buttons->controls.emplace_back(new ControllerEmu::Input("C"));
|
||||
m_buttons->controls.emplace_back(new ControllerEmu::Input("Z"));
|
||||
|
||||
// stick
|
||||
groups.emplace_back(m_stick = new AnalogStick("Stick", DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
groups.emplace_back(m_stick =
|
||||
new ControllerEmu::AnalogStick("Stick", DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
|
||||
// swing
|
||||
groups.emplace_back(m_swing = new Force("Swing"));
|
||||
groups.emplace_back(m_swing = new ControllerEmu::Force("Swing"));
|
||||
|
||||
// tilt
|
||||
groups.emplace_back(m_tilt = new Tilt("Tilt"));
|
||||
groups.emplace_back(m_tilt = new ControllerEmu::Tilt("Tilt"));
|
||||
|
||||
// shake
|
||||
groups.emplace_back(m_shake = new Buttons("Shake"));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("X"));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("Y"));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("Z"));
|
||||
groups.emplace_back(m_shake = new ControllerEmu::Buttons("Shake"));
|
||||
m_shake->controls.emplace_back(new ControllerEmu::Input("X"));
|
||||
m_shake->controls.emplace_back(new ControllerEmu::Input("Y"));
|
||||
m_shake->controls.emplace_back(new ControllerEmu::Input("Z"));
|
||||
|
||||
m_id = nunchuk_id;
|
||||
}
|
||||
|
@ -7,6 +7,15 @@
|
||||
#include <array>
|
||||
#include "Core/HW/WiimoteEmu/Attachment/Attachment.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class AnalogStick;
|
||||
class Buttons;
|
||||
class ControlGroup;
|
||||
class Force;
|
||||
class Tilt;
|
||||
}
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
enum class NunchukGroup;
|
||||
@ -20,7 +29,7 @@ public:
|
||||
void GetState(u8* const data) override;
|
||||
bool IsButtonPressed() const override;
|
||||
|
||||
ControlGroup* GetGroup(NunchukGroup group);
|
||||
ControllerEmu::ControlGroup* GetGroup(NunchukGroup group);
|
||||
|
||||
enum
|
||||
{
|
||||
@ -44,13 +53,13 @@ public:
|
||||
void LoadDefaults(const ControllerInterface& ciface) override;
|
||||
|
||||
private:
|
||||
Tilt* m_tilt;
|
||||
Force* m_swing;
|
||||
ControllerEmu::Tilt* m_tilt;
|
||||
ControllerEmu::Force* m_swing;
|
||||
|
||||
Buttons* m_shake;
|
||||
ControllerEmu::Buttons* m_shake;
|
||||
|
||||
Buttons* m_buttons;
|
||||
AnalogStick* m_stick;
|
||||
ControllerEmu::Buttons* m_buttons;
|
||||
ControllerEmu::AnalogStick* m_stick;
|
||||
|
||||
std::array<u8, 3> m_shake_step{};
|
||||
};
|
||||
|
@ -11,6 +11,13 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Slider.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Triggers.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
constexpr std::array<u8, 6> turntable_id{{0x03, 0x00, 0xa4, 0x20, 0x01, 0x03}};
|
||||
@ -29,23 +36,24 @@ constexpr std::array<const char*, 9> turntable_button_names{{
|
||||
Turntable::Turntable(ExtensionReg& reg) : Attachment(_trans("Turntable"), reg)
|
||||
{
|
||||
// buttons
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons("Buttons"));
|
||||
for (auto& turntable_button_name : turntable_button_names)
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input(turntable_button_name));
|
||||
m_buttons->controls.emplace_back(new ControllerEmu::Input(turntable_button_name));
|
||||
|
||||
// turntables
|
||||
groups.emplace_back(m_left_table = new Slider(_trans("Table Left")));
|
||||
groups.emplace_back(m_right_table = new Slider(_trans("Table Right")));
|
||||
groups.emplace_back(m_left_table = new ControllerEmu::Slider(_trans("Table Left")));
|
||||
groups.emplace_back(m_right_table = new ControllerEmu::Slider(_trans("Table Right")));
|
||||
|
||||
// stick
|
||||
groups.emplace_back(m_stick = new AnalogStick("Stick", DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
groups.emplace_back(m_stick =
|
||||
new ControllerEmu::AnalogStick("Stick", DEFAULT_ATTACHMENT_STICK_RADIUS));
|
||||
|
||||
// effect dial
|
||||
groups.emplace_back(m_effect_dial = new Triggers(_trans("Effect")));
|
||||
m_effect_dial->controls.emplace_back(new ControlGroup::Input(_trans("Dial")));
|
||||
groups.emplace_back(m_effect_dial = new ControllerEmu::Triggers(_trans("Effect")));
|
||||
m_effect_dial->controls.emplace_back(new ControllerEmu::Input(_trans("Dial")));
|
||||
|
||||
// crossfade
|
||||
groups.emplace_back(m_crossfade = new Slider(_trans("Crossfade")));
|
||||
groups.emplace_back(m_crossfade = new ControllerEmu::Slider(_trans("Crossfade")));
|
||||
|
||||
// set up register
|
||||
m_id = turntable_id;
|
||||
|
@ -6,6 +6,15 @@
|
||||
|
||||
#include "Core/HW/WiimoteEmu/Attachment/Attachment.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class AnalogStick;
|
||||
class Buttons;
|
||||
class ControlGroup;
|
||||
class Slider;
|
||||
class Triggers;
|
||||
}
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
enum class TurntableGroup;
|
||||
@ -18,7 +27,7 @@ public:
|
||||
void GetState(u8* const data) override;
|
||||
bool IsButtonPressed() const override;
|
||||
|
||||
ControlGroup* GetGroup(TurntableGroup group);
|
||||
ControllerEmu::ControlGroup* GetGroup(TurntableGroup group);
|
||||
|
||||
enum
|
||||
{
|
||||
@ -37,11 +46,11 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
Buttons* m_buttons;
|
||||
AnalogStick* m_stick;
|
||||
Triggers* m_effect_dial;
|
||||
Slider* m_left_table;
|
||||
Slider* m_right_table;
|
||||
Slider* m_crossfade;
|
||||
ControllerEmu::Buttons* m_buttons;
|
||||
ControllerEmu::AnalogStick* m_stick;
|
||||
ControllerEmu::Triggers* m_effect_dial;
|
||||
ControllerEmu::Slider* m_left_table;
|
||||
ControllerEmu::Slider* m_right_table;
|
||||
ControllerEmu::Slider* m_crossfade;
|
||||
};
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteHid.h"
|
||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Extension.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
@ -7,7 +7,9 @@
|
||||
#include "AudioCommon/AudioCommon.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
|
||||
//#define WIIMOTE_SPEAKER_DUMP
|
||||
#ifdef WIIMOTE_SPEAKER_DUMP
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
@ -10,6 +12,7 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/WiimoteEmu/Attachment/Classic.h"
|
||||
@ -18,13 +21,22 @@
|
||||
#include "Core/HW/WiimoteEmu/Attachment/Nunchuk.h"
|
||||
#include "Core/HW/WiimoteEmu/Attachment/Turntable.h"
|
||||
#include "Core/HW/WiimoteEmu/MatrixMath.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteHid.h"
|
||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||
#include "Core/Host.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/NetPlayClient.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Output.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Cursor.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Extension.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Force.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Tilt.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
// :)
|
||||
@ -239,27 +251,27 @@ Wiimote::Wiimote(const unsigned int index)
|
||||
// ---- set up all the controls ----
|
||||
|
||||
// buttons
|
||||
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons("Buttons"));
|
||||
for (auto& named_button : named_buttons)
|
||||
m_buttons->controls.emplace_back(new ControlGroup::Input(named_button));
|
||||
m_buttons->controls.emplace_back(new ControllerEmu::Input(named_button));
|
||||
|
||||
// ir
|
||||
groups.emplace_back(m_ir = new Cursor(_trans("IR")));
|
||||
groups.emplace_back(m_ir = new ControllerEmu::Cursor(_trans("IR")));
|
||||
|
||||
// swing
|
||||
groups.emplace_back(m_swing = new Force(_trans("Swing")));
|
||||
groups.emplace_back(m_swing = new ControllerEmu::Force(_trans("Swing")));
|
||||
|
||||
// tilt
|
||||
groups.emplace_back(m_tilt = new Tilt(_trans("Tilt")));
|
||||
groups.emplace_back(m_tilt = new ControllerEmu::Tilt(_trans("Tilt")));
|
||||
|
||||
// shake
|
||||
groups.emplace_back(m_shake = new Buttons(_trans("Shake")));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("X"));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("Y"));
|
||||
m_shake->controls.emplace_back(new ControlGroup::Input("Z"));
|
||||
groups.emplace_back(m_shake = new ControllerEmu::Buttons(_trans("Shake")));
|
||||
m_shake->controls.emplace_back(new ControllerEmu::Input("X"));
|
||||
m_shake->controls.emplace_back(new ControllerEmu::Input("Y"));
|
||||
m_shake->controls.emplace_back(new ControllerEmu::Input("Z"));
|
||||
|
||||
// extension
|
||||
groups.emplace_back(m_extension = new Extension(_trans("Extension")));
|
||||
groups.emplace_back(m_extension = new ControllerEmu::Extension(_trans("Extension")));
|
||||
m_extension->attachments.emplace_back(new WiimoteEmu::None(m_reg_ext));
|
||||
m_extension->attachments.emplace_back(new WiimoteEmu::Nunchuk(m_reg_ext));
|
||||
m_extension->attachments.emplace_back(new WiimoteEmu::Classic(m_reg_ext));
|
||||
@ -268,34 +280,40 @@ Wiimote::Wiimote(const unsigned int index)
|
||||
m_extension->attachments.emplace_back(new WiimoteEmu::Turntable(m_reg_ext));
|
||||
|
||||
m_extension->boolean_settings.emplace_back(
|
||||
std::make_unique<ControlGroup::BooleanSetting>(_trans("Motion Plus"), false));
|
||||
std::make_unique<ControllerEmu::ControlGroup::BooleanSetting>(_trans("Motion Plus"), false));
|
||||
|
||||
// rumble
|
||||
groups.emplace_back(m_rumble = new ControlGroup(_trans("Rumble")));
|
||||
m_rumble->controls.emplace_back(new ControlGroup::Output(_trans("Motor")));
|
||||
groups.emplace_back(m_rumble = new ControllerEmu::ControlGroup(_trans("Rumble")));
|
||||
m_rumble->controls.emplace_back(new ControllerEmu::Output(_trans("Motor")));
|
||||
|
||||
// dpad
|
||||
groups.emplace_back(m_dpad = new Buttons("D-Pad"));
|
||||
groups.emplace_back(m_dpad = new ControllerEmu::Buttons("D-Pad"));
|
||||
for (auto& named_direction : named_directions)
|
||||
m_dpad->controls.emplace_back(new ControlGroup::Input(named_direction));
|
||||
m_dpad->controls.emplace_back(new ControllerEmu::Input(named_direction));
|
||||
|
||||
// options
|
||||
groups.emplace_back(m_options = new ControlGroup(_trans("Options")));
|
||||
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
std::make_unique<ControlGroup::BackgroundInputSetting>(_trans("Background Input")));
|
||||
std::make_unique<ControllerEmu::ControlGroup::BackgroundInputSetting>(
|
||||
_trans("Background Input")));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
std::make_unique<ControlGroup::BooleanSetting>(_trans("Sideways Wii Remote"), false));
|
||||
std::make_unique<ControllerEmu::ControlGroup::BooleanSetting>(_trans("Sideways Wii Remote"),
|
||||
false));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
std::make_unique<ControlGroup::BooleanSetting>(_trans("Upright Wii Remote"), false));
|
||||
m_options->boolean_settings.emplace_back(std::make_unique<ControlGroup::BooleanSetting>(
|
||||
_trans("Iterative Input"), false, ControlGroup::SettingType::VIRTUAL));
|
||||
std::make_unique<ControllerEmu::ControlGroup::BooleanSetting>(_trans("Upright Wii Remote"),
|
||||
false));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
std::make_unique<ControllerEmu::ControlGroup::BooleanSetting>(
|
||||
_trans("Iterative Input"), false, ControllerEmu::ControlGroup::SettingType::VIRTUAL));
|
||||
m_options->numeric_settings.emplace_back(
|
||||
std::make_unique<ControlGroup::NumericSetting>(_trans("Speaker Pan"), 0, -127, 127));
|
||||
std::make_unique<ControllerEmu::ControlGroup::NumericSetting>(_trans("Speaker Pan"), 0, -127,
|
||||
127));
|
||||
m_options->numeric_settings.emplace_back(
|
||||
std::make_unique<ControlGroup::NumericSetting>(_trans("Battery"), 95.0 / 100, 0, 255));
|
||||
std::make_unique<ControllerEmu::ControlGroup::NumericSetting>(_trans("Battery"), 95.0 / 100,
|
||||
0, 255));
|
||||
|
||||
// hotkeys
|
||||
groups.emplace_back(m_hotkeys = new ModifySettingsButton(_trans("Hotkeys")));
|
||||
groups.emplace_back(m_hotkeys = new ControllerEmu::ModifySettingsButton(_trans("Hotkeys")));
|
||||
// hotkeys to temporarily modify the Wii Remote orientation (sideways, upright)
|
||||
// this setting modifier is toggled
|
||||
m_hotkeys->AddInput(_trans("Sideways Toggle"), true);
|
||||
@ -699,7 +717,7 @@ void Wiimote::Update()
|
||||
|
||||
// returns true if a report was sent
|
||||
{
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = GetStateLock();
|
||||
if (Step())
|
||||
return;
|
||||
}
|
||||
@ -724,7 +742,7 @@ void Wiimote::Update()
|
||||
data[0] = 0xA1;
|
||||
data[1] = m_reporting_mode;
|
||||
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = GetStateLock();
|
||||
|
||||
// hotkey/settings modifier
|
||||
m_hotkeys->GetState(); // data is later accessed in UpdateButtonsStatus and GetAccelData
|
||||
@ -959,7 +977,7 @@ void Wiimote::ConnectOnInput()
|
||||
}
|
||||
|
||||
u16 buttons = 0;
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = GetStateLock();
|
||||
m_buttons->GetState(&buttons, button_bitmasks);
|
||||
m_dpad->GetState(&buttons, dpad_bitmasks);
|
||||
|
||||
@ -974,7 +992,7 @@ void Wiimote::ConnectOnInput()
|
||||
|
||||
void Wiimote::LoadDefaults(const ControllerInterface& ciface)
|
||||
{
|
||||
ControllerEmu::LoadDefaults(ciface);
|
||||
EmulatedController::LoadDefaults(ciface);
|
||||
|
||||
// Buttons
|
||||
#if defined HAVE_X11 && HAVE_X11
|
||||
@ -1030,4 +1048,19 @@ void Wiimote::LoadDefaults(const ControllerInterface& ciface)
|
||||
// set nunchuk defaults
|
||||
m_extension->attachments[1]->LoadDefaults(ciface);
|
||||
}
|
||||
|
||||
int Wiimote::CurrentExtension() const
|
||||
{
|
||||
return m_extension->active_extension;
|
||||
}
|
||||
|
||||
bool Wiimote::HaveExtension() const
|
||||
{
|
||||
return m_extension->active_extension > 0;
|
||||
}
|
||||
|
||||
bool Wiimote::WantExtension() const
|
||||
{
|
||||
return m_extension->switch_extension != 0;
|
||||
}
|
||||
} // namespace WiimoteEmu
|
||||
|
@ -20,6 +20,17 @@
|
||||
|
||||
class PointerWrap;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class Buttons;
|
||||
class ControlGroup;
|
||||
class Cursor;
|
||||
class Extension;
|
||||
class Force;
|
||||
class ModifySettingsButton;
|
||||
class Tilt;
|
||||
}
|
||||
|
||||
namespace WiimoteReal
|
||||
{
|
||||
class Wiimote;
|
||||
@ -152,7 +163,7 @@ enum
|
||||
ACCEL_RANGE = (ACCEL_ONE_G - ACCEL_ZERO_G),
|
||||
};
|
||||
|
||||
class Wiimote : public ControllerEmu
|
||||
class Wiimote : public ControllerEmu::EmulatedController
|
||||
{
|
||||
friend class WiimoteReal::Wiimote;
|
||||
|
||||
@ -175,8 +186,8 @@ public:
|
||||
|
||||
Wiimote(const unsigned int index);
|
||||
std::string GetName() const override;
|
||||
ControlGroup* GetWiimoteGroup(WiimoteGroup group);
|
||||
ControlGroup* GetNunchukGroup(NunchukGroup group);
|
||||
ControllerEmu::ControlGroup* GetWiimoteGroup(WiimoteGroup group);
|
||||
ControllerEmu::ControlGroup* GetNunchukGroup(NunchukGroup group);
|
||||
ControllerEmu::ControlGroup* GetClassicGroup(ClassicGroup group);
|
||||
ControllerEmu::ControlGroup* GetGuitarGroup(GuitarGroup group);
|
||||
ControllerEmu::ControlGroup* GetDrumsGroup(DrumsGroup group);
|
||||
@ -193,7 +204,8 @@ public:
|
||||
|
||||
void LoadDefaults(const ControllerInterface& ciface) override;
|
||||
|
||||
int CurrentExtension() const { return m_extension->active_extension; }
|
||||
int CurrentExtension() const;
|
||||
|
||||
protected:
|
||||
bool Step();
|
||||
void HidOutputReport(const wm_report* const sr, const bool send_ack = true);
|
||||
@ -205,8 +217,9 @@ protected:
|
||||
void GetIRData(u8* const data, bool use_accel);
|
||||
void GetExtData(u8* const data);
|
||||
|
||||
bool HaveExtension() const { return m_extension->active_extension > 0; }
|
||||
bool WantExtension() const { return m_extension->switch_extension != 0; }
|
||||
bool HaveExtension() const;
|
||||
bool WantExtension() const;
|
||||
|
||||
private:
|
||||
struct ReadRequest
|
||||
{
|
||||
@ -225,14 +238,16 @@ private:
|
||||
bool NetPlay_GetWiimoteData(int wiimote, u8* data, u8 size, u8 reporting_mode);
|
||||
|
||||
// control groups
|
||||
Buttons *m_buttons, *m_dpad, *m_shake;
|
||||
Cursor* m_ir;
|
||||
Tilt* m_tilt;
|
||||
Force* m_swing;
|
||||
ControlGroup* m_rumble;
|
||||
Extension* m_extension;
|
||||
ControlGroup* m_options;
|
||||
ModifySettingsButton* m_hotkeys;
|
||||
ControllerEmu::Buttons* m_buttons;
|
||||
ControllerEmu::Buttons* m_dpad;
|
||||
ControllerEmu::Buttons* m_shake;
|
||||
ControllerEmu::Cursor* m_ir;
|
||||
ControllerEmu::Tilt* m_tilt;
|
||||
ControllerEmu::Force* m_swing;
|
||||
ControllerEmu::ControlGroup* m_rumble;
|
||||
ControllerEmu::Extension* m_extension;
|
||||
ControllerEmu::ControlGroup* m_options;
|
||||
ControllerEmu::ModifySettingsButton* m_hotkeys;
|
||||
|
||||
// Wiimote accel data
|
||||
AccelData m_accel;
|
||||
|
@ -2,11 +2,17 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/HotkeyManager.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Core/HotkeyManager.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
|
||||
const std::string hotkey_labels[] = {
|
||||
@ -255,19 +261,22 @@ HotkeyManager::HotkeyManager()
|
||||
{
|
||||
for (int group = 0; group < NUM_HOTKEY_GROUPS; group++)
|
||||
{
|
||||
m_hotkey_groups[group] = (m_keys[group] = new Buttons("Keys", groups_info[group].name));
|
||||
m_hotkey_groups[group] =
|
||||
(m_keys[group] = new ControllerEmu::Buttons("Keys", groups_info[group].name));
|
||||
groups.emplace_back(m_hotkey_groups[group]);
|
||||
for (int key = groups_info[group].first; key <= groups_info[group].last; key++)
|
||||
{
|
||||
m_keys[group]->controls.emplace_back(new ControlGroup::Input(hotkey_labels[key]));
|
||||
m_keys[group]->controls.emplace_back(new ControllerEmu::Input(hotkey_labels[key]));
|
||||
}
|
||||
}
|
||||
|
||||
groups.emplace_back(m_options = new ControlGroup(_trans("Options")));
|
||||
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
std::make_unique<ControlGroup::BackgroundInputSetting>(_trans("Background Input")));
|
||||
m_options->boolean_settings.emplace_back(std::make_unique<ControlGroup::BooleanSetting>(
|
||||
_trans("Iterative Input"), false, ControlGroup::SettingType::VIRTUAL));
|
||||
std::make_unique<ControllerEmu::ControlGroup::BackgroundInputSetting>(
|
||||
_trans("Background Input")));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
std::make_unique<ControllerEmu::ControlGroup::BooleanSetting>(
|
||||
_trans("Iterative Input"), false, ControllerEmu::ControlGroup::SettingType::VIRTUAL));
|
||||
}
|
||||
|
||||
HotkeyManager::~HotkeyManager()
|
||||
@ -281,7 +290,7 @@ std::string HotkeyManager::GetName() const
|
||||
|
||||
void HotkeyManager::GetInput(HotkeyStatus* const kb)
|
||||
{
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = GetStateLock();
|
||||
for (int group = 0; group < NUM_HOTKEY_GROUPS; group++)
|
||||
{
|
||||
const int group_count = (groups_info[group].last - groups_info[group].first) + 1;
|
||||
@ -319,7 +328,7 @@ int HotkeyManager::GetIndexForGroup(int group, int id) const
|
||||
|
||||
void HotkeyManager::LoadDefaults(const ControllerInterface& ciface)
|
||||
{
|
||||
ControllerEmu::LoadDefaults(ciface);
|
||||
EmulatedController::LoadDefaults(ciface);
|
||||
|
||||
#ifdef _WIN32
|
||||
const std::string NON = "(!(LMENU | RMENU) & !(LSHIFT | RSHIFT) & !(LCONTROL | RCONTROL))";
|
||||
|
@ -7,9 +7,16 @@
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class ControllerEmu;
|
||||
class Buttons;
|
||||
}
|
||||
|
||||
enum Hotkey
|
||||
{
|
||||
HK_OPEN,
|
||||
@ -183,7 +190,7 @@ struct HotkeyStatus
|
||||
s8 err;
|
||||
};
|
||||
|
||||
class HotkeyManager : public ControllerEmu
|
||||
class HotkeyManager : public ControllerEmu::EmulatedController
|
||||
{
|
||||
public:
|
||||
HotkeyManager();
|
||||
@ -191,16 +198,16 @@ public:
|
||||
|
||||
void GetInput(HotkeyStatus* const hk);
|
||||
std::string GetName() const override;
|
||||
ControlGroup* GetHotkeyGroup(HotkeyGroup group) const;
|
||||
ControlGroup* GetOptionsGroup() const;
|
||||
ControllerEmu::ControlGroup* GetHotkeyGroup(HotkeyGroup group) const;
|
||||
ControllerEmu::ControlGroup* GetOptionsGroup() const;
|
||||
int FindGroupByID(int id) const;
|
||||
int GetIndexForGroup(int group, int id) const;
|
||||
void LoadDefaults(const ControllerInterface& ciface) override;
|
||||
|
||||
private:
|
||||
Buttons* m_keys[NUM_HOTKEY_GROUPS];
|
||||
std::array<ControlGroup*, NUM_HOTKEY_GROUPS> m_hotkey_groups;
|
||||
ControlGroup* m_options;
|
||||
ControllerEmu::Buttons* m_keys[NUM_HOTKEY_GROUPS];
|
||||
std::array<ControllerEmu::ControlGroup*, NUM_HOTKEY_GROUPS> m_hotkey_groups;
|
||||
ControllerEmu::ControlGroup* m_options;
|
||||
};
|
||||
|
||||
namespace HotkeyManagerEmu
|
||||
|
@ -28,13 +28,11 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/SymbolDB.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/Debugger/Debugger_SymbolMap.h"
|
||||
#include "Core/Debugger/PPCDebugInterface.h"
|
||||
#include "Core/HW/CPU.h"
|
||||
#include "Core/HW/Memmap.h"
|
||||
#include "Core/HW/SystemTimers.h"
|
||||
#include "Core/Host.h"
|
||||
#include "Core/PowerPC/BreakPoints.h"
|
||||
#include "Core/PowerPC/Gekko.h"
|
||||
#include "Core/PowerPC/JitInterface.h"
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinWX/Input/InputConfigDiag.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cctype>
|
||||
@ -38,21 +40,27 @@
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/GCKeyboard.h"
|
||||
#include "Core/HW/GCPad.h"
|
||||
#include "Core/HW/Wiimote.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
#include "Core/HotkeyManager.h"
|
||||
|
||||
#include "DolphinWX/DolphinSlider.h"
|
||||
#include "DolphinWX/Input/ClassicInputConfigDiag.h"
|
||||
#include "DolphinWX/Input/DrumsInputConfigDiag.h"
|
||||
#include "DolphinWX/Input/GuitarInputConfigDiag.h"
|
||||
#include "DolphinWX/Input/InputConfigDiag.h"
|
||||
#include "DolphinWX/Input/NunchukInputConfigDiag.h"
|
||||
#include "DolphinWX/Input/TurntableInputConfigDiag.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControlReference/ExpressionParser.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Extension.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/ControllerInterface/Device.h"
|
||||
@ -385,7 +393,7 @@ bool ControlDialog::Validate()
|
||||
{
|
||||
control_reference->expression = WxStrToStr(textctrl->GetValue());
|
||||
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
m_parent->GetController()->default_device);
|
||||
|
||||
@ -424,7 +432,7 @@ void ControlDialog::ClearControl(wxCommandEvent&)
|
||||
{
|
||||
control_reference->expression.clear();
|
||||
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
m_parent->GetController()->default_device);
|
||||
|
||||
@ -483,7 +491,7 @@ void ControlDialog::SetSelectedControl(wxCommandEvent&)
|
||||
textctrl->WriteText(expr);
|
||||
control_reference->expression = textctrl->GetValue();
|
||||
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
m_parent->GetController()->default_device);
|
||||
|
||||
@ -519,7 +527,7 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
|
||||
textctrl->WriteText(expr);
|
||||
control_reference->expression = textctrl->GetValue();
|
||||
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
m_parent->GetController()->default_device);
|
||||
|
||||
@ -701,7 +709,7 @@ bool InputConfigDialog::DetectButton(ControlButton* button)
|
||||
wxString expr;
|
||||
GetExpressionForControl(expr, control_name);
|
||||
button->control_reference->expression = expr;
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
button->control_reference->UpdateReference(g_controller_interface,
|
||||
controller->default_device);
|
||||
success = true;
|
||||
@ -831,7 +839,7 @@ void InputConfigDialog::GetProfilePath(std::string& path)
|
||||
}
|
||||
}
|
||||
|
||||
ControllerEmu* InputConfigDialog::GetController() const
|
||||
ControllerEmu::EmulatedController* InputConfigDialog::GetController() const
|
||||
{
|
||||
return controller;
|
||||
}
|
||||
@ -930,8 +938,10 @@ ControlGroupBox::~ControlGroupBox()
|
||||
|
||||
bool ControlGroupBox::HasBitmapHeading() const
|
||||
{
|
||||
return control_group->type == GROUP_TYPE_STICK || control_group->type == GROUP_TYPE_TILT ||
|
||||
control_group->type == GROUP_TYPE_CURSOR || control_group->type == GROUP_TYPE_FORCE;
|
||||
return control_group->type == ControllerEmu::GROUP_TYPE_STICK ||
|
||||
control_group->type == ControllerEmu::GROUP_TYPE_TILT ||
|
||||
control_group->type == ControllerEmu::GROUP_TYPE_CURSOR ||
|
||||
control_group->type == ControllerEmu::GROUP_TYPE_FORCE;
|
||||
}
|
||||
|
||||
ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent,
|
||||
@ -986,10 +996,10 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
|
||||
switch (group->type)
|
||||
{
|
||||
case GROUP_TYPE_STICK:
|
||||
case GROUP_TYPE_TILT:
|
||||
case GROUP_TYPE_CURSOR:
|
||||
case GROUP_TYPE_FORCE:
|
||||
case ControllerEmu::GROUP_TYPE_STICK:
|
||||
case ControllerEmu::GROUP_TYPE_TILT:
|
||||
case ControllerEmu::GROUP_TYPE_CURSOR:
|
||||
case ControllerEmu::GROUP_TYPE_FORCE:
|
||||
{
|
||||
wxSize bitmap_size = parent->FromDIP(wxSize(64, 64));
|
||||
m_scale = bitmap_size.GetWidth() / 64.0;
|
||||
@ -1031,7 +1041,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
Add(h_szr, 0, wxEXPAND | wxLEFT | wxRIGHT, space3);
|
||||
}
|
||||
break;
|
||||
case GROUP_TYPE_BUTTONS:
|
||||
case ControllerEmu::GROUP_TYPE_BUTTONS:
|
||||
{
|
||||
// Draw buttons in rows of 8
|
||||
unsigned int button_cols = group->controls.size() > 8 ? 8 : group->controls.size();
|
||||
@ -1069,17 +1079,17 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
Add(static_bitmap, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, space3);
|
||||
}
|
||||
break;
|
||||
case GROUP_TYPE_MIXED_TRIGGERS:
|
||||
case GROUP_TYPE_TRIGGERS:
|
||||
case GROUP_TYPE_SLIDER:
|
||||
case ControllerEmu::GROUP_TYPE_MIXED_TRIGGERS:
|
||||
case ControllerEmu::GROUP_TYPE_TRIGGERS:
|
||||
case ControllerEmu::GROUP_TYPE_SLIDER:
|
||||
{
|
||||
int height = (int)(12 * group->controls.size());
|
||||
int width = 64;
|
||||
|
||||
if (GROUP_TYPE_MIXED_TRIGGERS == group->type)
|
||||
if (ControllerEmu::GROUP_TYPE_MIXED_TRIGGERS == group->type)
|
||||
width = 64 + 12 + 1;
|
||||
|
||||
if (GROUP_TYPE_TRIGGERS != group->type)
|
||||
if (ControllerEmu::GROUP_TYPE_TRIGGERS != group->type)
|
||||
height /= 2;
|
||||
height += 1;
|
||||
|
||||
@ -1113,7 +1123,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
Add(static_bitmap, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, space3);
|
||||
}
|
||||
break;
|
||||
case GROUP_TYPE_EXTENSION:
|
||||
case ControllerEmu::GROUP_TYPE_EXTENSION:
|
||||
{
|
||||
PadSettingExtension* const attachments =
|
||||
new PadSettingExtension(parent, (ControllerEmu::Extension*)group);
|
||||
|
@ -23,10 +23,10 @@
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/timer.h>
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerInterface/Device.h"
|
||||
|
||||
class ControlReference;
|
||||
class DolphinSlider;
|
||||
class InputConfig;
|
||||
class wxComboBox;
|
||||
@ -35,6 +35,12 @@ class wxStaticBitmap;
|
||||
class wxStaticText;
|
||||
class wxTextCtrl;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class EmulatedController;
|
||||
class Extension;
|
||||
}
|
||||
|
||||
class PadSetting
|
||||
{
|
||||
protected:
|
||||
@ -221,7 +227,7 @@ public:
|
||||
void AdjustBooleanSetting(wxCommandEvent& event);
|
||||
|
||||
void GetProfilePath(std::string& path);
|
||||
ControllerEmu* GetController() const;
|
||||
ControllerEmu::EmulatedController* GetController() const;
|
||||
|
||||
wxComboBox* profile_cbox = nullptr;
|
||||
wxComboBox* device_cbox = nullptr;
|
||||
@ -234,7 +240,7 @@ protected:
|
||||
wxBoxSizer* CreaterResetGroupBox(wxOrientation orientation);
|
||||
wxBoxSizer* CreateProfileChooserGroupBox();
|
||||
|
||||
ControllerEmu* const controller;
|
||||
ControllerEmu::EmulatedController* const controller;
|
||||
|
||||
wxTimer m_update_timer;
|
||||
|
||||
|
@ -22,6 +22,15 @@
|
||||
#include "DolphinWX/Input/InputConfigDiag.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Cursor.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Force.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Slider.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Tilt.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Triggers.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/ControllerInterface/Device.h"
|
||||
@ -150,9 +159,9 @@ static void DrawControlGroupBox(wxGraphicsContext* gc, ControlGroupBox* g)
|
||||
|
||||
switch (g->control_group->type)
|
||||
{
|
||||
case GROUP_TYPE_TILT:
|
||||
case GROUP_TYPE_STICK:
|
||||
case GROUP_TYPE_CURSOR:
|
||||
case ControllerEmu::GROUP_TYPE_TILT:
|
||||
case ControllerEmu::GROUP_TYPE_STICK:
|
||||
case ControllerEmu::GROUP_TYPE_CURSOR:
|
||||
{
|
||||
// this is starting to be a mess combining all these in one case
|
||||
|
||||
@ -160,19 +169,19 @@ static void DrawControlGroupBox(wxGraphicsContext* gc, ControlGroupBox* g)
|
||||
|
||||
switch (g->control_group->type)
|
||||
{
|
||||
case GROUP_TYPE_STICK:
|
||||
case ControllerEmu::GROUP_TYPE_STICK:
|
||||
((ControllerEmu::AnalogStick*)g->control_group)->GetState(&x, &y);
|
||||
break;
|
||||
case GROUP_TYPE_TILT:
|
||||
case ControllerEmu::GROUP_TYPE_TILT:
|
||||
((ControllerEmu::Tilt*)g->control_group)->GetState(&x, &y);
|
||||
break;
|
||||
case GROUP_TYPE_CURSOR:
|
||||
case ControllerEmu::GROUP_TYPE_CURSOR:
|
||||
((ControllerEmu::Cursor*)g->control_group)->GetState(&x, &y, &z);
|
||||
break;
|
||||
}
|
||||
|
||||
// ir cursor forward movement
|
||||
if (GROUP_TYPE_CURSOR == g->control_group->type)
|
||||
if (ControllerEmu::GROUP_TYPE_CURSOR == g->control_group->type)
|
||||
{
|
||||
gc->SetBrush(z ? *wxRED_BRUSH : *wxGREY_BRUSH);
|
||||
wxGraphicsPath path = gc->CreatePath();
|
||||
@ -182,7 +191,7 @@ static void DrawControlGroupBox(wxGraphicsContext* gc, ControlGroupBox* g)
|
||||
|
||||
// input zone
|
||||
gc->SetPen(*wxLIGHT_GREY_PEN);
|
||||
if (GROUP_TYPE_STICK == g->control_group->type)
|
||||
if (ControllerEmu::GROUP_TYPE_STICK == g->control_group->type)
|
||||
{
|
||||
gc->SetBrush(wxColour(0xDDDDDD)); // Light Gray
|
||||
|
||||
@ -222,9 +231,12 @@ static void DrawControlGroupBox(wxGraphicsContext* gc, ControlGroupBox* g)
|
||||
gc->DrawRectangle(16, 16, 32, 32);
|
||||
}
|
||||
|
||||
if (GROUP_TYPE_CURSOR != g->control_group->type)
|
||||
if (ControllerEmu::GROUP_TYPE_CURSOR != g->control_group->type)
|
||||
{
|
||||
int deadzone_idx = g->control_group->type == GROUP_TYPE_STICK ? SETTING_DEADZONE : 0;
|
||||
const int deadzone_idx = g->control_group->type == ControllerEmu::GROUP_TYPE_STICK ?
|
||||
ControllerEmu::AnalogStick::SETTING_DEADZONE :
|
||||
0;
|
||||
|
||||
wxGraphicsPath path = gc->CreatePath();
|
||||
path.AddCircle(VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE / 2,
|
||||
g->control_group->numeric_settings[deadzone_idx]->GetValue() *
|
||||
@ -255,7 +267,7 @@ static void DrawControlGroupBox(wxGraphicsContext* gc, ControlGroupBox* g)
|
||||
}
|
||||
break;
|
||||
|
||||
case GROUP_TYPE_FORCE:
|
||||
case ControllerEmu::GROUP_TYPE_FORCE:
|
||||
{
|
||||
ControlState raw_dot[3];
|
||||
ControlState adj_dot[3];
|
||||
@ -320,7 +332,7 @@ static void DrawControlGroupBox(wxGraphicsContext* gc, ControlGroupBox* g)
|
||||
}
|
||||
break;
|
||||
|
||||
case GROUP_TYPE_BUTTONS:
|
||||
case ControllerEmu::GROUP_TYPE_BUTTONS:
|
||||
{
|
||||
const unsigned int button_count = static_cast<unsigned int>(g->control_group->controls.size());
|
||||
std::vector<unsigned int> bitmasks(button_count);
|
||||
@ -349,7 +361,7 @@ static void DrawControlGroupBox(wxGraphicsContext* gc, ControlGroupBox* g)
|
||||
}
|
||||
break;
|
||||
|
||||
case GROUP_TYPE_TRIGGERS:
|
||||
case ControllerEmu::GROUP_TYPE_TRIGGERS:
|
||||
{
|
||||
const unsigned int trigger_count = static_cast<unsigned int>(g->control_group->controls.size());
|
||||
std::vector<ControlState> trigs(trigger_count);
|
||||
@ -391,7 +403,7 @@ static void DrawControlGroupBox(wxGraphicsContext* gc, ControlGroupBox* g)
|
||||
}
|
||||
break;
|
||||
|
||||
case GROUP_TYPE_MIXED_TRIGGERS:
|
||||
case ControllerEmu::GROUP_TYPE_MIXED_TRIGGERS:
|
||||
{
|
||||
const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size() / 2));
|
||||
|
||||
@ -431,7 +443,7 @@ static void DrawControlGroupBox(wxGraphicsContext* gc, ControlGroupBox* g)
|
||||
}
|
||||
break;
|
||||
|
||||
case GROUP_TYPE_SLIDER:
|
||||
case ControllerEmu::GROUP_TYPE_SLIDER:
|
||||
{
|
||||
const ControlState deadzone = g->control_group->numeric_settings[0]->GetValue();
|
||||
|
||||
@ -488,7 +500,7 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
g_controller_interface.UpdateInput();
|
||||
|
||||
wxMemoryDC dc;
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
for (ControlGroupBox* g : control_groups)
|
||||
{
|
||||
// Only if this control group has a bitmap
|
||||
|
@ -1,5 +1,19 @@
|
||||
set(SRCS InputConfig.cpp
|
||||
ControllerEmu/ControllerEmu.cpp
|
||||
ControllerEmu/Control/Control.cpp
|
||||
ControllerEmu/Control/Input.cpp
|
||||
ControllerEmu/Control/Output.cpp
|
||||
ControllerEmu/ControlGroup/AnalogStick.cpp
|
||||
ControllerEmu/ControlGroup/Buttons.cpp
|
||||
ControllerEmu/ControlGroup/ControlGroup.cpp
|
||||
ControllerEmu/ControlGroup/Cursor.cpp
|
||||
ControllerEmu/ControlGroup/Extension.cpp
|
||||
ControllerEmu/ControlGroup/Force.cpp
|
||||
ControllerEmu/ControlGroup/MixedTriggers.cpp
|
||||
ControllerEmu/ControlGroup/ModifySettingsButton.cpp
|
||||
ControllerEmu/ControlGroup/Slider.cpp
|
||||
ControllerEmu/ControlGroup/Tilt.cpp
|
||||
ControllerEmu/ControlGroup/Triggers.cpp
|
||||
ControllerInterface/ControllerInterface.cpp
|
||||
ControllerInterface/Device.cpp
|
||||
ControlReference/ControlReference.cpp
|
||||
|
15
Source/Core/InputCommon/ControllerEmu/Control/Control.cpp
Normal file
15
Source/Core/InputCommon/ControllerEmu/Control/Control.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Control::Control(ControlReference* ref, const std::string& name_) : control_ref(ref), name(name_)
|
||||
{
|
||||
}
|
||||
|
||||
Control::~Control() = default;
|
||||
} // namespace ControllerEmu
|
25
Source/Core/InputCommon/ControllerEmu/Control/Control.h
Normal file
25
Source/Core/InputCommon/ControllerEmu/Control/Control.h
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class ControlReference;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class Control
|
||||
{
|
||||
public:
|
||||
virtual ~Control();
|
||||
|
||||
std::unique_ptr<ControlReference> const control_ref;
|
||||
const std::string name;
|
||||
|
||||
protected:
|
||||
Control(ControlReference* ref, const std::string& name);
|
||||
};
|
||||
} // namespace ControllerEmu
|
15
Source/Core/InputCommon/ControllerEmu/Control/Input.cpp
Normal file
15
Source/Core/InputCommon/ControllerEmu/Control/Input.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
|
||||
#include <string>
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Input::Input(const std::string& name_) : Control(new InputReference, name_)
|
||||
{
|
||||
}
|
||||
} // namespace ControllerEmu
|
17
Source/Core/InputCommon/ControllerEmu/Control/Input.h
Normal file
17
Source/Core/InputCommon/ControllerEmu/Control/Input.h
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class Input : public Control
|
||||
{
|
||||
public:
|
||||
explicit Input(const std::string& name);
|
||||
};
|
||||
} // namespace ControllerEmu
|
15
Source/Core/InputCommon/ControllerEmu/Control/Output.cpp
Normal file
15
Source/Core/InputCommon/ControllerEmu/Control/Output.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Output.h"
|
||||
|
||||
#include <string>
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Output::Output(const std::string& name_) : Control(new OutputReference, name_)
|
||||
{
|
||||
}
|
||||
} // namespace ControllerEmu
|
17
Source/Core/InputCommon/ControllerEmu/Control/Output.h
Normal file
17
Source/Core/InputCommon/ControllerEmu/Control/Output.h
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class Output : public Control
|
||||
{
|
||||
public:
|
||||
explicit Output(const std::string& name);
|
||||
};
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,71 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
|
||||
#include "Common/Common.h"
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
AnalogStick::AnalogStick(const char* const name_, ControlState default_radius)
|
||||
: AnalogStick(name_, name_, default_radius)
|
||||
{
|
||||
}
|
||||
|
||||
AnalogStick::AnalogStick(const char* const name_, const char* const ui_name_,
|
||||
ControlState default_radius)
|
||||
: ControlGroup(name_, ui_name_, GROUP_TYPE_STICK)
|
||||
{
|
||||
for (auto& named_direction : named_directions)
|
||||
controls.emplace_back(std::make_unique<Input>(named_direction));
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Modifier")));
|
||||
numeric_settings.emplace_back(
|
||||
std::make_unique<NumericSetting>(_trans("Radius"), default_radius, 0, 100));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
void AnalogStick::GetState(ControlState* const x, ControlState* const y)
|
||||
{
|
||||
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 radius = numeric_settings[SETTING_RADIUS]->GetValue();
|
||||
ControlState deadzone = numeric_settings[SETTING_DEADZONE]->GetValue();
|
||||
ControlState m = controls[4]->control_ref->State();
|
||||
|
||||
ControlState ang = atan2(yy, xx);
|
||||
ControlState ang_sin = sin(ang);
|
||||
ControlState ang_cos = cos(ang);
|
||||
|
||||
ControlState dist = sqrt(xx * xx + yy * yy);
|
||||
|
||||
// dead zone code
|
||||
dist = std::max(0.0, dist - deadzone);
|
||||
dist /= (1 - deadzone);
|
||||
|
||||
// radius
|
||||
dist *= radius;
|
||||
|
||||
// The modifier halves the distance by 50%, which is useful
|
||||
// for keyboard controls.
|
||||
if (m)
|
||||
dist *= 0.5;
|
||||
|
||||
yy = std::max(-1.0, std::min(1.0, ang_sin * dist));
|
||||
xx = std::max(-1.0, std::min(1.0, ang_cos * dist));
|
||||
|
||||
*y = yy;
|
||||
*x = xx;
|
||||
}
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,26 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class AnalogStick : public ControlGroup
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
SETTING_RADIUS,
|
||||
SETTING_DEADZONE,
|
||||
};
|
||||
|
||||
// The GameCube controller and Wiimote attachments have a different default radius
|
||||
AnalogStick(const char* name, ControlState default_radius);
|
||||
AnalogStick(const char* name, const char* ui_name, ControlState default_radius);
|
||||
|
||||
void GetState(ControlState* x, ControlState* y);
|
||||
};
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,24 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Common.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Buttons::Buttons(const std::string& name_) : ControlGroup(name_, name_, GROUP_TYPE_BUTTONS)
|
||||
{
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
|
||||
}
|
||||
|
||||
Buttons::Buttons(const std::string& ini_name, const std::string& group_name)
|
||||
: ControlGroup(ini_name, group_name, GROUP_TYPE_BUTTONS)
|
||||
{
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
|
||||
}
|
||||
} // namespace ControllerEmu
|
33
Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h
Normal file
33
Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class Buttons : public ControlGroup
|
||||
{
|
||||
public:
|
||||
explicit Buttons(const std::string& name_);
|
||||
Buttons(const std::string& ini_name, const std::string& group_name);
|
||||
|
||||
template <typename C>
|
||||
void GetState(C* const buttons, const C* bitmasks)
|
||||
{
|
||||
for (auto& control : controls)
|
||||
{
|
||||
if (control->control_ref->State() > numeric_settings[0]->GetValue()) // threshold
|
||||
*buttons |= *bitmasks;
|
||||
|
||||
bitmasks++;
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,132 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/IniFile.h"
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Extension.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
ControlGroup::ControlGroup(const std::string& name_, const u32 type_)
|
||||
: name(name_), ui_name(name_), type(type_)
|
||||
{
|
||||
}
|
||||
|
||||
ControlGroup::ControlGroup(const std::string& name_, const std::string& ui_name_, const u32 type_)
|
||||
: name(name_), ui_name(ui_name_), type(type_)
|
||||
{
|
||||
}
|
||||
|
||||
ControlGroup::~ControlGroup() = default;
|
||||
|
||||
ControlGroup::BooleanSetting::~BooleanSetting() = default;
|
||||
|
||||
void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev,
|
||||
const std::string& base)
|
||||
{
|
||||
std::string group(base + name + "/");
|
||||
|
||||
// settings
|
||||
for (auto& s : numeric_settings)
|
||||
{
|
||||
if (s->m_type == SettingType::VIRTUAL)
|
||||
continue;
|
||||
|
||||
sec->Get(group + s->m_name, &s->m_value, s->m_default_value * 100);
|
||||
s->m_value /= 100;
|
||||
}
|
||||
|
||||
for (auto& s : boolean_settings)
|
||||
{
|
||||
if (s->m_type == SettingType::VIRTUAL)
|
||||
continue;
|
||||
|
||||
sec->Get(group + s->m_name, &s->m_value, s->m_default_value);
|
||||
}
|
||||
|
||||
for (auto& c : controls)
|
||||
{
|
||||
// control expression
|
||||
sec->Get(group + c->name, &c->control_ref->expression, "");
|
||||
|
||||
// range
|
||||
sec->Get(group + c->name + "/Range", &c->control_ref->range, 100.0);
|
||||
c->control_ref->range /= 100;
|
||||
}
|
||||
|
||||
// extensions
|
||||
if (type == GROUP_TYPE_EXTENSION)
|
||||
{
|
||||
Extension* const ext = (Extension*)this;
|
||||
|
||||
ext->switch_extension = 0;
|
||||
u32 n = 0;
|
||||
std::string extname;
|
||||
sec->Get(base + name, &extname, "");
|
||||
|
||||
for (auto& ai : ext->attachments)
|
||||
{
|
||||
ai->default_device.FromString(defdev);
|
||||
ai->LoadConfig(sec, base + ai->GetName() + "/");
|
||||
|
||||
if (ai->GetName() == extname)
|
||||
ext->switch_extension = n;
|
||||
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ControlGroup::SaveConfig(IniFile::Section* sec, const std::string& defdev,
|
||||
const std::string& base)
|
||||
{
|
||||
std::string group(base + name + "/");
|
||||
|
||||
for (auto& s : numeric_settings)
|
||||
{
|
||||
if (s->m_type == SettingType::VIRTUAL)
|
||||
continue;
|
||||
|
||||
sec->Set(group + s->m_name, s->m_value * 100.0, s->m_default_value * 100.0);
|
||||
}
|
||||
|
||||
for (auto& s : boolean_settings)
|
||||
{
|
||||
if (s->m_type == SettingType::VIRTUAL)
|
||||
continue;
|
||||
|
||||
sec->Set(group + s->m_name, s->m_value, s->m_default_value);
|
||||
}
|
||||
|
||||
for (auto& c : controls)
|
||||
{
|
||||
// control expression
|
||||
sec->Set(group + c->name, c->control_ref->expression, "");
|
||||
|
||||
// range
|
||||
sec->Set(group + c->name + "/Range", c->control_ref->range * 100.0, 100.0);
|
||||
}
|
||||
|
||||
// extensions
|
||||
if (type == GROUP_TYPE_EXTENSION)
|
||||
{
|
||||
Extension* const ext = (Extension*)this;
|
||||
sec->Set(base + name, ext->attachments[ext->switch_extension]->GetName(), "None");
|
||||
|
||||
for (auto& ai : ext->attachments)
|
||||
ai->SaveConfig(sec, base + ai->GetName() + "/");
|
||||
}
|
||||
}
|
||||
|
||||
void ControlGroup::SetControlExpression(int index, const std::string& expression)
|
||||
{
|
||||
controls.at(index)->control_ref->expression = expression;
|
||||
}
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,117 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "InputCommon/ControllerInterface/Device.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class Control;
|
||||
|
||||
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,
|
||||
GROUP_TYPE_SLIDER
|
||||
};
|
||||
|
||||
class ControlGroup
|
||||
{
|
||||
public:
|
||||
enum class SettingType
|
||||
{
|
||||
NORMAL, // normal settings are saved to configuration files
|
||||
VIRTUAL, // virtual settings are not saved at all
|
||||
};
|
||||
|
||||
class NumericSetting
|
||||
{
|
||||
public:
|
||||
NumericSetting(const std::string& setting_name, const ControlState default_value,
|
||||
const u32 low = 0, const u32 high = 100,
|
||||
const SettingType setting_type = SettingType::NORMAL)
|
||||
: m_type(setting_type), m_name(setting_name), m_default_value(default_value), m_low(low),
|
||||
m_high(high)
|
||||
{
|
||||
}
|
||||
|
||||
ControlState GetValue() const { return m_value; }
|
||||
void SetValue(ControlState value) { m_value = value; }
|
||||
const SettingType m_type;
|
||||
const std::string m_name;
|
||||
const ControlState m_default_value;
|
||||
const u32 m_low;
|
||||
const u32 m_high;
|
||||
ControlState m_value;
|
||||
};
|
||||
|
||||
class BooleanSetting
|
||||
{
|
||||
public:
|
||||
BooleanSetting(const std::string& setting_name, const bool default_value,
|
||||
const SettingType setting_type = SettingType::NORMAL)
|
||||
: m_type(setting_type), m_name(setting_name), m_default_value(default_value)
|
||||
{
|
||||
}
|
||||
virtual ~BooleanSetting();
|
||||
|
||||
virtual bool GetValue() const { return m_value; }
|
||||
virtual void SetValue(bool value) { m_value = value; }
|
||||
const SettingType m_type;
|
||||
const std::string m_name;
|
||||
const bool m_default_value;
|
||||
bool m_value;
|
||||
};
|
||||
|
||||
class BackgroundInputSetting : public BooleanSetting
|
||||
{
|
||||
public:
|
||||
BackgroundInputSetting(const std::string& setting_name)
|
||||
: BooleanSetting(setting_name, false, SettingType::VIRTUAL)
|
||||
{
|
||||
}
|
||||
|
||||
bool GetValue() const override { return SConfig::GetInstance().m_BackgroundInput; }
|
||||
void SetValue(bool value) override
|
||||
{
|
||||
m_value = value;
|
||||
SConfig::GetInstance().m_BackgroundInput = value;
|
||||
}
|
||||
};
|
||||
|
||||
explicit ControlGroup(const std::string& name, u32 type = GROUP_TYPE_OTHER);
|
||||
ControlGroup(const std::string& name, const std::string& ui_name, u32 type = GROUP_TYPE_OTHER);
|
||||
virtual ~ControlGroup();
|
||||
|
||||
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 = "");
|
||||
|
||||
void SetControlExpression(int index, const std::string& expression);
|
||||
|
||||
const std::string name;
|
||||
const std::string ui_name;
|
||||
const u32 type;
|
||||
|
||||
std::vector<std::unique_ptr<Control>> controls;
|
||||
std::vector<std::unique_ptr<NumericSetting>> numeric_settings;
|
||||
std::vector<std::unique_ptr<BooleanSetting>> boolean_settings;
|
||||
};
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,98 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Cursor.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/MathUtil.h"
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Cursor::Cursor(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_CURSOR)
|
||||
{
|
||||
for (auto& named_direction : named_directions)
|
||||
controls.emplace_back(std::make_unique<Input>(named_direction));
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>("Forward"));
|
||||
controls.emplace_back(std::make_unique<Input>("Backward"));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Hide")));
|
||||
controls.emplace_back(std::make_unique<Input>("Recenter"));
|
||||
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Center"), 0.5));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Width"), 0.5));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Height"), 0.5));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 20));
|
||||
boolean_settings.emplace_back(std::make_unique<BooleanSetting>(_trans("Relative Input"), false));
|
||||
}
|
||||
|
||||
void Cursor::GetState(ControlState* const x, ControlState* const y, ControlState* const z,
|
||||
const bool adjusted)
|
||||
{
|
||||
const ControlState 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.1, zz);
|
||||
else if (zz < m_z)
|
||||
m_z = std::max(m_z - 0.1, zz);
|
||||
|
||||
*z = m_z;
|
||||
|
||||
// hide
|
||||
if (controls[6]->control_ref->State() > 0.5)
|
||||
{
|
||||
*x = 10000;
|
||||
*y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
|
||||
ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
|
||||
|
||||
// adjust cursor according to settings
|
||||
if (adjusted)
|
||||
{
|
||||
xx *= (numeric_settings[1]->GetValue() * 2);
|
||||
yy *= (numeric_settings[2]->GetValue() * 2);
|
||||
yy += (numeric_settings[0]->GetValue() - 0.5);
|
||||
}
|
||||
|
||||
// relative input
|
||||
if (boolean_settings[0]->GetValue())
|
||||
{
|
||||
const ControlState deadzone = numeric_settings[3]->GetValue();
|
||||
// deadzone to avoid the cursor slowly drifting
|
||||
if (std::abs(xx) > deadzone)
|
||||
m_x = MathUtil::Clamp(m_x + xx * SPEED_MULTIPLIER, -1.0, 1.0);
|
||||
if (std::abs(yy) > deadzone)
|
||||
m_y = MathUtil::Clamp(m_y + yy * SPEED_MULTIPLIER, -1.0, 1.0);
|
||||
|
||||
// recenter
|
||||
if (controls[7]->control_ref->State() > 0.5)
|
||||
{
|
||||
m_x = 0.0;
|
||||
m_y = 0.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_x = xx;
|
||||
m_y = yy;
|
||||
}
|
||||
|
||||
*x = m_x;
|
||||
*y = m_y;
|
||||
}
|
||||
}
|
||||
} // namespace ControllerEmu
|
29
Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h
Normal file
29
Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class Cursor : public ControlGroup
|
||||
{
|
||||
public:
|
||||
explicit Cursor(const std::string& name);
|
||||
|
||||
void GetState(ControlState* x, ControlState* y, ControlState* z, bool adjusted = false);
|
||||
|
||||
ControlState m_z = 0.0;
|
||||
|
||||
private:
|
||||
// This is used to reduce the cursor speed for relative input
|
||||
// to something that makes sense with the default range.
|
||||
static constexpr double SPEED_MULTIPLIER = 0.04;
|
||||
|
||||
ControlState m_x = 0.0;
|
||||
ControlState m_y = 0.0;
|
||||
};
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,16 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Extension.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Extension::Extension(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_EXTENSION)
|
||||
{
|
||||
}
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,31 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class EmulatedController;
|
||||
|
||||
class Extension : public ControlGroup
|
||||
{
|
||||
public:
|
||||
explicit Extension(const std::string& name);
|
||||
|
||||
void GetState(u8* data);
|
||||
bool IsButtonPressed() const;
|
||||
|
||||
std::vector<std::unique_ptr<EmulatedController>> attachments;
|
||||
|
||||
int switch_extension = 0;
|
||||
int active_extension = 0;
|
||||
};
|
||||
} // namespace ControllerEmu
|
51
Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp
Normal file
51
Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Force.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Force::Force(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_FORCE)
|
||||
{
|
||||
memset(m_swing, 0, sizeof(m_swing));
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Up")));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Down")));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Left")));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Right")));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Forward")));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Backward")));
|
||||
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
void Force::GetState(ControlState* axis)
|
||||
{
|
||||
const ControlState deadzone = numeric_settings[0]->GetValue();
|
||||
|
||||
for (u32 i = 0; i < 6; i += 2)
|
||||
{
|
||||
ControlState tmpf = 0;
|
||||
const ControlState state =
|
||||
controls[i + 1]->control_ref->State() - controls[i]->control_ref->State();
|
||||
if (fabs(state) > deadzone)
|
||||
tmpf = ((state - (deadzone * sign(state))) / (1 - deadzone));
|
||||
|
||||
ControlState& ax = m_swing[i >> 1];
|
||||
*axis++ = (tmpf - ax);
|
||||
ax = tmpf;
|
||||
}
|
||||
}
|
||||
} // namespace ControllerEmu
|
22
Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.h
Normal file
22
Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.h
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class Force : public ControlGroup
|
||||
{
|
||||
public:
|
||||
explicit Force(const std::string& name);
|
||||
|
||||
void GetState(ControlState* axis);
|
||||
|
||||
private:
|
||||
ControlState m_swing[3];
|
||||
};
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,42 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
MixedTriggers::MixedTriggers(const std::string& name_)
|
||||
: ControlGroup(name_, GROUP_TYPE_MIXED_TRIGGERS)
|
||||
{
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.9));
|
||||
}
|
||||
|
||||
void MixedTriggers::GetState(u16* const digital, const u16* bitmasks, ControlState* analog)
|
||||
{
|
||||
const size_t trigger_count = controls.size() / 2;
|
||||
|
||||
for (size_t i = 0; i < trigger_count; ++i, ++bitmasks, ++analog)
|
||||
{
|
||||
if (controls[i]->control_ref->State() > numeric_settings[0]->GetValue()) // threshold
|
||||
{
|
||||
*analog = 1.0;
|
||||
*digital |= *bitmasks;
|
||||
}
|
||||
else
|
||||
{
|
||||
*analog = controls[i + trigger_count]->control_ref->State();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,19 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class MixedTriggers : public ControlGroup
|
||||
{
|
||||
public:
|
||||
explicit MixedTriggers(const std::string& name);
|
||||
|
||||
void GetState(u16* digital, const u16* bitmasks, ControlState* analog);
|
||||
};
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,77 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
ModifySettingsButton::ModifySettingsButton(std::string button_name)
|
||||
: Buttons(std::move(button_name))
|
||||
{
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
|
||||
}
|
||||
|
||||
void ModifySettingsButton::AddInput(std::string button_name, bool toggle)
|
||||
{
|
||||
controls.emplace_back(new Input(std::move(button_name)));
|
||||
threshold_exceeded.emplace_back(false);
|
||||
associated_settings.emplace_back(false);
|
||||
associated_settings_toggle.emplace_back(toggle);
|
||||
}
|
||||
|
||||
void ModifySettingsButton::GetState()
|
||||
{
|
||||
for (size_t i = 0; i < controls.size(); ++i)
|
||||
{
|
||||
ControlState state = controls[i]->control_ref->State();
|
||||
|
||||
if (!associated_settings_toggle[i])
|
||||
{
|
||||
// not toggled
|
||||
associated_settings[i] = state > numeric_settings[0]->GetValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
// toggle (loading savestates does not en-/disable toggle)
|
||||
// after we passed the threshold, we en-/disable. but after that, we don't change it
|
||||
// anymore
|
||||
if (!threshold_exceeded[i] && state > numeric_settings[0]->GetValue())
|
||||
{
|
||||
associated_settings[i] = !associated_settings[i];
|
||||
|
||||
if (associated_settings[i])
|
||||
OSD::AddMessage(controls[i]->name + ": " + _trans("on"));
|
||||
else
|
||||
OSD::AddMessage(controls[i]->name + ": " + _trans("off"));
|
||||
|
||||
threshold_exceeded[i] = true;
|
||||
}
|
||||
|
||||
if (state < numeric_settings[0]->GetValue())
|
||||
threshold_exceeded[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<bool>& ModifySettingsButton::isSettingToggled() const
|
||||
{
|
||||
return associated_settings_toggle;
|
||||
}
|
||||
|
||||
const std::vector<bool>& ModifySettingsButton::getSettingsModifier() const
|
||||
{
|
||||
return associated_settings;
|
||||
}
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,31 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class ModifySettingsButton : public Buttons
|
||||
{
|
||||
public:
|
||||
explicit ModifySettingsButton(std::string button_name);
|
||||
|
||||
void AddInput(std::string button_name, bool toggle = false);
|
||||
|
||||
void GetState();
|
||||
|
||||
const std::vector<bool>& isSettingToggled() const;
|
||||
const std::vector<bool>& getSettingsModifier() const;
|
||||
|
||||
private:
|
||||
std::vector<bool> threshold_exceeded; // internal calculation (if "state" was above threshold)
|
||||
std::vector<bool> associated_settings_toggle; // is setting toggled or hold?
|
||||
std::vector<bool> associated_settings; // result
|
||||
};
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,37 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Slider.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Slider::Slider(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_SLIDER)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Input>("Left"));
|
||||
controls.emplace_back(std::make_unique<Input>("Right"));
|
||||
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
void Slider::GetState(ControlState* const slider)
|
||||
{
|
||||
const ControlState deadzone = numeric_settings[0]->GetValue();
|
||||
const ControlState state = controls[1]->control_ref->State() - controls[0]->control_ref->State();
|
||||
|
||||
if (fabs(state) > deadzone)
|
||||
*slider = (state - (deadzone * sign(state))) / (1 - deadzone);
|
||||
else
|
||||
*slider = 0;
|
||||
}
|
||||
} // namespace ControllerEmu
|
19
Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.h
Normal file
19
Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.h
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class Slider : public ControlGroup
|
||||
{
|
||||
public:
|
||||
explicit Slider(const std::string& name);
|
||||
|
||||
void GetState(ControlState* slider);
|
||||
};
|
||||
} // namespace ControllerEmu
|
99
Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp
Normal file
99
Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Tilt.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Tilt::Tilt(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_TILT)
|
||||
{
|
||||
memset(m_tilt, 0, sizeof(m_tilt));
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>("Forward"));
|
||||
controls.emplace_back(std::make_unique<Input>("Backward"));
|
||||
controls.emplace_back(std::make_unique<Input>("Left"));
|
||||
controls.emplace_back(std::make_unique<Input>("Right"));
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Modifier")));
|
||||
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Circle Stick"), 0));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Angle"), 0.9, 0, 180));
|
||||
}
|
||||
|
||||
void Tilt::GetState(ControlState* const x, ControlState* const y, const bool step)
|
||||
{
|
||||
// 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 = numeric_settings[0]->GetValue();
|
||||
ControlState circle = numeric_settings[1]->GetValue();
|
||||
auto const angle = numeric_settings[2]->GetValue() / 1.8;
|
||||
ControlState m = controls[4]->control_ref->State();
|
||||
|
||||
// deadzone / circle stick code
|
||||
// this section might be all wrong, but its working good enough, I think
|
||||
|
||||
ControlState ang = atan2(yy, xx);
|
||||
ControlState ang_sin = sin(ang);
|
||||
ControlState ang_cos = cos(ang);
|
||||
|
||||
// the amt a full square stick would have at current angle
|
||||
ControlState square_full =
|
||||
std::min(ang_sin ? 1 / fabs(ang_sin) : 2, ang_cos ? 1 / fabs(ang_cos) : 2);
|
||||
|
||||
// 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);
|
||||
|
||||
ControlState dist = sqrt(xx * xx + yy * yy);
|
||||
|
||||
// dead zone code
|
||||
dist = std::max(0.0, dist - deadzone * stick_full);
|
||||
dist /= (1 - deadzone);
|
||||
|
||||
// circle stick code
|
||||
ControlState amt = dist / stick_full;
|
||||
dist += (square_full - 1) * amt * circle;
|
||||
|
||||
if (m)
|
||||
dist *= 0.5;
|
||||
|
||||
yy = std::max(-1.0, std::min(1.0, ang_sin * dist));
|
||||
xx = std::max(-1.0, std::min(1.0, ang_cos * dist));
|
||||
|
||||
// this is kinda silly here
|
||||
// gui being open will make this happen 2x as fast, o well
|
||||
|
||||
// silly
|
||||
if (step)
|
||||
{
|
||||
if (xx > m_tilt[0])
|
||||
m_tilt[0] = std::min(m_tilt[0] + 0.1, xx);
|
||||
else if (xx < m_tilt[0])
|
||||
m_tilt[0] = std::max(m_tilt[0] - 0.1, xx);
|
||||
|
||||
if (yy > m_tilt[1])
|
||||
m_tilt[1] = std::min(m_tilt[1] + 0.1, yy);
|
||||
else if (yy < m_tilt[1])
|
||||
m_tilt[1] = std::max(m_tilt[1] - 0.1, yy);
|
||||
}
|
||||
|
||||
*y = m_tilt[1] * angle;
|
||||
*x = m_tilt[0] * angle;
|
||||
}
|
||||
} // namespace ControllerEmu
|
22
Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.h
Normal file
22
Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.h
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class Tilt : public ControlGroup
|
||||
{
|
||||
public:
|
||||
explicit Tilt(const std::string& name);
|
||||
|
||||
void GetState(ControlState* x, ControlState* y, bool step = true);
|
||||
|
||||
private:
|
||||
ControlState m_tilt[2];
|
||||
};
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,31 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Triggers.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Triggers::Triggers(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_TRIGGERS)
|
||||
{
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
void Triggers::GetState(ControlState* analog)
|
||||
{
|
||||
const size_t trigger_count = controls.size();
|
||||
const ControlState deadzone = numeric_settings[0]->GetValue();
|
||||
|
||||
for (size_t i = 0; i < trigger_count; ++i, ++analog)
|
||||
*analog = std::max(controls[i]->control_ref->State() - deadzone, 0.0) / (1 - deadzone);
|
||||
}
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,19 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class Triggers : public ControlGroup
|
||||
{
|
||||
public:
|
||||
explicit Triggers(const std::string& name);
|
||||
|
||||
void GetState(ControlState* analog);
|
||||
};
|
||||
} // namespace ControllerEmu
|
@ -3,23 +3,36 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
|
||||
#include <memory>
|
||||
#include "Common/Common.h"
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "Common/IniFile.h"
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Extension.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
static std::recursive_mutex s_get_state_mutex;
|
||||
|
||||
EmulatedController::~EmulatedController() = default;
|
||||
|
||||
// This should be called before calling GetState() or State() on a control reference
|
||||
// to prevent a race condition.
|
||||
// This is a recursive mutex because UpdateReferences is recursive.
|
||||
static std::recursive_mutex s_get_state_mutex;
|
||||
std::unique_lock<std::recursive_mutex> ControllerEmu::GetStateLock()
|
||||
std::unique_lock<std::recursive_mutex> EmulatedController::GetStateLock()
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(s_get_state_mutex);
|
||||
return lock;
|
||||
}
|
||||
|
||||
void ControllerEmu::UpdateReferences(ControllerInterface& devi)
|
||||
void EmulatedController::UpdateReferences(ControllerInterface& devi)
|
||||
{
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
const auto lock = GetStateLock();
|
||||
for (auto& ctrlGroup : groups)
|
||||
{
|
||||
for (auto& control : ctrlGroup->controls)
|
||||
@ -34,7 +47,7 @@ void ControllerEmu::UpdateReferences(ControllerInterface& devi)
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerEmu::UpdateDefaultDevice()
|
||||
void EmulatedController::UpdateDefaultDevice()
|
||||
{
|
||||
for (auto& ctrlGroup : groups)
|
||||
{
|
||||
@ -50,62 +63,7 @@ void ControllerEmu::UpdateDefaultDevice()
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev,
|
||||
const std::string& base)
|
||||
{
|
||||
std::string group(base + name + "/");
|
||||
|
||||
// settings
|
||||
for (auto& s : numeric_settings)
|
||||
{
|
||||
if (s->m_type == SettingType::VIRTUAL)
|
||||
continue;
|
||||
sec->Get(group + s->m_name, &s->m_value, s->m_default_value * 100);
|
||||
s->m_value /= 100;
|
||||
}
|
||||
for (auto& s : boolean_settings)
|
||||
{
|
||||
if (s->m_type == SettingType::VIRTUAL)
|
||||
continue;
|
||||
sec->Get(group + s->m_name, &s->m_value, s->m_default_value);
|
||||
}
|
||||
|
||||
for (auto& c : controls)
|
||||
{
|
||||
// control expression
|
||||
sec->Get(group + c->name, &c->control_ref->expression, "");
|
||||
|
||||
// range
|
||||
sec->Get(group + c->name + "/Range", &c->control_ref->range, 100.0);
|
||||
c->control_ref->range /= 100;
|
||||
}
|
||||
|
||||
// extensions
|
||||
if (type == GROUP_TYPE_EXTENSION)
|
||||
{
|
||||
Extension* const ext = (Extension*)this;
|
||||
|
||||
ext->switch_extension = 0;
|
||||
unsigned int n = 0;
|
||||
std::string extname;
|
||||
sec->Get(base + name, &extname, "");
|
||||
|
||||
for (auto& ai : ext->attachments)
|
||||
{
|
||||
ai->default_device.FromString(defdev);
|
||||
ai->LoadConfig(sec, base + ai->GetName() + "/");
|
||||
|
||||
if (ai->GetName() == extname)
|
||||
ext->switch_extension = n;
|
||||
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ControllerEmu::ControlGroup::BooleanSetting::~BooleanSetting() = default;
|
||||
|
||||
void ControllerEmu::LoadConfig(IniFile::Section* sec, const std::string& base)
|
||||
void EmulatedController::LoadConfig(IniFile::Section* sec, const std::string& base)
|
||||
{
|
||||
std::string defdev = default_device.ToString();
|
||||
if (base.empty())
|
||||
@ -118,45 +76,7 @@ void ControllerEmu::LoadConfig(IniFile::Section* sec, const std::string& base)
|
||||
cg->LoadConfig(sec, defdev, base);
|
||||
}
|
||||
|
||||
void ControllerEmu::ControlGroup::SaveConfig(IniFile::Section* sec, const std::string& defdev,
|
||||
const std::string& base)
|
||||
{
|
||||
std::string group(base + name + "/");
|
||||
|
||||
for (auto& s : numeric_settings)
|
||||
{
|
||||
if (s->m_type == SettingType::VIRTUAL)
|
||||
continue;
|
||||
sec->Set(group + s->m_name, s->m_value * 100.0, s->m_default_value * 100.0);
|
||||
}
|
||||
for (auto& s : boolean_settings)
|
||||
{
|
||||
if (s->m_type == SettingType::VIRTUAL)
|
||||
continue;
|
||||
sec->Set(group + s->m_name, s->m_value, s->m_default_value);
|
||||
}
|
||||
|
||||
for (auto& c : controls)
|
||||
{
|
||||
// control expression
|
||||
sec->Set(group + c->name, c->control_ref->expression, "");
|
||||
|
||||
// range
|
||||
sec->Set(group + c->name + "/Range", c->control_ref->range * 100.0, 100.0);
|
||||
}
|
||||
|
||||
// extensions
|
||||
if (type == GROUP_TYPE_EXTENSION)
|
||||
{
|
||||
Extension* const ext = (Extension*)this;
|
||||
sec->Set(base + name, ext->attachments[ext->switch_extension]->GetName(), "None");
|
||||
|
||||
for (auto& ai : ext->attachments)
|
||||
ai->SaveConfig(sec, base + ai->GetName() + "/");
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerEmu::SaveConfig(IniFile::Section* sec, const std::string& base)
|
||||
void EmulatedController::SaveConfig(IniFile::Section* sec, const std::string& base)
|
||||
{
|
||||
const std::string defdev = default_device.ToString();
|
||||
if (base.empty())
|
||||
@ -166,154 +86,7 @@ void ControllerEmu::SaveConfig(IniFile::Section* sec, const std::string& base)
|
||||
ctrlGroup->SaveConfig(sec, defdev, base);
|
||||
}
|
||||
|
||||
void ControllerEmu::ControlGroup::SetControlExpression(int index, const std::string& expression)
|
||||
{
|
||||
controls.at(index)->control_ref->expression = expression;
|
||||
}
|
||||
|
||||
ControllerEmu::AnalogStick::AnalogStick(const char* const _name, ControlState default_radius)
|
||||
: AnalogStick(_name, _name, default_radius)
|
||||
{
|
||||
}
|
||||
|
||||
ControllerEmu::AnalogStick::AnalogStick(const char* const _name, const char* const _ui_name,
|
||||
ControlState default_radius)
|
||||
: ControlGroup(_name, _ui_name, GROUP_TYPE_STICK)
|
||||
{
|
||||
for (auto& named_direction : named_directions)
|
||||
controls.emplace_back(std::make_unique<Input>(named_direction));
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Modifier")));
|
||||
numeric_settings.emplace_back(
|
||||
std::make_unique<NumericSetting>(_trans("Radius"), default_radius, 0, 100));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
ControllerEmu::Buttons::Buttons(const std::string& _name)
|
||||
: ControlGroup(_name, _name, GROUP_TYPE_BUTTONS)
|
||||
{
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
|
||||
}
|
||||
|
||||
ControllerEmu::Buttons::Buttons(const std::string& ini_name, const std::string& group_name)
|
||||
: ControlGroup(ini_name, group_name, GROUP_TYPE_BUTTONS)
|
||||
{
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
|
||||
}
|
||||
|
||||
ControllerEmu::ModifySettingsButton::ModifySettingsButton(std::string button_name)
|
||||
: Buttons(std::move(button_name))
|
||||
{
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
|
||||
}
|
||||
|
||||
void ControllerEmu::ModifySettingsButton::AddInput(std::string button_name, bool toggle)
|
||||
{
|
||||
controls.emplace_back(new ControlGroup::Input(std::move(button_name)));
|
||||
threshold_exceeded.emplace_back(false);
|
||||
associated_settings.emplace_back(false);
|
||||
associated_settings_toggle.emplace_back(toggle);
|
||||
}
|
||||
|
||||
void ControllerEmu::ModifySettingsButton::GetState()
|
||||
{
|
||||
for (size_t i = 0; i < controls.size(); ++i)
|
||||
{
|
||||
ControlState state = controls[i]->control_ref->State();
|
||||
|
||||
if (!associated_settings_toggle[i])
|
||||
{
|
||||
// not toggled
|
||||
associated_settings[i] = state > numeric_settings[0]->GetValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
// toggle (loading savestates does not en-/disable toggle)
|
||||
// after we passed the threshold, we en-/disable. but after that, we don't change it
|
||||
// anymore
|
||||
if (!threshold_exceeded[i] && state > numeric_settings[0]->GetValue())
|
||||
{
|
||||
associated_settings[i] = !associated_settings[i];
|
||||
if (associated_settings[i])
|
||||
OSD::AddMessage(controls[i]->name + ": " + _trans("on"));
|
||||
else
|
||||
OSD::AddMessage(controls[i]->name + ": " + _trans("off"));
|
||||
threshold_exceeded[i] = true;
|
||||
}
|
||||
if (state < numeric_settings[0]->GetValue())
|
||||
threshold_exceeded[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ControllerEmu::MixedTriggers::MixedTriggers(const std::string& _name)
|
||||
: ControlGroup(_name, GROUP_TYPE_MIXED_TRIGGERS)
|
||||
{
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.9));
|
||||
}
|
||||
|
||||
ControllerEmu::Triggers::Triggers(const std::string& _name)
|
||||
: ControlGroup(_name, GROUP_TYPE_TRIGGERS)
|
||||
{
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
ControllerEmu::Slider::Slider(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_SLIDER)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Input>("Left"));
|
||||
controls.emplace_back(std::make_unique<Input>("Right"));
|
||||
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
ControllerEmu::Force::Force(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_FORCE)
|
||||
{
|
||||
memset(m_swing, 0, sizeof(m_swing));
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Up")));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Down")));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Left")));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Right")));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Forward")));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Backward")));
|
||||
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
ControllerEmu::Tilt::Tilt(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_TILT)
|
||||
{
|
||||
memset(m_tilt, 0, sizeof(m_tilt));
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>("Forward"));
|
||||
controls.emplace_back(std::make_unique<Input>("Backward"));
|
||||
controls.emplace_back(std::make_unique<Input>("Left"));
|
||||
controls.emplace_back(std::make_unique<Input>("Right"));
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Modifier")));
|
||||
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Circle Stick"), 0));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Angle"), 0.9, 0, 180));
|
||||
}
|
||||
|
||||
ControllerEmu::Cursor::Cursor(const std::string& _name)
|
||||
: ControlGroup(_name, GROUP_TYPE_CURSOR), m_z(0)
|
||||
{
|
||||
for (auto& named_direction : named_directions)
|
||||
controls.emplace_back(std::make_unique<Input>(named_direction));
|
||||
controls.emplace_back(std::make_unique<Input>("Forward"));
|
||||
controls.emplace_back(std::make_unique<Input>("Backward"));
|
||||
controls.emplace_back(std::make_unique<Input>(_trans("Hide")));
|
||||
controls.emplace_back(std::make_unique<Input>("Recenter"));
|
||||
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Center"), 0.5));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Width"), 0.5));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Height"), 0.5));
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 20));
|
||||
boolean_settings.emplace_back(std::make_unique<BooleanSetting>(_trans("Relative Input"), false));
|
||||
}
|
||||
|
||||
void ControllerEmu::LoadDefaults(const ControllerInterface& ciface)
|
||||
void EmulatedController::LoadDefaults(const ControllerInterface& ciface)
|
||||
{
|
||||
// load an empty inifile section, clears everything
|
||||
IniFile::Section sec;
|
||||
@ -326,3 +99,4 @@ void ControllerEmu::LoadDefaults(const ControllerInterface& ciface)
|
||||
UpdateDefaultDevice();
|
||||
}
|
||||
}
|
||||
} // namespace ControllerEmu
|
||||
|
@ -4,488 +4,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
|
||||
#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,
|
||||
GROUP_TYPE_SLIDER
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SETTING_RADIUS,
|
||||
SETTING_DEADZONE,
|
||||
};
|
||||
|
||||
const char* const named_directions[] = {"Up", "Down", "Left", "Right"};
|
||||
|
||||
class ControllerEmu
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class ControlGroup;
|
||||
|
||||
class EmulatedController
|
||||
{
|
||||
public:
|
||||
class ControlGroup
|
||||
{
|
||||
public:
|
||||
class Control
|
||||
{
|
||||
protected:
|
||||
Control(ControlReference* const _ref, const std::string& _name)
|
||||
: control_ref(_ref), name(_name)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual ~Control() {}
|
||||
std::unique_ptr<ControlReference> const control_ref;
|
||||
const std::string name;
|
||||
};
|
||||
|
||||
class Input : public Control
|
||||
{
|
||||
public:
|
||||
Input(const std::string& _name) : Control(new InputReference, _name) {}
|
||||
};
|
||||
|
||||
class Output : public Control
|
||||
{
|
||||
public:
|
||||
Output(const std::string& _name) : Control(new OutputReference, _name) {}
|
||||
};
|
||||
|
||||
enum class SettingType
|
||||
{
|
||||
NORMAL, // normal settings are saved to configuration files
|
||||
VIRTUAL, // virtual settings are not saved at all
|
||||
};
|
||||
|
||||
class NumericSetting
|
||||
{
|
||||
public:
|
||||
NumericSetting(const std::string& setting_name, const ControlState default_value,
|
||||
const unsigned int low = 0, const unsigned int high = 100,
|
||||
const SettingType setting_type = SettingType::NORMAL)
|
||||
: m_type(setting_type), m_name(setting_name), m_default_value(default_value), m_low(low),
|
||||
m_high(high)
|
||||
{
|
||||
}
|
||||
|
||||
ControlState GetValue() const { return m_value; }
|
||||
void SetValue(ControlState value) { m_value = value; }
|
||||
const SettingType m_type;
|
||||
const std::string m_name;
|
||||
const ControlState m_default_value;
|
||||
const unsigned int m_low, m_high;
|
||||
ControlState m_value;
|
||||
};
|
||||
|
||||
class BooleanSetting
|
||||
{
|
||||
public:
|
||||
BooleanSetting(const std::string& setting_name, const bool default_value,
|
||||
const SettingType setting_type = SettingType::NORMAL)
|
||||
: m_type(setting_type), m_name(setting_name), m_default_value(default_value)
|
||||
{
|
||||
}
|
||||
virtual ~BooleanSetting();
|
||||
|
||||
virtual bool GetValue() const { return m_value; }
|
||||
virtual void SetValue(bool value) { m_value = value; }
|
||||
const SettingType m_type;
|
||||
const std::string m_name;
|
||||
const bool m_default_value;
|
||||
bool m_value;
|
||||
};
|
||||
|
||||
class BackgroundInputSetting : public BooleanSetting
|
||||
{
|
||||
public:
|
||||
BackgroundInputSetting(const std::string& setting_name)
|
||||
: BooleanSetting(setting_name, false, SettingType::VIRTUAL)
|
||||
{
|
||||
}
|
||||
|
||||
bool GetValue() const override { return SConfig::GetInstance().m_BackgroundInput; }
|
||||
void SetValue(bool value) override
|
||||
{
|
||||
m_value = value;
|
||||
SConfig::GetInstance().m_BackgroundInput = value;
|
||||
}
|
||||
};
|
||||
|
||||
ControlGroup(const std::string& _name, const unsigned int _type = GROUP_TYPE_OTHER)
|
||||
: name(_name), ui_name(_name), type(_type)
|
||||
{
|
||||
}
|
||||
ControlGroup(const std::string& _name, const std::string& _ui_name,
|
||||
const unsigned int _type = GROUP_TYPE_OTHER)
|
||||
: name(_name), ui_name(_ui_name), type(_type)
|
||||
{
|
||||
}
|
||||
virtual ~ControlGroup() {}
|
||||
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 = "");
|
||||
|
||||
void SetControlExpression(int index, const std::string& expression);
|
||||
|
||||
const std::string name;
|
||||
const std::string ui_name;
|
||||
const unsigned int type;
|
||||
|
||||
std::vector<std::unique_ptr<Control>> controls;
|
||||
std::vector<std::unique_ptr<NumericSetting>> numeric_settings;
|
||||
std::vector<std::unique_ptr<BooleanSetting>> boolean_settings;
|
||||
};
|
||||
|
||||
class AnalogStick : public ControlGroup
|
||||
{
|
||||
public:
|
||||
// The GameCube controller and Wiimote attachments have a different default radius
|
||||
AnalogStick(const char* const _name, ControlState default_radius);
|
||||
AnalogStick(const char* const _name, const char* const _ui_name, ControlState default_radius);
|
||||
|
||||
void GetState(ControlState* const x, ControlState* const y)
|
||||
{
|
||||
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 radius = numeric_settings[SETTING_RADIUS]->GetValue();
|
||||
ControlState deadzone = numeric_settings[SETTING_DEADZONE]->GetValue();
|
||||
ControlState m = controls[4]->control_ref->State();
|
||||
|
||||
ControlState ang = atan2(yy, xx);
|
||||
ControlState ang_sin = sin(ang);
|
||||
ControlState ang_cos = cos(ang);
|
||||
|
||||
ControlState dist = sqrt(xx * xx + yy * yy);
|
||||
|
||||
// dead zone code
|
||||
dist = std::max(0.0, dist - deadzone);
|
||||
dist /= (1 - deadzone);
|
||||
|
||||
// radius
|
||||
dist *= radius;
|
||||
|
||||
// The modifier halves the distance by 50%, which is useful
|
||||
// for keyboard controls.
|
||||
if (m)
|
||||
dist *= 0.5;
|
||||
|
||||
yy = std::max(-1.0, std::min(1.0, ang_sin * dist));
|
||||
xx = std::max(-1.0, std::min(1.0, ang_cos * dist));
|
||||
|
||||
*y = yy;
|
||||
*x = xx;
|
||||
}
|
||||
};
|
||||
|
||||
class Buttons : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Buttons(const std::string& _name);
|
||||
Buttons(const std::string& ini_name, const std::string& group_name);
|
||||
|
||||
template <typename C>
|
||||
void GetState(C* const buttons, const C* bitmasks)
|
||||
{
|
||||
for (auto& control : controls)
|
||||
{
|
||||
if (control->control_ref->State() > numeric_settings[0]->GetValue()) // threshold
|
||||
*buttons |= *bitmasks;
|
||||
|
||||
bitmasks++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class ModifySettingsButton : public Buttons
|
||||
{
|
||||
public:
|
||||
ModifySettingsButton(std::string button_name);
|
||||
void AddInput(std::string button_name, bool toggle = false);
|
||||
|
||||
void GetState();
|
||||
|
||||
const std::vector<bool>& isSettingToggled() const { return associated_settings_toggle; }
|
||||
const std::vector<bool>& getSettingsModifier() const { return associated_settings; }
|
||||
private:
|
||||
std::vector<bool> threshold_exceeded; // internal calculation (if "state" was above threshold)
|
||||
std::vector<bool> associated_settings_toggle; // is setting toggled or hold?
|
||||
std::vector<bool> associated_settings; // result
|
||||
};
|
||||
|
||||
class MixedTriggers : public ControlGroup
|
||||
{
|
||||
public:
|
||||
MixedTriggers(const std::string& _name);
|
||||
|
||||
void GetState(u16* const digital, const u16* bitmasks, ControlState* analog)
|
||||
{
|
||||
const unsigned int trig_count = ((unsigned int)(controls.size() / 2));
|
||||
for (unsigned int i = 0; i < trig_count; ++i, ++bitmasks, ++analog)
|
||||
{
|
||||
if (controls[i]->control_ref->State() > numeric_settings[0]->GetValue()) // threshold
|
||||
{
|
||||
*analog = 1.0;
|
||||
*digital |= *bitmasks;
|
||||
}
|
||||
else
|
||||
{
|
||||
*analog = controls[i + trig_count]->control_ref->State();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Triggers : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Triggers(const std::string& _name);
|
||||
|
||||
void GetState(ControlState* analog)
|
||||
{
|
||||
const unsigned int trig_count = ((unsigned int)(controls.size()));
|
||||
const ControlState deadzone = numeric_settings[0]->GetValue();
|
||||
for (unsigned int i = 0; i < trig_count; ++i, ++analog)
|
||||
*analog = std::max(controls[i]->control_ref->State() - deadzone, 0.0) / (1 - deadzone);
|
||||
}
|
||||
};
|
||||
|
||||
class Slider : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Slider(const std::string& _name);
|
||||
|
||||
void GetState(ControlState* const slider)
|
||||
{
|
||||
const ControlState deadzone = numeric_settings[0]->GetValue();
|
||||
const ControlState state =
|
||||
controls[1]->control_ref->State() - controls[0]->control_ref->State();
|
||||
|
||||
if (fabs(state) > deadzone)
|
||||
*slider = (state - (deadzone * sign(state))) / (1 - deadzone);
|
||||
else
|
||||
*slider = 0;
|
||||
}
|
||||
};
|
||||
|
||||
class Force : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Force(const std::string& _name);
|
||||
|
||||
void GetState(ControlState* axis)
|
||||
{
|
||||
const ControlState deadzone = numeric_settings[0]->GetValue();
|
||||
for (unsigned int i = 0; i < 6; i += 2)
|
||||
{
|
||||
ControlState tmpf = 0;
|
||||
const ControlState state =
|
||||
controls[i + 1]->control_ref->State() - controls[i]->control_ref->State();
|
||||
if (fabs(state) > deadzone)
|
||||
tmpf = ((state - (deadzone * sign(state))) / (1 - deadzone));
|
||||
|
||||
ControlState& ax = m_swing[i >> 1];
|
||||
*axis++ = (tmpf - ax);
|
||||
ax = tmpf;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ControlState m_swing[3];
|
||||
};
|
||||
|
||||
class Tilt : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Tilt(const std::string& _name);
|
||||
|
||||
void GetState(ControlState* const x, ControlState* const y, const bool step = true)
|
||||
{
|
||||
// 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 = numeric_settings[0]->GetValue();
|
||||
ControlState circle = numeric_settings[1]->GetValue();
|
||||
auto const angle = numeric_settings[2]->GetValue() / 1.8;
|
||||
ControlState m = controls[4]->control_ref->State();
|
||||
|
||||
// deadzone / circle stick code
|
||||
// this section might be all wrong, but its working good enough, I think
|
||||
|
||||
ControlState ang = atan2(yy, xx);
|
||||
ControlState ang_sin = sin(ang);
|
||||
ControlState ang_cos = cos(ang);
|
||||
|
||||
// the amt a full square stick would have at current angle
|
||||
ControlState square_full =
|
||||
std::min(ang_sin ? 1 / fabs(ang_sin) : 2, ang_cos ? 1 / fabs(ang_cos) : 2);
|
||||
|
||||
// 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);
|
||||
|
||||
ControlState dist = sqrt(xx * xx + yy * yy);
|
||||
|
||||
// dead zone code
|
||||
dist = std::max(0.0, dist - deadzone * stick_full);
|
||||
dist /= (1 - deadzone);
|
||||
|
||||
// circle stick code
|
||||
ControlState amt = dist / stick_full;
|
||||
dist += (square_full - 1) * amt * circle;
|
||||
|
||||
if (m)
|
||||
dist *= 0.5;
|
||||
|
||||
yy = std::max(-1.0, std::min(1.0, ang_sin * dist));
|
||||
xx = std::max(-1.0, std::min(1.0, ang_cos * dist));
|
||||
|
||||
// this is kinda silly here
|
||||
// gui being open will make this happen 2x as fast, o well
|
||||
|
||||
// silly
|
||||
if (step)
|
||||
{
|
||||
if (xx > m_tilt[0])
|
||||
m_tilt[0] = std::min(m_tilt[0] + 0.1, xx);
|
||||
else if (xx < m_tilt[0])
|
||||
m_tilt[0] = std::max(m_tilt[0] - 0.1, xx);
|
||||
|
||||
if (yy > m_tilt[1])
|
||||
m_tilt[1] = std::min(m_tilt[1] + 0.1, yy);
|
||||
else if (yy < m_tilt[1])
|
||||
m_tilt[1] = std::max(m_tilt[1] - 0.1, yy);
|
||||
}
|
||||
|
||||
*y = m_tilt[1] * angle;
|
||||
*x = m_tilt[0] * angle;
|
||||
}
|
||||
|
||||
private:
|
||||
ControlState m_tilt[2];
|
||||
};
|
||||
|
||||
class Cursor : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Cursor(const std::string& _name);
|
||||
|
||||
void GetState(ControlState* const x, ControlState* const y, ControlState* const z,
|
||||
const bool adjusted = false)
|
||||
{
|
||||
const ControlState 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.1, zz);
|
||||
else if (zz < m_z)
|
||||
m_z = std::max(m_z - 0.1, zz);
|
||||
|
||||
*z = m_z;
|
||||
|
||||
// hide
|
||||
if (controls[6]->control_ref->State() > 0.5)
|
||||
{
|
||||
*x = 10000;
|
||||
*y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
|
||||
ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
|
||||
|
||||
// adjust cursor according to settings
|
||||
if (adjusted)
|
||||
{
|
||||
xx *= (numeric_settings[1]->GetValue() * 2);
|
||||
yy *= (numeric_settings[2]->GetValue() * 2);
|
||||
yy += (numeric_settings[0]->GetValue() - 0.5);
|
||||
}
|
||||
|
||||
// relative input
|
||||
if (boolean_settings[0]->GetValue())
|
||||
{
|
||||
const ControlState deadzone = numeric_settings[3]->GetValue();
|
||||
// deadzone to avoid the cursor slowly drifting
|
||||
if (std::abs(xx) > deadzone)
|
||||
m_x = MathUtil::Clamp(m_x + xx * SPEED_MULTIPLIER, -1.0, 1.0);
|
||||
if (std::abs(yy) > deadzone)
|
||||
m_y = MathUtil::Clamp(m_y + yy * SPEED_MULTIPLIER, -1.0, 1.0);
|
||||
|
||||
// recenter
|
||||
if (controls[7]->control_ref->State() > 0.5)
|
||||
{
|
||||
m_x = 0.0;
|
||||
m_y = 0.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_x = xx;
|
||||
m_y = yy;
|
||||
}
|
||||
|
||||
*x = m_x;
|
||||
*y = m_y;
|
||||
}
|
||||
}
|
||||
|
||||
ControlState m_z;
|
||||
|
||||
private:
|
||||
// This is used to reduce the cursor speed for relative input
|
||||
// to something that makes sense with the default range.
|
||||
static constexpr double SPEED_MULTIPLIER = 0.04;
|
||||
|
||||
ControlState m_x = 0.0;
|
||||
ControlState m_y = 0.0;
|
||||
};
|
||||
|
||||
class Extension : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Extension(const std::string& _name)
|
||||
: ControlGroup(_name, GROUP_TYPE_EXTENSION), switch_extension(0), active_extension(0)
|
||||
{
|
||||
}
|
||||
|
||||
~Extension() {}
|
||||
void GetState(u8* const data);
|
||||
bool IsButtonPressed() const;
|
||||
|
||||
std::vector<std::unique_ptr<ControllerEmu>> attachments;
|
||||
|
||||
int switch_extension;
|
||||
int active_extension;
|
||||
};
|
||||
|
||||
virtual ~ControllerEmu() {}
|
||||
virtual ~EmulatedController();
|
||||
virtual std::string GetName() const = 0;
|
||||
|
||||
virtual void LoadDefaults(const ControllerInterface& ciface);
|
||||
@ -506,3 +45,4 @@ public:
|
||||
|
||||
ciface::Core::DeviceQualifier default_device;
|
||||
};
|
||||
} // namespace ControllerEmu
|
||||
|
@ -36,6 +36,20 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ControllerEmu\ControllerEmu.cpp" />
|
||||
<ClCompile Include="ControllerEmu\Control\Control.cpp" />
|
||||
<ClCompile Include="ControllerEmu\Control\Input.cpp" />
|
||||
<ClCompile Include="ControllerEmu\Control\Output.cpp" />
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\AnalogStick.cpp" />
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Buttons.cpp" />
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\ControlGroup.cpp" />
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Cursor.cpp" />
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Extension.cpp" />
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Force.cpp" />
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\MixedTriggers.cpp" />
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\ModifySettingsButton.cpp" />
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Slider.cpp" />
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Tilt.cpp" />
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Triggers.cpp" />
|
||||
<ClCompile Include="ControllerInterface\ControllerInterface.cpp" />
|
||||
<ClCompile Include="ControllerInterface\Device.cpp" />
|
||||
<ClCompile Include="ControllerInterface\DInput\DInput.cpp" />
|
||||
@ -57,6 +71,20 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ControllerEmu\ControllerEmu.h" />
|
||||
<ClInclude Include="ControllerEmu\Control\Control.h" />
|
||||
<ClInclude Include="ControllerEmu\Control\Input.h" />
|
||||
<ClInclude Include="ControllerEmu\Control\Output.h" />
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\AnalogStick.h" />
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Buttons.h" />
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\ControlGroup.h" />
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Cursor.h" />
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Extension.h" />
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Force.h" />
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\MixedTriggers.h" />
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\ModifySettingsButton.h" />
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Slider.h" />
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Tilt.h" />
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Triggers.h" />
|
||||
<ClInclude Include="ControllerInterface\ControllerInterface.h" />
|
||||
<ClInclude Include="ControllerInterface\Device.h" />
|
||||
<ClInclude Include="ControllerInterface\DInput\DInput.h" />
|
||||
|
@ -16,6 +16,12 @@
|
||||
<Filter Include="ControllerEmu">
|
||||
<UniqueIdentifier>{4c839215-4085-4e34-a960-7960986ad015}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ControllerEmu\Control">
|
||||
<UniqueIdentifier>{19ddd862-a1e3-479b-b638-bb31700c5171}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ControllerEmu\ControlGroup">
|
||||
<UniqueIdentifier>{e805231c-dc4e-4540-8bf8-8c567f3d00ae}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="GCAdapter.cpp" />
|
||||
@ -23,6 +29,48 @@
|
||||
<ClCompile Include="ControllerEmu\ControllerEmu.cpp">
|
||||
<Filter>ControllerEmu</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\Control\Control.cpp">
|
||||
<Filter>ControllerEmu\Control</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\Control\Input.cpp">
|
||||
<Filter>ControllerEmu\Control</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\Control\Output.cpp">
|
||||
<Filter>ControllerEmu\Control</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\AnalogStick.cpp">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Buttons.cpp">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\ControlGroup.cpp">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Cursor.cpp">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Extension.cpp">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Force.cpp">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\MixedTriggers.cpp">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\ModifySettingsButton.cpp">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Slider.cpp">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Tilt.cpp">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerEmu\ControlGroup\Triggers.cpp">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ControllerInterface\DInput\DInput.cpp">
|
||||
<Filter>ControllerInterface\DInput</Filter>
|
||||
</ClCompile>
|
||||
@ -61,6 +109,48 @@
|
||||
<ClInclude Include="ControllerEmu\ControllerEmu.h">
|
||||
<Filter>ControllerEmu</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\Control\Control.h">
|
||||
<Filter>ControllerEmu\Control</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\Control\Input.h">
|
||||
<Filter>ControllerEmu\Control</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\Control\Output.h">
|
||||
<Filter>ControllerEmu\Control</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\AnalogStick.h">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Buttons.h">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\ControlGroup.h">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Cursor.h">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Extension.h">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Force.h">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\MixedTriggers.h">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\ModifySettingsButton.h">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Slider.h">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Tilt.h">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerEmu\ControlGroup\Triggers.h">
|
||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ControllerInterface\DInput\DInput.h">
|
||||
<Filter>ControllerInterface\DInput</Filter>
|
||||
</ClInclude>
|
||||
@ -98,4 +188,4 @@
|
||||
<ItemGroup>
|
||||
<Text Include="CMakeLists.txt" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -9,10 +9,19 @@
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/HW/Wiimote.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
|
||||
InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name,
|
||||
const std::string& profile_name)
|
||||
: m_ini_name(ini_name), m_gui_name(gui_name), m_profile_name(profile_name)
|
||||
{
|
||||
}
|
||||
|
||||
InputConfig::~InputConfig() = default;
|
||||
|
||||
bool InputConfig::LoadConfig(bool isGC)
|
||||
{
|
||||
IniFile inifile;
|
||||
@ -104,7 +113,7 @@ void InputConfig::SaveConfig()
|
||||
inifile.Save(ini_filename);
|
||||
}
|
||||
|
||||
ControllerEmu* InputConfig::GetController(int index)
|
||||
ControllerEmu::EmulatedController* InputConfig::GetController(int index)
|
||||
{
|
||||
return m_controllers.at(index).get();
|
||||
}
|
||||
|
@ -9,16 +9,18 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
class ControllerEmu;
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class EmulatedController;
|
||||
}
|
||||
|
||||
class InputConfig
|
||||
{
|
||||
public:
|
||||
InputConfig(const std::string& ini_name, const std::string& gui_name,
|
||||
const std::string& profile_name)
|
||||
: m_ini_name(ini_name), m_gui_name(gui_name), m_profile_name(profile_name)
|
||||
{
|
||||
}
|
||||
const std::string& profile_name);
|
||||
|
||||
~InputConfig();
|
||||
|
||||
bool LoadConfig(bool isGC);
|
||||
void SaveConfig();
|
||||
@ -29,7 +31,7 @@ public:
|
||||
m_controllers.emplace_back(std::make_unique<T>(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
ControllerEmu* GetController(int index);
|
||||
ControllerEmu::EmulatedController* GetController(int index);
|
||||
void ClearControllers();
|
||||
bool ControllersNeedToBeCreated() const;
|
||||
bool IsControllerControlledByGamepadDevice(int index) const;
|
||||
@ -37,7 +39,7 @@ public:
|
||||
std::string GetGUIName() const { return m_gui_name; }
|
||||
std::string GetProfileName() const { return m_profile_name; }
|
||||
private:
|
||||
std::vector<std::unique_ptr<ControllerEmu>> m_controllers;
|
||||
std::vector<std::unique_ptr<ControllerEmu::EmulatedController>> m_controllers;
|
||||
const std::string m_ini_name;
|
||||
const std::string m_gui_name;
|
||||
const std::string m_profile_name;
|
||||
|
Loading…
x
Reference in New Issue
Block a user