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.3 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();
virtual Status Initialize();
virtual void Exit();
Status OpenInterfaces();
void CloseInterfaces();
virtual ControllerType GetType() { return CONTROLLER_XBOXONEW; }
2019-11-12 17:55:50 +00:00
Status LoadFirmwarePart(uint32_t offset, uint8_t *start, uint8_t *end);
2019-11-09 20:22:41 +00:00
Status SendInitBytes();
2019-11-11 19:42:24 +00:00
Status 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();
2019-11-09 20:22:41 +00:00
};