mirror of
https://github.com/lowobservable/oec.git
synced 2026-02-28 09:18:45 +00:00
Implement keyboard clicker toggle
This commit is contained in:
@@ -9,6 +9,7 @@ from coax import poll, poll_ack, PollAction, KeystrokePollResponse, ReceiveTimeo
|
||||
ReceiveError, ProtocolError
|
||||
|
||||
from .terminal import Terminal, read_terminal_ids
|
||||
from .keyboard import Key
|
||||
from .session import SessionDisconnectedError
|
||||
|
||||
class Controller:
|
||||
@@ -155,7 +156,9 @@ class Controller:
|
||||
if not key:
|
||||
return
|
||||
|
||||
if self.session:
|
||||
if key == Key.CLICKER:
|
||||
self.terminal.keyboard.clicker = not self.terminal.keyboard.clicker
|
||||
elif self.session:
|
||||
self.session.handle_key(key, modifiers, scan_code)
|
||||
|
||||
def _poll(self):
|
||||
|
||||
@@ -114,7 +114,7 @@ class Key(Enum):
|
||||
CURSOR_SELECT = 402
|
||||
CURSOR_BLINK = 403
|
||||
ERASE_EOF = 404
|
||||
VOLUME = 405
|
||||
CLICKER = 405
|
||||
ALT_CURSOR = 406
|
||||
IDENT = 407
|
||||
|
||||
@@ -303,6 +303,8 @@ class Keyboard:
|
||||
|
||||
self.modifier_release = False
|
||||
|
||||
self.clicker = False
|
||||
|
||||
def get_key(self, scan_code):
|
||||
"""Map a scan code to key and update modifiers state."""
|
||||
key = self.keymap.default.get(scan_code)
|
||||
|
||||
@@ -14,7 +14,7 @@ KEYMAP_DEFAULT = {
|
||||
84: Key.CURSOR_BLINK,
|
||||
85: Key.ERASE_EOF,
|
||||
86: Key.PRINT,
|
||||
87: Key.VOLUME,
|
||||
87: Key.CLICKER,
|
||||
|
||||
# First Row
|
||||
61: Key.BACKTICK,
|
||||
|
||||
@@ -70,6 +70,7 @@ class Terminal:
|
||||
self.keyboard = Keyboard(keymap)
|
||||
|
||||
self.alarm = False
|
||||
self.last_poll_keyboard_clicker = None
|
||||
|
||||
def sound_alarm(self):
|
||||
self.alarm = True
|
||||
@@ -80,4 +81,9 @@ class Terminal:
|
||||
|
||||
return PollAction.ALARM
|
||||
|
||||
if self.keyboard.clicker != self.last_poll_keyboard_clicker:
|
||||
self.last_poll_keyboard_clicker = self.keyboard.clicker
|
||||
|
||||
return PollAction.ENABLE_KEYBOARD_CLICKER if self.keyboard.clicker else PollAction.DISABLE_KEYBOARD_CLICKER
|
||||
|
||||
return PollAction.NONE
|
||||
|
||||
Reference in New Issue
Block a user