Lines Matching full:self
44 def __init__(self, path): argument
45 self.path = path
47 def __set_value(self, value): argument
48 with open(self.path, "w") as f:
51 def __get_value(self): argument
52 with open(self.path) as f:
56 def int_value(self) -> int: argument
57 return int(self.__get_value())
60 def int_value(self, v: int) -> None: argument
61 self.__set_value(v)
64 def str_value(self) -> str: argument
65 return self.__get_value()
68 def str_value(self, v: str) -> None: argument
69 self.__set_value(v)
73 def __init__(self, sys_path): argument
74 self.max_brightness = SysfsFile(sys_path / "max_brightness").int_value
75 self.__brightness = SysfsFile(sys_path / "brightness")
78 def brightness(self) -> int: argument
79 return self.__brightness.int_value
82 def brightness(self, value: int) -> None: argument
83 self.__brightness.int_value = value
89 def __init__(self, sys_path): argument
90 self._capacity = SysfsFile(sys_path / "capacity")
91 self._status = SysfsFile(sys_path / "status")
92 self._type = SysfsFile(sys_path / "type")
95 def capacity(self) -> int: argument
96 return self._capacity.int_value
99 def status(self) -> str: argument
100 return self._status.str_value
103 def type(self) -> str: argument
104 return self._type.str_value
115 def __init__(self: "HIDIsReady", uhid: UHIDDevice) -> None:
116 self.uhid = uhid
118 def is_ready(self: "HIDIsReady") -> bool:
131 def __init__(self: "UdevHIDIsReady", uhid: UHIDDevice) -> None:
133 self._init_pyudev()
167 def is_ready(self: "UdevHIDIsReady") -> Tuple[bool, int]:
169 return self._uhid_devices[self.uhid.hid_id]
176 self: "EvdevMatch",
183 self.requires = requires
184 self.excludes = excludes
185 self.req_properties = req_properties
186 self.excl_properties = excl_properties
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:
213 self.sysfs = sysfs
214 self.event_node: Any = None
215 self.libevdev: Optional[libevdev.Device] = None
217 self.uevents = {}
223 self.uevents[key] = value.strip('"')
226 self.open()
229 def name(self: "EvdevDevice") -> str:
230 assert "NAME" in self.uevents
232 return self.uevents["NAME"]
235 def evdev(self: "EvdevDevice") -> Path:
236 return Path("/dev/input") / self.sysfs.name
239 self: "EvdevDevice", application: str, matches: Dict[str, EvdevMatch]
241 if self.libevdev is None:
245 return matches[application].is_a_match(self.libevdev)
252 def open(self: "EvdevDevice") -> libevdev.Device:
253 self.event_node = open(self.evdev, "rb")
254 self.libevdev = libevdev.Device(self.event_node)
256 assert self.libevdev.fd is not None
258 fd = self.libevdev.fd.fileno()
262 return self.libevdev
264 def close(self: "EvdevDevice") -> None:
265 if self.libevdev is not None and self.libevdev.fd is not None:
266 self.libevdev.fd.close()
267 self.libevdev = None
268 if self.event_node is not None:
269 self.event_node.close()
270 self.event_node = None
279 self, argument
286 self._kernel_is_ready: HIDIsReady = UdevHIDIsReady(self)
291 name = f"uhid gamepad test {self.__class__.__name__}"
294 self.name = name
295 self.info = input_info
296 self.default_reportID = None
297 self.opened = False
298 self.started = False
299 self.application = application
300 self._input_nodes: Optional[list[EvdevDevice]] = None
303 self.rdesc = hid.ReportDescriptor.from_human_descr(rdesc_str) # type: ignore
305 self.rdesc = rdesc # type: ignore
308 def power_supply_class(self: "BaseDevice") -> Optional[PowerSupply]:
309 ps = self.walk_sysfs("power_supply", "power_supply/*")
316 def led_classes(self: "BaseDevice") -> List[LED]:
317 leds = self.walk_sysfs("led", "**/max_brightness")
324 def kernel_is_ready(self: "BaseDevice") -> bool:
325 return self._kernel_is_ready.is_ready()[0] and self.started
328 def kernel_ready_count(self: "BaseDevice") -> int:
329 return self._kernel_is_ready.is_ready()[1]
332 def input_nodes(self: "BaseDevice") -> List[EvdevDevice]:
333 if self._input_nodes is not None:
334 return self._input_nodes
336 if not self.kernel_is_ready or not self.started:
339 self._input_nodes = [
341 for path in self.walk_sysfs("input", "input/input*/event*")
343 return self._input_nodes
345 def match_evdev_rule(self, application, evdev): argument
351 `self.input_nodes[type]`
357 def open(self): argument
358 self.opened = True
360 def _close_all_opened_evdev(self): argument
361 if self._input_nodes is not None:
362 for e in self._input_nodes:
365 def __del__(self): argument
366 self._close_all_opened_evdev()
368 def close(self): argument
369 self.opened = False
371 def start(self, flags): argument
372 self.started = True
374 def stop(self): argument
375 self.started = False
376 self._close_all_opened_evdev()
378 def next_sync_events(self, application=None): argument
379 evdev = self.get_evdev(application)
385 def application_matches(self: "BaseDevice") -> Dict[str, EvdevMatch]:
386 return self._application_matches
389 def application_matches(self: "BaseDevice", data: Dict[str, EvdevMatch]) -> None:
390 self._application_matches = data
392 def get_evdev(self, application=None): argument
394 application = self.application
396 if len(self.input_nodes) == 0:
399 assert self._input_nodes is not None
401 if len(self._input_nodes) == 1:
402 evdev = self._input_nodes[0]
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):
411 def is_ready(self): argument
419 (len(self.uhdev.leds_classes) == 4)
421 return self.kernel_is_ready