summaryrefslogtreecommitdiff
path: root/src/macros/qqsp.py
blob: 6ff04871f6f8ff699c6d87fbb1aaf6c9515a33e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# 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 build_application():
    configuration = skeleton.Configuration("qqsp")
    configuration.visible = False
    configuration.registerKey(
            0,
            "7",
            lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_SEVEN]),
            Color(0.333, 1.0, 0.0196))
    configuration.registerKey(
            1,
            "8",
            lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_EIGHT]),
            Color(0.266, 1.0, 0.0196))
    configuration.registerKey(
            2,
            "9",
            lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_NINE]),
            Color(0.166, 1.0, 0.0196))
    configuration.registerKey(
            3,
            "4",
            lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_FOUR]),
            Color(0.4, 1.0, 0.0196))
    configuration.registerKey(
            4,
            "5",
            lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_FIVE]),
            Color(0.333, 0.6, 0.0196))
    configuration.registerKey(
            5,
            "6",
            lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_SIX]),
            Color(0.16, 0.6, 0.0196))
    configuration.registerKey(
            6,
            "1",
            lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_ONE]),
            # 0x000505
            Color(0.5, 1.0, 0.0196))
    configuration.registerKey(
            7,
            "2",
            lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_TWO]),
            Color(0.5, 0.6, 0.0196))
    configuration.registerKey(
            8,
            "3",
            lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_THREE]),
            # 0x050505
            Color(0.01, 0.01, 0.0196))
    configuration.registerKey(
            9,
            "0",
            lambda macropad, key, pressed: Action().key(pressed, [Keycode.KEYPAD_ZERO]),
            # 0x000507
            Color(0.54, 1.0, 0.027))

    # The dot key.
    configuration.registerKey(
            11,
            "^O",
            lambda macropad, key, pressed: Action().key(pressed, [Keycode.CONTROL, Keycode.O]),
            0x050507)
    return configuration

configuration = build_application()