From 03afc0716108026f2617a1d4ec0ffed4eb065e80 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 21 Oct 2016 14:28:53 +0900 Subject: [PATCH] hhkb: Change unimap files --- keyboard/hhkb/unimap_hasu.c | 152 ++++++++++++++++++ keyboard/hhkb/unimap_hhkb.c | 36 ++--- keyboard/hhkb/unimap_jp.c | 34 ++-- .../hhkb/{unimap_common.h => unimap_trans.h} | 49 +++++- 4 files changed, 230 insertions(+), 41 deletions(-) create mode 100644 keyboard/hhkb/unimap_hasu.c rename keyboard/hhkb/{unimap_common.h => unimap_trans.h} (76%) diff --git a/keyboard/hhkb/unimap_hasu.c b/keyboard/hhkb/unimap_hasu.c new file mode 100644 index 00000000..da16e9c8 --- /dev/null +++ b/keyboard/hhkb/unimap_hasu.c @@ -0,0 +1,152 @@ +/* +Copyright 2016 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "unimap_trans.h" + + +/* id for user defined functions */ +enum function_id { + LSHIFT_LPAREN, +}; + +enum macro_id { + HELLO, + VOLUP, + ALT_TAB, +}; + +#define AC_L1 ACTION_LAYER_MOMENTARY(1) +#define AC_SLS2 ACTION_LAYER_TAP_KEY(2, KC_SLSH) +#define AC_SCL3 ACTION_LAYER_TAP_KEY(3, KC_SCLN) +#define AC_SPC4 ACTION_LAYER_TAP_KEY(4, KC_SPC) +#define AC_APSW ACTION_MACRO(ALT_TAB) +#define AC_BACK ACTION_MODS_KEY(MOD_LALT, KC_LEFT) +#define AC_FRWD ACTION_MODS_KEY(MOD_LALT, KC_RIGHT) +#define AC_ENT_ ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT) + +// Function: LShift with tap '(' +#define AC_LPRN ACTION_FUNCTION_TAP(LSHIFT_LPAREN) +// Macro: say hello +#define AC_HELO ACTION_MACRO(HELLO) + + +#ifdef KEYMAP_SECTION_ENABLE +const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = { +#else +const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = { +#endif + [0] = UNIMAP_HHKB( + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT_, + LPRN, Z, X, C, V, B, N, M, COMM,DOT, SLS2, RSFT,L1, + LGUI,LALT, SPC4, RALT,RGUI), + + [1] = UNIMAP_HHKB( + PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS, TRNS, + TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, PENT, + TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN, TRNS,TRNS, + TRNS,TRNS, TRNS, TRNS,TRNS), + + [2] = UNIMAP_HHKB( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, + LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, + LSFT, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, TRNS, RSFT,TRNS, + LGUI,LALT, SPC, RALT,RGUI), + + [3] = UNIMAP_HHKB( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + APSW,NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BACK,FRWD, APSW, + LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT, + LSFT, NO, NO, NO, NO, BTN3,BTN2,BTN1,BACK,FRWD,NO, RSFT,TRNS, + LGUI,LALT, BTN1, TRNS,TRNS), + + [4] = UNIMAP_HHKB( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + APSW,NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5, APSW, + LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, + LSFT, NO, NO, NO, NO, BTN3,BTN2,BTN1,BACK,FRWD,NO, RSFT,TRNS, + TRNS,TRNS, TRNS, TRNS,TRNS), +}; + + + +/* + * Macro definition + */ +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch (id) { + case HELLO: + return (record->event.pressed ? + MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) : + MACRO_NONE ); + case VOLUP: + return (record->event.pressed ? + MACRO( D(VOLU), U(VOLU), END ) : + MACRO_NONE ); + case ALT_TAB: + return (record->event.pressed ? + MACRO( D(LALT), D(TAB), END ) : + MACRO( U(TAB), END )); + } + return MACRO_NONE; +} + + + +/* + * user defined action function + */ +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + if (record->event.pressed) dprint("P"); else dprint("R"); + dprintf("%d", record->tap.count); + if (record->tap.interrupted) dprint("i"); + dprint("\n"); + + switch (id) { + case LSHIFT_LPAREN: + // Shift parentheses example: LShft + tap '(' + // http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses + // http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899 + if (record->event.pressed) { + if (record->tap.count > 0 && !record->tap.interrupted) { + if (record->tap.interrupted) { + dprint("tap interrupted\n"); + register_mods(MOD_BIT(KC_LSHIFT)); + } + } else { + register_mods(MOD_BIT(KC_LSHIFT)); + } + } else { + if (record->tap.count > 0 && !(record->tap.interrupted)) { + add_weak_mods(MOD_BIT(KC_LSHIFT)); + send_keyboard_report(); + register_code(KC_9); + unregister_code(KC_9); + del_weak_mods(MOD_BIT(KC_LSHIFT)); + send_keyboard_report(); + record->tap.count = 0; // ad hoc: cancel tap + } else { + unregister_mods(MOD_BIT(KC_LSHIFT)); + } + } + break; + } +} diff --git a/keyboard/hhkb/unimap_hhkb.c b/keyboard/hhkb/unimap_hhkb.c index de3a672e..6ace66c2 100644 --- a/keyboard/hhkb/unimap_hhkb.c +++ b/keyboard/hhkb/unimap_hhkb.c @@ -14,32 +14,28 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "unimap_common.h" +#include "unimap_trans.h" -#define AC_FN0 ACTION_LAYER_MOMENTARY(1) +#define AC_L1 ACTION_LAYER_MOMENTARY(1) + #ifdef KEYMAP_SECTION_ENABLE const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = { #else const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = { #endif - UNIMAP( - NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, - NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, - ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, NO, NO, NO, NO, NO, NO, NO, - TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC, NO, NO, NO, NO, NO, NO, NO, - LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NO, ENT, NO, NO, NO, NO, - LSFT,NO, Z, X, C, V, B, N, M, COMM,DOT, SLSH, NO, RSFT, NO, NO, NO, NO, NO, - NO, LGUI,LALT,NO, SPC, NO, NO, RALT,RGUI,NO, FN0, NO, NO, NO, NO, NO, NO - ), - UNIMAP( - TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, - TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, - PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, - CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, - TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, TRNS,PENT, TRNS,TRNS,TRNS,TRNS, - TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN, TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, - TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS, TRNS,TRNS - ), + [0] = UNIMAP_HHKB( + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, + LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT,L1, + LALT,LGUI, SPC, RGUI,RALT), + + [1] = UNIMAP_HHKB( + PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS, TRNS, + TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, PENT, + TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN, TRNS,TRNS, + TRNS,TRNS, TRNS, TRNS,TRNS), }; diff --git a/keyboard/hhkb/unimap_jp.c b/keyboard/hhkb/unimap_jp.c index 7a5f0003..3fdd8e58 100644 --- a/keyboard/hhkb/unimap_jp.c +++ b/keyboard/hhkb/unimap_jp.c @@ -14,32 +14,30 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "unimap_common.h" +#include "unimap_trans.h" -#define AC_FN0 ACTION_LAYER_MOMENTARY(1) +#define AC_L1 ACTION_LAYER_MOMENTARY(1) + #ifdef KEYMAP_SECTION_ENABLE const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = { #else const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = { #endif - UNIMAP( - NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, - ZKHK, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, - ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, NO, NO, NO, NO, NO, NO, NO, - TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, NO, NO, NO, NO, NO, NO, NO, NO, - LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, NO, NO, NO, NO, - LSFT,NO, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, NO, NO, NO, NO, - FN0, LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,NO, NO, FN0, LEFT,DOWN,RGHT, NO, NO, NO + [0] = UNIMAP_JP( + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS, ENT, + LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, UP, RSFT, + L1, ZKHK,LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,L1, LEFT,DOWN,RGHT ), - UNIMAP( - TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, - TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, - PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, - CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, - TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, TRNS,PENT, TRNS,TRNS,TRNS,TRNS, - TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN, TRNS,TRNS, PGUP, TRNS,TRNS,TRNS,TRNS, - TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, HOME,PGDN,END, TRNS, TRNS,TRNS + + [1] = UNIMAP_JP( + PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS, + TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS, PENT, + TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,PGUP,TRNS, + TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,HOME,PGDN,END ), }; diff --git a/keyboard/hhkb/unimap_common.h b/keyboard/hhkb/unimap_trans.h similarity index 76% rename from keyboard/hhkb/unimap_common.h rename to keyboard/hhkb/unimap_trans.h index 6589e4a1..40b8aa01 100644 --- a/keyboard/hhkb/unimap_common.h +++ b/keyboard/hhkb/unimap_trans.h @@ -14,14 +14,57 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef UNIMAP_COMMON_H -#define UNIMAP_COMMON_H +#ifndef UNIMAP_TRANS_H +#define UNIMAP_TRANS_H #include -#include +#include +#include "keycode.h" +#include "action.h" +#include "action_code.h" +#include "action_layer.h" +#include "action_macro.h" +#include "action_util.h" +#include "report.h" +#include "host.h" +#include "print.h" +#include "debug.h" #include "unimap.h" +#define UNIMAP_HHKB( \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K74,K2A, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K31, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K28, \ + K79, K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K7D,K7C, \ + K7A,K7B, K2C, K7F,K7E \ +) UNIMAP( \ + NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \ + NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K74,K2A, NO, NO, NO, NO, NO, NO, NO, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K31, NO, NO, NO, NO, NO, NO, NO, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, NO, K28, NO, NO, NO, NO, \ + K79,NO, K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, NO, K7D, NO, NO, NO, NO, NO, \ + NO, K7B,K7A,NO, K2C, NO, NO, K7E,K7F,NO, K7C, NO, NO, NO, NO, NO, NO \ +) + +#define UNIMAP_JP( \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K74,K2A, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34,K32, K28, \ + K79, K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38,K75,K52,K7D, \ + K78,K29,K7B,K7A,K77, K2C, K76,K00,K7E,K7C,K50,K51,K4F \ +) UNIMAP( \ + NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \ + K29, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K74,K2A, NO, NO, NO, NO, NO, NO, NO, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, NO, NO, NO, NO, NO, NO, NO, NO, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K32,K28, NO, NO, NO, NO, \ + K79,NO, K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K75,K7D, K52, NO, NO, NO, NO, \ + K78,K7B,K7A,K77, K2C, K76,K00,K7E,NO, NO, K7C, K50,K51,K4F, NO, NO, NO \ +) + + /* Mapping to Universal keyboard layout * * Universal keyboard layout