|
|
|
@ -11,6 +11,8 @@ import traceback |
|
|
|
#1 - 102 - w s |
|
|
|
#upButton = 1001 |
|
|
|
|
|
|
|
DEBUGIO = os.environ.get("DEBUGIO", False) |
|
|
|
|
|
|
|
class MOVEMENT: |
|
|
|
RIGHT = 1 |
|
|
|
NONE = 0 |
|
|
|
@ -41,7 +43,8 @@ class ENTER: |
|
|
|
self.pin = 1001 |
|
|
|
self.enter = "xdotool key Return".split() |
|
|
|
def __call__(self, data): |
|
|
|
print(self.enter) |
|
|
|
if DEBUGIO: |
|
|
|
print(self.enter) |
|
|
|
subprocess.Popen(self.enter) |
|
|
|
|
|
|
|
class AD: |
|
|
|
@ -52,10 +55,12 @@ class AD: |
|
|
|
|
|
|
|
def __call__(self, data): |
|
|
|
if data[2] == MOVEMENT.LEFT: |
|
|
|
print(self.a) |
|
|
|
if DEBUGIO: |
|
|
|
print(self.a) |
|
|
|
subprocess.Popen(self.a) |
|
|
|
if data[2] == MOVEMENT.RIGHT: |
|
|
|
print(self.d) |
|
|
|
if DEBUGIO: |
|
|
|
print(self.d) |
|
|
|
subprocess.Popen(self.d) |
|
|
|
|
|
|
|
class WS: |
|
|
|
@ -66,10 +71,12 @@ class WS: |
|
|
|
|
|
|
|
def __call__(self, data): |
|
|
|
if data[2] == MOVEMENT.LEFT: |
|
|
|
print(self.s) |
|
|
|
if DEBUGIO: |
|
|
|
print(self.s) |
|
|
|
subprocess.Popen(self.s) |
|
|
|
if data[2] == MOVEMENT.RIGHT: |
|
|
|
print(self.w) |
|
|
|
if DEBUGIO: |
|
|
|
print(self.w) |
|
|
|
subprocess.Popen(self.w) |
|
|
|
|
|
|
|
class MODE: |
|
|
|
@ -92,7 +99,8 @@ class MODE: |
|
|
|
self.current_key = self.max_key |
|
|
|
|
|
|
|
cmd = f"xdotool key {self.current_key}".split() |
|
|
|
print(cmd) |
|
|
|
if DEBUGIO: |
|
|
|
print(cmd) |
|
|
|
subprocess.Popen(cmd) |
|
|
|
|
|
|
|
class Listener(asyncio.Protocol): |
|
|
|
@ -119,12 +127,14 @@ class Listener(asyncio.Protocol): |
|
|
|
|
|
|
|
for line in lines[:-1]: |
|
|
|
line = line.decode().replace("\r", "") |
|
|
|
print(line) |
|
|
|
if DEBUGIO: |
|
|
|
print(line) |
|
|
|
try: |
|
|
|
pin, value = line.split("*") |
|
|
|
pin = int(pin) |
|
|
|
value = int(value) |
|
|
|
print(pin, value) |
|
|
|
if DEBUGIO: |
|
|
|
print(pin, value) |
|
|
|
|
|
|
|
if pin not in self.store: |
|
|
|
self.store[pin] = Pin(pin, value) |
|
|
|
@ -133,8 +143,11 @@ class Listener(asyncio.Protocol): |
|
|
|
|
|
|
|
self.useX(self.store[pin]()) |
|
|
|
except: |
|
|
|
traceback.print_exc() |
|
|
|
print("Cannot parse") |
|
|
|
if DEBUGIO: |
|
|
|
traceback.print_exc() |
|
|
|
print("Cannot parse") |
|
|
|
else: |
|
|
|
pass |
|
|
|
|
|
|
|
def useX(self, pin): |
|
|
|
if pin[0].id in self.binds: |
|
|
|
|