MCPcopy Create free account
hub / github.com/360Controller/360Controller / convertFromXboxOne

Method convertFromXboxOne

360Controller/Controller.cpp:617–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

615}
616
617void XboxOneControllerClass::convertFromXboxOne(void *buffer, UInt8 packetSize)
618{
619 XBOXONE_ELITE_IN_REPORT *reportXone = (XBOXONE_ELITE_IN_REPORT*)buffer;
620 XBOX360_IN_REPORT *report360 = (XBOX360_IN_REPORT*)buffer;
621 UInt8 trigL = 0, trigR = 0;
622 XBOX360_HAT left, right;
623
624 report360->header.command = 0x00;
625 report360->header.size = 0x14;
626
627 if (packetSize == 0x1a) // Fight Stick
628 {
629 if ((0x80 & reportXone->true_trigR) == 0x80) { trigL = 255; }
630 if ((0x40 & reportXone->true_trigR) == 0x40) { trigR = 255; }
631
632 left = reportXone->left;
633 right = reportXone->right;
634 }
635 else if (packetSize == 0x11) // Racing Wheel
636 {
637 XBOXONE_IN_WHEEL_REPORT *wheelReport=(XBOXONE_IN_WHEEL_REPORT*)buffer;
638
639 trigR = (wheelReport->accelerator / 1023.0) * 255; // UInt16 -> UInt8
640 trigL = (wheelReport->brake / 1023.0) * 255; // UInt16 -> UInt8
641 left.x = wheelReport->steering - 32768; // UInt16 -> SInt16
642 left.y = wheelReport->clutch * 128; // Clutch is 0-255. Upconvert to half signed 16 range. (0 - 32640)
643 right = {};
644 }
645 else // Traditional Controllers
646 {
647 trigL = (reportXone->trigL / 1023.0) * 255;
648 trigR = (reportXone->trigR / 1023.0) * 255;
649
650 left = reportXone->left;
651 right = reportXone->right;
652 }
653
654 report360->buttons = convertButtonPacket(reportXone->buttons);
655 report360->trigL = trigL;
656 report360->trigR = trigR;
657 report360->left = left;
658 report360->right = right;
659}
660
661IOReturn XboxOneControllerClass::handleReport(IOMemoryDescriptor * descriptor, IOHIDReportType reportType, IOOptionBits options)
662{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected