libaltos: Map generic windows device names to actual names
authorKeith Packard <keithp@keithp.com>
Mon, 31 Aug 2020 22:01:18 +0000 (15:01 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 26 Sep 2020 03:07:39 +0000 (20:07 -0700)
When we signed the .ini file for our windows 'driver', IDs 28 and 2c
hadn't been assigned to EasyMega and EasyMotor, so that file has
generic 'AltusMetrum28' and 'AltusMetrum2c' instead. Updating that
file is 'hard', so just map the names in the driver instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
libaltos/libaltos_windows.c

index 03c2958f52bc1a63b1a0dc71c01eb43a82472e8a..0c1f6782fd58f167be01d53a112dede4d04a426f 100644 (file)
@@ -131,6 +131,15 @@ altos_ftdi_list_start(void)
        return list;
 }
 
+static struct {
+       char    *windows;
+       char    *real;
+} name_map[] = {
+       { .windows = "AltusMetrum28", .real = "EasyMega" },
+       { .windows = "AltusMetrum2c", .real = "EasyMotor" },
+       { 0, 0 },
+};
+
 PUBLIC int
 altos_list_next(struct altos_list *list, struct altos_device *device)
 {
@@ -148,6 +157,7 @@ altos_list_next(struct altos_list *list, struct altos_device *device)
        DWORD           friendlyname_len;
        char            instanceid[1024];
        DWORD           instanceid_len;
+       int             i;
 
        dev_info_data.cbSize = sizeof (SP_DEVINFO_DATA);
        while(SetupDiEnumDeviceInfo(list->dev_info, list->index,
@@ -230,6 +240,12 @@ altos_list_next(struct altos_list *list, struct altos_device *device)
                        altos_set_last_windows_error();
                        continue;
                }
+               for (i = 0; name_map[i].windows; i++)
+                       if (!strcmp(name_map[i].windows, friendlyname)) {
+                               strcpy(friendlyname, name_map[i].real);
+                               break;
+                       }
+
                device->vendor = vid;
                device->product = pid;
                device->serial = serial;