aboutsummaryrefslogtreecommitdiff
path: root/json_layer.py
diff options
context:
space:
mode:
Diffstat (limited to 'json_layer.py')
-rw-r--r--json_layer.py62
1 files changed, 4 insertions, 58 deletions
diff --git a/json_layer.py b/json_layer.py
index 91699b5..8d12681 100644
--- a/json_layer.py
+++ b/json_layer.py
@@ -7,12 +7,8 @@
# {"get_layer"}
#
-from usb_cdc import data
-import json
-from kmk.modules import Module
from kmk.keys import Key, KC
-#from kmk.handlers.sequences import simple_key_sequence
from kmk.modules.macros import Delay, Macros, Tap
# This dictionnary is a sort of point of function.
@@ -48,7 +44,7 @@ def key_of_json(element, inside=False):
if isinstance(element, dict):
for key, value in element.items():
return operators[key](value)
- pass
+ return
def encode_macro(element):
""" Encode the result of the function key_of_json in order to build a macro
@@ -89,9 +85,9 @@ class Layer(object):
This class gives the property name in addition of the keymap list
"""
- def __init__(self, jdata):
- json_data = json.loads(jdata.strip())
- self.load(json_data)
+ def __init__(self):
+ self.name = ""
+ self.keys = []
def load(self, json_data):
""" Load the json dictionnary into the layer. The dictionnary shall be
@@ -118,53 +114,3 @@ class Layer(object):
""" Compare two layer by the name only
"""
return self.name == other.name
-
-class JsonLayer(Module):
-
- def during_bootup(self, keyboard):
- try:
- # Do not set any timeout, we check before reading a string if there
- # is any content to read, but block to be sure to read everything.
- data.timeout = None
- except AttributeError:
- pass
-
- def before_matrix_scan(self, keyboard):
- pass
-
- def after_matrix_scan(self, keyboard):
- pass
-
- def process_key(self, keyboard, key, is_pressed, int_coord):
- return key
-
- def before_hid_send(self, keyboard):
- # Serial.data isn't initialized.
- if not data:
- return
-
- if not data.connected:
- keyboard.keymap[0].name = "Disconnected"
- return
-
- # Nothing to parse.
- if data.in_waiting <= 0:
- return
- line = data.readline()
- if not line:
- return
-
- try:
- jdata = json.loads(line.decode().strip())
- keyboard.keymap[0].load(jdata)
- except Exception as err:
- print(err)
-
- def after_hid_send(self, keyboard):
- pass
-
- def on_powersave_enable(self, keyboard):
- pass
-
- def on_powersave_disable(self, keyboard):
- pass