summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2020-12-16 11:55:41 +0100
committerBastien Nocera <hadess@hadess.net>2020-12-16 13:09:04 +0100
commit67eefa17ddaab404837c2fb6caf25141ded67c12 (patch)
tree4f72ff20c89c2ac76c76d7bb09401dfa529f9839
parentc6d2618e95bea65472d353573afd406fbf59453b (diff)
lib: Add "Touchpad" device type
-rw-r--r--libupower-glib/up-device.c12
-rw-r--r--libupower-glib/up-types.c4
-rw-r--r--libupower-glib/up-types.h1
-rw-r--r--src/linux/hidpp-device.c4
-rwxr-xr-xsrc/linux/integration-test7
-rw-r--r--src/linux/up-device-supply.c5
-rw-r--r--src/linux/up-device-unifying.c4
-rw-r--r--src/up-daemon.c3
8 files changed, 28 insertions, 12 deletions
diff --git a/libupower-glib/up-device.c b/libupower-glib/up-device.c
index 01f752f..66695aa 100644
--- a/libupower-glib/up-device.c
+++ b/libupower-glib/up-device.c
@@ -307,20 +307,23 @@ up_device_to_text (UpDevice *device)
if (kind == UP_DEVICE_KIND_BATTERY ||
kind == UP_DEVICE_KIND_MOUSE ||
kind == UP_DEVICE_KIND_KEYBOARD ||
- kind == UP_DEVICE_KIND_UPS)
+ kind == UP_DEVICE_KIND_UPS ||
+ kind == UP_DEVICE_KIND_TOUCHPAD)
g_string_append_printf (string, " present: %s\n", up_device_bool_to_string (up_exported_device_get_is_present (priv->proxy_device)));
if ((kind == UP_DEVICE_KIND_PHONE ||
kind == UP_DEVICE_KIND_BATTERY ||
kind == UP_DEVICE_KIND_MOUSE ||
kind == UP_DEVICE_KIND_KEYBOARD ||
kind == UP_DEVICE_KIND_GAMING_INPUT ||
- kind == UP_DEVICE_KIND_PEN) &&
+ kind == UP_DEVICE_KIND_PEN ||
+ kind == UP_DEVICE_KIND_TOUCHPAD) &&
!is_display)
g_string_append_printf (string, " rechargeable: %s\n", up_device_bool_to_string (up_exported_device_get_is_rechargeable (priv->proxy_device)));
if (kind == UP_DEVICE_KIND_BATTERY ||
kind == UP_DEVICE_KIND_MOUSE ||
kind == UP_DEVICE_KIND_KEYBOARD ||
- kind == UP_DEVICE_KIND_UPS)
+ kind == UP_DEVICE_KIND_UPS ||
+ kind == UP_DEVICE_KIND_TOUCHPAD)
g_string_append_printf (string, " state: %s\n", up_device_state_to_string (up_exported_device_get_state (priv->proxy_device)));
g_string_append_printf (string, " warning-level: %s\n", up_device_level_to_string (up_exported_device_get_warning_level (priv->proxy_device)));
battery_level = up_exported_device_get_battery_level (priv->proxy_device);
@@ -369,7 +372,8 @@ up_device_to_text (UpDevice *device)
kind == UP_DEVICE_KIND_MEDIA_PLAYER ||
kind == UP_DEVICE_KIND_UPS ||
kind == UP_DEVICE_KIND_GAMING_INPUT ||
- kind == UP_DEVICE_KIND_PEN) {
+ kind == UP_DEVICE_KIND_PEN ||
+ kind == UP_DEVICE_KIND_TOUCHPAD) {
if (battery_level == UP_DEVICE_LEVEL_NONE)
g_string_append_printf (string, " percentage: %g%%\n", up_exported_device_get_percentage (priv->proxy_device));
else
diff --git a/libupower-glib/up-types.c b/libupower-glib/up-types.c
index 7cf9573..3f87db6 100644
--- a/libupower-glib/up-types.c
+++ b/libupower-glib/up-types.c
@@ -73,6 +73,8 @@ up_device_kind_to_string (UpDeviceKind type_enum)
return "gaming-input";
case UP_DEVICE_KIND_PEN:
return "pen";
+ case UP_DEVICE_KIND_TOUCHPAD:
+ return "touchpad";
default:
return "unknown";
}
@@ -117,6 +119,8 @@ up_device_kind_from_string (const gchar *type)
return UP_DEVICE_KIND_GAMING_INPUT;
if (g_str_equal (type, "pen"))
return UP_DEVICE_KIND_PEN;
+ if (g_str_equal (type, "touchpad"))
+ return UP_DEVICE_KIND_TOUCHPAD;
return UP_DEVICE_KIND_UNKNOWN;
}
diff --git a/libupower-glib/up-types.h b/libupower-glib/up-types.h
index 379d46c..8a2e7d8 100644
--- a/libupower-glib/up-types.h
+++ b/libupower-glib/up-types.h
@@ -50,6 +50,7 @@ typedef enum {
UP_DEVICE_KIND_COMPUTER,
UP_DEVICE_KIND_GAMING_INPUT,
UP_DEVICE_KIND_PEN,
+ UP_DEVICE_KIND_TOUCHPAD,
UP_DEVICE_KIND_LAST
} UpDeviceKind;
diff --git a/src/linux/hidpp-device.c b/src/linux/hidpp-device.c
index 1bd3337..16bce33 100644
--- a/src/linux/hidpp-device.c
+++ b/src/linux/hidpp-device.c
@@ -775,10 +775,12 @@ hidpp_device_refresh (HidppDevice *device,
break;
case HIDPP_READ_LONG_REGISTER_DEVICE_TYPE_MOUSE:
case HIDPP_READ_LONG_REGISTER_DEVICE_TYPE_TRACKBALL:
- case HIDPP_READ_LONG_REGISTER_DEVICE_TYPE_TOUCHPAD:
case HIDPP_READ_LONG_REGISTER_DEVICE_TYPE_PRESENTER:
priv->kind = HIDPP_DEVICE_KIND_MOUSE;
break;
+ case HIDPP_READ_LONG_REGISTER_DEVICE_TYPE_TOUCHPAD:
+ priv->kind = HIDPP_DEVICE_KIND_TOUCHPAD;
+ break;
case HIDPP_READ_LONG_REGISTER_DEVICE_TYPE_TABLET:
priv->kind = HIDPP_DEVICE_KIND_TABLET;
break;
diff --git a/src/linux/integration-test b/src/linux/integration-test
index b8364c8..254da46 100755
--- a/src/linux/integration-test
+++ b/src/linux/integration-test
@@ -87,7 +87,8 @@ BATTERY_IFACE = 'org.bluez.Battery1'
UP_DEVICE_KIND_TABLET,
UP_DEVICE_KIND_COMPUTER,
UP_DEVICE_KIND_GAMING_INPUT,
- UP_DEVICE_KIND_PEN) = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
+ UP_DEVICE_KIND_PEN,
+ UP_DEVICE_KIND_TOUCHPAD) = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
class Tests(dbusmock.DBusTestCase):
@classmethod
@@ -1275,7 +1276,7 @@ class Tests(dbusmock.DBusTestCase):
self.testbed.uevent(batt_dev, 'change')
time.sleep(0.5)
- self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'Type'), UP_DEVICE_KIND_MOUSE)
+ self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'Type'), UP_DEVICE_KIND_TOUCHPAD)
def test_hidpp_touchpad(self):
'''HID++ touchpad battery with 5 capacity levels'''
@@ -1313,7 +1314,7 @@ class Tests(dbusmock.DBusTestCase):
self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'Model'), 'Logitech T650')
self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'PowerSupply'), False)
- self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'Type'), UP_DEVICE_KIND_MOUSE)
+ self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'Type'), UP_DEVICE_KIND_TOUCHPAD)
self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'Serial'), '123456')
self.assertEqual(self.get_dbus_property('OnBattery'), False)
self.assertEqual(self.get_dbus_display_property('WarningLevel'), UP_DEVICE_LEVEL_NONE)
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index 9302119..7485b26 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -1053,9 +1053,10 @@ up_device_supply_guess_type (GUdevDevice *native,
sibling = up_device_supply_get_sibling_with_subsystem (native, "input");
if (sibling) {
- if (g_udev_device_get_property_as_boolean (sibling, "ID_INPUT_MOUSE") ||
- g_udev_device_get_property_as_boolean (sibling, "ID_INPUT_TOUCHPAD")) {
+ if (g_udev_device_get_property_as_boolean (sibling, "ID_INPUT_MOUSE")) {
type = UP_DEVICE_KIND_MOUSE;
+ } else if (g_udev_device_get_property_as_boolean (sibling, "ID_INPUT_TOUCHPAD")) {
+ type = UP_DEVICE_KIND_TOUCHPAD;
} else if (g_udev_device_get_property_as_boolean (sibling, "ID_INPUT_JOYSTICK")) {
type = UP_DEVICE_KIND_GAMING_INPUT;
} else {
diff --git a/src/linux/up-device-unifying.c b/src/linux/up-device-unifying.c
index b725318..75ef22f 100644
--- a/src/linux/up-device-unifying.c
+++ b/src/linux/up-device-unifying.c
@@ -114,10 +114,12 @@ up_device_unifying_get_device_kind (UpDeviceUnifying *unifying)
UpDeviceKind kind;
switch (hidpp_device_get_kind (unifying->priv->hidpp_device)) {
case HIDPP_DEVICE_KIND_MOUSE:
- case HIDPP_DEVICE_KIND_TOUCHPAD:
case HIDPP_DEVICE_KIND_TRACKBALL:
kind = UP_DEVICE_KIND_MOUSE;
break;
+ case HIDPP_DEVICE_KIND_TOUCHPAD:
+ kind = UP_DEVICE_KIND_TOUCHPAD;
+ break;
case HIDPP_DEVICE_KIND_KEYBOARD:
kind = UP_DEVICE_KIND_KEYBOARD;
break;
diff --git a/src/up-daemon.c b/src/up-daemon.c
index 5263c34..ef2cd6b 100644
--- a/src/up-daemon.c
+++ b/src/up-daemon.c
@@ -651,7 +651,8 @@ up_daemon_compute_warning_level (UpDaemon *daemon,
* battery level, so this avoids falling directly
* into critical (or off) before any warnings */
if (kind == UP_DEVICE_KIND_MOUSE ||
- kind == UP_DEVICE_KIND_KEYBOARD) {
+ kind == UP_DEVICE_KIND_KEYBOARD ||
+ kind == UP_DEVICE_KIND_TOUCHPAD) {
if (percentage <= 5.0f)
return UP_DEVICE_LEVEL_CRITICAL;
else if (percentage <= 10.0f)