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