Enforce hysteresis on modifier list requests.
With the tone and effect libraries implemented on rp355, it appears that the device will send multiple NOTIFY_MODIFIER_GROUP_CHANGED messages in response to selecting a new tone or effect library. If we receive a NOTIFY_MODIFIER_GROUP_CHANGED, but haven't yet processed the RECEIVE_MODIFIER_LINKABLE_LIST from the previous notification, we will drop the most recent. This greatly reduces the device churn and time it takes to apply a new library setting.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ gdigi
|
|||||||
*.orig
|
*.orig
|
||||||
*.swp
|
*.swp
|
||||||
images/gdigi_icon.h
|
images/gdigi_icon.h
|
||||||
|
core
|
||||||
|
|||||||
11
gdigi.c
11
gdigi.c
@@ -388,6 +388,8 @@ MessageID get_message_id(GString *msg)
|
|||||||
|
|
||||||
#define HEX_WIDTH 26
|
#define HEX_WIDTH 26
|
||||||
|
|
||||||
|
static guint modifier_linkable_list_request_pending;
|
||||||
|
|
||||||
void push_message(GString *msg)
|
void push_message(GString *msg)
|
||||||
{
|
{
|
||||||
MessageID msgid = get_message_id(msg);
|
MessageID msgid = get_message_id(msg);
|
||||||
@@ -484,7 +486,11 @@ void push_message(GString *msg)
|
|||||||
"id %d changed",
|
"id %d changed",
|
||||||
(str[9] << 8) | (str[10]));
|
(str[9] << 8) | (str[10]));
|
||||||
|
|
||||||
send_message(REQUEST_MODIFIER_LINKABLE_LIST, "\x00\x01", 2);
|
if (!modifier_linkable_list_request_pending) {
|
||||||
|
send_message(REQUEST_MODIFIER_LINKABLE_LIST, "\x00\x01", 2);
|
||||||
|
modifier_linkable_list_request_pending = 1;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -526,6 +532,8 @@ void push_message(GString *msg)
|
|||||||
|
|
||||||
|
|
||||||
case RECEIVE_MODIFIER_LINKABLE_LIST:
|
case RECEIVE_MODIFIER_LINKABLE_LIST:
|
||||||
|
|
||||||
|
modifier_linkable_list_request_pending = 0;
|
||||||
unpack_message(msg);
|
unpack_message(msg);
|
||||||
tot = (unsigned char)msg->str[9];
|
tot = (unsigned char)msg->str[9];
|
||||||
|
|
||||||
@@ -536,6 +544,7 @@ void push_message(GString *msg)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
update_modifier_linkable_list(msg);
|
update_modifier_linkable_list(msg);
|
||||||
|
|
||||||
g_string_free(msg, TRUE);
|
g_string_free(msg, TRUE);
|
||||||
|
|||||||
Reference in New Issue
Block a user