mirror of
https://github.com/cathery/sys-con.git
synced 2025-01-11 18:36:24 +00:00
Xbox360: Set LED on init and fix endpoints
This commit is contained in:
parent
59c99da458
commit
99c195e3d3
@ -60,6 +60,26 @@ enum Xbox360InputPacketType
|
||||
XBOX360INPUT_RUMBLE = 3,
|
||||
};
|
||||
|
||||
enum Xbox360LEDValue
|
||||
{
|
||||
XBOX360LED_OFF,
|
||||
XBOX360LED_ALLBLINK,
|
||||
XBOX360LED_TOPLEFTBLINK,
|
||||
XBOX360LED_TOPRIGHTBLINK,
|
||||
XBOX360LED_BOTTOMLEFTBLINK,
|
||||
XBOX360LED_BOTTOMRIGHTBLINK,
|
||||
XBOX360LED_TOPLEFT,
|
||||
XBOX360LED_TOPRIGHT,
|
||||
XBOX360LED_BOTTOMLEFT,
|
||||
XBOX360LED_BOTTOMRIGHT,
|
||||
XBOX360LED_ROTATE,
|
||||
XBOX360LED_BLINK,
|
||||
XBOX360LED_SLOWBLINK,
|
||||
XBOX360LED_ROTATE_2,
|
||||
XBOX360LED_ALLSLOWBLINK,
|
||||
XBOX360LED_BLINKONCE,
|
||||
};
|
||||
|
||||
class Xbox360Controller : public IController
|
||||
{
|
||||
private:
|
||||
@ -99,5 +119,7 @@ public:
|
||||
Status SendInitBytes();
|
||||
Status SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude);
|
||||
|
||||
Status SetLED(Xbox360LEDValue value);
|
||||
|
||||
static void LoadConfig(const ControllerConfig *config);
|
||||
};
|
@ -20,6 +20,8 @@ Status Xbox360Controller::Initialize()
|
||||
rc = OpenInterfaces();
|
||||
if (S_FAILED(rc))
|
||||
return rc;
|
||||
|
||||
SetLED(XBOX360LED_TOPLEFT);
|
||||
return rc;
|
||||
}
|
||||
void Xbox360Controller::Exit()
|
||||
@ -47,27 +49,35 @@ Status Xbox360Controller::OpenInterfaces()
|
||||
|
||||
if (!m_inPipe)
|
||||
{
|
||||
IUSBEndpoint *inEndpoint = interface->GetEndpoint(IUSBEndpoint::USB_ENDPOINT_IN, 0);
|
||||
if (inEndpoint)
|
||||
for (int i = 0; i != 15; ++i)
|
||||
{
|
||||
rc = inEndpoint->Open();
|
||||
if (S_FAILED(rc))
|
||||
return 55555;
|
||||
IUSBEndpoint *inEndpoint = interface->GetEndpoint(IUSBEndpoint::USB_ENDPOINT_IN, i);
|
||||
if (inEndpoint)
|
||||
{
|
||||
rc = inEndpoint->Open();
|
||||
if (S_FAILED(rc))
|
||||
return 55555;
|
||||
|
||||
m_inPipe = inEndpoint;
|
||||
m_inPipe = inEndpoint;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_outPipe)
|
||||
{
|
||||
IUSBEndpoint *outEndpoint = interface->GetEndpoint(IUSBEndpoint::USB_ENDPOINT_OUT, 0);
|
||||
if (outEndpoint)
|
||||
for (int i = 0; i != 15; ++i)
|
||||
{
|
||||
rc = outEndpoint->Open();
|
||||
if (S_FAILED(rc))
|
||||
return 66666;
|
||||
IUSBEndpoint *outEndpoint = interface->GetEndpoint(IUSBEndpoint::USB_ENDPOINT_OUT, i);
|
||||
if (outEndpoint)
|
||||
{
|
||||
rc = outEndpoint->Open();
|
||||
if (S_FAILED(rc))
|
||||
return 66666;
|
||||
|
||||
m_outPipe = outEndpoint;
|
||||
m_outPipe = outEndpoint;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -199,6 +209,12 @@ Status Xbox360Controller::SetRumble(uint8_t strong_magnitude, uint8_t weak_magni
|
||||
return m_outPipe->Write(rumbleData, sizeof(rumbleData));
|
||||
}
|
||||
|
||||
Status Xbox360Controller::SetLED(Xbox360LEDValue value)
|
||||
{
|
||||
uint8_t ledPacket[]{0x01, 0x03, static_cast<uint8_t>(value)};
|
||||
return m_outPipe->Write(ledPacket, sizeof(ledPacket));
|
||||
}
|
||||
|
||||
void Xbox360Controller::LoadConfig(const ControllerConfig *config)
|
||||
{
|
||||
_xbox360ControllerConfig = *config;
|
||||
|
Loading…
Reference in New Issue
Block a user