Improvements to braill driver.
This commit is contained in:
parent
b54a226833
commit
bc72765544
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
@ -9,9 +9,9 @@ from fenrirscreenreader.core import debug
|
||||
class brailleDriver():
|
||||
def __init__(self):
|
||||
self._isInitialized = False
|
||||
self.deviceSize = None
|
||||
self._brl = None
|
||||
|
||||
self.deviceSize = None
|
||||
|
||||
def initialize(self, environment):
|
||||
"""Initialize the BRLTTY connection."""
|
||||
self.env = environment
|
||||
@ -36,22 +36,19 @@ class brailleDriver():
|
||||
if not self._isInitialized:
|
||||
return
|
||||
try:
|
||||
# Ensure text doesn't exceed display width
|
||||
if self.deviceSize:
|
||||
text = text[:self.deviceSize[0]]
|
||||
self._brl.writeText(text)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('ERROR: Writing braille failed:' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def connectDevice(self):
|
||||
"""Attempt to connect to the braille device."""
|
||||
def readKeypress(self):
|
||||
"""Read a keypress from the braille display."""
|
||||
if not self._isInitialized:
|
||||
return None
|
||||
try:
|
||||
if self._brl:
|
||||
self._brl.enterTtyMode()
|
||||
return True
|
||||
return self._brl.readKey(wait=0)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('ERROR: Connecting braille failed:' + str(e),debug.debugLevel.ERROR)
|
||||
return False
|
||||
self.env['runtime']['debug'].writeDebugOut('ERROR: Reading key failed:' + str(e),debug.debugLevel.ERROR)
|
||||
return None
|
||||
|
||||
def enterScreen(self, screen):
|
||||
"""Enter a new screen context."""
|
||||
|
Loading…
Reference in New Issue
Block a user