forked from drath/libratbag
implement 'DeviceType' property
Signed-off-by: Julian Kandlhofer <julian.kandlhofer@gmail.com>
This commit is contained in:
committed by
Yaroslav Chvanov
parent
931ec44ff2
commit
4f36371af3
@@ -83,6 +83,22 @@ class RatbagErrorCode(metaclass=MetaRatbag):
|
||||
IMPLEMENTATION = libratbag.RATBAG_ERROR_IMPLEMENTATION
|
||||
|
||||
|
||||
class RatbagDeviceType(IntEnum):
|
||||
"""DeviceType property specified in the .device files"""
|
||||
|
||||
"""There was no DeviceType specified for this device"""
|
||||
UNSPECIFIED = 0
|
||||
|
||||
"""Device is specified as anything other than a mouse or a keyboard"""
|
||||
OTHER = 1
|
||||
|
||||
"""Device is specified as a mouse"""
|
||||
MOUSE = 2
|
||||
|
||||
"""Device is specified as a keyboard"""
|
||||
KEYBOARD = 3
|
||||
|
||||
|
||||
class RatbagdUnavailable(Exception):
|
||||
"""Signals DBus is unavailable or the ratbagd daemon is not available."""
|
||||
pass
|
||||
@@ -262,6 +278,11 @@ class RatbagdDevice(metaclass=MetaRatbag):
|
||||
"""The device name, usually provided by the kernel."""
|
||||
return libratbag.ratbag_device_get_name(self._device)
|
||||
|
||||
@property
|
||||
def device_type(self):
|
||||
"""The device type, see RatbagDeviceType"""
|
||||
return RatbagDeviceType(libratbag.ratbag_device_get_device_type(self._device))
|
||||
|
||||
@property
|
||||
def firmware_version(self):
|
||||
"""The firmware version of the device."""
|
||||
|
||||
@@ -26,7 +26,7 @@ import sys
|
||||
import argparse
|
||||
import re
|
||||
|
||||
from ratbagd import Ratbagd, RatbagdDevice, RatbagdProfile, RatbagdMacro, RatbagdResolution, RatbagdButton, RatbagdLed, RatbagdUnavailable, RatbagError, RatbagErrorCode, RatbagErrorCapability # NOQA
|
||||
from ratbagd import Ratbagd, RatbagdDevice, RatbagdProfile, RatbagdMacro, RatbagdResolution, RatbagdButton, RatbagdLed, RatbagdUnavailable, RatbagError, RatbagErrorCode, RatbagErrorCapability, RatbagDeviceType # NOQA
|
||||
|
||||
|
||||
def humanize(string):
|
||||
@@ -229,6 +229,7 @@ def print_device(d, level):
|
||||
|
||||
print(" " * level + "{} - {}".format(d.id, d.name))
|
||||
print(" " * level + " Model: {}".format(d.model))
|
||||
print(" " * level + " Device Type: {}".format(d.device_type.name))
|
||||
if d.firmware_version:
|
||||
print(" " * level + " Firmware version: {}".format(d.firmware_version))
|
||||
print(" " * level + " Number of Buttons: {}".format(len(p.buttons)))
|
||||
|
||||
@@ -60,6 +60,22 @@ class RatbagErrorCode(IntEnum):
|
||||
IMPLEMENTATION = -1004
|
||||
|
||||
|
||||
class RatbagDeviceType(IntEnum):
|
||||
"""DeviceType property specified in the .device files"""
|
||||
|
||||
"""There was no DeviceType specified for this device"""
|
||||
UNSPECIFIED = 0
|
||||
|
||||
"""Device is specified as anything other than a mouse or a keyboard"""
|
||||
OTHER = 1
|
||||
|
||||
"""Device is specified as a mouse"""
|
||||
MOUSE = 2
|
||||
|
||||
"""Device is specified as a keyboard"""
|
||||
KEYBOARD = 3
|
||||
|
||||
|
||||
class RatbagdIncompatible(Exception):
|
||||
"""ratbagd is incompatible with this client"""
|
||||
def __init__(self, ratbagd_version, required_version):
|
||||
@@ -347,6 +363,11 @@ class RatbagdDevice(_RatbagdDBus):
|
||||
"""The device name, usually provided by the kernel."""
|
||||
return self._get_dbus_property("Name")
|
||||
|
||||
@GObject.Property
|
||||
def device_type(self):
|
||||
"""The device type, see RatbagDeviceType"""
|
||||
return RatbagDeviceType(self._get_dbus_property("DeviceType"))
|
||||
|
||||
@GObject.Property
|
||||
def firmware_version(self):
|
||||
"""The firmware version of the device."""
|
||||
|
||||
Reference in New Issue
Block a user