1
2
3
4
5
6
7 from ctypes import *
8 from ctypes.wintypes import *
9 import itertools
10 import hwPortUtils
11 import braille
12 import inputCore
13 from baseObject import ScriptableObject
14 from winUser import WNDCLASSEXW, WNDPROC, LRESULT, HCURSOR
15
16
17 try:
18 fsbLib=windll.fsbrldspapi
19 except:
20 fsbLib=None
21
22
23 if fsbLib:
24 fbOpen=getattr(fsbLib,'_fbOpen@12')
25 fbGetCellCount=getattr(fsbLib,'_fbGetCellCount@4')
26 fbWrite=getattr(fsbLib,'_fbWrite@16')
27 fbClose=getattr(fsbLib,'_fbClose@4')
28
29 FB_INPUT=1
30 FB_DISCONNECT=2
31
32 LRESULT=c_long
33 HCURSOR=c_long
34
35 appInstance=windll.kernel32.GetModuleHandleW(None)
36
37 nvdaFsBrlWm=windll.user32.RegisterWindowMessageW(u"nvdaFsBrlWm")
38
39 inputType_keys=3
40 inputType_routing=4
41 inputType_wizWheel=5
80
81 nvdaFsBrlWndCls=WNDCLASSEXW()
82 nvdaFsBrlWndCls.cbSize=sizeof(nvdaFsBrlWndCls)
83 nvdaFsBrlWndCls.lpfnWndProc=nvdaFsBrlWndProc
84 nvdaFsBrlWndCls.hInstance=appInstance
85 nvdaFsBrlWndCls.lpszClassName=u"nvdaFsBrlWndCls"
88
89 name="freedomScientific"
90 description=_("Freedom Scientific Focus/PAC Mate series")
91
92 @classmethod
95
96 wizWheelActions=[
97 (_("display scroll"),("globalCommands","GlobalCommands","braille_scrollBack"),("globalCommands","GlobalCommands","braille_scrollForward")),
98 (_("line scroll"),("globalCommands","GlobalCommands","braille_previousLine"),("globalCommands","GlobalCommands","braille_nextLine")),
99 ]
100
102 self.gestureMap=inputCore.GlobalGestureMap()
103 self.gestureMap.add("br(freedomScientific):routing","globalCommands","GlobalCommands","braille_routeTo")
104 self.leftWizWheelActionCycle=itertools.cycle(self.wizWheelActions)
105 action=self.leftWizWheelActionCycle.next()
106 self.gestureMap.add("br(freedomScientific):leftWizWheelUp",*action[1])
107 self.gestureMap.add("br(freedomScientific):leftWizWheelDown",*action[2])
108 self.rightWizWheelActionCycle=itertools.cycle(self.wizWheelActions)
109 action=self.rightWizWheelActionCycle.next()
110 self.gestureMap.add("br(freedomScientific):rightWizWheelUp",*action[1])
111 self.gestureMap.add("br(freedomScientific):rightWizWheelDown",*action[2])
112 super(BrailleDisplayDriver,self).__init__()
113 self._messageWindowClassAtom=windll.user32.RegisterClassExW(byref(nvdaFsBrlWndCls))
114 self._messageWindow=windll.user32.CreateWindowExW(0,self._messageWindowClassAtom,u"nvdaFsBrlWndCls window",0,0,0,0,0,None,None,appInstance,None)
115 fbHandle=-1
116 for port in itertools.chain(("USB",),
117 (portInfo["port"].encode("mbcs") for portInfo in hwPortUtils.listComPorts(onlyAvailable=True)
118 if portInfo.get("bluetoothName") == "Focus 40 BT")
119 ):
120 fbHandle=fbOpen(port,self._messageWindow,nvdaFsBrlWm)
121 if fbHandle!=-1:
122 break
123 if fbHandle==-1:
124 raise RuntimeError("No display found")
125 self.fbHandle=fbHandle
126
132
135
137 cells="".join([chr(x) for x in cells])
138 fbWrite(self.fbHandle,0,len(cells),cells)
139
141 action=self.leftWizWheelActionCycle.next()
142 self.gestureMap.add("br(freedomScientific):leftWizWheelUp",*action[1],replace=True)
143 self.gestureMap.add("br(freedomScientific):leftWizWheelDown",*action[2],replace=True)
144 braille.handler.message(action[0])
145
147 action=self.rightWizWheelActionCycle.next()
148 self.gestureMap.add("br(freedomScientific):rightWizWheelUp",*action[1],replace=True)
149 self.gestureMap.add("br(freedomScientific):rightWizWheelDown",*action[2],replace=True)
150 braille.handler.message(action[0])
151
152 __gestures={
153 "br(freedomScientific):leftWizWheelPress":"toggleLeftWizWheelAction",
154 "br(freedomScientific):rightWizWheelPress":"toggleRightWizWheelAction",
155 }
156
159
161
162 keyLabels=[
163
164 'dot1','dot2','dot3','dot4','dot5','dot6','dot7','dot8',
165
166 'leftWizWheelPress','rightWizWheelPress',
167 'leftShiftKey','rightShiftKey',
168 'leftAdvanceBar','rightAdvanceBar',
169 None,
170 'brailleSpaceBar',
171
172 'leftGDFButton','rightGDFButton',
173 None,
174 'leftBumperBarUp','leftBumperBarDown','rightBumperBarUp','rightBumperBarDown',
175 ]
176
180
182
183 - def __init__(self,routingIndex,topRow=False):
190
192
194 which="right" if isRight else "left"
195 direction="Down" if isDown else "Up"
196 self.id="%sWizWheel%s"%(which,direction)
197 super(WizWheelGesture,self).__init__()
198