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/XboxOneAdapter.h

48 lines
1.4 KiB
C
Raw Normal View History

2019-11-09 20:22:41 +00:00
#pragma once
#include "IController.h"
#include "Controllers/XboxOneController.h"
//References used:
//https://github.com/quantus/xbox-one-controller-protocol
//https://cs.chromium.org/chromium/src/device/gamepad/xbox_controller_mac.mm
2019-11-11 19:42:24 +00:00
enum VendorRequest
{
MT_VEND_DEV_MODE = 0x1,
MT_VEND_WRITE = 0x2,
MT_VEND_MULTI_WRITE = 0x6,
MT_VEND_MULTI_READ = 0x7,
MT_VEND_READ_EEPROM = 0x9,
MT_VEND_WRITE_FCE = 0x42,
MT_VEND_WRITE_CFG = 0x46,
MT_VEND_READ_CFG = 0x47,
};
2019-11-09 20:22:41 +00:00
class XboxOneAdapter : public IController
{
private:
2019-11-11 19:42:24 +00:00
IUSBEndpoint *m_inPipePacket = nullptr;
2019-11-09 20:22:41 +00:00
IUSBEndpoint *m_inPipe = nullptr;
IUSBEndpoint *m_outPipe = nullptr;
2019-11-11 19:42:24 +00:00
IUSBInterface *m_interface = nullptr;
2019-11-09 20:22:41 +00:00
public:
XboxOneAdapter(std::unique_ptr<IUSBDevice> &&interface);
virtual ~XboxOneAdapter() override;
2019-11-09 20:22:41 +00:00
virtual Result Initialize() override;
virtual void Exit() override;
2019-11-09 20:22:41 +00:00
2019-11-13 11:16:13 +00:00
Result OpenInterfaces();
2019-11-09 20:22:41 +00:00
void CloseInterfaces();
virtual ControllerType GetType() override { return CONTROLLER_XBOXONEW; }
2019-11-09 20:22:41 +00:00
2019-11-13 11:16:13 +00:00
Result LoadFirmwarePart(uint32_t offset, uint8_t *start, uint8_t *end);
Result SendInitBytes();
Result ControlWrite(IUSBInterface *interface, uint16_t address, uint32_t value, VendorRequest request = MT_VEND_MULTI_WRITE);
2019-11-12 17:55:50 +00:00
static void LoadConfig(const ControllerConfig *config, const char *path);
virtual ControllerConfig *GetConfig() override;
2019-11-09 20:22:41 +00:00
};