More pep8 fixes. A tiny bit of refactoring.
This commit is contained in:
@ -2,9 +2,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
import time
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
from fenrirscreenreader.core.inputDriver import InputDriver as inputDriver
|
||||
|
||||
@ -15,38 +16,38 @@ class driver(inputDriver):
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self.env['runtime']['InputManager'].set_shortcut_type('KEY')
|
||||
self.env["runtime"]["InputManager"].set_shortcut_type("KEY")
|
||||
self._initialized = True
|
||||
print('Input Debug Driver: Initialized')
|
||||
print("Input Debug Driver: Initialized")
|
||||
|
||||
def shutdown(self):
|
||||
if self._initialized:
|
||||
self.remove_all_devices()
|
||||
self._initialized = False
|
||||
print('Input Debug Driver: Shutdown')
|
||||
print("Input Debug Driver: Shutdown")
|
||||
|
||||
def get_input_event(self):
|
||||
time.sleep(0.1)
|
||||
if not self._initialized:
|
||||
return None
|
||||
print('Input Debug Driver: get_input_event')
|
||||
print("Input Debug Driver: get_input_event")
|
||||
return None
|
||||
|
||||
def write_event_buffer(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
print('Input Debug Driver: write_event_buffer')
|
||||
print("Input Debug Driver: write_event_buffer")
|
||||
|
||||
def clear_event_buffer(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
del self.env['input']['eventBuffer'][:]
|
||||
print('Input Debug Driver: clear_event_buffer')
|
||||
del self.env["input"]["eventBuffer"][:]
|
||||
print("Input Debug Driver: clear_event_buffer")
|
||||
|
||||
def update_input_devices(self, new_devices=None, init=False):
|
||||
if not self._initialized:
|
||||
return
|
||||
print('Input Debug Driver: update_input_devices')
|
||||
print("Input Debug Driver: update_input_devices")
|
||||
|
||||
def get_led_state(self, led=0):
|
||||
if not self._initialized:
|
||||
@ -56,24 +57,24 @@ class driver(inputDriver):
|
||||
def toggle_led_state(self, led=0):
|
||||
if not self._initialized:
|
||||
return
|
||||
print('Input Debug Driver: toggle_led_state')
|
||||
print("Input Debug Driver: toggle_led_state")
|
||||
|
||||
def grab_all_devices(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
print('Input Debug Driver: grab_all_devices')
|
||||
print("Input Debug Driver: grab_all_devices")
|
||||
|
||||
def ungrab_all_devices(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
print('Input Debug Driver: ungrab_all_devices')
|
||||
print("Input Debug Driver: ungrab_all_devices")
|
||||
|
||||
def remove_all_devices(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
print('Input Debug Driver: remove_all_devices')
|
||||
print("Input Debug Driver: remove_all_devices")
|
||||
|
||||
def __del__(self):
|
||||
if self._initialized:
|
||||
self.remove_all_devices()
|
||||
print('Input Debug Driver: __del__')
|
||||
print("Input Debug Driver: __del__")
|
||||
|
@ -2,9 +2,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
import time
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
from fenrirscreenreader.core.inputDriver import InputDriver as inputDriver
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,19 +2,44 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
import time
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
from fenrirscreenreader.core.inputDriver import InputDriver as inputDriver
|
||||
|
||||
|
||||
class driver(inputDriver):
|
||||
"""PTY (Pseudo-terminal) input driver for Fenrir screen reader.
|
||||
|
||||
This driver provides input handling for terminal emulation environments
|
||||
where direct device access (evdev) is not available or appropriate.
|
||||
It uses byte-based input processing instead of key event processing.
|
||||
|
||||
This is primarily used when running Fenrir in terminal emulators,
|
||||
desktop environments, or other contexts where traditional TTY device
|
||||
access is not available.
|
||||
|
||||
Features:
|
||||
- Byte-based input processing
|
||||
- Terminal emulation compatibility
|
||||
- Simplified input handling for non-TTY environments
|
||||
"""
|
||||
def __init__(self):
|
||||
self._is_initialized = False
|
||||
inputDriver.__init__(self)
|
||||
|
||||
def initialize(self, environment):
|
||||
"""Initialize the PTY input driver.
|
||||
|
||||
Sets the input manager to use byte-based shortcuts instead of
|
||||
key-based shortcuts, enabling proper operation in terminal
|
||||
emulation environments.
|
||||
|
||||
Args:
|
||||
environment: Fenrir environment dictionary
|
||||
"""
|
||||
self.env = environment
|
||||
self.env['runtime']['InputManager'].set_shortcut_type('BYTE')
|
||||
self.env["runtime"]["InputManager"].set_shortcut_type("BYTE")
|
||||
self._is_initialized = True
|
||||
|
Reference in New Issue
Block a user