dolphin/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h
Lioncash 6a75ea5653 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.
2017-02-09 18:18:52 -05:00

48 lines
1.4 KiB
C++

// Copyright 2010 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <mutex>
#include <string>
#include <vector>
#include "Common/IniFile.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#define sign(x) ((x) ? (x) < 0 ? -1 : 1 : 0)
const char* const named_directions[] = {"Up", "Down", "Left", "Right"};
namespace ControllerEmu
{
class ControlGroup;
class EmulatedController
{
public:
virtual ~EmulatedController();
virtual std::string GetName() const = 0;
virtual void LoadDefaults(const ControllerInterface& ciface);
virtual void LoadConfig(IniFile::Section* sec, const std::string& base = "");
virtual void SaveConfig(IniFile::Section* sec, const std::string& base = "");
void UpdateDefaultDevice();
void UpdateReferences(ControllerInterface& devi);
// This returns a lock that should be held before calling State() on any control
// references and GetState(), by extension. This prevents a race condition
// which happens while handling a hotplug event because a control reference's State()
// could be called before we have finished updating the reference.
static std::unique_lock<std::recursive_mutex> GetStateLock();
std::vector<std::unique_ptr<ControlGroup>> groups;
ciface::Core::DeviceQualifier default_device;
};
} // namespace ControllerEmu