summaryrefslogtreecommitdiffstats
path: root/app/keybind_event_machine.py
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-05-30 21:31:05 -0700
committeryum <yum.food.vr@gmail.com>2025-05-30 21:31:05 -0700
commit73de7cb2d8fb964e7f76ab55420e9bc331bf7bea (patch)
treea99566ce36d6a82be627820d639a8af2b40c0672 /app/keybind_event_machine.py
parent7fb9c575aea4d318e9c14b82174d1b323171b62b (diff)
More stuff
- add desktop and vr input threads - add audio feedback for input - add volume control for audio feedback - add UI for custom chatbox/built in chatbox - add ability to dismiss built in chatbox (sync empty messages) - limit lines in python console - limit length of each transcript
Diffstat (limited to 'app/keybind_event_machine.py')
-rw-r--r--app/keybind_event_machine.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/keybind_event_machine.py b/app/keybind_event_machine.py
new file mode 100644
index 0000000..3ce6794
--- /dev/null
+++ b/app/keybind_event_machine.py
@@ -0,0 +1,21 @@
+import keyboard
+import time
+
+class KeybindEventMachine:
+ def __init__(self, keybind: str):
+ self.keybind = keybind
+ self.events = []
+ keyboard.add_hotkey(keybind, self.onPress)
+
+ def onPress(self) -> None:
+ self.events.append(time.time())
+
+ # Returns the timestamp when the keybind was pressed, or 0 if no keypresses
+ # are queued.
+ def getNextPressTime(self) -> int:
+ if len(self.events) == 0:
+ return 0
+ ret = self.events[0]
+ self.events = self.events[1:]
+ return ret
+