mirror of
https://github.com/cathery/sys-con.git
synced 2024-07-05 10:48:46 +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,
|
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
|
class Xbox360Controller : public IController
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -99,5 +119,7 @@ public:
|
||||||
Status SendInitBytes();
|
Status SendInitBytes();
|
||||||
Status SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude);
|
Status SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude);
|
||||||
|
|
||||||
|
Status SetLED(Xbox360LEDValue value);
|
||||||
|
|
||||||
static void LoadConfig(const ControllerConfig *config);
|
static void LoadConfig(const ControllerConfig *config);
|
||||||
};
|
};
|
|
@ -20,6 +20,8 @@ Status Xbox360Controller::Initialize()
|
||||||
rc = OpenInterfaces();
|
rc = OpenInterfaces();
|
||||||
if (S_FAILED(rc))
|
if (S_FAILED(rc))
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
SetLED(XBOX360LED_TOPLEFT);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
void Xbox360Controller::Exit()
|
void Xbox360Controller::Exit()
|
||||||
|
@ -47,7 +49,9 @@ Status Xbox360Controller::OpenInterfaces()
|
||||||
|
|
||||||
if (!m_inPipe)
|
if (!m_inPipe)
|
||||||
{
|
{
|
||||||
IUSBEndpoint *inEndpoint = interface->GetEndpoint(IUSBEndpoint::USB_ENDPOINT_IN, 0);
|
for (int i = 0; i != 15; ++i)
|
||||||
|
{
|
||||||
|
IUSBEndpoint *inEndpoint = interface->GetEndpoint(IUSBEndpoint::USB_ENDPOINT_IN, i);
|
||||||
if (inEndpoint)
|
if (inEndpoint)
|
||||||
{
|
{
|
||||||
rc = inEndpoint->Open();
|
rc = inEndpoint->Open();
|
||||||
|
@ -55,12 +59,16 @@ Status Xbox360Controller::OpenInterfaces()
|
||||||
return 55555;
|
return 55555;
|
||||||
|
|
||||||
m_inPipe = inEndpoint;
|
m_inPipe = inEndpoint;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_outPipe)
|
if (!m_outPipe)
|
||||||
{
|
{
|
||||||
IUSBEndpoint *outEndpoint = interface->GetEndpoint(IUSBEndpoint::USB_ENDPOINT_OUT, 0);
|
for (int i = 0; i != 15; ++i)
|
||||||
|
{
|
||||||
|
IUSBEndpoint *outEndpoint = interface->GetEndpoint(IUSBEndpoint::USB_ENDPOINT_OUT, i);
|
||||||
if (outEndpoint)
|
if (outEndpoint)
|
||||||
{
|
{
|
||||||
rc = outEndpoint->Open();
|
rc = outEndpoint->Open();
|
||||||
|
@ -68,6 +76,8 @@ Status Xbox360Controller::OpenInterfaces()
|
||||||
return 66666;
|
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));
|
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)
|
void Xbox360Controller::LoadConfig(const ControllerConfig *config)
|
||||||
{
|
{
|
||||||
_xbox360ControllerConfig = *config;
|
_xbox360ControllerConfig = *config;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user