diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-18 14:13:23 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-19 20:12:58 +0900 |
commit | c4899aa8f1ba9ec97818bc138c0dd63f4d02b683 (patch) | |
tree | 9bc639fbf5e41051bdd545a50d4f5b07666aa7d9 /windows.c | |
parent | 047032ee46ef00d924dea0ee68b0f2726975fcd6 (diff) | |
download | subsurface-c4899aa8f1ba9ec97818bc138c0dd63f4d02b683.tar.gz |
Download from dive computer: Fix the broken selection of devices
The old code was completely bogus - it's confused about what the variable
'i' is counting.
This also let's us select the Uemis mount point by default if that's the
only valid "device" that we found.
Compile tested on Windows, untested on Mac.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'windows.c')
-rw-r--r-- | windows.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -90,6 +90,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type) } if (dc_type != DC_TYPE_SERIAL) { int i; + int count_drives = 0; const int bufdef = 512; const char *dlabels[] = {"UEMISSDA", NULL}; char bufname[bufdef], bufval[bufdef], *p; @@ -110,12 +111,14 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type) snprintf(data, sizeof(data), "%s (%s)", p, dlabels[i]); callback(data, userdata); if (is_default_dive_computer_device(p)) - index = i; - i++; + index = count_drives; + count_drives++; } } p = &p[strlen(p) + 1]; } + if (count_drives == 1) /* we found exactly one Uemis "drive" */ + index = 0; /* make it the selected "device" */ } } return index; |