summaryrefslogtreecommitdiff
path: root/examples/detect.c
diff options
context:
space:
mode:
authorLinus Walleij <triad@df.lth.se>2006-05-08 09:22:01 +0000
committerLinus Walleij <triad@df.lth.se>2006-05-08 09:22:01 +0000
commit1fd2d27cdba34bc450e6a17671b65542dbe8fad4 (patch)
treef3d9d11e64d6789246c6a3fa8e88e3ef0b39efb6 /examples/detect.c
parent685137f375d15a94d283ccff61ab5ff96a446ebb (diff)
downloadlibmtp-1fd2d27cdba34bc450e6a17671b65542dbe8fad4.tar.gz
Some detection of MTP devices.
Diffstat (limited to 'examples/detect.c')
-rw-r--r--examples/detect.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/detect.c b/examples/detect.c
index e39693a..e018fa3 100644
--- a/examples/detect.c
+++ b/examples/detect.c
@@ -46,8 +46,27 @@ int main (int argc, char **argv)
uint8_t maxbattlevel;
uint8_t currbattlevel;
int ret;
+ int probeonly = 0;
LIBMTP_Init();
+
+ if (argc > 1 && !strcmp(argv[1], "-p")) {
+ probeonly = 1;
+ }
+
+ if (probeonly) {
+ uint16_t vid;
+ uint16_t pid;
+
+ ret = LIBMTP_Detect_Descriptor(&vid, &pid);
+ if (ret > 0) {
+ printf("DETECTED MTP DEVICE WITH VID:%04x, PID:%04X\n", vid, pid);
+ exit(0);
+ } else {
+ exit(1);
+ }
+ }
+
device = LIBMTP_Get_First_Device();
if (device == NULL) {
printf("No devices.\n");