| 90 | } |
| 91 | |
| 92 | Result XboxOneController::OpenInterfaces() |
| 93 | { |
| 94 | Result rc; |
| 95 | rc = m_device->Open(); |
| 96 | if (R_FAILED(rc)) |
| 97 | return rc; |
| 98 | |
| 99 | //This will open each interface and try to acquire Xbox One controller's in and out endpoints, if it hasn't already |
| 100 | std::vector<std::unique_ptr<IUSBInterface>> &interfaces = m_device->GetInterfaces(); |
| 101 | for (auto &&interface : interfaces) |
| 102 | { |
| 103 | rc = interface->Open(); |
| 104 | if (R_FAILED(rc)) |
| 105 | return rc; |
| 106 | |
| 107 | if (interface->GetDescriptor()->bInterfaceProtocol != 208) |
| 108 | continue; |
| 109 | |
| 110 | if (interface->GetDescriptor()->bNumEndpoints < 2) |
| 111 | continue; |
| 112 | |
| 113 | if (!m_inPipe) |
| 114 | { |
| 115 | for (uint8_t i = 0; i != 15; ++i) |
| 116 | { |
| 117 | IUSBEndpoint *inEndpoint = interface->GetEndpoint(IUSBEndpoint::USB_ENDPOINT_IN, i); |
| 118 | if (inEndpoint) |
| 119 | { |
| 120 | rc = inEndpoint->Open(); |
| 121 | if (R_FAILED(rc)) |
| 122 | return 5555; |
| 123 | |
| 124 | m_inPipe = inEndpoint; |
| 125 | break; |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | if (!m_outPipe) |
| 131 | { |
| 132 | for (uint8_t i = 0; i != 15; ++i) |
| 133 | { |
| 134 | IUSBEndpoint *outEndpoint = interface->GetEndpoint(IUSBEndpoint::USB_ENDPOINT_OUT, i); |
| 135 | if (outEndpoint) |
| 136 | { |
| 137 | rc = outEndpoint->Open(); |
| 138 | if (R_FAILED(rc)) |
| 139 | return 6666; |
| 140 | |
| 141 | m_outPipe = outEndpoint; |
| 142 | break; |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if (!m_inPipe || !m_outPipe) |
| 149 | return 69; |
nothing calls this directly
no test coverage detected