2018-08-11


#include "iris.h"
#include "action_layer.h"
#include "eeconfig.h"

extern keymap_config_t keymap_config;

#define _QWERTY 0
#define _LOWER 1
#define _RAISE 2
#define _NUMPAD 4
#define _MOUSECURSOR 8
#define _ADJUST 16

enum custom_keycodes {
  QWERTY = SAFE_RANGE,
  LOWER,
  RAISE,
  NUMPAD,
  MOUSECURSOR,
  ADJUST,
};

/* Tap Dance */
enum {
  TD_LGUIESC=0,
  TD_LGUIAPP,
  TD_LALTAPP,
  TD_SHIFTCAPS
};


#define KC_ KC_TRNS
#define _______ KC_TRNS

#define KC_LOWR LOWER
#define KC_RASE RAISE
#define KC_RST RESET
#define KC_BL_S BL_STEP
#define KC_DBUG DEBUG
#define KC_RTOG RGB_TOG
#define KC_RMOD RGB_MOD
#define KC_RHUI RGB_HUI
#define KC_RHUD RGB_HUD
#define KC_RSAI RGB_SAI
#define KC_RSAD RGB_SAD
#define KC_RVAI RGB_VAI
#define KC_RVAD RGB_VAD
#define KC_MCPW KC_POWER
#define KC_MCVU KC__VOLUP
#define KC_MCVD KC__VOLDOWN

#define KC_BSGU MT(MOD_LGUI, KC_BSPC) // tap BackSpace , Hold RGUI
#define KC_BSAL MT(MOD_LALT, KC_BSPC) // tap BackSpace , Hold LALT
#define KC_TBAL MT(MOD_LALT, KC_TAB) // tap TAB , Hold LALT
#define KC_SLGU MT(MOD_LGUI, KC_SLSH) // tap Slash , Hold LGUI
#define KC_DOAL MT(MOD_LALT, KC_DOT) // tap Dot , Hold LALT
#define KC_COCT MT(MOD_LCTL, KC_COMM) // tap Comma , Hold LCTL
#define KC_BLRS MT(MOD_RSFT, KC_BSLS) // tap BackSlash , Hold RSFT
#define KC_SPAT MT(MOD_LALT, KC_SPC) // tap Space , Hold LALT
#define KC_ESCT MT(MOD_LCTL, KC_ESC) // tap Escape , Hold LCTL
#define KC_TBCT MT(MOD_LCTL, KC_TAB) // tap TAB , Hold LCTL

#define KC_CMZ LGUI(KC_Z)
#define KC_CMX LGUI(KC_X)
#define KC_CMC LGUI(KC_C)
#define KC_CMV LGUI(KC_V)
#define KC_CADL ALTG(KC_DEL)
#define KC_STAB S(KC_TAB)


#define KC_SPLW LT(_LOWER,KC_SPC) // tap Space , Hold LowerLayer
#define KC_ENLW LT(_LOWER,KC_ENTER) // tap Enter , Hold LowerLayer
#define KC_ESRA LT(_RAISE,KC_ESC) // tap ESC , Hold RaiseLayer
#define KC_DLRA LT(_RAISE,KC_DEL) // tap ESC , Hold RaiseLayer
#define KC_NPD TT(_NUMPAD) // tap Momentary NUMPAD , DualTap toggle NUMPAD
#define KC_MSC TT(_MOUSECURSOR) // tap Momentary NUMPAD , DualTap toggle numpad

/* Tap Dance */
#define KC_LGES TD(TD_LGUIESC)
#define KC_LGAP TD(TD_LGUIAPP)
#define KC_LAAP TD(TD_LALTAPP)
#define KC_SHCL TD(TD_SHIFTCAPS)

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {


  [_QWERTY] = LAYOUT_kc(
  //,----+----+----+----+----+----.              ,----+----+----+----+----+----.
     GRV , 1  , 2  , 3  , 4  , 5  ,                6  , 7  , 8  , 9  , 0  ,MINS,
  //|----+----+----+----+----+----|              |----+----+----+----+----+----|
     TBAL, Q  , W  , E  , R  , T  ,                Y  , U  , I  , O  , P  ,EQL ,
  //|----+----+----+----+----+----|              |----+----+----+----+----+----|
     LCTL, A  , S  , D  , F  , G  ,                H  , J  , K  , L  ,SCLN,QUOT,
  //|----+----+----+----+----+----+----.    ,----|----+----+----+----+----+----|
     SHCL, Z  , X  , C  , V  , B  ,ESRA,     RASE, N  , M  ,COCT,DOAL,SLGU,BLRS,
  //`----+----+----+--+-+----+----+----/    \----+----+----+----+----+----+----'
                       LAAP,SPLW,TBCT,         BSAL,ENLW,LGES
  //                  `----+----+----'        `----+----+----'
  ),


  [_LOWER] = LAYOUT_kc(
  //,----+----+----+----+----+----.              ,----+----+----+----+----+----.
     ESC ,EXLM, AT ,HASH,DLR ,PERC,               CIRC,AMPR,ASTR,LPRN,RPRN,DEL ,
  //|----+----+----+----+----+----|              |----+----+----+----+----+----|
         ,TILD,UNDS,PLUS,PIPE,LABK,               RABK,PGUP, UP ,PGDN,HOME,BSPC,
  //|----+----+----+----+----+----|              |----+----+----+----+----+----|
         ,GRV ,MINS,EQL ,BSLS,LBRC,               RBRC,LEFT,DOWN,RGHT,END ,ENT ,
  //|----+----+----+----+----+----+----.    ,----|----+----+----+----+----+----|
         , RO ,JYEN,QUES,LPRN,LCBR,TAB ,         ,RCBR,RPRN,    ,    ,    ,    ,
  //`----+----+----+--+-+----+----+----/    \----+----+----+----+----+----+----'
                       LGUI,    ,ESC ,         DEL ,    ,NPD
  //                  `----+----+----'        `----+----+----'
  ),


  [_RAISE] = LAYOUT_kc(
  //,----+----+----+----+----+----.              ,----+----+----+----+----+----.
     F12 , F1 , F2 , F3 , F4 , F5 ,                F6 , F7 , F8 , F9 ,F10 ,F11 ,
  //|----+----+----+----+----+----|              |----+----+----+----+----+----|
     CADL, 1  , 2  , 3  , 4  , 5  ,                6  , 7  , 8  , 9  , 0  ,BSPC,
  //|----+----+----+----+----+----+              |----+----+----+----+----+----|
         ,EXLM, AT ,HASH,DLR ,PERC,               CIRC,AMPR,ASTR,LPRN,RPRN,ENT ,
  //|----+----+----+----+----+----|----.    ,----|----+----+----+----+----+----|
     MUTE,PLUS,MINS,EQL ,BSLS,QUOT,    ,         ,DQUO,SLSH,    ,    ,    ,PSCR,
  //`----+----+----+--+-+----+----+----/    \----+----+----+----+----+----+----'
                           ,SPC ,TAB ,         BSPC,ENT ,MSC
  //                  `----+----+----'        `----+----+----'
  ),

  [_NUMPAD] = LAYOUT_kc(
  //,----+----+----+----+----+----.              ,----+----+----+----+----+----.
     ESC ,    ,    ,    ,    ,    ,                   , P7 , P8 , P9 ,PMNS,DEL ,
  //|----+----+----+----+----+----|              |----+----+----+----+----+----|
         ,HOME,PGUP, UP ,PGDN,LABK,               RABK, P4 , P5 , P6 ,PPLS,BSPC,
  //|----+----+----+----+----+----|              |----+----+----+----+----+----|
         ,END ,LEFT,DOWN,RGHT,LPRN,               RPRN, P1 , P2 , P3 ,PAST,COLN,
  //|----+----+----+----+----+----+----.    ,----|----+----+----+----+----+----|
         ,    ,    ,    ,    ,STAB,NLCK,      P0 ,EQL , P0 ,COMM,DOT ,PSLS,PENT,
  //`----+----+----+--+-+----+----+----/    \----+----+----+----+----+----+----'
                           ,    ,    ,             ,    ,
  //                  `----+----+----'        `----+----+----'
  ),

  [_MOUSECURSOR] = LAYOUT_kc(
  //,----+----+----+----+----+----.              ,----+----+----+----+----+----.
         ,    ,    ,    ,    ,    ,                   ,    ,    ,    ,    ,    ,
  //|----+----+----+----+----+----|              |----+----+----+----+----+----|
         ,HOME,PGUP, UP ,PGDN,    ,               WH_D,WH_R,MS_U,ACL0,ACL1,ACL2,
  //|----+----+----+----+----+----|              |----+----+----+----+----+----|
         ,END ,LEFT,DOWN,RGHT,    ,               WH_L,MS_L,MS_D,MS_R,BTN1,BTN2,
  //|----+----+----+----+----+----+----.    ,----|----+----+----+----+----+----|
         ,    ,    ,    ,    ,    ,    ,         ,WH_U,LEFT,DOWN, UP ,RGHT,BTN3,
  //`----+----+----+----+----+----+----/    \----+----+----+----+----+----+----'
                           ,    ,    ,             ,    ,
  //                  `----+----+----'        `----+----+----'
),


  [_ADJUST] = LAYOUT_kc(
  //,----+----+----+----+----+----.              ,----+----+----+----+----+----.
     RST ,MUTE,VOLD,VOLU,    ,    ,                   ,    ,    ,    ,    ,    ,
  //|----+----+----+----+----+----|              |----+----+----+----+----+----|
         ,    ,    ,    ,    ,    ,               RTOG,RMOD,RHUI,RSAI,RVAI,    ,
  //|----+----+----+----+----+----|              |----+----+----+----+----+----|
     MCPW,EJCT,MCVD,MCVU,    ,    ,                   ,DBUG,RHUD,RSAD,RVAD,    ,
  //|----+----+----+----+----+----+----.    ,----|----+----+----+----+----+----|
     MUTE,    ,VOLD,VOLU,    ,    ,    ,         ,    ,    ,    ,    ,    ,BL_S,
  //`----+----+----+--+-+----+----+----/    \----+----+----+----+----+----+----'
                           ,    ,    ,             ,    ,
  //                  `----+----+----'        `----+----+----'
  )

};


/* TAP DANCE */
void shift_caps_down (qk_tap_dance_state_t *state, void *user_data) {
  if (state->count >= 3) {
    register_code (KC_CAPS);
  } else {
    register_code (KC_LSFT);
  }
}

void shift_caps_up (qk_tap_dance_state_t *state, void *user_data) {
  if (state->count >= 3) {
    unregister_code (KC_CAPS);
  } else {
    unregister_code (KC_LSFT);
  }
}


qk_tap_dance_action_t tap_dance_actions[] = {

  // Tap once for L-GUI(Windows), twice for R-GUI(APP)
        [TD_LGUIESC] = ACTION_TAP_DANCE_DOUBLE(KC_LGUI, KC_ESC),
  // Tap once for L-GUI(Windows), twice for R-GUI(APP)
        [TD_LGUIAPP] = ACTION_TAP_DANCE_DOUBLE(KC_LGUI, KC_APP),
  // Tap once for R-Alt, twice for R-GUI
        [TD_LALTAPP] = ACTION_TAP_DANCE_DOUBLE(KC_LALT, KC_APP),
  // Tap once for Left Shift , trice for CAPS Lock
        [TD_SHIFTCAPS] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, shift_caps_down, shift_caps_up)
};

/* END TAP DANCE */


void persistent_default_layer_set(uint16_t default_layer) {
  eeconfig_update_default_layer(default_layer);
  default_layer_set(default_layer);
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case QWERTY:
      if (record->event.pressed) {
        persistent_default_layer_set(1UL<<_qwerty break="" case="" false="" if="" lower:="" record-="" return="">event.pressed) {
        layer_on(_LOWER);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      } else {
        layer_off(_LOWER);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      }
      return false;
      break;
    case RAISE:
      if (record->event.pressed) {
        layer_on(_RAISE);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      } else {
        layer_off(_RAISE);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      }
      return false;
      break;
    case ADJUST:
      if (record->event.pressed) {
        layer_on(_ADJUST);
      } else {
        layer_off(_ADJUST);
      }
      return false;
      break;
  }
  return true;
}



0 コメント:

自己紹介

自分の写真
東京都, Japan
憂鬱な凍死家です。こちらではmixiとは異なり固めの話題中心です。

Total Page View

Categories

Powered by Blogger.

Popular Posts

Blog Archive