summaryrefslogtreecommitdiff
path: root/users/zyber/zyber.c
blob: 72852d091a809f10d764e753d175c35bfe6b38ff (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
// Copyright 2022 ZyBeR (@ZyberSE)
// SPDX-License-Identifier: GPL-2.0

#include "zyber.h"


__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }

uint16_t key_timer;

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
	if (record->event.pressed) {
		key_timer = timer_read();
	}

	if (!process_caps_word(keycode, record)) {
		return false;
	}

	switch(keycode) {
		case C_BLK:
			if (record->event.pressed) {
				send_string("```" SS_DELAY(80) SS_LCMD("v") SS_DELAY(80) "```");
			}
			break;

		case CTRL_C_UP:
			if (record->event.pressed) {
				register_mods(MOD_BIT(KC_LEFT_CTRL));
			} else {
				unregister_mods(MOD_BIT(KC_LEFT_CTRL));
				if (timer_elapsed(key_timer) < TAPPING_TERM) {
					tap_code16(C(KC_UP));
				}
			}
			return false;
			break;

		case L1_EXPL:
			if (record->event.pressed) {
				layer_on(1);
			} else {
				layer_off(1);
				if (timer_elapsed(key_timer) < TAPPING_TERM) {
					tap_code16(C(KC_UP));
				}
			}
			return false;
			break;

		case ROPT_SRH:
			if (record->event.pressed) {
				register_mods(MOD_BIT(KC_ROPT));
			} else {
				unregister_mods(MOD_BIT(KC_ROPT));
				if (timer_elapsed(key_timer) < TAPPING_TERM) {
					tap_code16(G(KC_SPC));
				}
			}
			return false;
			break;
	}

	return process_record_keymap(keycode, record);
}

/* Screenshoot */
void dance_SSHT_finished(tap_dance_state_t *state, void *user_data) {
	if (state->count == 2) {
		tap_code16(C(S(G(KC_4))));
	} else {
		tap_code(KC_4);
	}
}
void dance_SSHT_reset(tap_dance_state_t *state, void *user_data) {
	if (state->count == 2) {
		unregister_code16(C(S(G(KC_4))));
	} else {
		unregister_code(KC_4);
	}
}

/* Å */
void dance_LBRC_finished(tap_dance_state_t *state, void *user_data) {
	if (state->count == 2) {
		tap_code16(A(KC_LBRC));
	} else {
		tap_code(KC_LBRC);
	}
}
void dance_LBRC_reset(tap_dance_state_t *state, void *user_data) {
	if (state->count == 2) {
		unregister_code16(A(KC_LBRC));
	} else {
		unregister_code(KC_LBRC);
	}
}

/* Ö */
void dance_SCLN_finished(tap_dance_state_t *state, void *user_data) {
	if (state->count == 2) {
		tap_code16(A(KC_SCLN));
	} else {
		tap_code(KC_SCLN);
	}
}
void dance_SCLN_reset(tap_dance_state_t *state, void *user_data) {
	if (state->count == 2) {
		unregister_code16(A(KC_SCLN));
	} else {
		unregister_code(KC_SCLN);
	}
}

/* Ä */
void dance_QUOT_finished(tap_dance_state_t *state, void *user_data) {
	if (state->count == 2) {
		tap_code16(A(KC_QUOT));
	} else {
		tap_code(KC_QUOT);
	}
}
void dance_QUOT_reset(tap_dance_state_t *state, void *user_data) {
	if (state->count == 2) {
		unregister_code16(A(KC_QUOT));
	} else {
		unregister_code(KC_QUOT);
	}
}

tap_dance_action_t tap_dance_actions[] = {
	[SSHT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_SSHT_finished, dance_SSHT_reset),
	[LBRC] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_LBRC_finished, dance_LBRC_reset),
	[SCLN] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_SCLN_finished, dance_SCLN_reset),
	[QUOT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_QUOT_finished, dance_QUOT_reset),
	[END_HOME] = ACTION_TAP_DANCE_DOUBLE(LGUI(KC_LEFT), LGUI(KC_RIGHT))
};