diff --git a/TODO b/TODO index ae92e20..d080099 100644 --- a/TODO +++ b/TODO @@ -4,3 +4,4 @@ -buildsystem (install knob.png to share dir, don't use inline knob pixbuf) -add expression pedal settings to gui -read asynchronously from MIDI IN +-guess device port when user doesn't explicitly provide it (don't use hardcoded "hw:1,0,0") diff --git a/effects.c b/effects.c index 31acfc3..436e3ae 100644 --- a/effects.c +++ b/effects.c @@ -1262,7 +1262,7 @@ static Effect rp500_eq_effect[] = { {"Enable Equalizer", EQ_ON_OFF, EQ_POSITION, rp500_eq_group, G_N_ELEMENTS(rp500_eq_group)}, }; -EffectList rp250_effects[] = { +static EffectList rp250_effects[] = { {"Wah", wah_effect, G_N_ELEMENTS(wah_effect)}, {"Amplifier", rp250_amp_effect, G_N_ELEMENTS(rp250_amp_effect)}, {"Equalizer", rp250_eq_effect, G_N_ELEMENTS(rp250_eq_effect)}, @@ -1274,9 +1274,9 @@ EffectList rp250_effects[] = { {"Reverb", reverb_effect, G_N_ELEMENTS(reverb_effect)}, }; -int n_rp250_effects = G_N_ELEMENTS(rp250_effects); +static int n_rp250_effects = G_N_ELEMENTS(rp250_effects); -EffectList rp500_effects[] = { +static EffectList rp500_effects[] = { {"Wah", wah_effect, G_N_ELEMENTS(wah_effect)}, {"Amplifier", rp500_amp_effect, G_N_ELEMENTS(rp500_amp_effect)}, {"Equalizer", rp500_eq_effect, G_N_ELEMENTS(rp500_eq_effect)}, @@ -1288,7 +1288,14 @@ EffectList rp500_effects[] = { {"Reverb", reverb_effect, G_N_ELEMENTS(reverb_effect)}, }; -int n_rp500_effects = G_N_ELEMENTS(rp500_effects); +static int n_rp500_effects = G_N_ELEMENTS(rp500_effects); + +SupportedDevices supported_devices[] = { + {"DigiTech RP250", rp250_effects, G_N_ELEMENTS(rp250_effects)}, + {"DigiTech RP500", rp500_effects, G_N_ELEMENTS(rp500_effects)}, +}; + +int n_supported_devices = G_N_ELEMENTS(supported_devices); #endif /* DOXYGEN_SHOULD_SKIP_THIS */ @@ -1598,13 +1605,11 @@ gboolean get_effect_list(unsigned char device_id, unsigned char family_id, *n_list = n_rp500_effects; return TRUE; default: - g_warning("Unsupported RP model. Using RP250-compability mode!"); - *list = rp250_effects; - *n_list = n_rp250_effects; - return TRUE; + g_message("Unsupported RP model!"); + return FALSE; } default: - g_error("Unsupported device family!"); + g_message("Unsupported device family!"); return FALSE; } } diff --git a/effects.h b/effects.h index 0488a93..55531d3 100644 --- a/effects.h +++ b/effects.h @@ -60,6 +60,12 @@ typedef struct { gint group_amt; } ModifierGroup; +typedef struct { + gchar *name; + EffectList *list; + int n_list; +} SupportedDevices; + ModifierGroup *modifier_linkable_list(); void modifier_group_free(ModifierGroup *modifier_group); gboolean get_effect_list(unsigned char device_id, unsigned char family_id, diff --git a/gdigi.c b/gdigi.c index 66b475d..a2e28f4 100644 --- a/gdigi.c +++ b/gdigi.c @@ -566,11 +566,16 @@ int main(int argc, char *argv[]) { if (request_who_am_i(&device_id, &family_id, &product_id) == FALSE) { show_error_message(NULL, "No suitable reply from device"); } else { - EffectList *list; - int n_list; + EffectList *list = NULL; + int n_list = -1; + if (get_effect_list(device_id, family_id, product_id, &list, &n_list) == FALSE) { - show_error_message(NULL, "Unsupported hardware. Please check HACKING file."); - } else { + if (unsupported_device_dialog(&list, &n_list) == FALSE) { + g_message("Shutting down"); + } + } + + if (list != NULL && n_list != -1) { gui_create(list, n_list); gtk_main(); gui_free(); diff --git a/gui.c b/gui.c index 07b9cf0..b3d860c 100644 --- a/gui.c +++ b/gui.c @@ -22,13 +22,6 @@ #include "gtkknob.h" #include "knob.h" -#ifndef DOXYGEN_SHOULD_SKIP_THIS - -extern EffectList effects[]; -extern int n_effects; - -#endif /* DOXYGEN_SHOULD_SKIP_THIS */ - typedef struct { GtkObject *widget; gint id; @@ -908,3 +901,57 @@ void gui_free() gtk_knob_animation_free(knob_anim); knob_anim = NULL; } + +/** + * \param list Variable to hold effect list + * \param n_list Variable to hold length of effect list + * + * Displays dialogbox stating that device is unsupported. + * + * \return TRUE if user selects "compability mode", otherwise FALSE. + **/ +gboolean unsupported_device_dialog(EffectList **list, int *n_list) +{ + extern SupportedDevices supported_devices[]; + extern int n_supported_devices; + + GtkWidget *dialog; + GtkWidget *label; + GtkWidget *combo_box; + int x; + + dialog = gtk_dialog_new_with_buttons("Unsupported device", + NULL, GTK_DIALOG_MODAL, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + + + label = gtk_label_new("Your device appears to be unsupported by gdigi.\n" + "As some of the settings may be common between different devices,\n" + "you can now select compability mode with one of the supported devices.\n" + "Please take a look at gdigi's HACKING file."); + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); + + combo_box = gtk_combo_box_new_text(); + for (x=0; xvbox), combo_box); + + gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { + gint number = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_box)); + if (number != -1 && number #include "effects.h" void show_error_message(GtkWidget *parent, gchar *message); void gui_create(EffectList *list, int n_list); void gui_free(); +gboolean unsupported_device_dialog(EffectList **list, int *n_list); #endif /* GDIGI_GUI_H */