test doesnt spam keycodes

master
bel 2022-04-12 21:04:23 -06:00
parent 721a8e7e38
commit 90667cba52
3 changed files with 43 additions and 19 deletions

View File

@ -26,11 +26,30 @@ def __init_keys__():
assert(_p.returncode == 0)
stdout = _p.stdout
result = []
allowed = ["F"+str(i) for i in range(13, 25)]
unassigned = []
# already assigned
for line in stdout.split("\n".encode())[1:]:
if line:
words = line.split()
key = int(words[1])
if len(words) < 4:
unassigned.append(key)
elif words[3].decode() in allowed:
allowed.remove(words[3].decode())
result.append(key)
# not assigned
for key in unassigned:
if not allowed:
break
word = allowed.pop()
if word:
assert(subprocess.run([
"xmodmap", "-e", f"keycode {key} = {word}",
]).returncode == 0)
result.append(key)
print("unassigned", unassigned)
print("allowed", allowed)
print("result", result)
return result
keys = __init_keys__()

View File

@ -21,7 +21,6 @@ def main():
buckets[key][0] = False if line[0] == "/" else float(line.split()[-1])
for key in buckets:
keyindex = buckets[key][1]
print("getting", keyindex, "of", len(buckets))
keycode = buttons.keys[keyindex]
if buckets[key][0]:
print(f"+{key}", end=" ")

View File

@ -16,7 +16,8 @@ trap cleanup EXIT
python3 ./state_to_buttons.py &
python3 ./testdata/rand_0_n_weighted_stream.py \
(
python3 ./testdata/rand_0_n_weighted_stream.py \
-n 6 \
-b-min 1 \
-b-max 10 \
@ -29,8 +30,13 @@ python3 ./testdata/rand_0_n_weighted_stream.py \
-d-max 3000 \
-between 10 \
-w 3 \
| peek \
| python3 ./stream_to_state.py \
| peek \
| python3 ./stream_to_state.py \
-n 1 \
-m .25 \
-r .3
) &
while true; do
read -s var
done