diff options
author | fauxpark <fauxpark@gmail.com> | 2019-11-06 11:42:16 +1100 |
---|---|---|
committer | Joel Challis <git@zvecr.com> | 2019-11-06 00:42:16 +0000 |
commit | dfb78d2a086daa2ceb3fd043afce03785abfa23a (patch) | |
tree | 7cd724b1cd12a65025bbc9d3cb32d7dd39cb9928 /tmk_core/common | |
parent | ed0575fc8aacdfdd83a31fc98df2b1cad2e977f4 (diff) | |
download | qmk_firmware-dfb78d2a086daa2ceb3fd043afce03785abfa23a.tar.gz qmk_firmware-dfb78d2a086daa2ceb3fd043afce03785abfa23a.zip |
New and improved lock LED callbacks (#7215)
* New and improved lock LED callbacks
* Include stdbool
* Update documentation
* Use full function signatures and add keyboard-level example
Diffstat (limited to 'tmk_core/common')
-rw-r--r-- | tmk_core/common/host.c | 6 | ||||
-rw-r--r-- | tmk_core/common/host.h | 2 | ||||
-rw-r--r-- | tmk_core/common/led.h | 13 |
3 files changed, 21 insertions, 0 deletions
diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c index ce39760a5..713b0d945 100644 --- a/tmk_core/common/host.c +++ b/tmk_core/common/host.c | |||
@@ -39,6 +39,12 @@ uint8_t host_keyboard_leds(void) { | |||
39 | if (!driver) return 0; | 39 | if (!driver) return 0; |
40 | return (*driver->keyboard_leds)(); | 40 | return (*driver->keyboard_leds)(); |
41 | } | 41 | } |
42 | |||
43 | led_t host_keyboard_led_state(void) { | ||
44 | if (!driver) return (led_t) {0}; | ||
45 | return (led_t)((*driver->keyboard_leds)()); | ||
46 | } | ||
47 | |||
42 | /* send report */ | 48 | /* send report */ |
43 | void host_keyboard_send(report_keyboard_t *report) { | 49 | void host_keyboard_send(report_keyboard_t *report) { |
44 | if (!driver) return; | 50 | if (!driver) return; |
diff --git a/tmk_core/common/host.h b/tmk_core/common/host.h index b2a7f9842..2cffef6e1 100644 --- a/tmk_core/common/host.h +++ b/tmk_core/common/host.h | |||
@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
22 | #include "report.h" | 22 | #include "report.h" |
23 | #include "host_driver.h" | 23 | #include "host_driver.h" |
24 | #include "led.h" | ||
24 | 25 | ||
25 | #define IS_LED_ON(leds, led_name) ((leds) & (1 << (led_name))) | 26 | #define IS_LED_ON(leds, led_name) ((leds) & (1 << (led_name))) |
26 | #define IS_LED_OFF(leds, led_name) (~(leds) & (1 << (led_name))) | 27 | #define IS_LED_OFF(leds, led_name) (~(leds) & (1 << (led_name))) |
@@ -41,6 +42,7 @@ host_driver_t *host_get_driver(void); | |||
41 | 42 | ||
42 | /* host driver interface */ | 43 | /* host driver interface */ |
43 | uint8_t host_keyboard_leds(void); | 44 | uint8_t host_keyboard_leds(void); |
45 | led_t host_keyboard_led_state(void); | ||
44 | void host_keyboard_send(report_keyboard_t *report); | 46 | void host_keyboard_send(report_keyboard_t *report); |
45 | void host_mouse_send(report_mouse_t *report); | 47 | void host_mouse_send(report_mouse_t *report); |
46 | void host_system_send(uint16_t data); | 48 | void host_system_send(uint16_t data); |
diff --git a/tmk_core/common/led.h b/tmk_core/common/led.h index 2c28fe540..daf974bed 100644 --- a/tmk_core/common/led.h +++ b/tmk_core/common/led.h | |||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
18 | #ifndef LED_H | 18 | #ifndef LED_H |
19 | #define LED_H | 19 | #define LED_H |
20 | #include "stdint.h" | 20 | #include "stdint.h" |
21 | #include "stdbool.h" | ||
21 | 22 | ||
22 | /* FIXME: Add doxygen comments here. */ | 23 | /* FIXME: Add doxygen comments here. */ |
23 | 24 | ||
@@ -32,6 +33,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
32 | extern "C" { | 33 | extern "C" { |
33 | #endif | 34 | #endif |
34 | 35 | ||
36 | typedef union { | ||
37 | uint8_t raw; | ||
38 | struct { | ||
39 | bool num_lock : 1; | ||
40 | bool caps_lock : 1; | ||
41 | bool scroll_lock : 1; | ||
42 | bool compose : 1; | ||
43 | bool kana : 1; | ||
44 | uint8_t reserved : 3; | ||
45 | }; | ||
46 | } led_t; | ||
47 | |||
35 | void led_set(uint8_t usb_led); | 48 | void led_set(uint8_t usb_led); |
36 | 49 | ||
37 | void led_init_ports(void); | 50 | void led_init_ports(void); |