summaryrefslogtreecommitdiffstats
path: root/users/mtdjr/mtdjr.c
blob: ac5c5911ff60a5397270371cc634830f4d804d3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include "mtdjr.h"

#ifdef SOLENOID_ENABLE
  #include "solenoid.h"
#endif

#ifndef RGB_MODE
  #define RGB_MODE 16
#endif
#ifndef RGB_HUE
  #define RGB_HUE 285
#endif

// Tap Dance Definitions
qk_tap_dance_action_t tap_dance_actions[] = {
  [TD_ESC]     = ACTION_TAP_DANCE_DOUBLE(KC_GRV, KC_ESC),
  [TD_ALTLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_RALT, LGUI(KC_L)),
  [TD_ENDLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_END, LGUI(KC_L)),
  [TD_PRINT]   = ACTION_TAP_DANCE_DOUBLE(LGUI(LSFT(KC_3)), LGUI(LSFT(KC_4))),
};

// Macros
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
  if (record->event.pressed) {
      switch(id) {
          case ROOT:
              SEND_STRING("sudo su -\n");
              return false; break;
          case PPLY:
              SEND_STRING("puppet apply /etc/puppetlabs/code/environments/production/manifests/site.pp\n");
              return false; break;
          case PSEF:
              SEND_STRING("ps -ef | grep ");
              return false; break;
      }
  }
  return MACRO_NONE;
};

void matrix_init_user(void) {
  #ifdef RGBLIGHT_ENABLE
    rgblight_enable_noeeprom();
    rgblight_mode_noeeprom(RGB_MODE);
    rgblight_sethsv (RGB_HUE, 255, 255);
  #endif
  #ifdef SOLENOID_ENABLE
    solenoid_setup();
  #endif
}

void matrix_scan_user(void) {
  #ifdef SOLENOID_ENABLE
    solenoid_check();
  #endif
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  #ifdef SOLENOID_ENABLE
    if (record->event.pressed) {
      solenoid_fire();
    }
  #endif
  switch (keycode) {
    case QWERTY:
      if (record->event.pressed) {
        set_single_persistent_default_layer(_QWERTY);
      }
      return false;
      break;
    case LOWER:
      if (record->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);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      } else {
        layer_off(_ADJUST);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      }
      return false;
      break;
    case SOLENOID_TOG:
      #ifdef SOLENOID_ENABLE
        if (record->event.pressed) {
          solenoid_toggle();
        }
      #endif
      break;
    case SOLENOID_DWELL_MINUS:
      #ifdef SOLENOID_ENABLE
        if (record->event.pressed) {
          solenoid_dwell_minus();
        }
      #endif
      break;
    case SOLENOID_DWELL_PLUS:
      #ifdef SOLENOID_ENABLE
        if (record->event.pressed) {
          solenoid_dwell_plus();
        }
        #endif
      break;
    case SOLENOID_BUZZ_ON:
      #ifdef SOLENOID_ENABLE
        if (record->event.pressed) {
          solenoid_buzz_on();
        }
      #endif
      break;
    case SOLENOID_BUZZ_OFF:
      #ifdef SOLENOID_ENABLE
        if (record->event.pressed) {
          solenoid_buzz_off();
        }
      #endif
      break;
  }
  return true;
};

uint32_t layer_state_set_user(uint32_t state) {
#ifdef RGBLIGHT_ENABLE
  switch (biton32(state)) {
    case _RAISE:
      rgblight_sethsv_noeeprom (240, 255, 255);
      break;
    case _LOWER:
      rgblight_sethsv_noeeprom (0, 255, 255);
      break;
    case _ADJUST:
      rgblight_sethsv_noeeprom (0, 0, 255);
      break;
    default:
      rgblight_sethsv_noeeprom (RGB_HUE, 255, 255);
      break;
    }
  return state;
#endif
}