Skip to content

Commit 8d0795a

Browse files
committed
solaar: make hid-parser an optional dependency
1 parent 9ce0fd7 commit 8d0795a

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "python-hid-parser"]
2-
path = python-hid-parser
3-
url = https://github.com/usb-tools/python-hid-parser

docs/installation.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ layout: page
77

88
## Downloading
99

10-
Clone Solaar from GitHub by `git clone --recurse-submodules https://github.com/pwr-Solaar/Solaar.git`.
11-
Make sure that the submodule python-hid-parser was cloned, i.e., the directory `python-hid-parser` has content.
10+
Clone Solaar from GitHub by `git clone https://github.com/pwr-Solaar/Solaar.git`.
1211

1312
## Requirements for Solaar
1413

@@ -33,6 +32,11 @@ in Fedora you need `gtk3` and `python3-gobject`.
3332
You may have to install `gcc` and the Python development package (`python3-dev` or `python3-devel`,
3433
depending on your distribution).
3534

35+
If the `hid_parser` Python package is available, Solaar parses HID report descriptors
36+
and can control more HID++ devices that do not use a receiver.
37+
This package may not be available in some distributions but can be installed using pip
38+
via `pip install --user hid-parser`.
39+
3640
If you are running a version of Python different from the system version,
3741
you may need to use pip to install projects that provide the above Python packages.
3842

lib/hid_parser

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/hidapi/udev.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
from time import sleep
3737
from time import time as _timestamp
3838

39-
from hid_parser import ReportDescriptor as _ReportDescriptor
40-
from hid_parser import Usage as _Usage
4139
from pyudev import Context as _Context
4240
from pyudev import Device as _Device
4341
from pyudev import DeviceNotFoundError
@@ -103,8 +101,13 @@ def _match(action, device, filterfn):
103101
if not hid_id:
104102
return # there are reports that sometimes the id isn't set up right so be defensive
105103
bid, vid, pid = hid_id.split(':')
104+
hid_hid_device = hid_device.find_parent('hid')
105+
if hid_hid_device:
106+
return # these are devices connected through a receiver so don't pick them up here
106107

107108
try: # if report descriptor does not indicate HID++ capabilities then this device is not of interest to Solaar
109+
from hid_parser import ReportDescriptor as _ReportDescriptor
110+
from hid_parser import Usage as _Usage
108111
hidpp_short = hidpp_long = False
109112
devfile = '/sys' + hid_device.get('DEVPATH') + '/report_descriptor'
110113
with fileopen(devfile, 'rb') as fd:
@@ -122,9 +125,6 @@ def _match(action, device, filterfn):
122125
except Exception as e: # if can't process report descriptor fall back to old scheme
123126
hidpp_short = hidpp_long = None
124127
_log.warn('Report Descriptor not processed for BID %s VID %s PID %s: %s', bid, vid, pid, e)
125-
hid_hid_device = hid_device.find_parent('hid')
126-
if hid_hid_device:
127-
return # these are devices connected through a receiver so don't pick them up here
128128

129129
filter = filterfn(int(bid, 16), int(vid, 16), int(pid, 16), hidpp_short, hidpp_long)
130130
if not filter:

python-hid-parser

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ def _data_files():
6767
'python-xlib (>= 0.27)',
6868
'psutil (>= 5.4.3)',
6969
],
70+
extras_require={
71+
'report-descriptor': ['hid-parser'],
72+
'desktop-notifications': ['Notify (>= 0.7)'],
73+
},
7074
package_dir={'': 'lib'},
71-
packages=['keysyms', 'hidapi', 'hid_parser', 'logitech_receiver', 'solaar', 'solaar.ui', 'solaar.cli'],
75+
packages=['keysyms', 'hidapi', 'logitech_receiver', 'solaar', 'solaar.ui', 'solaar.cli'],
7276
data_files=list(_data_files()),
7377
scripts=_glob('bin/*'),
7478
)

0 commit comments

Comments
 (0)