multi threading
This commit is contained in:
parent
97f006abcc
commit
1d8d6471ee
@ -21,4 +21,4 @@ class inputManager():
|
|||||||
for event in self.devices[fd].read():
|
for event in self.devices[fd].read():
|
||||||
if event.type == evdev.ecodes.EV_KEY:
|
if event.type == evdev.ecodes.EV_KEY:
|
||||||
print(evdev.categorize(event))
|
print(evdev.categorize(event))
|
||||||
|
return runtime
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
# Fenrir TTY screen reader
|
# Fenrir TTY screen reader
|
||||||
# By Chrys, Storm Dragon, and contributers.
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
|
|
||||||
import os, sys
|
import os, sys, time
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
if not os.getcwd() in sys.path:
|
if not os.getcwd() in sys.path:
|
||||||
sys.path.append(os.getcwd())
|
sys.path.append(os.getcwd())
|
||||||
|
|
||||||
|
from threading import Thread
|
||||||
from core import environment
|
from core import environment
|
||||||
from core import inputManager
|
from core import inputManager
|
||||||
from utils import debug
|
from utils import debug
|
||||||
@ -21,6 +21,8 @@ from screen import linux as lx
|
|||||||
|
|
||||||
class fenrir():
|
class fenrir():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.threadUpdateScreen = None
|
||||||
|
self.threadHandleInput = None
|
||||||
self.runtime = environment.runtime
|
self.runtime = environment.runtime
|
||||||
self.runtime['inputManager'] = inputManager.inputManager()
|
self.runtime['inputManager'] = inputManager.inputManager()
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
@ -37,13 +39,25 @@ class fenrir():
|
|||||||
self.runtime['screenDriver'] = lx.screenManager()
|
self.runtime['screenDriver'] = lx.screenManager()
|
||||||
|
|
||||||
def proceed(self):
|
def proceed(self):
|
||||||
|
self.threadUpdateScreen = Thread(target=self.updateScreen, args=())
|
||||||
|
self.threadHandleInput = Thread(target=self.handleInput, args=())
|
||||||
|
self.threadUpdateScreen.start()
|
||||||
|
self.threadHandleInput.start()
|
||||||
while(self.runtime['running']):
|
while(self.runtime['running']):
|
||||||
self.runtime = self.runtime['screenDriver'].analyzeScreen(self.runtime)
|
time.sleep(2)
|
||||||
# self.runtime = self.runtime['inputManager'].getKeyPressed(self.runtime)
|
|
||||||
self.shutdown()
|
self.shutdown()
|
||||||
|
|
||||||
|
def handleInput(self):
|
||||||
|
while(self.runtime['running']):
|
||||||
|
self.runtime = self.runtime['inputManager'].getKeyPressed(self.runtime)
|
||||||
|
|
||||||
|
def updateScreen(self):
|
||||||
|
while(self.runtime['running']):
|
||||||
|
self.runtime = self.runtime['screenDriver'].analyzeScreen(self.runtime)
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
pass
|
self.threadUpdateScreen.stop()
|
||||||
|
self.threadHandleInput.stop()
|
||||||
|
|
||||||
app = fenrir()
|
app = fenrir()
|
||||||
app.proceed()
|
app.proceed()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user