feedback-manager: Add hint to select feedback profile per event
This e.g. allows events that are meant for haptic only to avoid emitting a sound by omitting the 'full' level and using "quiet" instead. Closes: #7
This commit is contained in:
committed by
Guido Gunther
parent
421c163bdd
commit
6692d8922b
@@ -224,6 +224,21 @@ get_max_level (FbdFeedbackProfileLevel global_level,
|
||||
return level;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_hints (GVariant *hints, FbdFeedbackProfileLevel *level)
|
||||
{
|
||||
const gchar *profile;
|
||||
gboolean found;
|
||||
g_auto (GVariantDict) dict = G_VARIANT_DICT_INIT (NULL);
|
||||
|
||||
g_variant_dict_init (&dict, hints);
|
||||
found = g_variant_dict_lookup (&dict, "profile", "&s", &profile);
|
||||
|
||||
if (level && found)
|
||||
*level = fbd_feedback_profile_level (profile);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
fbd_feedback_manager_handle_trigger_feedback (LfbGdbusFeedback *object,
|
||||
GDBusMethodInvocation *invocation,
|
||||
@@ -259,6 +274,13 @@ fbd_feedback_manager_handle_trigger_feedback (LfbGdbusFeedback *object,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!parse_hints (arg_hints, &hint_level)) {
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
|
||||
G_DBUS_ERROR_INVALID_ARGS,
|
||||
"Invalid hints");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (arg_timeout < -1)
|
||||
arg_timeout = -1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user