|
@@ -50,7 +50,16 @@
|
|
|
uint64_t key_state[4] = { 0x0, 0x0, 0x0, 0x0 };
|
|
|
bool watching = false;
|
|
|
|
|
|
-bool process_key_lock(uint16_t keycode, keyrecord_t *record) {
|
|
|
+
|
|
|
+uint16_t inline translate_keycode(uint16_t keycode) {
|
|
|
+ if (keycode > QK_ONE_SHOT_MOD && keycode <= QK_ONE_SHOT_MOD_MAX) {
|
|
|
+ return keycode ^ QK_ONE_SHOT_MOD;
|
|
|
+ } else {
|
|
|
+ return keycode;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+bool process_key_lock(uint16_t *keycode, keyrecord_t *record) {
|
|
|
|
|
|
|
|
|
|
|
@@ -76,44 +85,54 @@ bool process_key_lock(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ uint16_t translated_keycode = translate_keycode(*keycode);
|
|
|
+
|
|
|
if (record->event.pressed) {
|
|
|
|
|
|
- if (!(IS_STANDARD_KEYCODE(keycode) || keycode == KC_LOCK)) {
|
|
|
+ if (!(IS_STANDARD_KEYCODE(translated_keycode) || translated_keycode == KC_LOCK)) {
|
|
|
watching = false;
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (keycode == KC_LOCK) {
|
|
|
+ if (translated_keycode == KC_LOCK) {
|
|
|
watching = !watching;
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
- if (IS_STANDARD_KEYCODE(keycode)) {
|
|
|
+
|
|
|
+ if (IS_STANDARD_KEYCODE(translated_keycode)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (watching) {
|
|
|
watching = false;
|
|
|
- SET_KEY_STATE(keycode);
|
|
|
+ SET_KEY_STATE(translated_keycode);
|
|
|
+
|
|
|
+
|
|
|
+ *keycode = translated_keycode;
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
- if (KEY_STATE(keycode)) {
|
|
|
- UNSET_KEY_STATE(keycode);
|
|
|
+
|
|
|
+ if (KEY_STATE(translated_keycode)) {
|
|
|
+ UNSET_KEY_STATE(translated_keycode);
|
|
|
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
return true;
|
|
|
} else {
|
|
|
|
|
|
- return !(IS_STANDARD_KEYCODE(keycode) && KEY_STATE(keycode));
|
|
|
+ return !(IS_STANDARD_KEYCODE(translated_keycode) && KEY_STATE(translated_keycode));
|
|
|
}
|
|
|
}
|
|
|
+
|