From 1586913fc7688018332ef2bc45f9149c14de96d7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 19 Dec 2018 11:56:23 +1000 Subject: [PATCH] tools: don't allow setting macros where not supported Fixes #585 Signed-off-by: Peter Hutterer --- tools/ratbagctl.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/ratbagctl.in b/tools/ratbagctl.in index 2b317980..6608426a 100755 --- a/tools/ratbagctl.in +++ b/tools/ratbagctl.in @@ -379,12 +379,17 @@ def func_button_get(r, args): def func_button_action_set_button(r, args): b, p, d = find_button(r, args) + if not d.CAP_BUTTON in d.capabilities: + raise RatbagErrorCapability("assigning a button is not supported on this device") b.mapping = args.target_button commit(d, args) def func_button_action_set_special(r, args): b, p, d = find_button(r, args) + if not d.CAP_BUTTON in d.capabilities: + raise RatbagErrorCapability("assigning a button is not supported on this device") + try: special = args.target_special except AttributeError: @@ -396,6 +401,9 @@ def func_button_action_set_special(r, args): def func_button_action_set_macro(r, args): b, p, d = find_button(r, args) + if not d.CAP_BUTTON_MACROS in d.capabilities: + raise RatbagErrorCapability("assigning a macro is not supported on this device") + macro_keys = args.target_macro macro = RatbagdMacro() for s in macro_keys: