diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2016-05-18 23:47:16 -0400 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2016-05-18 23:47:16 -0400 |
| commit | b732b79b49b098dba8e14493c745075f336747d8 (patch) | |
| tree | 069f529df73ba8bfbcf7003f5ddd3987ecaadc57 /keyboard | |
| parent | bf545061f2a71b054ccdca6f6261bb7c2ffa4957 (diff) | |
| download | qmk_firmware-b732b79b49b098dba8e14493c745075f336747d8.tar.gz qmk_firmware-b732b79b49b098dba8e14493c745075f336747d8.zip | |
adapts unicode to quantum.c (#333)
* Unicode
to have unicode input you need to:
- set your OS input method to UNICODE if needed
- enable unicode in your makefile
- copy the action_function from
keyboard/planck/keymaps/unicode/unicode.c to your keymap.c
set the target OS method in your keymap.c: void matrix_init_user() {
set_unicode_mode(UC_OSX); } you can then switch when you want with:
set_unicode_mode(UC_OSX); set_unicode_mode(UC_LNX);
set_unicode_mode(UC_WIN);
put some unicode codes in your keymap like so: UC(0x0061)
I did change the bit mask in quantum/keymap_common.c and .h
I’m afraid we will need uint32 to get a total support for all unicode
tables or relocate the handler as @mbarkhau did.
* rearranges keycode values, hooks-up unicode
* removes extra lalt ref
* adds unicode shortcuts and example
Diffstat (limited to 'keyboard')
| -rw-r--r-- | keyboard/planck/keymaps/unicode/keymap.c | 326 | ||||
| -rw-r--r-- | keyboard/planck/keymaps/unicode/makefile.mk | 1 |
2 files changed, 327 insertions, 0 deletions
diff --git a/keyboard/planck/keymaps/unicode/keymap.c b/keyboard/planck/keymaps/unicode/keymap.c new file mode 100644 index 000000000..d73e7e09d --- /dev/null +++ b/keyboard/planck/keymaps/unicode/keymap.c | |||
| @@ -0,0 +1,326 @@ | |||
| 1 | /* | ||
| 2 | Copyright | ||
| 3 | 2015 Jack Humbert <jack.humb@gmail.com> | ||
| 4 | 2016 Francois Marlier <fmarlier@gmail.com> | ||
| 5 | |||
| 6 | This program is free software: you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation, either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | For more info on how this works per OS, see here | ||
| 20 | https://en.wikipedia.org/wiki/Unicode_input#Hexadecimal_code_input | ||
| 21 | */ | ||
| 22 | |||
| 23 | |||
| 24 | #include "planck.h" | ||
| 25 | #include "action_layer.h" | ||
| 26 | #ifdef AUDIO_ENABLE | ||
| 27 | #include "audio.h" | ||
| 28 | #endif | ||
| 29 | #include "eeconfig.h" | ||
| 30 | |||
| 31 | extern keymap_config_t keymap_config; | ||
| 32 | |||
| 33 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
| 34 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
| 35 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
| 36 | // entirely and just use numbers. | ||
| 37 | #define _QWERTY 0 | ||
| 38 | #define _COLEMAK 1 | ||
| 39 | #define _DVORAK 2 | ||
| 40 | #define _LOWER 3 | ||
| 41 | #define _RAISE 4 | ||
| 42 | #define _PLOVER 5 | ||
| 43 | #define _ADJUST 16 | ||
| 44 | |||
| 45 | // Macro name shortcuts | ||
| 46 | #define QWERTY M(_QWERTY) | ||
| 47 | #define COLEMAK M(_COLEMAK) | ||
| 48 | #define DVORAK M(_DVORAK) | ||
| 49 | #define LOWER M(_LOWER) | ||
| 50 | #define RAISE M(_RAISE) | ||
| 51 | #define M_BL 5 | ||
| 52 | #define PLOVER M(12) | ||
| 53 | #define EXT_PLV M(13) | ||
| 54 | #define TOG_OUT M(14) | ||
| 55 | |||
| 56 | // Fillers to make layering more clear | ||
| 57 | #define _______ KC_TRNS | ||
| 58 | #define XXXXXXX KC_NO | ||
| 59 | |||
| 60 | |||
| 61 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 62 | |||
| 63 | /* Qwerty | ||
| 64 | * ,-----------------------------------------------------------------------------------. | ||
| 65 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | | ||
| 66 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 67 | * | Esc | A | S | D | F | G | H | J | K | L | ; | " | | ||
| 68 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 69 | * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | | ||
| 70 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 71 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | ||
| 72 | * `-----------------------------------------------------------------------------------' | ||
| 73 | */ | ||
| 74 | [_QWERTY] = { | ||
| 75 | {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, | ||
| 76 | {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, | ||
| 77 | {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, | ||
| 78 | {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | ||
| 79 | }, | ||
| 80 | |||
| 81 | /* Colemak | ||
| 82 | * ,-----------------------------------------------------------------------------------. | ||
| 83 | * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp | | ||
| 84 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 85 | * | Esc | A | R | S | T | D | H | N | E | I | O | " | | ||
| 86 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 87 | * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter | | ||
| 88 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 89 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | ||
| 90 | * `-----------------------------------------------------------------------------------' | ||
| 91 | */ | ||
| 92 | [_COLEMAK] = { | ||
| 93 | {KC_TAB, UC_q, UC_w, UC_f, UC_p, UC_g, UC_j, UC_l, UC_u, UC_y, UC_SCLN, UC_BSPC}, | ||
| 94 | {KC_ESC, UC_a, UC_r, UC_s, UC_t, UC_d, UC_h, UC_n, UC_e, UC_i, UC_o, UC_QUOT}, | ||
| 95 | {KC_LSFT, UC_z, UC_x, UC_c, UC_v, UC_b, UC_k, UC_m, UC_COMM, UC_DOT, UC_SLSH, KC_ENT}, | ||
| 96 | {KC_TRNS, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | ||
| 97 | }, | ||
| 98 | |||
| 99 | /* Dvorak | ||
| 100 | * ,-----------------------------------------------------------------------------------. | ||
| 101 | * | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp | | ||
| 102 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 103 | * | Esc | A | O | E | U | I | D | H | T | N | S | / | | ||
| 104 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 105 | * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter | | ||
| 106 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 107 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | ||
| 108 | * `-----------------------------------------------------------------------------------' | ||
| 109 | */ | ||
| 110 | [_DVORAK] = { | ||
| 111 | {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, | ||
| 112 | {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, | ||
| 113 | {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, | ||
| 114 | {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | ||
| 115 | }, | ||
| 116 | |||
| 117 | /* Lower | ||
| 118 | * ,-----------------------------------------------------------------------------------. | ||
| 119 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | | ||
| 120 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 121 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | | ||
| 122 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 123 | * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | | ||
| 124 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 125 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
| 126 | * `-----------------------------------------------------------------------------------' | ||
| 127 | */ | ||
| 128 | [_LOWER] = { | ||
| 129 | {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, | ||
| 130 | {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, | ||
| 131 | {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, | ||
| 132 | {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} | ||
| 133 | }, | ||
| 134 | |||
| 135 | /* Raise | ||
| 136 | * ,-----------------------------------------------------------------------------------. | ||
| 137 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
| 138 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 139 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | | ||
| 140 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 141 | * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | | ||
| 142 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 143 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
| 144 | * `-----------------------------------------------------------------------------------' | ||
| 145 | */ | ||
| 146 | [_RAISE] = { | ||
| 147 | {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, | ||
| 148 | {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, | ||
| 149 | {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, | ||
| 150 | {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} | ||
| 151 | }, | ||
| 152 | |||
| 153 | /* Plover layer (http://opensteno.org) | ||
| 154 | * ,-----------------------------------------------------------------------------------. | ||
| 155 | * | # | # | # | # | # | # | # | # | # | # | # | # | | ||
| 156 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 157 | * | | S | T | P | H | * | * | F | P | L | T | D | | ||
| 158 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 159 | * |TogOut| S | K | W | R | * | * | R | B | G | S | Z | | ||
| 160 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 161 | * | Exit | | | A | O | | E | U | | | | | ||
| 162 | * `-----------------------------------------------------------------------------------' | ||
| 163 | */ | ||
| 164 | |||
| 165 | [_PLOVER] = { | ||
| 166 | {KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 }, | ||
| 167 | {XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC}, | ||
| 168 | {TOG_OUT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, | ||
| 169 | {EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX} | ||
| 170 | }, | ||
| 171 | |||
| 172 | /* Adjust (Lower + Raise) | ||
| 173 | * ,-----------------------------------------------------------------------------------. | ||
| 174 | * | | Reset| | | | | | | | | | Del | | ||
| 175 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 176 | * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| | | ||
| 177 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 178 | * | |Voice-|Voice+|Mus on|Musoff| | | | | | | | | ||
| 179 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 180 | * | | | | | | | | | | | | | ||
| 181 | * `-----------------------------------------------------------------------------------' | ||
| 182 | */ | ||
| 183 | [_ADJUST] = { | ||
| 184 | {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, | ||
| 185 | {_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______}, | ||
| 186 | {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______}, | ||
| 187 | {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} | ||
| 188 | } | ||
| 189 | |||
| 190 | |||
| 191 | }; | ||
| 192 | |||
| 193 | const uint16_t PROGMEM fn_actions[] = { | ||
| 194 | |||
| 195 | }; | ||
| 196 | |||
| 197 | #ifdef AUDIO_ENABLE | ||
| 198 | float tone_startup[][2] = { | ||
| 199 | {440.0*pow(2.0,(31)/12.0), 12}, | ||
| 200 | {440.0*pow(2.0,(28)/12.0), 8}, | ||
| 201 | {440.0*pow(2.0,(19)/12.0), 8}, | ||
| 202 | {440.0*pow(2.0,(24)/12.0), 8}, | ||
| 203 | {440.0*pow(2.0,(28)/12.0), 20} | ||
| 204 | }; | ||
| 205 | |||
| 206 | float tone_qwerty[][2] = SONG(QWERTY_SOUND); | ||
| 207 | float tone_dvorak[][2] = SONG(DVORAK_SOUND); | ||
| 208 | float tone_colemak[][2] = SONG(COLEMAK_SOUND); | ||
| 209 | float tone_plover[][2] = SONG(PLOVER_SOUND); | ||
| 210 | float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); | ||
| 211 | |||
| 212 | float goodbye[][2] = SONG(GOODBYE_SOUND); | ||
| 213 | #endif | ||
| 214 | |||
| 215 | |||
| 216 | void persistant_default_layer_set(uint16_t default_layer) { | ||
| 217 | eeconfig_update_default_layer(default_layer); | ||
| 218 | default_layer_set(default_layer); | ||
| 219 | } | ||
| 220 | |||
| 221 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
| 222 | { | ||
| 223 | switch(id) { | ||
| 224 | case _QWERTY: | ||
| 225 | if (record->event.pressed) { | ||
| 226 | #ifdef AUDIO_ENABLE | ||
| 227 | PLAY_NOTE_ARRAY(tone_qwerty, false, 0); | ||
| 228 | #endif | ||
| 229 | persistant_default_layer_set(1UL<<_QWERTY); | ||
| 230 | } | ||
| 231 | break; | ||
| 232 | case _COLEMAK: | ||
| 233 | if (record->event.pressed) { | ||
| 234 | #ifdef AUDIO_ENABLE | ||
| 235 | PLAY_NOTE_ARRAY(tone_colemak, false, 0); | ||
| 236 | #endif | ||
| 237 | persistant_default_layer_set(1UL<<_COLEMAK); | ||
| 238 | } | ||
| 239 | break; | ||
| 240 | case _DVORAK: | ||
| 241 | if (record->event.pressed) { | ||
| 242 | #ifdef AUDIO_ENABLE | ||
| 243 | PLAY_NOTE_ARRAY(tone_dvorak, false, 0); | ||
| 244 | #endif | ||
| 245 | persistant_default_layer_set(1UL<<_DVORAK); | ||
| 246 | } | ||
| 247 | break; | ||
| 248 | case _LOWER: | ||
| 249 | if (record->event.pressed) { | ||
| 250 | layer_on(_LOWER); | ||
| 251 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
| 252 | } else { | ||
| 253 | layer_off(_LOWER); | ||
| 254 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
| 255 | } | ||
| 256 | break; | ||
| 257 | case _RAISE: | ||
| 258 | if (record->event.pressed) { | ||
| 259 | layer_on(_RAISE); | ||
| 260 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
| 261 | } else { | ||
| 262 | layer_off(_RAISE); | ||
| 263 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
| 264 | } | ||
| 265 | break; | ||
| 266 | case M_BL: | ||
| 267 | if (record->event.pressed) { | ||
| 268 | register_code(KC_RSFT); | ||
| 269 | #ifdef BACKLIGHT_ENABLE | ||
| 270 | backlight_step(); | ||
| 271 | #endif | ||
| 272 | } else { | ||
| 273 | unregister_code(KC_RSFT); | ||
| 274 | } | ||
| 275 | break; | ||
| 276 | case 12: | ||
| 277 | if (record->event.pressed) { | ||
| 278 | #ifdef AUDIO_ENABLE | ||
| 279 | stop_all_notes(); | ||
| 280 | PLAY_NOTE_ARRAY(tone_plover, false, 0); | ||
| 281 | #endif | ||
| 282 | layer_off(_RAISE); | ||
| 283 | layer_off(_LOWER); | ||
| 284 | layer_off(_ADJUST); | ||
| 285 | layer_on(_PLOVER); | ||
| 286 | if (!eeconfig_is_enabled()) { | ||
| 287 | eeconfig_init(); | ||
| 288 | } | ||
| 289 | keymap_config.raw = eeconfig_read_keymap(); | ||
| 290 | keymap_config.nkro = 1; | ||
| 291 | eeconfig_update_keymap(keymap_config.raw); | ||
| 292 | } | ||
| 293 | break; | ||
| 294 | case 13: | ||
| 295 | if (record->event.pressed) { | ||
| 296 | #ifdef AUDIO_ENABLE | ||
| 297 | PLAY_NOTE_ARRAY(tone_plover_gb, false, 0); | ||
| 298 | #endif | ||
| 299 | layer_off(_PLOVER); | ||
| 300 | } | ||
| 301 | break; | ||
| 302 | case 14: | ||
| 303 | if (record->event.pressed) { | ||
| 304 | return MACRO( D(E), D(R), D(F), D(V), D(O), D(L), U(E), U(R), U(F), U(V), U(O), U(L), END ); | ||
| 305 | } | ||
| 306 | break; | ||
| 307 | } | ||
| 308 | return MACRO_NONE; | ||
| 309 | }; | ||
| 310 | |||
| 311 | void matrix_init_user(void) { | ||
| 312 | #ifdef AUDIO_ENABLE | ||
| 313 | _delay_ms(20); // stops the tick | ||
| 314 | PLAY_NOTE_ARRAY(tone_startup, false, 0); | ||
| 315 | #endif | ||
| 316 | } | ||
| 317 | |||
| 318 | #ifdef AUDIO_ENABLE | ||
| 319 | void play_goodbye_tone() | ||
| 320 | { | ||
| 321 | PLAY_NOTE_ARRAY(goodbye, false, 0); | ||
| 322 | _delay_ms(150); | ||
| 323 | } | ||
| 324 | #endif | ||
| 325 | |||
| 326 | |||
diff --git a/keyboard/planck/keymaps/unicode/makefile.mk b/keyboard/planck/keymaps/unicode/makefile.mk new file mode 100644 index 000000000..9b27b08be --- /dev/null +++ b/keyboard/planck/keymaps/unicode/makefile.mk | |||
| @@ -0,0 +1 @@ | |||
| UNICODE_ENABLE = yes # Unicode | |||
