From ec223eb2e63fc4fa5a93a2977629c25d1e23cac5 Mon Sep 17 00:00:00 2001 From: Ogier Bouvier Date: Tue, 12 Dec 2017 10:57:38 +0100 Subject: [PATCH] hidpp20: force at least one profile to be enabled fix #428 Signed-off-by: Ogier Bouvier --- src/hidpp20.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/hidpp20.c b/src/hidpp20.c index e0ffabcf..0c3382a6 100644 --- a/src/hidpp20.c +++ b/src/hidpp20.c @@ -2545,6 +2545,7 @@ hidpp20_onboard_profiles_commit(struct hidpp20_device *device, { struct hidpp20_profile *profile; unsigned int i; + bool enabled_profile = false; int rc; for (i = 0; i < profiles_list->num_profiles; i++) { @@ -2556,6 +2557,19 @@ hidpp20_onboard_profiles_commit(struct hidpp20_device *device, i); if (rc < 0) return rc; + + enabled_profile = true; + } + } + + if (!enabled_profile) { + if (profiles_list->num_profiles > 0) { + profiles_list->profiles[0].enabled = 1; + rc = hidpp20_onboard_profiles_write_profile(device, + profiles_list, + 0); + if (rc < 0) + return rc; } }