1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-11-06 02:26:33 +00:00
sys-con/ControllerUSB/include/Controllers/Xbox360WirelessController.h

59 lines
1.4 KiB
C
Raw Normal View History

2019-11-08 12:56:20 +00:00
#pragma once
#include "IController.h"
#include "Xbox360Controller.h"
//References used:
2019-11-08 14:15:02 +00:00
//https://github.com/torvalds/linux/blob/master/drivers/input/joystick/xpad.c
2019-11-08 12:56:20 +00:00
2019-11-08 18:06:02 +00:00
struct OutputPacket
{
const uint8_t *packet;
uint8_t length;
};
2019-11-08 12:56:20 +00:00
class Xbox360WirelessController : public IController
{
private:
IUSBEndpoint *m_inPipe = nullptr;
IUSBEndpoint *m_outPipe = nullptr;
Xbox360ButtonData m_buttonData;
bool m_presence = false;
2019-11-08 12:56:20 +00:00
2019-11-08 18:06:02 +00:00
std::vector<OutputPacket> m_outputBuffer;
2019-11-08 12:56:20 +00:00
public:
Xbox360WirelessController(std::unique_ptr<IUSBDevice> &&interface);
virtual ~Xbox360WirelessController();
virtual Status Initialize();
virtual void Exit();
Status OpenInterfaces();
void CloseInterfaces();
virtual Status GetInput();
virtual NormalizedButtonData GetNormalizedButtonData();
virtual ControllerType GetType() { return CONTROLLER_XBOX360W; }
inline const Xbox360ButtonData &GetButtonData() { return m_buttonData; };
float NormalizeTrigger(uint8_t value);
void NormalizeAxis(int16_t x, int16_t y, uint8_t deadzonePercent, float *x_out, float *y_out);
Status SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude);
Status SetLED(Xbox360LEDValue value);
Status OnControllerConnect();
Status OnControllerDisconnect();
2019-11-08 12:56:20 +00:00
static void LoadConfig(const ControllerConfig *config);
2019-11-08 18:06:02 +00:00
Status OutputBuffer();
bool IsControllerActive() override { return m_presence; }
2019-11-08 12:56:20 +00:00
};