update GUI on remote preset change

This commit is contained in:
Tomasz Moń
2009-05-04 17:04:32 +02:00
parent af1d3a2906
commit 2633bac5d8
4 changed files with 69 additions and 28 deletions

73
gdigi.c
View File

@@ -202,35 +202,52 @@ void push_message(GString *msg)
printf("%02x ", (unsigned char)msg->str[x]); printf("%02x ", (unsigned char)msg->str[x]);
printf("\n"); printf("\n");
if (get_message_id(msg) == ACK) { switch (get_message_id(msg)) {
g_message("Received ACK"); case ACK:
g_string_free(msg, TRUE); g_message("Received ACK");
return; g_string_free(msg, TRUE);
return;
case NACK:
g_message("Received NACK");
g_string_free(msg, TRUE);
return;
case RECEIVE_PARAMETER_VALUE:
unpack_message(msg);
SettingParam *param = setting_param_new_from_data(&msg->str[8], NULL);
g_message("Received parameter change ID: %d Position: %d Value: %d", param->id, param->position, param->value);
GDK_THREADS_ENTER();
apply_setting_param_to_gui(param);
GDK_THREADS_LEAVE();
setting_param_free(param);
g_string_free(msg, TRUE);
return;
case RECEIVE_DEVICE_NOTIFICATION:
unpack_message(msg);
unsigned char *str = (unsigned char*)msg->str;
switch (str[8]) {
case NOTIFY_PRESET_MOVED:
if (str[11] == PRESETS_EDIT_BUFFER && str[12] == 0) {
g_message("Loaded preset %d from bank %d", str[10], str[9]);
GDK_THREADS_ENTER();
g_timeout_add(0, apply_current_preset_to_gui, NULL);
GDK_THREADS_LEAVE();
} else
g_message("%d %d moved to %d %d", str[9], str[10], str[11], str[12]);
return;
default:
g_message("Received unhandled device notification");
}
default:
g_mutex_lock(message_queue_mutex);
g_queue_push_tail(message_queue, msg);
g_mutex_unlock(message_queue_mutex);
} }
if (get_message_id(msg) == NACK) {
g_message("Received NACK");
g_string_free(msg, TRUE);
return;
}
if (get_message_id(msg) == RECEIVE_PARAMETER_VALUE) {
unpack_message(msg);
SettingParam *param = setting_param_new_from_data(&msg->str[8], NULL);
g_message("Received parameter change ID: %d Position: %d Value: %d", param->id, param->position, param->value);
GDK_THREADS_ENTER();
apply_setting_param_to_gui(param);
GDK_THREADS_LEAVE();
setting_param_free(param);
g_string_free(msg, TRUE);
return;
}
g_mutex_lock(message_queue_mutex);
g_queue_push_tail(message_queue, msg);
g_mutex_unlock(message_queue_mutex);
} }
gpointer read_data_thread(gboolean *stop) gpointer read_data_thread(gboolean *stop)

17
gdigi.h
View File

@@ -637,6 +637,23 @@ typedef enum {
PRESETS_EXTERNAL = 6 PRESETS_EXTERNAL = 6
} PresetBank; } PresetBank;
typedef enum {
/* Version 0 only */
NOTIFY_PRESET_LOADED = 0,
NOTIFY_PRESET_STORED = 1,
NOTIFY_MODIFIER_GROUP_CHANGED = 2,
/* Version 1 */
NOTIFY_PRESET_MOVED = 3,
NOTIFY_OBJECT_MOVED = 4,
NOTIFY_OBJECT_RENAMED = 5,
NOTIFY_MEDIA_CARD_PRESENT_CHANGED = 6,
NOTIFY_ALL_GLOBALS_CHANGED = 7,
NOTIFY_PRESET_INDEX_TABLE_CHANGED = 8,
NOTIFY_PRESET_RENAMED = 9
} NotifyCode;
typedef enum { typedef enum {
REQUEST_WHO_AM_I = 0x01, REQUEST_WHO_AM_I = 0x01,
RECEIVE_WHO_AM_I = 0x02, RECEIVE_WHO_AM_I = 0x02,

6
gui.c
View File

@@ -199,6 +199,12 @@ static void apply_current_preset()
preset_free(preset); preset_free(preset);
} }
gboolean apply_current_preset_to_gui(gpointer data)
{
apply_current_preset();
return FALSE;
}
/** /**
* \param settings effect parameters * \param settings effect parameters
* \param amt amount of effect parameters * \param amt amount of effect parameters

1
gui.h
View File

@@ -22,6 +22,7 @@
void show_error_message(GtkWidget *parent, gchar *message); void show_error_message(GtkWidget *parent, gchar *message);
void apply_setting_param_to_gui(SettingParam *param); void apply_setting_param_to_gui(SettingParam *param);
gboolean apply_current_preset_to_gui(gpointer data);
void gui_create(Device *device); void gui_create(Device *device);
void gui_free(); void gui_free();
gboolean unsupported_device_dialog(Device **device); gboolean unsupported_device_dialog(Device **device);