<%# ---------------------------------------------------------------------%>
<%# A much simplified copy of the vi_mode.json.erb file, for TouchCursor %>
<%# ---------------------------------------------------------------------%>
{
    "title": "TouchCursor Mode (rev 2)",
    "rules": [
        {
            "description": "TouchCursor Mode [Space as Trigger Key] (rev 2)",
            "manipulators": [

                <%# -------------------------------------------------- %>
                <%# press spacebar to enter TouchCursor Mode, release to quit %>
                <%# -------------------------------------------------- %>
                {
                    "type": "basic",
                    "from": <%= from("spacebar", [], ["caps_lock"]) %>,
                    "to": [
                        { "set_variable": { "name": "touchcursor_mode", "value": 1 } }
                    ],
                    "to_if_alone": <%= to([["spacebar"]]) %>,
                    "to_after_key_up": [
                        { "set_variable": { "name": "touchcursor_mode", "value": 0 } }
                    ]
                },

                <%# -------------------------------------------------- %>
                <%# change j/k/i/l to arrow keys %>
                <%# -------------------------------------------------- %>
                {
                    "type": "basic",
                    "from": <%= from("j", [], ["any"]) %>,
                    "to": <%= to([["left_arrow"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("k", [], ["any"]) %>,
                    "to": <%= to([["down_arrow"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("i", [], ["any"]) %>,
                    "to": <%= to([["up_arrow"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("l", [], ["any"]) %>,
                    "to": <%= to([["right_arrow"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },

                <%# -------------------------------------------------- %>
                <%# change u/o to Home/End, y to Insert, and %>
                <%# m/p to delete_forward/delete_or_backspace %>
                <%# -------------------------------------------------- %>
                {
                    "type": "basic",
                    "from": <%= from("u", [], ["any"]) %>,
                    "to": <%= to([["left_arrow", ["command"]]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("o", [], ["any"]) %>,
                    "to": <%= to([["right_arrow", ["command"]]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("y", [], ["caps_lock"]) %>,
                    "to": <%= to([["insert"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("m", [], ["any"]) %>,
                    "to": <%= to([["delete_forward"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("p", [], ["any"]) %>,
                    "to": <%= to([["delete_or_backspace"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },

                <%# -------------------------------------------------- %>
                <%# change h/n page_up/page_down %>
                <%# -------------------------------------------------- %>
                {
                    "type": "basic",
                    "from": <%= from("h", [], ["any"]) %>,
                    "to": <%= to([["page_up"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("n", [], ["any"]) %>,
                    "to": <%= to([["page_down"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },

                <%# -------------------------------------------------- %>
                <%# normalize return & tab %>
                <%# -------------------------------------------------- %>
                {
                    "type": "basic",
                    "from": <%= from("return_or_enter", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["return_or_enter"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("tab", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["tab"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },

                <%# -------------------------------------------------- %>
                <%# normalize punctuation marks %>
                <%# -------------------------------------------------- %>
                {
                    "type": "basic",
                    "from": <%= from("hyphen", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["hyphen"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("equal_sign", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["equal_sign"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("open_bracket", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["open_bracket"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("close_bracket", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["close_bracket"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("backslash", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["backslash"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("non_us_pound", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["non_us_pound"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("semicolon", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["semicolon"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("quote", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["quote"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("grave_accent_and_tilde", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["grave_accent_and_tilde"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("comma", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["comma"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("period", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["period"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("slash", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["slash"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("non_us_backslash", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["non_us_backslash"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },

                <%# -------------------------------------------------- %>
                <%# normalize number keys %>
                <%# -------------------------------------------------- %>
                {
                    "type": "basic",
                    "from": <%= from("1", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["1"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("2", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["2"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("3", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["3"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("4", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["4"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("5", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["5"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("6", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["6"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("7", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["7"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("8", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["8"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("9", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["9"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("0", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["0"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },

                <%# -------------------------------------------------- %>
                <%# normalize letter keys (except for h, i, j, k, l, m, n, o, p, u, y) %>
                <%# -------------------------------------------------- %>
                {
                    "type": "basic",
                    "from": <%= from("a", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["a"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("b", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["b"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("c", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["c"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("d", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["d"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("e", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["e"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("f", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["f"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("g", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["g"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("q", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["q"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("r", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["r"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("s", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["s"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("t", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["t"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("v", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["v"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("w", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["w"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("x", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["x"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                },
                {
                    "type": "basic",
                    "from": <%= from("z", [], ["caps_lock"]) %>,
                    "to": <%= to([["spacebar"], ["z"], ["vk_none"]]) %>,
                    "conditions": [
                        { "type": "variable_if", "name": "touchcursor_mode", "value": 1 }
                    ]
                }
            ]
        }
    ]
}
