954ee538017261bcb1d15d06971c0440fd700f34
[tmk_keyboard.git] / keyboard / tv44 / keymap_tv44.c
1 #include "actionmap.h"
2 #include "action_code.h"
3 #include "actionmap_common.h"
4 #include "action.h"
5 #include "action_util.h"
6
7 /* Notes:
8 * - Tab and Super+[hjkl] are uncomfortable to type
9 * - toggleable clasic left hand mods: esc/tab/shift/ctrl-alt
10 */
11
12 // action key names are for german layout!
13 #define AC_____ AC_NO
14 #define AC_FN1 ACTION_LAYER_MOMENTARY(1)
15 #define AC_FN2 ACTION_LAYER_MOMENTARY(2)
16 #define AC_TAB2 ACTION_LAYER_TAP_KEY(2, KC_TAB)
17 #define AC_FN3 ACTION_LAYER_MOMENTARY(3)
18 #define AC_DEG ACTION_MODS_KEY(MOD_LSFT, KC_GRV)
19 #define AC_EXCL ACTION_MODS_KEY(MOD_LSFT, KC_1)
20 #define AC_DQOT ACTION_MODS_KEY(MOD_LSFT, KC_2)
21 #define AC_SECT ACTION_MODS_KEY(MOD_LSFT, KC_3)
22 #define AC_DLLR ACTION_MODS_KEY(MOD_LSFT, KC_4)
23 #define AC_PERC ACTION_MODS_KEY(MOD_LSFT, KC_5)
24 #define AC_AMP ACTION_MODS_KEY(MOD_LSFT, KC_6)
25 #define AC_SLAS ACTION_MODS_KEY(MOD_LSFT, KC_7)
26 #define AC_LPAR ACTION_MODS_KEY(MOD_LSFT, KC_8)
27 #define AC_RPAR ACTION_MODS_KEY(MOD_LSFT, KC_9)
28 #define AC_EQUL ACTION_MODS_KEY(MOD_LSFT, KC_0)
29 #define AC_GRAV ACTION_MODS_KEY(MOD_LSFT, KC_EQL)
30 #define AC_SUP2 ACTION_MODS_KEY(MOD_RALT, KC_2)
31 #define AC_SUP3 ACTION_MODS_KEY(MOD_RALT, KC_3)
32 #define AC_LBRA ACTION_MODS_KEY(MOD_RALT, KC_7)
33 #define AC_LBRK ACTION_MODS_KEY(MOD_RALT, KC_8)
34 #define AC_RBRK ACTION_MODS_KEY(MOD_RALT, KC_9)
35 #define AC_RBRA ACTION_MODS_KEY(MOD_RALT, KC_0)
36 #define AC_BKSL ACTION_MODS_KEY(MOD_RALT, KC_MINS)
37 #define AC_ASTK ACTION_MODS_KEY(MOD_LSFT, KC_RBRC)
38 #define AC_SQOT ACTION_MODS_KEY(MOD_LSFT, KC_NUHS)
39 #define AC_AT ACTION_MODS_KEY(MOD_RALT, KC_Q)
40 #define AC_EUR ACTION_MODS_KEY(MOD_RALT, KC_E)
41 #define AC_TILD ACTION_MODS_KEY(MOD_RALT, KC_RBRC)
42 #define AC_RANG ACTION_MODS_KEY(MOD_LSFT, KC_NUBS)
43 #define AC_BAR ACTION_MODS_KEY(MOD_RALT, KC_NUBS)
44 #define AC_MU ACTION_MODS_KEY(MOD_RALT, KC_M)
45 #define AC_CIRC AC_GRV
46 #define AC_SS AC_MINS
47 #define AC_PLUS AC_RBRC
48 #define AC_HASH AC_NUHS
49 #define AC_LANG AC_NUBS
50 #define AC_DASH AC_SLSH
51 #define AC_WORD ACTION_MODS_KEY(MOD_LCTL, KC_RIGHT)
52 #define AC_BACK ACTION_MODS_KEY(MOD_LCTL, KC_LEFT)
53 #define AC_AUML ACTION_MODS_KEY(MOD_LSFT, KC_QUOT)
54 #define AC_OUML ACTION_MODS_KEY(MOD_LSFT, KC_SCLN)
55 #define AC_UUML ACTION_MODS_KEY(MOD_LSFT, KC_LBRC)
56 #define AC_aUML AC_QUOT
57 #define AC_oUML AC_SCLN
58 #define AC_uUML AC_LBRC
59 #define AC_SLQU ACTION_FUNCTION(SLASH_QUESTION)
60
61 enum function_id {
62 SLASH_QUESTION,
63 };
64
65 void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
66 uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));
67 static uint8_t slqu_pressed; //for SLASH_QUESTION
68
69
70 switch (id) {
71 case SLASH_QUESTION:
72 /* when the key is pressed without any modifiers, a slash (Shift+7)
73 is typed; if shift is active, a question mark (Shift+ß) is typed.
74 Minor difference to native behaviour: if shift is released while
75 key is still held down, more question marks are typed instead of
76 switching to slashes. */
77 if (record->event.pressed) {
78 slqu_pressed = shifted?KC_MINS:KC_7;
79 add_weak_mods(MOD_BIT(KC_LSHIFT)), send_keyboard_report();
80 add_key(slqu_pressed), send_keyboard_report();
81 } else {
82 del_key(slqu_pressed), send_keyboard_report();
83 del_weak_mods(MOD_BIT(KC_LSHIFT)), send_keyboard_report();
84 }
85 break;
86 }
87 }
88
89 const action_t PROGMEM actionmaps[][MATRIX_ROWS][MATRIX_COLS] = {
90 /* Layer: Base Layer
91 * ,-------------------------------------------------.
92 * |Esc| Q| W| E| R| T| Z| U| I| O| P| BSp |
93 * |-------------------------------------------------|
94 * |Ctrl| A| S| D| F| G| H| J| K| L| ?/|Fn2 |
95 * |-------------------------------------------------|
96 * |Shift| Y| X| C| V| B| N| M| ,| .| -|Sft|
97 * |-------------------------------------------------|
98 * |Alt |Tab/Fn2|Fn1 |Enter| Space |Fn1 |Super| Fn3 |
99 * `-------------------------------------------------'
100 */
101 ACTIONMAP(
102 ESC , Q, W, E, R, T, Y, U, I, O, P, BSPC, \
103 LCTRL, A, S, D, F, G, H, J, K, L,SLQU, FN2, \
104 LSHIFT, Z, X, C, V, B, N, M,COMM, DOT,DASH, RSHIFT, \
105 LALT, TAB2, FN1 , ENT, SPC, FN1, LGUI, FN3 ),
106
107 /* Layer: Movement Layer (wrd=ctrl-right, bck=crtl-left) ~~TOGGLE~~MOMENTARY
108 * ,-------------------------------------------------.
109 * |Esc| |wrd| |END| | |PUp| |Hom|Ins| Del |
110 * |-------------------------------------------------|
111 * | | | |PDn| | |Lft| Up| Dn| Rt| | |
112 * |-------------------------------------------------|
113 * | |PSc| | | |bck| |PAU|NUM|CAP|SCR| |
114 * |-------------------------------------------------|
115 * | | | | | | | | |
116 * `-------------------------------------------------'
117 */
118 ACTIONMAP(
119 TRNS,____,WORD,____, END,____,____,PGUP,____,HOME, INS, DEL, \
120 TRNS ,____,____,PGDN,____,____,LEFT,DOWN, UP,RGHT,____, TRNS, \
121 TRNS ,PSCR,____,____,____,BACK,____,PAUS,NLCK,CAPS,SLCK,TRNS, \
122 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS ),
123
124 /* Layer: Numbers and ASCII-Symbols Layer MOMENTARY+~~TOGGLE~~
125 * ,-------------------------------------------------.
126 * | ^| !| "| '| $| %| &| @| (| )| =| BSp |
127 * |-------------------------------------------------|
128 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0|Fn2 |
129 * |-------------------------------------------------|
130 * | #| <| || >| +| *| {| [| ]| }| \| ~|
131 * |-------------------------------------------------|
132 * | | | | | | | | |
133 * `-------------------------------------------------'
134 */
135 ACTIONMAP(
136 CIRC,EXCL,DQOT,SQOT,DLLR,PERC, AMP, AT,LPAR,RPAR,EQUL, TRNS, \
137 GRAV , 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, TRNS, \
138 HASH ,LANG, BAR,RANG,PLUS,ASTK,LBRA,LBRK,RBRK,RBRA,BKSL,TILD, \
139 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS ),
140
141 /* Layer: Layer for Function keys and Unicode Symbols MOMENTARY
142 * ,-------------------------------------------------.
143 * | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11| F12|
144 * |-------------------------------------------------|
145 * | | | | | | | | | Ä| Ö| Ü| |
146 * |-------------------------------------------------|
147 * | | €| §| °| ²| ³| µ| ä| ö| ü| ß| |
148 * |-------------------------------------------------|
149 * | | | | | | | | Fn3 |
150 * `-------------------------------------------------'
151 */
152 ACTIONMAP(
153 F1 , F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, \
154 TRNS ,____,____,____,____,____,____,____,AUML,OUML,UUML, TRNS, \
155 TRNS , EUR,SECT, DEG,SUP2,SUP3, MU,aUML,oUML,uUML, SS,TRNS, \
156 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS ),
157 };
Imprint / Impressum