implement synth
This commit is contained in:
parent
e2ecacfb2a
commit
b5c94a506d
@ -47,6 +47,9 @@ class inputDriver():
|
|||||||
def removeAllDevices(self):
|
def removeAllDevices(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
|
def sendKey(self):
|
||||||
|
if not self._initialized:
|
||||||
|
return
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
|
@ -62,7 +62,23 @@ class inputManager():
|
|||||||
self.grabAllDevices()
|
self.grabAllDevices()
|
||||||
self.executeDeviceGrab = False
|
self.executeDeviceGrab = False
|
||||||
def sendKeys(self, keyMacro):
|
def sendKeys(self, keyMacro):
|
||||||
pass
|
for e in keyMacro:
|
||||||
|
key = ''
|
||||||
|
value = 0
|
||||||
|
if len(e) != 2:
|
||||||
|
continue
|
||||||
|
if isinstance(e[0], int) and isinstance(e[1], str):
|
||||||
|
key = e[1].upper()
|
||||||
|
value = e[0]
|
||||||
|
elif isinstance(e[1], int) and isinstance(e[0], str):
|
||||||
|
key = e[0].upper()
|
||||||
|
value = e[1]
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
if key.upper() == 'SLEEP':
|
||||||
|
time.sleep(value)
|
||||||
|
else:
|
||||||
|
self.env['runtime']['inputDriver'].sendKey(key, value)
|
||||||
def handleInputEvent(self, eventData):
|
def handleInputEvent(self, eventData):
|
||||||
#print(eventData)
|
#print(eventData)
|
||||||
if not eventData:
|
if not eventData:
|
||||||
|
@ -10,7 +10,7 @@ _evdevAvailableError = ''
|
|||||||
_udevAvailableError = ''
|
_udevAvailableError = ''
|
||||||
try:
|
try:
|
||||||
import evdev
|
import evdev
|
||||||
from evdev import InputDevice, UInput
|
from evdev import InputDevice, UInput, ecodes as e
|
||||||
_evdevAvailable = True
|
_evdevAvailable = True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -43,6 +43,7 @@ class driver(inputDriver):
|
|||||||
self.gDevices = {}
|
self.gDevices = {}
|
||||||
self.iDeviceNo = 0
|
self.iDeviceNo = 0
|
||||||
self.watchDog = Value(c_bool, True)
|
self.watchDog = Value(c_bool, True)
|
||||||
|
self.UInputinject = UInput()
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
self.env['runtime']['inputManager'].setShortcutType('KEY')
|
self.env['runtime']['inputManager'].setShortcutType('KEY')
|
||||||
@ -381,6 +382,15 @@ class driver(inputDriver):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def sendKey(self, key, state):
|
||||||
|
if not self._initialized:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
self.UInputinject.write(e.EV_KEY, e.ecodes[key], state)
|
||||||
|
self.UInputinject.syn()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def removeAllDevices(self):
|
def removeAllDevices(self):
|
||||||
if not self.hasIDevices():
|
if not self.hasIDevices():
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user