diff --git a/src/bin/Jamfile b/src/bin/Jamfile index 66dede506f..fdbd62908f 100644 --- a/src/bin/Jamfile +++ b/src/bin/Jamfile @@ -162,6 +162,7 @@ StdBinCommands # standard commands that need libbe.so, libdevice.so StdBinCommands listusb.cpp + setusbconfig.cpp : be libdevice.so : $(haiku-utils_rsrc) ; # standard commands that need libbluetooth.so, due the Bluetooth Kit diff --git a/src/bin/setusbconfig.cpp b/src/bin/setusbconfig.cpp new file mode 100644 index 0000000000..6f793797d1 --- /dev/null +++ b/src/bin/setusbconfig.cpp @@ -0,0 +1,41 @@ +#include +#include + +#include + + +int +main(int argc, char *argv[]) +{ + if (argc < 3) { + printf("usage: %s \n", argv[0]); + return 1; + } + + BUSBDevice device(argv[1]); + if (device.InitCheck() != B_OK) { + printf("failed to open device %s\n", argv[1]); + return 2; + } + + uint32 index; + if (sscanf(argv[2], "%lu", &index) != 1) { + printf("could not parse configuration index\n"); + return 3; + } + + const BUSBConfiguration *config = device.ConfigurationAt(index); + if (config == NULL) { + printf("couldn't get configuration at %lu\n", index); + return 4; + } + + status_t result = device.SetConfiguration(config); + if (result != B_OK) { + printf("failed to set configuration: %s\n", strerror(result)); + return 5; + } + + printf("configuration %lu set on device %s\n", index, argv[1]); + return 0; +}