MCPcopy Create free account
hub / github.com/AIRLegend/aitrack / getUSBPortPath

Method getUSBPortPath

PS3Driver/src/ps3eye.cpp:1161–1202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1159#define MAX_USB_DEVICE_PORT_PATH 7
1160
1161bool PS3EYECam::getUSBPortPath(char *out_identifier, size_t max_identifier_length) const
1162{
1163 bool success = false;
1164
1165 if (isInitialized())
1166 {
1167 uint8_t port_numbers[MAX_USB_DEVICE_PORT_PATH];
1168
1169 memset(out_identifier, 0, max_identifier_length);
1170
1171 memset(port_numbers, 0, sizeof(port_numbers));
1172 int port_count = libusb_get_port_numbers(device_, port_numbers, MAX_USB_DEVICE_PORT_PATH);
1173 int bus_id = libusb_get_bus_number(device_);
1174
1175 snprintf(out_identifier, max_identifier_length, "b%d", bus_id);
1176 if (port_count > 0)
1177 {
1178 success = true;
1179
1180 for (int port_index = 0; port_index < port_count; ++port_index)
1181 {
1182 uint8_t port_number = port_numbers[port_index];
1183 char port_string[8];
1184
1185 snprintf(port_string, sizeof(port_string), (port_index == 0) ? "_p%d" : ".%d", port_number);
1186 port_string[sizeof(port_string) - 1] = '0';
1187
1188 if (strlen(out_identifier)+strlen(port_string)+1 <= max_identifier_length)
1189 {
1190 std::strcat(out_identifier, port_string);
1191 }
1192 else
1193 {
1194 success = false;
1195 break;
1196 }
1197 }
1198 }
1199 }
1200
1201 return success;
1202}
1203
1204uint32_t PS3EYECam::getOutputBytesPerPixel() const
1205{

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected