Lines Matching +full:in +full:- +full:application

2 # SPDX-License-Identifier: GPL-2.0
3 # -*- coding: utf-8 -*-
13 # This program is distributed in the hope that it will be useful,
56 def int_value(self) -> int:
60 def int_value(self, v: int) -> None:
64 def str_value(self) -> str:
68 def str_value(self, v: str) -> None:
78 def brightness(self) -> int:
82 def brightness(self, value: int) -> None:
95 def capacity(self) -> int:
99 def status(self) -> str:
103 def type(self) -> str:
115 def __init__(self: "HIDIsReady", uhid: UHIDDevice) -> None:
118 def is_ready(self: "HIDIsReady") -> bool:
120 Overwrite in subclasses: should return True or False whether
131 def __init__(self: "UdevHIDIsReady", uhid: UHIDDevice) -> None:
136 def _init_pyudev(cls: Type["UdevHIDIsReady"]) -> None:
148 def _cls_udev_event_callback(cls: Type["UdevHIDIsReady"]) -> None:
152 for event in iter(functools.partial(cls._pyudev_monitor.poll, 0.02), None):
153 if event.action not in ["bind", "remove", "unbind"]:
156 logger.debug(f"udev event: {event.action} -> {event}")
158 id = int(event.sys_path.strip().split(".")[-1], 16)
167 def is_ready(self: "UdevHIDIsReady") -> Tuple[bool, int]:
182 ) -> None:
188 def is_a_match(self: "EvdevMatch", evdev: libevdev.Device) -> bool:
189 for m in self.requires:
192 for m in self.excludes:
195 for p in self.req_properties:
198 for p in self.excl_properties:
212 def __init__(self: "EvdevDevice", sysfs: Path) -> None:
218 # all of the interesting properties are stored in the input uevent, so in the parent
221 for line in f.readlines():
225 # we open all evdev nodes in order to not miss any event
229 def name(self: "EvdevDevice") -> str:
230 assert "NAME" in self.uevents
235 def evdev(self: "EvdevDevice") -> Path:
239 self: "EvdevDevice", application: str, matches: Dict[str, EvdevMatch]
240 ) -> bool:
244 if application in matches:
245 return matches[application].is_a_match(self.libevdev)
248 f"application '{application}' is unknown, please update/fix hid-tools"
250 assert False # hid-tools likely needs an update
252 def open(self: "EvdevDevice") -> libevdev.Device:
264 def close(self: "EvdevDevice") -> None:
275 # to be set in the subclasses to have get_evdev() working
281 application, argument
285 ) -> None:
299 self.application = application
308 def power_supply_class(self: "BaseDevice") -> Optional[PowerSupply]:
316 def led_classes(self: "BaseDevice") -> List[LED]:
321 return [LED(led.parent) for led in leds]
324 def kernel_is_ready(self: "BaseDevice") -> bool:
328 def kernel_ready_count(self: "BaseDevice") -> int:
332 def input_nodes(self: "BaseDevice") -> List[EvdevDevice]:
341 for path in self.walk_sysfs("input", "input/input*/event*")
345 def match_evdev_rule(self, application, evdev): argument
346 """Replace this in subclasses if the device has multiple reports
362 for e in self._input_nodes:
378 def next_sync_events(self, application=None): argument
379 evdev = self.get_evdev(application)
385 def application_matches(self: "BaseDevice") -> Dict[str, EvdevMatch]:
389 def application_matches(self: "BaseDevice", data: Dict[str, EvdevMatch]) -> None:
392 def get_evdev(self, application=None): argument
393 if application is None:
394 application = self.application
403 if self.match_evdev_rule(application, evdev.libevdev):
406 for _evdev in self._input_nodes:
407 if _evdev.matches_application(application, self.application_matches):
408 if self.match_evdev_rule(application, _evdev.libevdev):
412 """Returns whether a UHID device is ready. Can be overwritten in
416 - we need to wait on different types of input devices to be ready
418 - we need to have at least 4 LEDs present
420 - or any other combinations"""