summaryrefslogtreecommitdiff
path: root/src/macros/olympia.py
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2023-05-22 08:40:47 +0200
committerSébastien Dailly <sebastien@dailly.me>2023-05-22 08:40:47 +0200
commit597b007333d8ec0d9cfd29e6941fcbe57379108a (patch)
tree0cf87e1ac487e7deb91acf7f2bec70bd4dd06703 /src/macros/olympia.py
Initial commit
Diffstat (limited to 'src/macros/olympia.py')
-rw-r--r--src/macros/olympia.py91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/macros/olympia.py b/src/macros/olympia.py
new file mode 100644
index 0000000..b124075
--- /dev/null
+++ b/src/macros/olympia.py
@@ -0,0 +1,91 @@
+# SPDX-FileCopyrightText: 2021 Phillip Burgess for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+
+# MACROPAD Hotkeys example: Mouse control
+
+# The syntax for Mouse macros is highly peculiar, in order to maintain
+# backward compatibility with the original keycode-only macro files.
+# The third item for each macro is a list in brackets, and each value within
+# is normally an integer (Keycode), float (delay) or string (typed literally).
+# Consumer Control codes were added as list-within-list, and then mouse
+# further complicates this by adding dicts-within-list. Each mouse-related
+# dict can have any mix of keys 'buttons' w/integer mask of button values
+# (positive to press, negative to release), 'x' w/horizontal motion,
+# 'y' w/vertical and 'wheel' with scrollwheel motion.
+
+# To reference Mouse constants, import Mouse like so...
+from keycode_win_frnb import Keycode # Use the french bepo layout
+import colorsys
+
+import skeleton
+from actions import Action
+
+
+class Color(object):
+ """ Represent the color of a key in the HSV model.
+
+ The class implements the int() function in order to being compatible with
+ the remaining of the application.
+ """
+ def __init__(self, h, s, v):
+ self.col = (h, s, v)
+
+ def __int__(self):
+ r, g, b = colorsys.hsv_to_rgb(self.col[0], self.col[1], self.col[2])
+ return (r<<16) + (g<<8) + b
+
+def key(code):
+ def action(macropad, key, pressed):
+ Action().key(pressed, code)
+ return action
+
+def build_application():
+ configuration = skeleton.Configuration("Olympia")
+ configuration.hidden = False
+ configuration.registerKey(0, "vue", key([Keycode.V]), 0x000500)
+ configuration.registerKey(1, "map", key([Keycode.M]), 0x000005)
+ configuration.registerKey(2, "x", key([Keycode.CONTROL, Keycode.W]), 0x050000)
+ configuration.registerKey(3, "\\", key([Keycode.KEYPAD_SEVEN]), Color(0.333, 1.0, 0.0196))
+ configuration.registerKey(
+ 4,
+ "|",
+ lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_EIGHT]),
+ Color(0.266, 1.0, 0.0196))
+ configuration.registerKey(
+ 5,
+ "/",
+ lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_NINE]),
+ Color(0.166, 1.0, 0.0196))
+ configuration.registerKey(
+ 6,
+ "<",
+ lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_FOUR]),
+ Color(0.4, 1.0, 0.0196))
+
+ configuration.registerKey(7, "Inventaire", key([Keycode.I]), Color(0.333, 0.6, 0.0196))
+
+ configuration.registerKey(
+ 8,
+ ">",
+ lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_SIX]),
+ # 0x050502
+ Color(0.16, 0.6, 0.0196))
+ configuration.registerKey(
+ 9,
+ "/",
+ key([Keycode.KEYPAD_ONE]),
+ 0x000505)
+ configuration.registerKey(
+ 10,
+ "|",
+ lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_TWO]),
+ Color(0.5, 0.6, 0.0196))
+ configuration.registerKey(
+ 11,
+ "\\",
+ key([Keycode.KEYPAD_THREE]),
+ 0x050505)
+ return configuration
+
+configuration = build_application()