Skip to content

Commit

Permalink
Merge branch 'master' into test_notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
MattHag authored Jan 1, 2025
2 parents 0d602ee + 800d349 commit 135f0f3
Show file tree
Hide file tree
Showing 41 changed files with 2,723 additions and 2,260 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# 1.1.14rc3
# 1.1.14

* Handle fake feature enums in show
* Fix battery entries in config.yaml
* Add ratchet setting for smart shift enhanced devices
* Refactor Gesture into enum
* Replace ERROR NamedInts by IntEnum (#2645)
* Refactor hidpp20 to use enum
* Update Swedish, Norwegian Nynorsk (nn), and Norwegian Bokmål (nb) translations
* Update Polish, Swedish, Norwegian Nynorsk (nn), and Norwegian Bokmål (nb) translations
* Use IntEnum for firmware and cidgroup constances
* Change pairing error values to intenums
* Fix initialization bug for PackedRangeControl
Expand Down
4 changes: 4 additions & 0 deletions Release_Notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Notes on Major Changes in Releases

## Version 1.1.15

* Solaar supports configuration of Bluetooth devices on macOS.

## Version 1.1.13

* Solaar will drop support for Python 3.7 immediately after version 1.1.13.
Expand Down
15 changes: 1 addition & 14 deletions bin/solaar
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,7 @@ def init_paths():
import os.path
import sys

# Python 3 might have problems converting back to UTF-8 in case of Unicode surrogates
decoded_path = None
try:
decoded_path = sys.path[0]
sys.path[0].encode(sys.getfilesystemencoding())

except UnicodeError:
sys.stderr.write(
"ERROR: Solaar cannot recognize encoding of filesystem path, "
"this may happen due to non UTF-8 characters in the pathname.\n"
)
sys.exit(1)

root = os.path.join(os.path.realpath(decoded_path), "..")
root = os.path.join(os.path.realpath(sys.path[0]), "..")
prefix = os.path.normpath(root)
src_lib = os.path.join(prefix, "lib")
share_lib = os.path.join(prefix, "share", "solaar", "lib")
Expand Down
34 changes: 16 additions & 18 deletions lib/hidapi/hidapi_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,8 @@ def _enumerate_devices():
p = p.contents.next
_hidapi.hid_free_enumeration(c_devices)

keyboard_or_mouse = {d["path"] for d in devices if d["usage_page"] == 1 and d["usage"] in (6, 2)}
unique_devices = {}
for device in devices:
# On macOS we cannot access keyboard or mouse devices without special permissions. Since
# we don't need them anyway we remove them so opening them doesn't cause errors later.
if device["path"] in keyboard_or_mouse:
# print(f"Ignoring keyboard or mouse device: {device}")
continue

# hidapi returns separate entries for each usage page of a device.
# Deduplicate by path to only keep one device entry.
if device["path"] not in unique_devices:
Expand Down Expand Up @@ -228,7 +221,7 @@ def run(self):

def _match(
action: str,
device,
device: dict[str, Any],
filter_func: Callable[[int, int, int, bool, bool], dict[str, Any]],
):
"""
Expand All @@ -255,15 +248,20 @@ def _match(
device_handle = None
try:
device_handle = open_path(device["path"])
report = _get_input_report(device_handle, 0x10, 32)
if len(report) == 1 + 6 and report[0] == 0x10:
device["hidpp_short"] = True
report = _get_input_report(device_handle, 0x11, 32)
if len(report) == 1 + 19 and report[0] == 0x11:
device["hidpp_long"] = True
except HIDError as e: # noqa: F841
if logger.isEnabledFor(logging.INFO):
logger.info(f"Error opening device {device['path']} ({bus_id}/{vid:04X}/{pid:04X}) for hidpp check: {e}") # noqa
try:
report = _get_input_report(device_handle, 0x10, 32)
if len(report) == 1 + 6 and report[0] == 0x10:
device["hidpp_short"] = True
except HIDError as e:
if logger.isEnabledFor(logging.INFO):
logger.info(f"Error opening device {device['path']} ({bus_id}/{vid:04X}/{pid:04X}) for hidpp check: {e}")
try:
report = _get_input_report(device_handle, 0x11, 32)
if len(report) == 1 + 19 and report[0] == 0x11:
device["hidpp_long"] = True
except HIDError as e:
if logger.isEnabledFor(logging.INFO):
logger.info(f"Error opening device {device['path']} ({bus_id}/{vid:04X}/{pid:04X}) for hidpp check: {e}")
finally:
if device_handle:
close(device_handle)
Expand Down Expand Up @@ -393,7 +391,7 @@ def open(vendor_id, product_id, serial=None):
return device_handle


def open_path(device_path) -> Any:
def open_path(device_path: str) -> int:
"""Open a HID device by its path name.
:param device_path: the path of a ``DeviceInfo`` tuple returned by enumerate().
Expand Down
Loading

0 comments on commit 135f0f3

Please sign in to comment.