difonlib 0.3.2__tar.gz → 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: difonlib
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: python libraries
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "difonlib"
3
- version = "0.3.2"
3
+ version = "0.3.3"
4
4
  description = "python libraries"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -142,7 +142,7 @@ def idev_get_by_field(field: str, field_value: str) -> Optional[List[IDevKbd]]:
142
142
  return kdevs
143
143
 
144
144
 
145
- def idev_key_monitor(dev_event: str) -> Optional[IDevKbdKey]:
145
+ def idev_key_monitor(dev_path: str) -> Optional[IDevKbdKey]:
146
146
  """
147
147
  Wait for any pressed key on dev_event
148
148
  Return: ( key_event.scancode, hold_time, key_event.keycode )"""
@@ -150,9 +150,9 @@ def idev_key_monitor(dev_event: str) -> Optional[IDevKbdKey]:
150
150
  press_time: float | None = None # timer key down timestamp
151
151
  key: IDevKbdKey | None = None
152
152
 
153
- dev = InputDevice(f"/dev/input/{dev_event}")
153
+ dev = InputDevice(dev_path)
154
154
  dbg(f"Listening on: {dev.name}")
155
-
155
+ dev.grab() # capture input device
156
156
  for event in dev.read_loop():
157
157
  # if event.type == ecodes.EV_KEY:
158
158
  key_event = categorize(event)
@@ -173,17 +173,19 @@ def idev_key_monitor(dev_event: str) -> Optional[IDevKbdKey]:
173
173
  else key_event.keycode[0]
174
174
  )
175
175
  break
176
+ dev.ungrab()
176
177
  dev.close()
177
178
  return key
178
179
 
179
180
 
180
- async def idev_get_pressed_key(dev_event: str, timeout: int = 5) -> Optional[IDevKbdKey]:
181
+ async def idev_get_pressed_key(dev_path: str, timeout: int = 5) -> Optional[IDevKbdKey]:
181
182
  """
182
183
  Wait timeout seconds for pressed key on dev_event
183
184
  """
184
- dev = InputDevice(f"/dev/input/{dev_event}")
185
+ dev = InputDevice(dev_path)
185
186
  dbg(f" - Listening on: {dev.name}")
186
187
  # key = await _get_first_key_event(dev)
188
+ dev.grab()
187
189
  try:
188
190
  # asyncio.wait_for ограничивает выполнение асинхронной задачи по времени
189
191
  key = await asyncio.wait_for(
@@ -201,6 +203,7 @@ async def idev_get_pressed_key(dev_event: str, timeout: int = 5) -> Optional[IDe
201
203
  print(f" =!= Error: {e}")
202
204
 
203
205
  finally:
206
+ dev.ungrab()
204
207
  dev.close()
205
208
  return None
206
209
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: difonlib
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: python libraries
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
File without changes
File without changes
File without changes
File without changes
File without changes