1
0
Fork 0

Update to drashna keymaps (#4)

* Minor updates to keymaps

* Minor updates to keymaps
This commit is contained in:
Drashna Jaelre 2017-11-17 11:59:54 -08:00 committed by Jack Humbert
parent 1d703a476a
commit dbd33782f2
11 changed files with 352 additions and 497 deletions

View file

@ -13,5 +13,6 @@
#define RGBLIGHT_EFFECT_BREATHE_CENTER 1 #define RGBLIGHT_EFFECT_BREATHE_CENTER 1
#endif // RGBLIGHT_ENABLE #endif // RGBLIGHT_ENABLE
#define FORCE_NKRO
#endif #endif

View file

@ -32,125 +32,17 @@ bool skip_leds = false;
#ifdef TAP_DANCE_ENABLE #ifdef TAP_DANCE_ENABLE
#define KC_D3_1 TD(TD_D3_1)
//define diablo macro timer variables #define KC_D3_2 TD(TD_D3_2)
static uint16_t diablo_timer[4]; #define KC_D3_3 TD(TD_D3_3)
static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 }; #define KC_D3_4 TD(TD_D3_4)
static uint8_t diablo_key_time[4]; #else
#define KC_D3_1 KC_1
bool check_dtimer(uint8_t dtimer) { #define KC_D3_2 KC_2
// has the correct number of seconds elapsed (as defined by diablo_times) #define KC_D3_3 KC_3
return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true; #define KC_D3_4 KC_4
};
enum {
TD_FLSH = 0,
TD_DIABLO_1,
TD_DIABLO_2,
TD_DIABLO_3,
TD_DIABLO_4
};
// on each tap, light up one led, from right to left
// on the forth tap, turn them off from right to left
void dance_flsh_each(qk_tap_dance_state_t *state, void *user_data) {
if (!skip_leds) {
ergodox_board_led_off();
ergodox_right_led_1_off();
ergodox_right_led_2_off();
ergodox_right_led_3_off();
skip_leds = true;
}
switch (state->count) {
case 1:
ergodox_right_led_1_on();
break;
case 2:
ergodox_right_led_2_on();
break;
case 3:
ergodox_right_led_3_on();
break;
case 4:
ergodox_right_led_1_off();
_delay_ms(50);
ergodox_right_led_2_off();
_delay_ms(50);
ergodox_right_led_3_off();
}
}
// on the fourth tap, set the keyboard on flash state
// and set the underglow to red, because red == bad
void dance_flsh_finished(qk_tap_dance_state_t *state, void *user_data) {
if (state->count >= 4) {
#ifdef RGBLIGHT_ENABLE
rgblight_enable();
rgblight_mode(1);
rgblight_setrgb(0xff, 0x00, 0x00);
#endif #endif
reset_tap_dance(state);
reset_keyboard();
}
}
// Cycle through the times for the macro, starting at 0, for disabled.
// Max of six values, so don't exceed
void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
if (state->count >= 7) {
diablo_key_time[diablo_key] = diablo_times[0];
reset_tap_dance(state);
}
else {
diablo_key_time[diablo_key] = diablo_times[state->count - 1];
}
}
// Would rather have one function for all of this, but no idea how to do that...
void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 0);
}
void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 1);
}
void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 2);
}
void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 3);
}
// if the flash state didnt happen, then turn off leds, left to right
void dance_flsh_reset(qk_tap_dance_state_t *state, void *user_data) {
_delay_ms(200);
ergodox_right_led_3_off();
_delay_ms(200);
ergodox_right_led_2_off();
_delay_ms(200);
ergodox_right_led_1_off();
_delay_ms(500);
skip_leds = false;
}
//Tap Dance Definitions
qk_tap_dance_action_t tap_dance_actions[] = {
//Once for Blue, Twice for Green, Thrice for Red, and four to flash
[TD_FLSH] = ACTION_TAP_DANCE_FN_ADVANCED(dance_flsh_each, dance_flsh_finished, dance_flsh_reset),
// tap once to disable, and more to enable timed micros
[TD_DIABLO_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
[TD_DIABLO_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
[TD_DIABLO_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
[TD_DIABLO_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
};
#endif
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Basic layer /* Keymap 0: Basic layer
@ -430,9 +322,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/ */
[_DIABLO] = LAYOUT_ergodox( [_DIABLO] = LAYOUT_ergodox(
KC_ESCAPE, KC_V, KC_D, KC_LALT, KC_NO, KC_NO, KC_NO, KC_ESCAPE, KC_V, KC_D, KC_LALT, KC_NO, KC_NO, KC_NO,
KC_TAB, KC_S, KC_F, KC_I, KC_M, KC_T, KC_TRNS, KC_TAB, KC_S, KC_I, KC_F, KC_M, KC_T, KC_TRNS,
KC_Q, KC_1, KC_2, KC_3, KC_4, KC_G, KC_Q, KC_1, KC_2, KC_3, KC_4, KC_G,
KC_LCTL, TD(TD_DIABLO_1), TD(TD_DIABLO_2), TD(TD_DIABLO_3), TD(TD_DIABLO_4), KC_Z, KC_NO, KC_LCTL, KC_D3_1, KC_D3_2, KC_D3_3, KC_D3_4, KC_Z, KC_NO,
KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
KC_L, KC_J, KC_L, KC_J,
KC_F, KC_F,
@ -499,44 +391,6 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
return true; return true;
} }
#ifdef TAP_DANCE_ENABLE
// Sends the key press to system, but only if on the Diablo layer
void send_diablo_keystroke(uint8_t diablo_key) {
if (biton32(layer_state) == _DIABLO) {
switch (diablo_key) {
case 0:
SEND_STRING("1");
break;
case 1:
SEND_STRING("2");
break;
case 2:
SEND_STRING("3");
break;
case 3:
SEND_STRING("4");
break;
}
}
}
// Checks each of the 4 timers/keys to see if enough time has elapsed
// Runs the "send string" command if enough time has passed, and resets the timer.
void run_diablo_macro_check(void) {
uint8_t dtime;
for (dtime = 0; dtime < 4; dtime++) {
if (check_dtimer(dtime) && diablo_key_time[dtime]) {
diablo_timer[dtime] = timer_read();
send_diablo_keystroke(dtime);
}
}
}
#endif
void matrix_init_keymap(void) { // Runs boot tasks for keyboard void matrix_init_keymap(void) { // Runs boot tasks for keyboard
}; };
@ -566,9 +420,5 @@ void matrix_scan_keymap(void) { // runs frequently to update info
} }
// Run Diablo 3 macro checking code.
#ifdef TAP_DANCE_ENABLE
run_diablo_macro_check();
#endif
}; };

View file

@ -24,6 +24,7 @@
#endif // TAP_DANCE_ENABLE #endif // TAP_DANCE_ENABLE
#define B5_AUDIO
#ifdef RGBLIGHT_ENABLE #ifdef RGBLIGHT_ENABLE
@ -38,6 +39,6 @@
#define RGBLIGHT_EFFECT_BREATHE_CENTER 1 #define RGBLIGHT_EFFECT_BREATHE_CENTER 1
#endif // RGBLIGHT_ENABLE #endif // RGBLIGHT_ENABLE
#define FORCE_NKRO
#endif #endif

View file

@ -24,78 +24,23 @@
// Fillers to make layering more clear // Fillers to make layering more clear
#define _______ KC_TRNS #define _______ KC_TRNS
#define XXXXXXX KC_NO #define XXXXXXX KC_NO
#ifdef TAP_DANCE_ENABLE
#define KC_D3_1 TD(TD_D3_1)
#define KC_D3_2 TD(TD_D3_2)
#define KC_D3_3 TD(TD_D3_3)
#define KC_D3_4 TD(TD_D3_4)
#else
#define KC_D3_1 KC_1
#define KC_D3_2 KC_2
#define KC_D3_3 KC_3
#define KC_D3_4 KC_4
#endif
//define layer change stuff for underglow indicator //define layer change stuff for underglow indicator
bool skip_leds = false; bool skip_leds = false;
#ifdef TAP_DANCE_ENABLE
//define diablo macro timer variables
static uint16_t diablo_timer[4];
static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
static uint8_t diablo_key_time[4];
bool check_dtimer(uint8_t dtimer) {
// has the correct number of seconds elapsed (as defined by diablo_times)
return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true;
};
#endif
#ifdef TAP_DANCE_ENABLE
enum {
TD_D3_1 = 0,
TD_D3_2,
TD_D3_3,
TD_D3_4
};
// Cycle through the times for the macro, starting at 0, for disabled.
// Max of six values, so don't exceed
void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
if (state->count >= 7) {
diablo_key_time[diablo_key] = diablo_times[0];
reset_tap_dance(state);
}
else {
diablo_key_time[diablo_key] = diablo_times[state->count - 1];
}
}
// Would rather have one function for all of this, but no idea how to do that...
void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 0);
}
void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 1);
}
void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 2);
}
void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 3);
}
//Tap Dance Definitions
qk_tap_dance_action_t tap_dance_actions[] = {
// tap once to disable, and more to enable timed micros
[TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
[TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
[TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
[TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
};
#endif
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_NUMLOCK] = KEYMAP( /* Base */ [_NUMLOCK] = KEYMAP( /* Base */
@ -112,29 +57,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_END, KC_DOWN, KC_PGDN, _______, \ KC_END, KC_DOWN, KC_PGDN, _______, \
KC_INS, KC_DEL, _______, _______ \ KC_INS, KC_DEL, _______, _______ \
), ),
#ifdef TAP_DANCE_ENABLE
[_DIABLO] = KEYMAP( /* Base */ [_DIABLO] = KEYMAP( /* Base */
KC_ESC, _______, _______, _______,\ KC_ESC, _______, XXXXXXX, _______,\
KC_S, KC_F, KC_I, KC_M, \ KC_S, KC_I, KC_F, KC_M, \
KC_1, KC_2, KC_3, KC_4, \ KC_1, KC_2, KC_3, KC_4, \
TD(TD_D3_1), TD(TD_D3_2), TD(TD_D3_3), TD(TD_D3_4), \ KC_D3_1, KC_D3_2, KC_D3_3, KC_D3_4, \
_______, KC_DIABLO_CLEAR, KC_Q, SFT_T(KC_SPACE) \ XXXXXXX, KC_DIABLO_CLEAR, KC_Q, SFT_T(KC_SPACE) \
), ),
#else
[_DIABLO] = KEYMAP( /* Base */
KC_ESC, _______, _______, _______,\
KC_S, KC_F, KC_I, KC_M, \
KC_1, KC_2, KC_3, KC_4, \
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
_______, KC_DIABLO_CLEAR, KC_Q, SFT_T(KC_SPACE) \
),
#endif
[_MACROS] = KEYMAP( /* Base */ [_MACROS] = KEYMAP( /* Base */
KC_OVERWATCH, _______, _______, XXXXXXX,\ KC_OVERWATCH, XXXXXXX, _______, XXXXXXX,\
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ KC_JUSTGAME, XXXXXXX, XXXXXXX, KC_C9, \
XXXXXXX, XXXXXXX, XXXXXXX, KC_JUSTGAME, \ XXXXXXX, XXXXXXX, KC_AIM, KC_GGEZ, \
KC_SYMM, KC_TORB, XXXXXXX, KC_GOODGAME, \ KC_SYMM, KC_TORB, XXXXXXX, KC_GOODGAME, \
KC_SALT, KC_MORESALT, KC_SALTHARD, KC_GLHF \ KC_SALT, KC_MORESALT, KC_SALTHARD, KC_GLHF \
), ),
@ -142,8 +76,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_RESET, KC_MUTE, KC_VOLD, KC_VOLU,\ KC_RESET, KC_MUTE, KC_VOLD, KC_VOLU,\
KC_MAKE, _______, RGB_HUI, RGB_HUD, \ KC_MAKE, _______, RGB_HUI, RGB_HUD, \
KC_MPLY, KC_MSTP, KC_MPRV, KC_MNXT, \ KC_MPLY, KC_MSTP, KC_MPRV, KC_MNXT, \
RGB_TOG, RGB_MOD, RGB_SAI, RGB_VAI, \ RGB_TOG, RGB_SMOD, RGB_SAI, RGB_VAI, \
_______, _______, RGB_SAD, RGB_VAD \ _______, KC_RGB_T, RGB_SAD, RGB_VAD \
), ),
}; };
@ -158,60 +92,7 @@ void numlock_led_off(void) {
} }
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
#ifdef TAP_DANCE_ENABLE
case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
if (record->event.pressed) {
uint8_t dtime;
for (dtime = 0; dtime < 4; dtime++) {
diablo_key_time[dtime] = diablo_times[0];
}
}
return false;
break;
#endif
}
return true;
}
#ifdef TAP_DANCE_ENABLE
// Sends the key press to system, but only if on the Diablo layer
void send_diablo_keystroke(uint8_t diablo_key) {
if (biton32(layer_state) == _DIABLO) {
switch (diablo_key) {
case 0:
SEND_STRING("1");
break;
case 1:
SEND_STRING("2");
break;
case 2:
SEND_STRING("3");
break;
case 3:
SEND_STRING("4");
break;
}
}
}
// Checks each of the 4 timers/keys to see if enough time has elapsed
// Runs the "send string" command if enough time has passed, and resets the timer.
void run_diablo_macro_check(void) {
uint8_t dtime;
for (dtime = 0; dtime < 4; dtime++) {
if (check_dtimer(dtime) && diablo_key_time[dtime]) {
diablo_timer[dtime] = timer_read();
send_diablo_keystroke(dtime);
}
}
}
#endif
void matrix_init_keymap(void) { void matrix_init_keymap(void) {
// set Numlock LED to output and low // set Numlock LED to output and low
DDRF |= (1 << 7); DDRF |= (1 << 7);
@ -226,13 +107,10 @@ void matrix_init_keymap(void) {
void matrix_scan_keymap(void) { void matrix_scan_keymap(void) {
numlock_led_off(); numlock_led_off();
if ((is_overwatch && biton32(layer_state) == _MACROS) || (biton32(layer_state) == _NAV)) { if ((is_overwatch && biton32(layer_state) == _MACROS) || (biton32(layer_state) == _NUMLOCK)) {
numlock_led_on(); numlock_led_on();
} }
// Run Diablo 3 macro checking code. // Run Diablo 3 macro checking code.
#ifdef TAP_DANCE_ENABLE
run_diablo_macro_check();
#endif
} }

View file

@ -1,10 +1,10 @@
TAP_DANCE_ENABLE = yes TAP_DANCE_ENABLE = yes
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend COMMAND_ENABLE = no # Commands for debug and configuration
COMMAND_ENABLE = yes # Commands for debug and configuration
RGBLIGHT_ENABLE = yes RGBLIGHT_ENABLE = yes
MIDI_ENABLE = no MIDI_ENABLE = no
CONSOLE_ENABLE = no CONSOLE_ENABLE = no
NKRO_ENABLE = yes NKRO_ENABLE = yes
MOUSEKEY_ENABLE = no
EXTRAFLAGS = -flto EXTRAFLAGS = -flto

View file

@ -61,7 +61,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_LOWER] = KEYMAP(\ [_LOWER] = KEYMAP(\
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \ KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F11, XXXXXXX, KC_F12, _______, XXXXXXX, KC_RCTL, XXXXXXX, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \ KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F11, XXXXXXX, KC_F12, _______, XXXXXXX, KC_RCTL, XXXXXXX, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
TD(TD_FLSH),KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______, _______, _______, _______, _______, _______, XXXXXXX, KC_HOME, KC_COMM, KC_DOT, KC_END, _______ \ _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______, _______, _______, _______, _______, _______, XXXXXXX, KC_HOME, KC_COMM, KC_DOT, KC_END, _______ \
), ),
[_RAISE] = KEYMAP(\ [_RAISE] = KEYMAP(\
@ -72,15 +72,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_ADJUST] = KEYMAP(\ [_ADJUST] = KEYMAP(\
KC_MAKE,KC_RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ KC_MAKE,KC_RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, AU_ON, AU_OFF, AG_NORM, _______, XXXXXXX, _______, _______, XXXXXXX, _______, AG_SWAP, KC_QWERTY, KC_COLEMAK, KC_DVORAK, KC_WORKMAN, _______, \ RGB_SMOD,RGB_HUI, _______, AU_ON, AU_OFF, AG_NORM, _______, XXXXXXX, _______, _______, XXXXXXX, _______, AG_SWAP, KC_QWERTY, KC_COLEMAK, KC_DVORAK, KC_WORKMAN, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, MAGIC_TOGGLE_NKRO, KC_MUTE, KC_VOLD, KC_VOLU, KC_MNXT, KC_MPLY \ KC_RGB_T,RGB_HUD, MU_ON, MU_OFF, MU_TOG, MU_MOD, _______, _______, _______, _______, _______, _______, MAGIC_TOGGLE_NKRO, KC_MUTE, KC_VOLD, KC_VOLU, KC_MNXT, KC_MPLY \
) )
}; };
#ifdef FAUXCLICKY_ENABLE #ifdef FAUXCLICKY_ENABLE
float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_A4, 0.0625); // (_D4, 0.25); float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_A6, 2); // (_D4, 0.25);
float fauxclicky_released_note[2] = MUSICAL_NOTE(_A4, 0.0625); // (_C4, 0.125); float fauxclicky_released_note[2] = MUSICAL_NOTE(_A6, 2); // (_C4, 0.125);
float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C6, 0.25); // (_C4, 0.25); float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C6, 2); // (_C4, 0.25);
#endif #endif

View file

@ -42,4 +42,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGBLIGHT_EFFECT_BREATHE_CENTER 1 #define RGBLIGHT_EFFECT_BREATHE_CENTER 1
#ifdef AUDIO_ENABLE
#define C6_AUDIO
#endif
#endif #endif

View file

@ -21,74 +21,10 @@ extern keymap_config_t keymap_config;
#define MEDIA TG(_MEDIA) #define MEDIA TG(_MEDIA)
#define COVECUBE TG(_COVECUBE) #define COVECUBE TG(_COVECUBE)
enum more_custom_keycodes {
KC_KP_00 = NEW_SAFE_RANGE
#ifdef TAP_DANCE_ENABLE
//define diablo macro timer variables
static uint16_t diablo_timer[4];
static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
static uint8_t diablo_key_time[4];
bool check_dtimer(uint8_t dtimer) {
// has the correct number of seconds elapsed (as defined by diablo_times)
return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true;
}; };
enum {
TD_D3_1 = 0,
TD_D3_2,
TD_D3_3,
TD_D3_4
};
// Cycle through the times for the macro, starting at 0, for disabled.
// Max of six values, so don't exceed
void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
if (state->count >= 7) {
diablo_key_time[diablo_key] = diablo_times[0];
reset_tap_dance(state);
}
else {
diablo_key_time[diablo_key] = diablo_times[state->count - 1];
}
}
// Would rather have one function for all of this, but no idea how to do that...
void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 0);
}
void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 1);
}
void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 2);
}
void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 3);
}
//Tap Dance Definitions
qk_tap_dance_action_t tap_dance_actions[] = {
// tap once to disable, and more to enable timed micros
[TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
[TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
[TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
[TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
};
#endif
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_NUMLOCK] = KEYMAP( [_NUMLOCK] = KEYMAP(
@ -143,68 +79,22 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}; };
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
switch (keycode) { switch (keycode) {
#ifdef TAP_DANCE_ENABLE case KC_KP_00:
case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
if (record->event.pressed) { if (record->event.pressed) {
uint8_t dtime; register_code(KC_KP_0);
unregister_code(KC_KP_0);
for (dtime = 0; dtime < 4; dtime++) { register_code(KC_KP_0);
diablo_key_time[dtime] = diablo_times[0]; unregister_code(KC_KP_0);
}
} }
return false; return false;
break; break;
#endif
} }
return true; return true;
} }
#ifdef TAP_DANCE_ENABLE
// Sends the key press to system, but only if on the Diablo layer
void send_diablo_keystroke(uint8_t diablo_key) {
if (biton32(layer_state) == _DIABLO) {
switch (diablo_key) {
case 0:
SEND_STRING("1");
break;
case 1:
SEND_STRING("2");
break;
case 2:
SEND_STRING("3");
break;
case 3:
SEND_STRING("4");
break;
}
}
}
// Checks each of the 4 timers/keys to see if enough time has elapsed
// Runs the "send string" command if enough time has passed, and resets the timer.
void run_diablo_macro_check(void) {
uint8_t dtime;
for (dtime = 0; dtime < 4; dtime++) {
if (check_dtimer(dtime) && diablo_key_time[dtime]) {
diablo_timer[dtime] = timer_read();
send_diablo_keystroke(dtime);
}
}
}
#endif
void matrix_scan_keymap(void) { // runs frequently to update info
#ifdef TAP_DANCE_ENABLE
// Run Diablo 3 macro checking code.
run_diablo_macro_check();
#endif
};

View file

@ -1,4 +1,5 @@
CONSOLE_ENABLE = no CONSOLE_ENABLE = no
COMMAND_ENABLE = no # Commands for debug and configuration
TAP_DANCE_ENABLE = yes TAP_DANCE_ENABLE = yes
RGBLIGHT_ENABLE = yes RGBLIGHT_ENABLE = yes
MOUSEKEY_ENABLE = no MOUSEKEY_ENABLE = no

View file

@ -1,8 +1,84 @@
/*
Copyright 2017 Christopher Courtney <drashna@live.com> @drashna
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 <http://www.gnu.org/licenses/>.
*/
#include "drashna.h" #include "drashna.h"
#include "quantum.h" #include "quantum.h"
#include "action.h" #include "action.h"
#include "version.h" #include "version.h"
#ifdef TAP_DANCE_ENABLE
//define diablo macro timer variables
static uint16_t diablo_timer[4];
static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
static uint8_t diablo_key_time[4];
bool check_dtimer(uint8_t dtimer) {
// has the correct number of seconds elapsed (as defined by diablo_times)
return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true;
};
// Cycle through the times for the macro, starting at 0, for disabled.
// Max of six values, so don't exceed
void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
if (state->count >= 7) {
diablo_key_time[diablo_key] = diablo_times[0];
reset_tap_dance(state);
}
else {
diablo_key_time[diablo_key] = diablo_times[state->count - 1];
}
}
// Would rather have one function for all of this, but no idea how to do that...
void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 0);
}
void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 1);
}
void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 2);
}
void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
diablo_tapdance_master(state, user_data, 3);
}
//Tap Dance Definitions
qk_tap_dance_action_t tap_dance_actions[] = {
// tap once to disable, and more to enable timed micros
[TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
[TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
[TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
[TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
};
#endif
// Add reconfigurable functions here, for keymap customization // Add reconfigurable functions here, for keymap customization
// This allows for a global, userspace functions, and continued // This allows for a global, userspace functions, and continued
// customization of the keymap. Use _keymap instead of _user // customization of the keymap. Use _keymap instead of _user
@ -17,12 +93,22 @@ __attribute__ ((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
return true; return true;
} }
__attribute__ ((weak)) __attribute__ ((weak))
uint32_t layer_state_set_keymap (uint32_t state) { uint32_t layer_state_set_keymap (uint32_t state) {
return state; return state;
} }
__attribute__ ((weak))
void led_set_keymap(uint8_t usb_led) {}
bool is_overwatch = false; bool is_overwatch = false;
#ifdef RGBLIGHT_ENABLE
bool rgb_layer_change = true;
#endif
// Call user matrix init, set default RGB colors and then // Call user matrix init, set default RGB colors and then
// call the keymap's init function // call the keymap's init function
@ -54,13 +140,56 @@ void matrix_init_user(void) {
#endif #endif
matrix_init_keymap(); matrix_init_keymap();
} }
#ifdef TAP_DANCE_ENABLE
// Sends the key press to system, but only if on the Diablo layer
void send_diablo_keystroke(uint8_t diablo_key) {
if (biton32(layer_state) == _DIABLO) {
switch (diablo_key) {
case 0:
SEND_STRING("1");
break;
case 1:
SEND_STRING("2");
break;
case 2:
SEND_STRING("3");
break;
case 3:
SEND_STRING("4");
break;
}
}
}
// Checks each of the 4 timers/keys to see if enough time has elapsed
// Runs the "send string" command if enough time has passed, and resets the timer.
void run_diablo_macro_check(void) {
uint8_t dtime;
for (dtime = 0; dtime < 4; dtime++) {
if (check_dtimer(dtime) && diablo_key_time[dtime]) {
diablo_timer[dtime] = timer_read();
send_diablo_keystroke(dtime);
}
}
}
#endif
// No global matrix scan code, so just run keymap's matix // No global matrix scan code, so just run keymap's matix
// scan function // scan function
void matrix_scan_user(void) { void matrix_scan_user(void) {
#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
run_diablo_macro_check();
#endif
matrix_scan_keymap(); matrix_scan_keymap();
} }
void led_set_user(uint8_t usb_led) {
led_set_keymap(usb_led);
}
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
float tone_qwerty[][2] = SONG(QWERTY_SOUND); float tone_qwerty[][2] = SONG(QWERTY_SOUND);
float tone_dvorak[][2] = SONG(DVORAK_SOUND); float tone_dvorak[][2] = SONG(DVORAK_SOUND);
@ -254,11 +383,47 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
_delay_ms(50); _delay_ms(50);
SEND_STRING("That aim is absolutely amazing. It's almost like you're a machine!" SS_TAP(X_ENTER)); SEND_STRING("That aim is absolutely amazing. It's almost like you're a machine!" SS_TAP(X_ENTER));
_delay_ms(50); _delay_ms(3000);
register_code(is_overwatch ? KC_BSPC : KC_ENTER);
unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
SEND_STRING("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!" SS_TAP(X_ENTER)); SEND_STRING("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!" SS_TAP(X_ENTER));
} }
return false; return false;
break; break;
case KC_C9:
if (!record->event.pressed) {
register_code(is_overwatch ? KC_BSPC : KC_ENTER);
unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
_delay_ms(50);
SEND_STRING("OMG!!! C9!!!");
register_code(KC_ENTER);
unregister_code(KC_ENTER);
}
return false;
break;
case KC_GGEZ:
if (!record->event.pressed) {
register_code(is_overwatch ? KC_BSPC : KC_ENTER);
unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
_delay_ms(50);
SEND_STRING("That was a fantastic game, though it was a bit easy. Try harder next time!");
register_code(KC_ENTER);
unregister_code(KC_ENTER);
}
return false;
break;
#endif
#ifdef TAP_DANCE_ENABLE
case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
if (record->event.pressed) {
uint8_t dtime;
for (dtime = 0; dtime < 4; dtime++) {
diablo_key_time[dtime] = diablo_times[0];
}
}
return false;
break;
#endif #endif
case KC_MAKE: case KC_MAKE:
if (!record->event.pressed) { if (!record->event.pressed) {
@ -310,6 +475,33 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
} }
return false; return false;
break; break;
case KC_RGB_T: // Because I want the option to go back to normal RGB mode rather than always layer indication
if (record->event.pressed) {
rgb_layer_change = !rgb_layer_change;
}
return false;
break;
case RGB_MOD:
case RGB_SMOD:
case RGB_HUI:
case RGB_HUD:
case RGB_SAI:
case RGB_SAD:
case RGB_VAI:
case RGB_VAD:
case RGB_MODE_PLAIN:
case RGB_MODE_BREATHE:
case RGB_MODE_RAINBOW:
case RGB_MODE_SWIRL:
case RGB_MODE_SNAKE:
case RGB_MODE_KNIGHT:
case RGB_MODE_XMAS:
case RGB_MODE_GRADIENT:
if (record->event.pressed) {
rgb_layer_change = false;
}
return true;
break;
} }
return process_record_keymap(keycode, record); return process_record_keymap(keycode, record);
} }
@ -320,7 +512,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
uint32_t layer_state_set_user(uint32_t state) { uint32_t layer_state_set_user(uint32_t state) {
#ifdef RGBLIGHT_ENABLE #ifdef RGBLIGHT_ENABLE
uint8_t default_layer = eeconfig_read_default_layer(); uint8_t default_layer = eeconfig_read_default_layer();
if (rgb_layer_change) {
switch (biton32(state)) { switch (biton32(state)) {
case _NAV: case _NAV:
rgblight_set_blue; rgblight_set_blue;
@ -381,6 +573,9 @@ uint32_t layer_state_set_user (uint32_t state) {
rgblight_mode(1); rgblight_mode(1);
break; break;
} }
}
#endif #endif
return layer_state_set_keymap (state); return layer_state_set_keymap (state);
} }

View file

@ -1,3 +1,20 @@
/*
Copyright 2017 Christopher Courtney <drashna@live.com> @drashna
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 <http://www.gnu.org/licenses/>.
*/
#ifndef USERSPACE #ifndef USERSPACE
#define USERSPACE #define USERSPACE
@ -26,6 +43,7 @@
#define MODS_SHIFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)) #define MODS_SHIFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
#define MODS_CTRL_MASK (MOD_BIT(KC_LCTL)|MOD_BIT(KC_RCTRL)) #define MODS_CTRL_MASK (MOD_BIT(KC_LCTL)|MOD_BIT(KC_RCTRL))
#define MODS_ALT_MASK (MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT)) #define MODS_ALT_MASK (MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT))
#define MODS_GUI_MASK (MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI))
#ifdef RGBLIGHT_ENABLE #ifdef RGBLIGHT_ENABLE
#define rgblight_set_blue rgblight_sethsv (0xFF, 0xFF, 0xFF); #define rgblight_set_blue rgblight_sethsv (0xFF, 0xFF, 0xFF);
@ -39,8 +57,9 @@
#endif #endif
extern bool is_overwatch; extern bool is_overwatch;
extern bool rgb_layer_change;
enum custom_keycodes { enum userrpace_custom_keycodes {
PLACEHOLDER = SAFE_RANGE, // can always be here PLACEHOLDER = SAFE_RANGE, // can always be here
EPRM, EPRM,
VRSN, VRSN,
@ -62,9 +81,24 @@ enum custom_keycodes {
KC_GLHF, KC_GLHF,
KC_TORB, KC_TORB,
KC_AIM, KC_AIM,
KC_C9,
KC_GGEZ,
KC_MAKE, KC_MAKE,
KC_RESET, KC_RESET,
NEWPLACEHOLDER //use "NEWPLACEHOLDER for keymap specific codes KC_RGB_T,
NEW_SAFE_RANGE //use "NEWPLACEHOLDER for keymap specific codes
}; };
#ifdef TAP_DANCE_ENABLE
enum {
TD_D3_1 = 0,
TD_D3_2,
TD_D3_3,
TD_D3_4
};
#endif
#endif #endif