From 79711dfdad8a1066d2797c11bb586897276210c1 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 22 Feb 2019 14:56:31 +1000 Subject: [PATCH] Drop the Button.Type property The button type was the physical button type, not the logically assigned button number. This property is basically unused and of questionable use anyway. GUI applications would need to rely on drawings of the mouse anyway. Scripts don't really care because ratbagctl uses the button index anyway. The only time this matters is when we're looking at (human) device discovery. But often clicking around is enough to figure out the index. So let's drop this API on the assumption that it's not really needed and maintaining and extending that enum forever is not necessary. This is not a full purge, merely the DBus API that gets dropped. Signed-off-by: Peter Hutterer --- doc/dbus.rst | 10 ---------- ratbagd/ratbagd-button.c | 19 ------------------- src/libratbag-enums.h | 4 ++++ src/libratbag.c | 6 ------ src/libratbag.h | 19 ------------------- tools/ratbagc.py.in | 5 ----- tools/ratbagctl.in | 29 +---------------------------- tools/ratbagctl.test.in | 28 ++++++++++++++-------------- tools/ratbagd.py | 30 ------------------------------ 9 files changed, 19 insertions(+), 131 deletions(-) diff --git a/doc/dbus.rst b/doc/dbus.rst index 871a726b..8a9a88c7 100644 --- a/doc/dbus.rst +++ b/doc/dbus.rst @@ -367,16 +367,6 @@ org.freedesktop.ratbag1.Button Index of the button -.. attribute:: Type - - :type: u - :flags: read-only, constant - - Enum describing the button physical type, see - :cpp:enum:`ratbag_button_type`. This type is unrelated to the - logical button mapping and serves to easily identify the button on - the device. - .. attribute:: ButtonMapping :type: u diff --git a/ratbagd/ratbagd-button.c b/ratbagd/ratbagd-button.c index fbaa5728..f6b2d486 100644 --- a/ratbagd/ratbagd-button.c +++ b/ratbagd/ratbagd-button.c @@ -45,24 +45,6 @@ struct ratbagd_button { char *path; }; -static int ratbagd_button_get_type(sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *error) -{ - struct ratbagd_button *button = userdata; - enum ratbag_button_type t; - - t = ratbag_button_get_type(button->lib_button); - - verify_unsigned_int(t); - - return sd_bus_message_append(reply, "u", t); -} - static int ratbagd_button_get_button(sd_bus *bus, const char *path, const char *interface, @@ -363,7 +345,6 @@ static int ratbagd_button_disable(sd_bus_message *m, const sd_bus_vtable ratbagd_button_vtable[] = { SD_BUS_VTABLE_START(0), SD_BUS_PROPERTY("Index", "u", NULL, offsetof(struct ratbagd_button, index), SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("Type", "u", ratbagd_button_get_type, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_WRITABLE_PROPERTY("ButtonMapping", "u", ratbagd_button_get_button, ratbagd_button_set_button, diff --git a/src/libratbag-enums.h b/src/libratbag-enums.h index 9b1e6f7e..447d8010 100644 --- a/src/libratbag-enums.h +++ b/src/libratbag-enums.h @@ -142,6 +142,10 @@ enum ratbag_resolution_capability { * @ingroup enums * * Button types describing the physical button. + * + * This enum is deprecated and should not be used. + * + * @deprecated */ enum ratbag_button_type { RATBAG_BUTTON_TYPE_UNKNOWN = 0, diff --git a/src/libratbag.c b/src/libratbag.c index 00e21215..482817a1 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -1240,12 +1240,6 @@ ratbag_profile_get_button(struct ratbag_profile *profile, return NULL; } -LIBRATBAG_EXPORT enum ratbag_button_type -ratbag_button_get_type(struct ratbag_button *button) -{ - return button->type; -} - LIBRATBAG_EXPORT enum ratbag_button_action_type ratbag_button_get_action_type(struct ratbag_button *button) { diff --git a/src/libratbag.h b/src/libratbag.h index ba0d9c12..d9aa47d6 100644 --- a/src/libratbag.h +++ b/src/libratbag.h @@ -1056,25 +1056,6 @@ ratbag_button_set_user_data(struct ratbag_button *button, void *userdata); void* ratbag_button_get_user_data(const struct ratbag_button *button); -/** - * @ingroup button - * - * Return the type of the physical button. This function is intended to be - * used by configuration tools to provide a generic list of button names or - * handles to configure devices. The type describes the physical location of - * the button and remains constant for the lifetime of the device. - * For example, a button of type @ref RATBAG_BUTTON_TYPE_WHEEL_CLICK may be - * mapped to a logical middle button, but the physical description is that - * of a wheel click. - * - * For the button currently mapped to this physical button, see - * ratbag_button_get_button() - * - * @return The type of the button - */ -enum ratbag_button_type -ratbag_button_get_type(struct ratbag_button *button); - /** * @ingroup button * diff --git a/tools/ratbagc.py.in b/tools/ratbagc.py.in index f2189118..652d096c 100644 --- a/tools/ratbagc.py.in +++ b/tools/ratbagc.py.in @@ -565,11 +565,6 @@ class RatbagdButton(metaclass=MetaRatbag): """The index of this button.""" return self._id - @property - def type(self): - """An enum describing this button's type.""" - return libratbag.ratbag_button_get_type(self._button) - @property def mapping(self): """An integer of the current button mapping, if mapping to a button.""" diff --git a/tools/ratbagctl.in b/tools/ratbagctl.in index 891f4aa2..31dd348f 100755 --- a/tools/ratbagctl.in +++ b/tools/ratbagctl.in @@ -179,34 +179,7 @@ def print_led_caps(d, p, l, level): def print_button(d, p, b, level): - types = { - RatbagdButton.TYPE_UNKNOWN: "unknown", - RatbagdButton.TYPE_LEFT: "left", - RatbagdButton.TYPE_MIDDLE: "middle", - RatbagdButton.TYPE_RIGHT: "right", - RatbagdButton.TYPE_THUMB: "thumb", - RatbagdButton.TYPE_THUMB2: "thumb2", - RatbagdButton.TYPE_THUMB3: "thumb3", - RatbagdButton.TYPE_THUMB4: "thumb4", - RatbagdButton.TYPE_WHEEL_LEFT: "wheel-left", - RatbagdButton.TYPE_WHEEL_RIGHT: "wheel-right", - RatbagdButton.TYPE_WHEEL_CLICK: "wheel-click", - RatbagdButton.TYPE_WHEEL_UP: "wheel-up", - RatbagdButton.TYPE_WHEEL_DOWN: "wheel-down", - RatbagdButton.TYPE_WHEEL_RATCHET_MODE_SHIFT: "wheel-ratchet-mode-shift", - RatbagdButton.TYPE_EXTRA: "extra", - RatbagdButton.TYPE_SIDE: "side", - RatbagdButton.TYPE_PINKIE: "pinkie", - RatbagdButton.TYPE_PINKIE2: "pinkie2", - RatbagdButton.TYPE_RESOLUTION_CYCLE_UP: "resolution-cycle-up", - RatbagdButton.TYPE_RESOLUTION_UP: "resolution-up", - RatbagdButton.TYPE_RESOLUTION_DOWN: "resolution-down", - RatbagdButton.TYPE_PROFILE_CYCLE_UP: "profile-cycle-up", - RatbagdButton.TYPE_PROFILE_UP: "profile-up", - RatbagdButton.TYPE_PROFILE_DOWN: "profile-down", - } - t = types[b.type] - header = " " * level + "Button: {} type {} is mapped to ".format(b.index, t) + header = " " * level + "Button: {} is mapped to ".format(b.index) if b.action_type == RatbagdButton.ACTION_TYPE_BUTTON: print("{}'button {}'".format(header, b.mapping)) diff --git a/tools/ratbagctl.test.in b/tools/ratbagctl.test.in index 1f5aa9c5..21e54882 100755 --- a/tools/ratbagctl.test.in +++ b/tools/ratbagctl.test.in @@ -402,13 +402,13 @@ class TestRatbagCtlButton(TestRatbagCtl): def test_button_n_get(self): self.setProfile(0) r = self.launch_good_test("button 0 get test_device") - self.assertEqual(r, "Button: 0 type left is mapped to 'button 0'") + self.assertEqual(r, "Button: 0 is mapped to 'button 0'") r = self.launch_good_test("button 1 get test_device") - self.assertEqual(r, "Button: 1 type middle is mapped to UNKNOWN") + self.assertEqual(r, "Button: 1 is mapped to UNKNOWN") r = self.launch_good_test("button 2 get test_device") - self.assertEqual(r, "Button: 2 type right is mapped to 'profile-cycle-up'") + self.assertEqual(r, "Button: 2 is mapped to 'profile-cycle-up'") r = self.launch_good_test("button 3 get test_device") - self.assertEqual(r, "Button: 3 type unknown is mapped to macro '↕B 300ms'") + self.assertEqual(r, "Button: 3 is mapped to macro '↕B 300ms'") self.launch_fail_test("button 1 get 10 test_device") self.launch_fail_test("button 10 get test_device") self.launch_fail_test("button 1 get test_device X") @@ -416,7 +416,7 @@ class TestRatbagCtlButton(TestRatbagCtl): def test_button_n_action_get(self): self.setProfile(0) r = self.launch_good_test("button 0 action get test_device") - self.assertEqual(r, "Button: 0 type left is mapped to 'button 0'") + self.assertEqual(r, "Button: 0 is mapped to 'button 0'") self.launch_fail_test("button 1 action get 10 test_device") self.launch_fail_test("button 10 action get test_device") self.launch_fail_test("button 1 action get test_device X") @@ -425,11 +425,11 @@ class TestRatbagCtlButton(TestRatbagCtl): self.setProfile(2) command = "button 2 action set button" r = self.launch_good_test("button 2 action get test_device") - self.assertEqual(r, "Button: 2 type right is mapped to 'button 2'") + self.assertEqual(r, "Button: 2 is mapped to 'button 2'") r = self.launch_good_test(command + " 1 test_device") self.assertEqual(r, '') r = self.launch_good_test("button 2 action get test_device") - self.assertEqual(r, "Button: 2 type right is mapped to 'button 1'") + self.assertEqual(r, "Button: 2 is mapped to 'button 1'") self.launch_fail_test(command) self.launch_fail_test(command + " X test_device") self.launch_fail_test(command + " 100 test_device X") @@ -438,11 +438,11 @@ class TestRatbagCtlButton(TestRatbagCtl): self.setProfile(2) command = "button 0 action set special " r = self.launch_good_test("button 0 action get test_device") - self.assertEqual(r, "Button: 0 type left is mapped to 'profile-cycle-up'") + self.assertEqual(r, "Button: 0 is mapped to 'profile-cycle-up'") r = self.launch_good_test(command + " second-mode test_device") self.assertEqual(r, '') r = self.launch_good_test("button 0 action get test_device") - self.assertEqual(r, "Button: 0 type left is mapped to 'second-mode'") + self.assertEqual(r, "Button: 0 is mapped to 'second-mode'") self.launch_fail_test(command) self.launch_fail_test(command + " X test_device") self.launch_fail_test(command + " 100 test_device X") @@ -451,22 +451,22 @@ class TestRatbagCtlButton(TestRatbagCtl): command = "button 2 action set macro " self.launch_good_test(command + '+KEY_B KEY_A -KEY_B KEY_C test_device') r = self.launch_good_test("button 2 get test_device") - self.assertEqual(r, "Button: 2 type right is mapped to macro '↓B ↕A ↑B ↕C'") + self.assertEqual(r, "Button: 2 is mapped to macro '↓B ↕A ↑B ↕C'") self.launch_good_test(command + 't100 t200 test_device') r = self.launch_good_test("button 2 get test_device") - self.assertEqual(r, "Button: 2 type right is mapped to macro '100ms 200ms'") + self.assertEqual(r, "Button: 2 is mapped to macro '100ms 200ms'") self.launch_good_test(command + 'KeY_z test_device') r = self.launch_good_test("button 2 get test_device") - self.assertEqual(r, "Button: 2 type right is mapped to macro '↕Z'") + self.assertEqual(r, "Button: 2 is mapped to macro '↕Z'") self.launch_good_test(command + ' test_device') r = self.launch_good_test("button 2 get test_device") - self.assertEqual(r, "Button: 2 type right is mapped to macro 'None'") + self.assertEqual(r, "Button: 2 is mapped to macro 'None'") self.launch_fail_test(command) self.launch_fail_test(command + " KEY_A test_device X") def test_prefix_button(self): r = self.launch_good_test("Profile 2 Button 3 get test_device") - self.assertEqual(r, "Button: 3 type unknown is mapped to 'button 3'") + self.assertEqual(r, "Button: 3 is mapped to 'button 3'") self.launch_fail_test("Profile 2 Profile 2 Button 3 get test_device") self.launch_fail_test("Profile 2 Resolution 2 Button 3 get test_device") diff --git a/tools/ratbagd.py b/tools/ratbagd.py index b70e20c9..d4e72922 100644 --- a/tools/ratbagd.py +++ b/tools/ratbagd.py @@ -662,31 +662,6 @@ class RatbagdButton(_RatbagdDBus): MACRO_KEY_RELEASE = 2 MACRO_WAIT = 3 - TYPE_UNKNOWN = 0 - TYPE_LEFT = 1 - TYPE_MIDDLE = 2 - TYPE_RIGHT = 3 - TYPE_THUMB = 4 - TYPE_THUMB2 = 5 - TYPE_THUMB3 = 6 - TYPE_THUMB4 = 7 - TYPE_WHEEL_LEFT = 8 - TYPE_WHEEL_RIGHT = 9 - TYPE_WHEEL_CLICK = 10 - TYPE_WHEEL_UP = 11 - TYPE_WHEEL_DOWN = 12 - TYPE_WHEEL_RATCHET_MODE_SHIFT = 13 - TYPE_EXTRA = 14 - TYPE_SIDE = 15 - TYPE_PINKIE = 16 - TYPE_PINKIE2 = 17 - TYPE_RESOLUTION_CYCLE_UP = 18 - TYPE_RESOLUTION_UP = 19 - TYPE_RESOLUTION_DOWN = 20 - TYPE_PROFILE_CYCLE_UP = 21 - TYPE_PROFILE_UP = 22 - TYPE_PROFILE_DOWN = 23 - """A table mapping a button's index to its usual function as defined by X and the common desktop environments.""" BUTTON_DESCRIPTION = { @@ -733,11 +708,6 @@ class RatbagdButton(_RatbagdDBus): """The index of this button.""" return self._get_dbus_property("Index") - @GObject.Property - def type(self): - """An enum describing this button's type.""" - return self._get_dbus_property("Type") - @GObject.Property def mapping(self): """An integer of the current button mapping, if mapping to a button."""