try out TTY detection

This commit is contained in:
chrys 2016-07-06 01:13:28 +02:00
parent 5b3e5eecf6
commit c2d01cd780
3 changed files with 29 additions and 12 deletions

11
TODO
View File

@ -11,11 +11,6 @@ http://serverfault.com/questions/306854/how-to-find-out-the-currently-active-lin
http://mielke.cc/brltty/doc/Manual-BrlAPI/English/BrlAPI.html http://mielke.cc/brltty/doc/Manual-BrlAPI/English/BrlAPI.html
https://git.gnome.org/browse/orca/tree/src/orca/braille.py https://git.gnome.org/browse/orca/tree/src/orca/braille.py
- implement speechdriver speechd
https://git.gnome.org/browse/orca/tree/src/orca/speech.py
https://git.gnome.org/browse/orca/tree/src/orca/speechdispatcherfactory.py
http://devel.freebsoft.org/doc/speechd/speech-dispatcher.html#Client-Programming
- implement speechdriver generic (say) - implement speechdriver generic (say)
- threading ReadContent, ReadShortcuts, executeCommands, listenNewTTYsForListen, controllThread (main) - threading ReadContent, ReadShortcuts, executeCommands, listenNewTTYsForListen, controllThread (main)
- debugging - debugging
@ -45,3 +40,9 @@ it seems we have this info in vcsa
- get current cursor - get current cursor
- implement speechdriver speechd
https://git.gnome.org/browse/orca/tree/src/orca/speech.py
https://git.gnome.org/browse/orca/tree/src/orca/speechdispatcherfactory.py
http://devel.freebsoft.org/doc/speechd/speech-dispatcher.html#Client-Programming

View File

@ -13,7 +13,7 @@ runtime = {
'running':True, 'running':True,
'columns': 0, 'columns': 0,
'lines': 0, 'lines': 0,
'screenDriver': '/dev/vcsa3', 'screenDriver': '/dev/vcsa',
'delta': '', 'delta': '',
'oldCursor':{'x':0,'y':0}, 'oldCursor':{'x':0,'y':0},
'oldContentBytes': b'', 'oldContentBytes': b'',
@ -23,15 +23,25 @@ runtime = {
'newContentBytes': b'', 'newContentBytes': b'',
'newContentText': '', 'newContentText': '',
'newContentAttrib': b'', 'newContentAttrib': b'',
'oldTTY':'0',
'newTTY':'0',
'speechDriverString':'sd', 'speechDriverString':'sd',
'speechDriver': sd.speech() 'speechDriver': sd.speech()
} }
while(runtime['running']): while(runtime['running']):
# read screen # read screen
vcsa = open(runtime['screenDriver'],'rb') currTTY = open('/sys/devices/virtual/tty/tty0/active','r')
runtime['newContentBytes'] = vcsa.read() runtime['newTTY'] = currTTY.read()[3:-1]
vcsa.close() currTTY.close()
runtime['newTTY'] = '3'
try:
vcsa = open(runtime['screenDriver'] + runtime['newTTY'] ,'rb')
runtime['newContentBytes'] = vcsa.read()
vcsa.close()
except:
print(runtime['screenDriver'] + runtime['newTTY'])
continue
# get metadata like cursor or screensize # get metadata like cursor or screensize
runtime['lines'] = int( runtime['newContentBytes'][0]) runtime['lines'] = int( runtime['newContentBytes'][0])
@ -43,7 +53,13 @@ while(runtime['running']):
runtime['newContentText'] = str(runtime['newContentBytes'][4:][::2].decode('cp1252').encode('utf-8')) runtime['newContentText'] = str(runtime['newContentBytes'][4:][::2].decode('cp1252').encode('utf-8'))
runtime['newContentAttrib'] = runtime['newContentBytes'][5:][::2] runtime['newContentAttrib'] = runtime['newContentBytes'][5:][::2]
runtime['newContentText'] = '\n'.join(textwrap.wrap(runtime['newContentText'], runtime['columns'])) runtime['newContentText'] = '\n'.join(textwrap.wrap(runtime['newContentText'], runtime['columns']))
if runtime['newTTY'] != runtime['oldTTY']:
runtime['oldContentBytes'] = b''
runtime['oldContentAttrib'] = b''
runtime['oldContentText'] = ''
runtime['oldCursor']['x'] = 0
runtime['oldCursor']['y'] = 0
# changes on the screen # changes on the screen
if runtime['oldContentBytes'] != runtime['newContentBytes']: if runtime['oldContentBytes'] != runtime['newContentBytes']:
if len(runtime['delta']) < 3: if len(runtime['delta']) < 3:
@ -62,4 +78,4 @@ while(runtime['running']):
runtime['oldContentTextAttrib'] = runtime['newContentAttrib'] runtime['oldContentTextAttrib'] = runtime['newContentAttrib']
runtime['oldCursor']['x'] = runtime['newCursor']['x'] runtime['oldCursor']['x'] = runtime['newCursor']['x']
runtime['oldCursor']['y'] = runtime['newCursor']['y'] runtime['oldCursor']['y'] = runtime['newCursor']['y']
runtime['oldTTY'] = runtime['newTTY']

View File

@ -63,7 +63,7 @@ class speech():
if not self.isInitialized: if not self.isInitialized:
return False return False
try: try:
self.sd..set_output_module(module) self.sd.set_output_module(module)
return True return True
except: except:
return False return False