1
1
#brailleDisplayDrivers/brltty.py
2
2
#A part of NonVisual Desktop Access (NVDA)
3
#Copyright (C) 2006-2009 NVDA Contributors <http://www.nvda-project.org/>
4
3
#This file is covered by the GNU General Public License.
5
4
#See the file COPYING for more details.
5
#Copyright (C) 2008-2010 James Teh <jamie@jantrid.net>
10
10
from logHandler import log
14
BRLAPI_CMD_KEYS = dict((code, name[8:].lower())
15
for name, code in brlapi.__dict__.iteritems() if name.startswith("KEY_CMD_"))
13
16
except ImportError:
16
19
KEY_CHECK_INTERVAL = 50
18
class BrailleDisplayDriver(braille.BrailleDisplayDriverWithCursor):
21
class BrailleDisplayDriver(braille.BrailleDisplayDriver):
19
22
"""brltty braille display driver.
58
61
def _get_numCells(self):
59
62
return self._con.displaySize[0]
61
def _display(self, cells):
64
def display(self, cells):
62
65
cells = "".join(chr(cell) for cell in cells)
63
66
# HACK: Temporarily work around a bug which causes brltty to freeze if data is written while there are key presses waiting.
64
67
# Simply consume and act upon any waiting key presses.
81
84
keyType = key["type"]
82
85
command = key["command"]
83
86
argument = key["argument"]
85
if keyType == brlapi.KEY_TYPE_CMD:
86
if command == brlapi.KEY_CMD_FWINLT:
87
braille.handler.scrollBack()
88
elif command == brlapi.KEY_CMD_FWINRT:
89
braille.handler.scrollForward()
90
elif command == brlapi.KEY_CMD_ROUTE:
91
braille.handler.routeTo(argument)
93
log.error("Error executing key press action", exc_info=True)
87
if keyType == brlapi.KEY_TYPE_CMD:
89
inputCore.manager.executeGesture(InputGesture(command, argument))
90
except inputCore.NoInputGestureAction:
93
gestureMap = inputCore.GlobalGestureMap({
94
"globalCommands.GlobalCommands": {
95
"braille_scrollBack": ("br(brltty):fwinlt",),
96
"braille_scrollForward": ("br(brltty):fwinrt",),
97
"braille_previousLine": ("br(brltty):lnup",),
98
"braille_nextLine": ("br(brltty):lndn",),
99
"braille_routeTo": ("br(brltty):route",),
103
class InputGesture(braille.BrailleDisplayGesture):
105
source = BrailleDisplayDriver.name
107
def __init__(self, command, argument):
108
super(InputGesture, self).__init__()
109
self.id = BRLAPI_CMD_KEYS[command]
110
if command == brlapi.KEY_CMD_ROUTE:
111
self.routingIndex = argument