diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/action.c | 5 | ||||
-rw-r--r-- | quantum/keyboard.c | 7 | ||||
-rw-r--r-- | quantum/process_keycode/process_programmable_button.c | 31 | ||||
-rw-r--r-- | quantum/process_keycode/process_programmable_button.h | 23 | ||||
-rw-r--r-- | quantum/programmable_button.c | 37 | ||||
-rw-r--r-- | quantum/programmable_button.h | 30 | ||||
-rw-r--r-- | quantum/quantum.c | 3 | ||||
-rw-r--r-- | quantum/quantum.h | 4 | ||||
-rw-r--r-- | quantum/quantum_keycodes.h | 70 |
9 files changed, 210 insertions, 0 deletions
diff --git a/quantum/action.c b/quantum/action.c index be135f18f..95f39d23d 100644 --- a/quantum/action.c +++ b/quantum/action.c | |||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
18 | #include "keycode.h" | 18 | #include "keycode.h" |
19 | #include "keyboard.h" | 19 | #include "keyboard.h" |
20 | #include "mousekey.h" | 20 | #include "mousekey.h" |
21 | #include "programmable_button.h" | ||
21 | #include "command.h" | 22 | #include "command.h" |
22 | #include "led.h" | 23 | #include "led.h" |
23 | #include "action_layer.h" | 24 | #include "action_layer.h" |
@@ -988,6 +989,10 @@ void clear_keyboard_but_mods_and_keys() { | |||
988 | mousekey_clear(); | 989 | mousekey_clear(); |
989 | mousekey_send(); | 990 | mousekey_send(); |
990 | #endif | 991 | #endif |
992 | #ifdef PROGRAMMABLE_BUTTON_ENABLE | ||
993 | programmable_button_clear(); | ||
994 | programmable_button_send(); | ||
995 | #endif | ||
991 | } | 996 | } |
992 | 997 | ||
993 | /** \brief Utilities for actions. (FIXME: Needs better description) | 998 | /** \brief Utilities for actions. (FIXME: Needs better description) |
diff --git a/quantum/keyboard.c b/quantum/keyboard.c index 5846507b3..6054faa03 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c | |||
@@ -76,6 +76,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
76 | #ifdef JOYSTICK_ENABLE | 76 | #ifdef JOYSTICK_ENABLE |
77 | # include "process_joystick.h" | 77 | # include "process_joystick.h" |
78 | #endif | 78 | #endif |
79 | #ifdef PROGRAMMABLE_BUTTON_ENABLE | ||
80 | # include "programmable_button.h" | ||
81 | #endif | ||
79 | #ifdef HD44780_ENABLE | 82 | #ifdef HD44780_ENABLE |
80 | # include "hd44780.h" | 83 | # include "hd44780.h" |
81 | #endif | 84 | #endif |
@@ -542,6 +545,10 @@ MATRIX_LOOP_END: | |||
542 | digitizer_task(); | 545 | digitizer_task(); |
543 | #endif | 546 | #endif |
544 | 547 | ||
548 | #ifdef PROGRAMMABLE_BUTTON_ENABLE | ||
549 | programmable_button_send(); | ||
550 | #endif | ||
551 | |||
545 | // update LED | 552 | // update LED |
546 | if (led_status != host_keyboard_leds()) { | 553 | if (led_status != host_keyboard_leds()) { |
547 | led_status = host_keyboard_leds(); | 554 | led_status = host_keyboard_leds(); |
diff --git a/quantum/process_keycode/process_programmable_button.c b/quantum/process_keycode/process_programmable_button.c new file mode 100644 index 000000000..c6e77faac --- /dev/null +++ b/quantum/process_keycode/process_programmable_button.c | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | Copyright 2021 Thomas Weißschuh <thomas@t-8ch.de> | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "process_programmable_button.h" | ||
19 | #include "programmable_button.h" | ||
20 | |||
21 | bool process_programmable_button(uint16_t keycode, keyrecord_t *record) { | ||
22 | if (keycode >= PROGRAMMABLE_BUTTON_MIN && keycode <= PROGRAMMABLE_BUTTON_MAX) { | ||
23 | uint8_t button = keycode - PROGRAMMABLE_BUTTON_MIN + 1; | ||
24 | if (record->event.pressed) { | ||
25 | programmable_button_on(button); | ||
26 | } else { | ||
27 | programmable_button_off(button); | ||
28 | } | ||
29 | } | ||
30 | return true; | ||
31 | } | ||
diff --git a/quantum/process_keycode/process_programmable_button.h b/quantum/process_keycode/process_programmable_button.h new file mode 100644 index 000000000..47c6ce561 --- /dev/null +++ b/quantum/process_keycode/process_programmable_button.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | Copyright 2021 Thomas Weißschuh <thomas@t-8ch.de> | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #pragma once | ||
19 | |||
20 | #include <stdint.h> | ||
21 | #include "quantum.h" | ||
22 | |||
23 | bool process_programmable_button(uint16_t keycode, keyrecord_t *record); | ||
diff --git a/quantum/programmable_button.c b/quantum/programmable_button.c new file mode 100644 index 000000000..be828fd17 --- /dev/null +++ b/quantum/programmable_button.c | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | Copyright 2021 Thomas Weißschuh <thomas@t-8ch.de> | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "programmable_button.h" | ||
19 | #include "host.h" | ||
20 | |||
21 | #define REPORT_BIT(index) (((uint32_t)1) << (index - 1)) | ||
22 | |||
23 | static uint32_t programmable_button_report = 0; | ||
24 | |||
25 | void programmable_button_clear(void) { programmable_button_report = 0; } | ||
26 | |||
27 | void programmable_button_send(void) { host_programmable_button_send(programmable_button_report); } | ||
28 | |||
29 | void programmable_button_on(uint8_t index) { programmable_button_report |= REPORT_BIT(index); } | ||
30 | |||
31 | void programmable_button_off(uint8_t index) { programmable_button_report &= ~REPORT_BIT(index); } | ||
32 | |||
33 | bool programmable_button_is_on(uint8_t index) { return !!(programmable_button_report & REPORT_BIT(index)); }; | ||
34 | |||
35 | uint32_t programmable_button_get_report(void) { return programmable_button_report; }; | ||
36 | |||
37 | void programmable_button_set_report(uint32_t report) { programmable_button_report = report; } | ||
diff --git a/quantum/programmable_button.h b/quantum/programmable_button.h new file mode 100644 index 000000000..e89b8b9fd --- /dev/null +++ b/quantum/programmable_button.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | Copyright 2021 Thomas Weißschuh <thomas@t-8ch.de> | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #pragma once | ||
19 | |||
20 | #include <stdint.h> | ||
21 | #include <stdbool.h> | ||
22 | #include "report.h" | ||
23 | |||
24 | void programmable_button_clear(void); | ||
25 | void programmable_button_send(void); | ||
26 | void programmable_button_on(uint8_t index); | ||
27 | void programmable_button_off(uint8_t index); | ||
28 | bool programmable_button_is_on(uint8_t index); | ||
29 | uint32_t programmable_button_get_report(void); | ||
30 | void programmable_button_set_report(uint32_t report); | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index 9d77fa438..326c8370b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -296,6 +296,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
296 | #ifdef JOYSTICK_ENABLE | 296 | #ifdef JOYSTICK_ENABLE |
297 | process_joystick(keycode, record) && | 297 | process_joystick(keycode, record) && |
298 | #endif | 298 | #endif |
299 | #ifdef PROGRAMMABLE_BUTTON_ENABLE | ||
300 | process_programmable_button(keycode, record) && | ||
301 | #endif | ||
299 | true)) { | 302 | true)) { |
300 | return false; | 303 | return false; |
301 | } | 304 | } |
diff --git a/quantum/quantum.h b/quantum/quantum.h index 86b717e44..5cbe84d0c 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
@@ -147,6 +147,10 @@ extern layer_state_t layer_state; | |||
147 | # include "process_joystick.h" | 147 | # include "process_joystick.h" |
148 | #endif | 148 | #endif |
149 | 149 | ||
150 | #ifdef PROGRAMMABLE_BUTTON_ENABLE | ||
151 | # include "process_programmable_button.h" | ||
152 | #endif | ||
153 | |||
150 | #ifdef GRAVE_ESC_ENABLE | 154 | #ifdef GRAVE_ESC_ENABLE |
151 | # include "process_grave_esc.h" | 155 | # include "process_grave_esc.h" |
152 | #endif | 156 | #endif |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index ef4b0f457..2ea81dd4c 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
@@ -524,6 +524,40 @@ enum quantum_keycodes { | |||
524 | // Additional magic key | 524 | // Additional magic key |
525 | MAGIC_TOGGLE_GUI, | 525 | MAGIC_TOGGLE_GUI, |
526 | 526 | ||
527 | // Programmable Button | ||
528 | PROGRAMMABLE_BUTTON_1, | ||
529 | PROGRAMMABLE_BUTTON_2, | ||
530 | PROGRAMMABLE_BUTTON_3, | ||
531 | PROGRAMMABLE_BUTTON_4, | ||
532 | PROGRAMMABLE_BUTTON_5, | ||
533 | PROGRAMMABLE_BUTTON_6, | ||
534 | PROGRAMMABLE_BUTTON_7, | ||
535 | PROGRAMMABLE_BUTTON_8, | ||
536 | PROGRAMMABLE_BUTTON_9, | ||
537 | PROGRAMMABLE_BUTTON_10, | ||
538 | PROGRAMMABLE_BUTTON_11, | ||
539 | PROGRAMMABLE_BUTTON_12, | ||
540 | PROGRAMMABLE_BUTTON_13, | ||
541 | PROGRAMMABLE_BUTTON_14, | ||
542 | PROGRAMMABLE_BUTTON_15, | ||
543 | PROGRAMMABLE_BUTTON_16, | ||
544 | PROGRAMMABLE_BUTTON_17, | ||
545 | PROGRAMMABLE_BUTTON_18, | ||
546 | PROGRAMMABLE_BUTTON_19, | ||
547 | PROGRAMMABLE_BUTTON_20, | ||
548 | PROGRAMMABLE_BUTTON_21, | ||
549 | PROGRAMMABLE_BUTTON_22, | ||
550 | PROGRAMMABLE_BUTTON_23, | ||
551 | PROGRAMMABLE_BUTTON_24, | ||
552 | PROGRAMMABLE_BUTTON_25, | ||
553 | PROGRAMMABLE_BUTTON_26, | ||
554 | PROGRAMMABLE_BUTTON_27, | ||
555 | PROGRAMMABLE_BUTTON_28, | ||
556 | PROGRAMMABLE_BUTTON_29, | ||
557 | PROGRAMMABLE_BUTTON_30, | ||
558 | PROGRAMMABLE_BUTTON_31, | ||
559 | PROGRAMMABLE_BUTTON_32, | ||
560 | |||
527 | // Start of custom keycode range for keyboards and keymaps - always leave at the end | 561 | // Start of custom keycode range for keyboards and keymaps - always leave at the end |
528 | SAFE_RANGE | 562 | SAFE_RANGE |
529 | }; | 563 | }; |
@@ -854,3 +888,39 @@ enum quantum_keycodes { | |||
854 | #define OS_TOGG ONESHOT_TOGGLE | 888 | #define OS_TOGG ONESHOT_TOGGLE |
855 | #define OS_ON ONESHOT_ENABLE | 889 | #define OS_ON ONESHOT_ENABLE |
856 | #define OS_OFF ONESHOT_DISABLE | 890 | #define OS_OFF ONESHOT_DISABLE |
891 | |||
892 | // Programmable Button aliases | ||
893 | #define PB_1 PROGRAMMABLE_BUTTON_1 | ||
894 | #define PB_2 PROGRAMMABLE_BUTTON_2 | ||
895 | #define PB_3 PROGRAMMABLE_BUTTON_3 | ||
896 | #define PB_4 PROGRAMMABLE_BUTTON_4 | ||
897 | #define PB_5 PROGRAMMABLE_BUTTON_5 | ||
898 | #define PB_6 PROGRAMMABLE_BUTTON_6 | ||
899 | #define PB_7 PROGRAMMABLE_BUTTON_7 | ||
900 | #define PB_8 PROGRAMMABLE_BUTTON_8 | ||
901 | #define PB_9 PROGRAMMABLE_BUTTON_9 | ||
902 | #define PB_10 PROGRAMMABLE_BUTTON_10 | ||
903 | #define PB_11 PROGRAMMABLE_BUTTON_11 | ||
904 | #define PB_12 PROGRAMMABLE_BUTTON_12 | ||
905 | #define PB_13 PROGRAMMABLE_BUTTON_13 | ||
906 | #define PB_14 PROGRAMMABLE_BUTTON_14 | ||
907 | #define PB_15 PROGRAMMABLE_BUTTON_15 | ||
908 | #define PB_16 PROGRAMMABLE_BUTTON_16 | ||
909 | #define PB_17 PROGRAMMABLE_BUTTON_17 | ||
910 | #define PB_18 PROGRAMMABLE_BUTTON_18 | ||
911 | #define PB_19 PROGRAMMABLE_BUTTON_19 | ||
912 | #define PB_20 PROGRAMMABLE_BUTTON_20 | ||
913 | #define PB_21 PROGRAMMABLE_BUTTON_21 | ||
914 | #define PB_22 PROGRAMMABLE_BUTTON_22 | ||
915 | #define PB_23 PROGRAMMABLE_BUTTON_23 | ||
916 | #define PB_24 PROGRAMMABLE_BUTTON_24 | ||
917 | #define PB_25 PROGRAMMABLE_BUTTON_25 | ||
918 | #define PB_26 PROGRAMMABLE_BUTTON_26 | ||
919 | #define PB_27 PROGRAMMABLE_BUTTON_27 | ||
920 | #define PB_28 PROGRAMMABLE_BUTTON_28 | ||
921 | #define PB_29 PROGRAMMABLE_BUTTON_29 | ||
922 | #define PB_30 PROGRAMMABLE_BUTTON_30 | ||
923 | #define PB_31 PROGRAMMABLE_BUTTON_31 | ||
924 | #define PB_32 PROGRAMMABLE_BUTTON_32 | ||
925 | #define PROGRAMMABLE_BUTTON_MIN PROGRAMMABLE_BUTTON_1 | ||
926 | #define PROGRAMMABLE_BUTTON_MAX PROGRAMMABLE_BUTTON_32 | ||