diff options
| author | Ryan <fauxpark@gmail.com> | 2022-10-15 14:33:24 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-15 14:33:24 +1100 |
| commit | f0b2bfd5ca5b416a9c7c9bef8c2850f1084bd106 (patch) | |
| tree | 2e3cc54b3fb899f05f15bf8008bcbb4816b5ffb5 /quantum/programmable_button.c | |
| parent | 19aed5e999ef177a2ff0b2b705443bde9c70588c (diff) | |
Programmable Button API refactor and improve docs (#18641)
Diffstat (limited to 'quantum/programmable_button.c')
| -rw-r--r-- | quantum/programmable_button.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/quantum/programmable_button.c b/quantum/programmable_button.c index a3ef42d82b..b6c9ad3189 100644 --- a/quantum/programmable_button.c +++ b/quantum/programmable_button.c | |||
| @@ -24,27 +24,38 @@ static uint32_t programmable_button_report = 0; | |||
| 24 | 24 | ||
| 25 | void programmable_button_clear(void) { | 25 | void programmable_button_clear(void) { |
| 26 | programmable_button_report = 0; | 26 | programmable_button_report = 0; |
| 27 | programmable_button_flush(); | ||
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | void programmable_button_send(void) { | 30 | void programmable_button_add(uint8_t index) { |
| 30 | host_programmable_button_send(programmable_button_report); | ||
| 31 | } | ||
| 32 | |||
| 33 | void programmable_button_on(uint8_t index) { | ||
| 34 | programmable_button_report |= REPORT_BIT(index); | 31 | programmable_button_report |= REPORT_BIT(index); |
| 35 | } | 32 | } |
| 36 | 33 | ||
| 37 | void programmable_button_off(uint8_t index) { | 34 | void programmable_button_remove(uint8_t index) { |
| 38 | programmable_button_report &= ~REPORT_BIT(index); | 35 | programmable_button_report &= ~REPORT_BIT(index); |
| 39 | } | 36 | } |
| 40 | 37 | ||
| 38 | void programmable_button_register(uint8_t index) { | ||
| 39 | programmable_button_add(index); | ||
| 40 | programmable_button_flush(); | ||
| 41 | } | ||
| 42 | |||
| 43 | void programmable_button_unregister(uint8_t index) { | ||
| 44 | programmable_button_remove(index); | ||
| 45 | programmable_button_flush(); | ||
| 46 | } | ||
| 47 | |||
| 41 | bool programmable_button_is_on(uint8_t index) { | 48 | bool programmable_button_is_on(uint8_t index) { |
| 42 | return !!(programmable_button_report & REPORT_BIT(index)); | 49 | return !!(programmable_button_report & REPORT_BIT(index)); |
| 43 | }; | 50 | } |
| 51 | |||
| 52 | void programmable_button_flush(void) { | ||
| 53 | host_programmable_button_send(programmable_button_report); | ||
| 54 | } | ||
| 44 | 55 | ||
| 45 | uint32_t programmable_button_get_report(void) { | 56 | uint32_t programmable_button_get_report(void) { |
| 46 | return programmable_button_report; | 57 | return programmable_button_report; |
| 47 | }; | 58 | } |
| 48 | 59 | ||
| 49 | void programmable_button_set_report(uint32_t report) { | 60 | void programmable_button_set_report(uint32_t report) { |
| 50 | programmable_button_report = report; | 61 | programmable_button_report = report; |
