implement synth
This commit is contained in:
parent
e2ecacfb2a
commit
b5c94a506d
@ -47,6 +47,9 @@ class inputDriver():
|
||||
def removeAllDevices(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
def sendKey(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
def __del__(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
|
@ -62,7 +62,23 @@ class inputManager():
|
||||
self.grabAllDevices()
|
||||
self.executeDeviceGrab = False
|
||||
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):
|
||||
#print(eventData)
|
||||
if not eventData:
|
||||
|
@ -10,7 +10,7 @@ _evdevAvailableError = ''
|
||||
_udevAvailableError = ''
|
||||
try:
|
||||
import evdev
|
||||
from evdev import InputDevice, UInput
|
||||
from evdev import InputDevice, UInput, ecodes as e
|
||||
_evdevAvailable = True
|
||||
|
||||
except Exception as e:
|
||||
@ -43,6 +43,7 @@ class driver(inputDriver):
|
||||
self.gDevices = {}
|
||||
self.iDeviceNo = 0
|
||||
self.watchDog = Value(c_bool, True)
|
||||
self.UInputinject = UInput()
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self.env['runtime']['inputManager'].setShortcutType('KEY')
|
||||
@ -381,6 +382,15 @@ class driver(inputDriver):
|
||||
return False
|
||||
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):
|
||||
if not self.hasIDevices():
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user