forked from vial-kb/vial-qmk
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
5,145 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* Copyright 2022 @ lokher (https://www.keychron.com) | ||
* | ||
* 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/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#define FACTORY_RESET_CHECK process_record_factory_test | ||
#define FACTORY_RESET_TASK factory_test_task | ||
|
||
void factory_test_init(void); | ||
|
||
#if defined(LED_MATRIX_ENABLE) || defined(RGB_MATRIX_ENABLE) | ||
bool factory_test_indicator(void); | ||
#endif | ||
|
||
//void process_record_factory_test(uint16_t keycode, keyrecord_t *record); | ||
bool factory_reset_indicating(void); | ||
void factory_test_task(void); | ||
void factory_test_rx(uint8_t *data, uint8_t length); | ||
|
||
bool process_record_factory_test(uint16_t keycode, keyrecord_t *record); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* Copyright 2022 @ Keychron (https://www.keychron.com) | ||
* | ||
* 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 QMK_KEYBOARD_H | ||
#include "lemokey_common.h" | ||
|
||
#ifdef FACTORY_TEST_ENABLE | ||
# include "factory_test.h" | ||
# include "lemokey_common.h" | ||
#endif | ||
|
||
#ifdef LK_WIRELESS_ENABLE | ||
# include "lkbt51.h" | ||
#endif | ||
|
||
static uint8_t mac_keycode[4] = {KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD}; | ||
|
||
static key_combination_t key_comb_list[3] = { | ||
{2, {KC_LWIN, KC_TAB}}, | ||
{2, {KC_LWIN, KC_E}}, | ||
{2, {KC_LWIN, KC_L}}, | ||
}; | ||
|
||
bool process_record_lemokey_common(uint16_t keycode, keyrecord_t *record) { | ||
switch (keycode) { | ||
case KC_TASK_VIEW: | ||
case KC_FILE_EXPLORER: | ||
case KC_LOCK_SCREEN: | ||
if (record->event.pressed) { | ||
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) { | ||
register_code(key_comb_list[keycode - KC_TASK].keycode[i]); | ||
} | ||
} else { | ||
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) { | ||
unregister_code(key_comb_list[keycode - KC_TASK].keycode[i]); | ||
} | ||
} | ||
return false; // Skip all further processing of this key | ||
case KC_MCTRL: | ||
if (record->event.pressed) { | ||
register_code(KC_MISSION_CONTROL); | ||
} else { | ||
unregister_code(KC_MISSION_CONTROL); | ||
} | ||
return false; // Skip all further processing of this key | ||
case KC_LANCH: | ||
if (record->event.pressed) { | ||
register_code(KC_LAUNCHPAD); | ||
} else { | ||
unregister_code(KC_LAUNCHPAD); | ||
} | ||
return false; // Skip all further processing of this key | ||
case KC_LOPTN: | ||
case KC_ROPTN: | ||
case KC_LCMMD: | ||
case KC_RCMMD: | ||
if (record->event.pressed) { | ||
register_code(mac_keycode[keycode - KC_LOPTN]); | ||
} else { | ||
unregister_code(mac_keycode[keycode - KC_LOPTN]); | ||
} | ||
return false; // Skip all further processing of this key | ||
default: | ||
return true; // Process all other keycodes normally | ||
} | ||
} | ||
|
||
void lemokey_common_task(void) {} | ||
|
||
#ifdef ENCODER_ENABLE | ||
static void encoder0_pad_cb(void *param) { | ||
(void)param; | ||
encoder_inerrupt_read(0); | ||
} | ||
|
||
void encoder_cb_init(void) { | ||
pin_t encoders_pad_a[] = ENCODERS_PAD_A; | ||
pin_t encoders_pad_b[] = ENCODERS_PAD_B; | ||
palEnableLineEvent(encoders_pad_a[0], PAL_EVENT_MODE_BOTH_EDGES); | ||
palEnableLineEvent(encoders_pad_b[0], PAL_EVENT_MODE_BOTH_EDGES); | ||
palSetLineCallback(encoders_pad_a[0], encoder0_pad_cb, NULL); | ||
palSetLineCallback(encoders_pad_b[0], encoder0_pad_cb, NULL); | ||
} | ||
#endif | ||
|
||
//__attribute__((weak)) bool raw_hid_receive_lemokey(uint8_t *data, uint8_t length) { return true; } | ||
|
||
bool via_command_kb(uint8_t *data, uint8_t length) { | ||
// if (!raw_hid_receive_lemokey(data, length)) | ||
// return false; | ||
|
||
switch (data[0]) { | ||
#ifdef LK_WIRELESS_ENABLE | ||
case 0xAA: | ||
lkbt51_dfu_rx(data, length); | ||
break; | ||
#endif | ||
#ifdef FACTORY_TEST_ENABLE | ||
case 0xAB: | ||
factory_test_rx(data, length); | ||
break; | ||
#endif | ||
default: | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
#if !defined(VIA_ENABLE) | ||
void raw_hid_receive(uint8_t *data, uint8_t length) { | ||
switch (data[0]) { | ||
case RAW_HID_CMD: | ||
via_command_kb(data, length); | ||
break; | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* Copyright 2022 @ Keychron (https://www.lemokey.com) | ||
* | ||
* 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/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "stdint.h" | ||
|
||
// clang-format off | ||
enum { | ||
KC_TASK_VIEW = QK_KB_0, | ||
KC_FILE_EXPLORER, | ||
KC_LOCK_SCREEN, // Lock screen | ||
KC_MCTRL, | ||
KC_LANCH, | ||
KC_LOPTN, | ||
KC_ROPTN, | ||
KC_LCMMD, | ||
KC_RCMMD, | ||
#ifdef LK_WIRELESS_ENABLE | ||
BT_HST1, | ||
BT_HST2, | ||
BT_HST3, | ||
P2P4G, | ||
BAT_LVL, | ||
#else | ||
BT_HST1 = _______, | ||
BT_HST2 = _______, | ||
BT_HST3 = _______, | ||
P2P4G = _______, | ||
BAT_LVL = _______, | ||
#endif | ||
|
||
NEW_SAFE_RANGE, | ||
}; | ||
|
||
#define KC_TASK KC_TASK_VIEW | ||
#define KC_FILE KC_FILE_EXPLORER | ||
#define KC_LOCK KC_LOCK_SCREEN | ||
|
||
typedef struct PACKED { | ||
uint8_t len; | ||
uint8_t keycode[2]; | ||
} key_combination_t; | ||
|
||
bool process_record_lemokey_common(uint16_t keycode, keyrecord_t *record); | ||
void lemokey_common_task(void); | ||
|
||
#ifdef ENCODER_ENABLE | ||
void encoder_cb_init(void); | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
OPT_DEFS += -DFACTORY_TEST_ENABLE | ||
|
||
LEMOKEY_COMMON_DIR = common | ||
SRC += \ | ||
$(LEMOKEY_COMMON_DIR)/lemokey_task.c \ | ||
$(LEMOKEY_COMMON_DIR)/lemokey_common.c \ | ||
$(LEMOKEY_COMMON_DIR)/factory_test.c | ||
|
||
VPATH += $(TOP_DIR)/keyboards/lemokey/$(LEMOKEY_COMMON_DIR) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* Copyright 2023 @ Keychron (https://www.keychron.com) | ||
* | ||
* 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 <stdlib.h> | ||
#include "lemokey_task.h" | ||
#include "quantum.h" | ||
#include "lemokey_common.h" | ||
#ifdef FACTORY_TEST_ENABLE | ||
# include "factory_test.h" | ||
#endif | ||
|
||
__attribute__((weak)) bool process_record_lemokey_kb(uint16_t keycode, keyrecord_t *record) { | ||
return true; | ||
} | ||
|
||
bool process_record_lemokey(uint16_t keycode, keyrecord_t *record) { | ||
#ifdef LK_WIRELESS_ENABLE | ||
extern bool process_record_wireless(uint16_t keycode, keyrecord_t * record); | ||
if (!process_record_wireless(keycode, record)) return false; | ||
#endif | ||
#ifdef FACTORY_TEST_ENABLE | ||
if (!process_record_factory_test(keycode, record)) return false; | ||
#endif | ||
// extern bool process_record_lemokey_kb(uint16_t keycode, keyrecord_t *record); | ||
|
||
if (!process_record_lemokey_kb(keycode, record)) return false; | ||
|
||
return true; | ||
} | ||
|
||
#if defined(LED_MATRIX_ENABLE) | ||
bool led_matrix_indicators_lemokey(void) { | ||
# ifdef LK_WIRELESS_ENABLE | ||
extern bool led_matrix_indicators_bt(void); | ||
led_matrix_indicators_bt(); | ||
# endif | ||
# ifdef FACTORY_TEST_ENABLE | ||
factory_test_indicator(); | ||
# endif | ||
return true; | ||
} | ||
#endif | ||
|
||
#if defined(RGB_MATRIX_ENABLE) | ||
bool rgb_matrix_indicators_lemokey(void) { | ||
# ifdef LK_WIRELESS_ENABLE | ||
extern bool rgb_matrix_indicators_bt(void); | ||
rgb_matrix_indicators_bt(); | ||
# endif | ||
# ifdef FACTORY_TEST_ENABLE | ||
factory_test_indicator(); | ||
# endif | ||
return true; | ||
} | ||
#endif | ||
|
||
__attribute__((weak)) bool lemokey_task_kb(void) { | ||
return true; | ||
} | ||
|
||
void lemokey_task(void) { | ||
#ifdef LK_WIRELESS_ENABLE | ||
extern void wireless_tasks(void); | ||
wireless_tasks(); | ||
#endif | ||
#ifdef FACTORY_TEST_ENABLE | ||
factory_test_task(); | ||
#endif | ||
lemokey_common_task(); | ||
|
||
lemokey_task_kb(); | ||
} | ||
|
||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
if (!process_record_user(keycode, record)) return false; | ||
|
||
if (!process_record_lemokey(keycode, record)) return false; | ||
|
||
return true; | ||
} | ||
|
||
#ifdef RGB_MATRIX_ENABLE | ||
bool rgb_matrix_indicators_kb(void) { | ||
if (!rgb_matrix_indicators_user()) return false; | ||
|
||
rgb_matrix_indicators_lemokey(); | ||
|
||
return true; | ||
} | ||
#endif | ||
|
||
#ifdef LED_MATRIX_ENABLE | ||
bool led_matrix_indicators_kb(void) { | ||
if (!led_matrix_indicators_user()) return false; | ||
|
||
led_matrix_indicators_lemokey(); | ||
|
||
return true; | ||
} | ||
#endif | ||
|
||
void housekeeping_task_kb(void) { | ||
lemokey_task(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* Copyright 2022 @ Keychron (https://www.lemokey.com) | ||
* | ||
* 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/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "stdint.h" | ||
#include "action.h" | ||
|
||
bool lemokey_task_kb(void); | ||
bool process_record_lemokey_kb(uint16_t keycode, keyrecord_t *record); | ||
void lemokey_task(void); |
Oops, something went wrong.