1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-11-16 14:09:51 +00:00
sys-con/source/ControllerLib/IController.h

42 lines
1.1 KiB
C
Raw Permalink Normal View History

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
{
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:
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; }
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
};