solaar: make hid-parser an optional dependency

This commit is contained in:
Peter F. Patel-Schneider 2022-10-25 09:59:50 -04:00
parent 9ce0fd7060
commit 8d0795af53
6 changed files with 16 additions and 13 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "python-hid-parser"]
path = python-hid-parser
url = https://github.com/usb-tools/python-hid-parser

View File

@ -7,8 +7,7 @@ layout: page
## Downloading
Clone Solaar from GitHub by `git clone --recurse-submodules https://github.com/pwr-Solaar/Solaar.git`.
Make sure that the submodule python-hid-parser was cloned, i.e., the directory `python-hid-parser` has content.
Clone Solaar from GitHub by `git clone https://github.com/pwr-Solaar/Solaar.git`.
## Requirements for Solaar
@ -33,6 +32,11 @@ in Fedora you need `gtk3` and `python3-gobject`.
You may have to install `gcc` and the Python development package (`python3-dev` or `python3-devel`,
depending on your distribution).
If the `hid_parser` Python package is available, Solaar parses HID report descriptors
and can control more HID++ devices that do not use a receiver.
This package may not be available in some distributions but can be installed using pip
via `pip install --user hid-parser`.
If you are running a version of Python different from the system version,
you may need to use pip to install projects that provide the above Python packages.

View File

@ -1 +0,0 @@
../python-hid-parser/hid_parser

View File

@ -36,8 +36,6 @@ from select import select as _select
from time import sleep
from time import time as _timestamp
from hid_parser import ReportDescriptor as _ReportDescriptor
from hid_parser import Usage as _Usage
from pyudev import Context as _Context
from pyudev import Device as _Device
from pyudev import DeviceNotFoundError
@ -103,8 +101,13 @@ def _match(action, device, filterfn):
if not hid_id:
return # there are reports that sometimes the id isn't set up right so be defensive
bid, vid, pid = hid_id.split(':')
hid_hid_device = hid_device.find_parent('hid')
if hid_hid_device:
return # these are devices connected through a receiver so don't pick them up here
try: # if report descriptor does not indicate HID++ capabilities then this device is not of interest to Solaar
from hid_parser import ReportDescriptor as _ReportDescriptor
from hid_parser import Usage as _Usage
hidpp_short = hidpp_long = False
devfile = '/sys' + hid_device.get('DEVPATH') + '/report_descriptor'
with fileopen(devfile, 'rb') as fd:
@ -122,9 +125,6 @@ def _match(action, device, filterfn):
except Exception as e: # if can't process report descriptor fall back to old scheme
hidpp_short = hidpp_long = None
_log.warn('Report Descriptor not processed for BID %s VID %s PID %s: %s', bid, vid, pid, e)
hid_hid_device = hid_device.find_parent('hid')
if hid_hid_device:
return # these are devices connected through a receiver so don't pick them up here
filter = filterfn(int(bid, 16), int(vid, 16), int(pid, 16), hidpp_short, hidpp_long)
if not filter:

@ -1 +0,0 @@
Subproject commit 4b7944f4999e152c678cd7fa76278b7e2535c3ff

View File

@ -67,8 +67,12 @@ For instructions on installing Solaar see https://pwr-solaar.github.io/Solaar/in
'python-xlib (>= 0.27)',
'psutil (>= 5.4.3)',
],
extras_require={
'report-descriptor': ['hid-parser'],
'desktop-notifications': ['Notify (>= 0.7)'],
},
package_dir={'': 'lib'},
packages=['keysyms', 'hidapi', 'hid_parser', 'logitech_receiver', 'solaar', 'solaar.ui', 'solaar.cli'],
packages=['keysyms', 'hidapi', 'logitech_receiver', 'solaar', 'solaar.ui', 'solaar.cli'],
data_files=list(_data_files()),
scripts=_glob('bin/*'),
)