2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:09:55 -06:00
|
|
|
// Refer to the license.txt file included.
|
2010-06-12 11:15:16 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-02-01 15:20:35 -07:00
|
|
|
#include <memory>
|
2016-07-14 09:45:59 -06:00
|
|
|
#include <mutex>
|
2010-06-13 03:26:00 -06:00
|
|
|
#include <string>
|
2014-02-17 03:18:15 -07:00
|
|
|
#include <vector>
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/IniFile.h"
|
2017-04-04 13:37:31 -06:00
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
|
|
|
|
|
|
|
class ControllerInterface;
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
#define sign(x) ((x) ? (x) < 0 ? -1 : 1 : 0)
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2017-02-08 20:15:43 -07:00
|
|
|
const char* const named_directions[] = {"Up", "Down", "Left", "Right"};
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2017-02-08 20:15:43 -07:00
|
|
|
namespace ControllerEmu
|
2011-11-10 01:27:33 -07:00
|
|
|
{
|
2017-02-08 20:15:43 -07:00
|
|
|
class ControlGroup;
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2017-02-08 20:15:43 -07:00
|
|
|
class EmulatedController
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
|
|
|
public:
|
2017-02-08 20:15:43 -07:00
|
|
|
virtual ~EmulatedController();
|
2016-06-24 02:43:46 -06:00
|
|
|
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 = "");
|
2017-11-04 15:08:26 -06:00
|
|
|
|
|
|
|
const ciface::Core::DeviceQualifier& GetDefaultDevice() const;
|
|
|
|
void SetDefaultDevice(const std::string& device);
|
|
|
|
void SetDefaultDevice(ciface::Core::DeviceQualifier devq);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-02-10 22:29:22 -07:00
|
|
|
void UpdateReferences(const ControllerInterface& devi);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2016-07-14 09:45:59 -06:00
|
|
|
// 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();
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
std::vector<std::unique_ptr<ControlGroup>> groups;
|
|
|
|
|
2017-11-04 15:08:26 -06:00
|
|
|
private:
|
|
|
|
ciface::Core::DeviceQualifier m_default_device;
|
2010-06-03 12:05:08 -06:00
|
|
|
};
|
2017-02-08 20:15:43 -07:00
|
|
|
} // namespace ControllerEmu
|