summaryrefslogtreecommitdiffstats
path: root/users/spacebarracecar/spacebarracecar.c
diff options
context:
space:
mode:
authorSpacebarRacecar <42380065+SpacebarRacecar@users.noreply.github.com>2018-10-22 22:23:22 +0200
committerDrashna Jaelre <drashna@live.com>2018-10-22 13:23:22 -0700
commit704a2e8d3c0bd15f6c8accd5a39fb88ca6c9e2d5 (patch)
treee3ed96d6cc1d4a78c65db1dc571956feeaef83e6 /users/spacebarracecar/spacebarracecar.c
parente7451448361b0d1490f74aae6dfe4f80e86ea1ca (diff)
Keymap: Updates to personal userspace and keymaps (#4206)
* - updated personal userspace - updated fc660c, niu mini and planck keymaps - added prime_o keymap * Rename README.md to readme.md
Diffstat (limited to 'users/spacebarracecar/spacebarracecar.c')
-rw-r--r--users/spacebarracecar/spacebarracecar.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/users/spacebarracecar/spacebarracecar.c b/users/spacebarracecar/spacebarracecar.c
index 404331f8df..f7048869ed 100644
--- a/users/spacebarracecar/spacebarracecar.c
+++ b/users/spacebarracecar/spacebarracecar.c
@@ -1,18 +1,29 @@
#include "spacebarracecar.h"
#ifdef GERMAN_ENABLE
+// These indicate if left and right shift are physically pressed
bool lshift = false;
bool rshift = false;
+
+// Interrupt and times for space cadet shift
bool lshiftp = false;
bool rshiftp = false;
uint16_t lshift_timer = 0;
uint16_t rshift_timer = 0;
+// Number of items that are saved in prev_kcs
uint8_t prev_indx = 0;
+// Used to save the last 6 actual keycodes activated by frankenkeycodes
uint16_t prev_kcs[6] = {0, 0, 0, 0, 0, 0};
+// If true the deadkey characters grave and circonflexe are not automatically escaped
bool esct = false;
+/*
+Used to add a keycode to a prev_kcs to remember it.
+When full the last code gets discarded and replaced by
+the new one.
+*/
void add_to_prev(uint16_t kc){
for (int i=0; i<prev_indx; i++){
if (kc == prev_kcs[i])
@@ -29,6 +40,13 @@ void add_to_prev(uint16_t kc){
}
}
+/*
+Unregisters all codes saved in prev_kcs and resets prev_indx.
+gets called on multiple occasions mainly when shift is released
+and when frankenkeycodes are pressed. Prevents output of
+wrong characters when really specific key combinations
+that would never occur during normal usage are pressed.
+*/
void unreg_prev(void){
if (prev_indx == 0)
return;
@@ -39,11 +57,14 @@ void unreg_prev(void){
}
#endif
-// stuff for nav esc
+// Interrupt and times for Nav/Esc
bool navesc = false;
uint16_t navesc_timer = 0;
+
+// If true Gui keys and Space Cadet Shift get disabled
bool game = false;
+// Interrupts all timers
void timer_timeout(void){
#ifdef GERMAN_ENABLE
lshiftp = false;
@@ -52,15 +73,19 @@ void timer_timeout(void){
navesc = false;
}
-bool process_record_userspace(uint16_t keycode, keyrecord_t *record) {
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case CU_GAME:
if(record->event.pressed) {
+ timer_timeout();
game = !game;
}
- return false;
+ // allows keymap to execute further commands when CU_GAME is pressed, for example enabling a macro layer
+ return process_record_keymap(keycode, record) && false;
case KC_LGUI:
case KC_RGUI:
+ if (record->event.pressed)
+ timer_timeout();
if (game)
return false;
else
@@ -77,11 +102,21 @@ bool process_record_userspace(uint16_t keycode, keyrecord_t *record) {
}
layer_off(_NAV);
}
- return false;
+ return false;
+ case KC_P00:
+ if(record->event.pressed) {
+ timer_timeout();
+ register_code(KC_P0);
+ unregister_code(KC_P0);
+ register_code(KC_P0);
+ unregister_code(KC_P0);
+ }
+ return false;
#ifdef RGBLIGHT_ENABLE
case CU_RGBV:
if(record->event.pressed) {
+ timer_timeout();
if (rgblight_get_val()+32>255)
rgblight_sethsv(rgblight_get_hue(), rgblight_get_sat(), 31);
else
@@ -133,6 +168,7 @@ bool process_record_userspace(uint16_t keycode, keyrecord_t *record) {
return false;
case CU_ESCT:
if(record->event.pressed) {
+ timer_timeout();
esct = !esct;
}
return false;
@@ -282,6 +318,7 @@ bool process_record_userspace(uint16_t keycode, keyrecord_t *record) {
case KC_LCTL:
case KC_RCTL:
if(!record->event.pressed) {
+ timer_timeout();
unregister_code(KC_Z);
unregister_code(KC_Y);
}
@@ -300,6 +337,6 @@ bool process_record_userspace(uint16_t keycode, keyrecord_t *record) {
#endif
}
- return true;
+ return process_record_keymap(keycode, record);
}
}