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