From d85e83c89e7856e840cc55b51742f28fc0fbfdc7 Mon Sep 17 00:00:00 2001 From: Jaco Kroon Date: Wed, 13 May 2009 07:27:11 +0200 Subject: [PATCH] make get_device_info interate over list of supported product and family ID --- effects.c | 38 +++++++++++++------------------------- effects.h | 2 ++ 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/effects.c b/effects.c index ca4aa90..3ba147f 100644 --- a/effects.c +++ b/effects.c @@ -1738,6 +1738,8 @@ static Banks gnx_banks[] = { static Device rp250 = { .name = "DigiTech RP250", + .family_id = 0x5E, + .product_id = 0x02, .effects = rp250_effects, .n_effects = G_N_ELEMENTS(rp250_effects), .banks = rp_banks, @@ -1746,6 +1748,8 @@ static Device rp250 = { static Device rp500 = { .name = "DigiTech RP500", + .family_id = 0x5E, + .product_id = 0x05, .effects = rp500_effects, .n_effects = G_N_ELEMENTS(rp500_effects), .banks = rp_banks, @@ -1754,6 +1758,8 @@ static Device rp500 = { static Device gnx3000 = { .name = "DigiTech GNX3000", + .family_id = 0x5C, + .product_id = 0x04, .effects = gnx3000_effects, .n_effects = G_N_ELEMENTS(gnx3000_effects), .banks = gnx_banks, @@ -2063,31 +2069,13 @@ gboolean get_device_info(unsigned char device_id, unsigned char family_id, unsigned char product_id, Device **device) { - switch (family_id) { - case 0x5E: /* RP series */ - switch (product_id) { - case 0x02: /* RP250 */ - *device = &rp250; - return TRUE; - case 0x05: /* RP500 */ - *device = &rp500; - return TRUE; - default: - g_message("Unsupported RP model!"); - return FALSE; - } - case 0x5C: - switch (product_id) { - case 0x04: /* GNX3000 */ - *device = &gnx3000; - return TRUE; - default: - g_message("Unsupported model!"); - return FALSE; - } - default: - g_message("Unsupported device family!"); - return FALSE; + int x; + for (x = 0; x < G_N_ELEMENTS(supported_devices); x++) { + if (supported_devices[x]->product_id == product_id && supported_devices[x]->family_id == family_id) { + *device = supported_devices[x]; + return TRUE; + } } + return FALSE; } diff --git a/effects.h b/effects.h index ac966ed..55fd3ce 100644 --- a/effects.h +++ b/effects.h @@ -67,6 +67,8 @@ typedef struct { typedef struct { gchar *name; + unsigned char family_id; + unsigned char product_id; EffectList *effects; gint n_effects; Banks *banks;