2019-10-31 18:00:42 +00:00
|
|
|
#pragma once
|
|
|
|
#include "IUSBDevice.h"
|
|
|
|
#include "ControllerTypes.h"
|
2019-11-06 22:20:58 +00:00
|
|
|
#include "ControllerConfig.h"
|
2019-10-31 18:00:42 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
struct NormalizedButtonData
|
|
|
|
{
|
2020-04-22 00:54:49 +00:00
|
|
|
bool buttons[MAX_CONTROLLER_BUTTONS];
|
2019-11-07 17:46:47 +00:00
|
|
|
float triggers[2];
|
|
|
|
NormalizedStick sticks[2];
|
2019-10-31 18:00:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IController
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
std::unique_ptr<IUSBDevice> m_device;
|
|
|
|
|
|
|
|
public:
|
2019-11-13 16:53:23 +00:00
|
|
|
IController(std::unique_ptr<IUSBDevice> &&interface) : m_device(std::move(interface))
|
|
|
|
{
|
|
|
|
}
|
2019-10-31 18:00:42 +00:00
|
|
|
virtual ~IController() = default;
|
|
|
|
|
2019-11-13 11:16:13 +00:00
|
|
|
virtual Result Initialize() = 0;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
2019-11-13 11:16:13 +00:00
|
|
|
//Since Exit is used to clean up resources, no Result report should be needed
|
2019-10-31 18:00:42 +00:00
|
|
|
virtual void Exit() = 0;
|
|
|
|
|
2019-11-13 11:16:13 +00:00
|
|
|
virtual Result GetInput() { return 1; }
|
2019-10-31 18:00:42 +00:00
|
|
|
|
2019-11-09 20:26:47 +00:00
|
|
|
virtual NormalizedButtonData GetNormalizedButtonData() { return NormalizedButtonData(); }
|
2019-10-31 18:00:42 +00:00
|
|
|
|
|
|
|
inline IUSBDevice *GetDevice() { return m_device.get(); }
|
|
|
|
virtual ControllerType GetType() = 0;
|
2019-11-13 11:16:13 +00:00
|
|
|
virtual Result SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude) { return 1; }
|
2019-11-08 23:31:49 +00:00
|
|
|
virtual bool IsControllerActive() { return true; }
|
2019-11-08 18:06:02 +00:00
|
|
|
|
2019-11-13 11:16:13 +00:00
|
|
|
virtual Result OutputBuffer() { return 1; };
|
2019-11-09 20:26:47 +00:00
|
|
|
|
|
|
|
virtual ControllerConfig *GetConfig() { return nullptr; }
|
2019-10-31 18:00:42 +00:00
|
|
|
};
|