2018-03-21 06:10:28 -04:00
|
|
|
#!/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# Fenrir TTY screen reader
|
|
|
|
# By Chrys, Storm Dragon, and contributers.
|
|
|
|
|
|
|
|
from fenrirscreenreader.core import debug
|
|
|
|
|
|
|
|
class inputDriver():
|
|
|
|
def __init__(self):
|
|
|
|
self._initialized = False
|
|
|
|
def initialize(self, environment):
|
|
|
|
self.env = environment
|
2018-03-26 03:10:05 -04:00
|
|
|
self.env['runtime']['inputManager'].setShortcutType('KEY')
|
2018-03-21 06:10:28 -04:00
|
|
|
self._isInitialized = True
|
|
|
|
def shutdown(self):
|
|
|
|
if self._initialized:
|
2018-05-24 05:22:58 -04:00
|
|
|
self.removeAllDevices()
|
2018-03-21 06:10:28 -04:00
|
|
|
self._isInitialized = False
|
|
|
|
def getInputEvent(self):
|
2018-05-24 05:22:58 -04:00
|
|
|
time.sleep(0.1)
|
2018-03-21 06:10:28 -04:00
|
|
|
return None
|
|
|
|
def clearEventBuffer(self):
|
|
|
|
if not self._initialized:
|
|
|
|
return
|
2018-05-26 17:23:58 -04:00
|
|
|
del self.env['input']['eventBuffer'][:]
|
2018-05-24 21:03:07 -04:00
|
|
|
def updateInputDevices(self, newDevices = None, init = False):
|
2018-03-21 06:10:28 -04:00
|
|
|
if not self._initialized:
|
|
|
|
return
|
|
|
|
def getLedState(self, led = 0):
|
|
|
|
if not self._initialized:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
def toggleLedState(self, led = 0):
|
|
|
|
if not self._initialized:
|
2018-05-14 08:58:17 -04:00
|
|
|
return
|
2018-05-14 08:57:38 -04:00
|
|
|
def grabAllDevices(self):
|
2018-03-21 06:10:28 -04:00
|
|
|
if not self._initialized:
|
2018-05-14 08:58:17 -04:00
|
|
|
return
|
2018-05-14 08:57:38 -04:00
|
|
|
def ungrabAllDevices(self):
|
2018-03-21 06:10:28 -04:00
|
|
|
if not self._initialized:
|
2018-05-14 08:58:17 -04:00
|
|
|
return
|
2018-05-24 05:22:58 -04:00
|
|
|
def hasIDevices(self):
|
|
|
|
if not self._initialized:
|
|
|
|
return False
|
2018-05-26 17:23:58 -04:00
|
|
|
return True
|
2018-05-14 08:57:38 -04:00
|
|
|
def removeAllDevices(self):
|
|
|
|
if not self._initialized:
|
2018-05-14 08:58:17 -04:00
|
|
|
return
|
2019-01-29 17:07:20 -05:00
|
|
|
def sendKey(self):
|
|
|
|
if not self._initialized:
|
|
|
|
return
|
2018-03-21 06:10:28 -04:00
|
|
|
def __del__(self):
|
|
|
|
if not self._initialized:
|
2018-05-24 05:22:58 -04:00
|
|
|
return
|
|
|
|
try:
|
|
|
|
self.removeAllDevices()
|
|
|
|
except:
|
|
|
|
pass
|