diff options
author | Liyang HU <github.com@liyang.hu> | 2021-02-20 19:53:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-20 14:53:53 -0500 |
commit | c4bd6af837ada55cd3cbc21f0e50d6a2d620bcf8 (patch) | |
tree | b4510734d4d0a90ae95ade91e8230221cf0f79f6 /tmk_core/common/report.h | |
parent | 2e4f0876151d7016172fa51d1588def1c96102fc (diff) | |
download | qmk_firmware-c4bd6af837ada55cd3cbc21f0e50d6a2d620bcf8.tar.gz qmk_firmware-c4bd6af837ada55cd3cbc21f0e50d6a2d620bcf8.zip |
tmk_core/common/action.c: refactor for code size; merge multiple `case`s into one (#11943)
* tmk_core/common/report.h: define `enum mouse_buttons` in terms of `#define MOUSE_BTN_MASK()`
* tmk_core/common/action.c: collapse multiple `case KC_MS_BTN[1-8]:` into single `MOUSE_BTN_MASK(action.key.code - KC_MS_BTN1)`
We all love tapping on our keyboards but this is taking the piss.
This saves ~134 bytes on my ATmega32.
Diffstat (limited to 'tmk_core/common/report.h')
-rw-r--r-- | tmk_core/common/report.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index bcf5cab38..606a25964 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h | |||
@@ -34,15 +34,16 @@ enum hid_report_ids { | |||
34 | }; | 34 | }; |
35 | 35 | ||
36 | /* Mouse buttons */ | 36 | /* Mouse buttons */ |
37 | #define MOUSE_BTN_MASK(n) (1 << (n)) | ||
37 | enum mouse_buttons { | 38 | enum mouse_buttons { |
38 | MOUSE_BTN1 = (1 << 0), | 39 | MOUSE_BTN1 = MOUSE_BTN_MASK(0), |
39 | MOUSE_BTN2 = (1 << 1), | 40 | MOUSE_BTN2 = MOUSE_BTN_MASK(1), |
40 | MOUSE_BTN3 = (1 << 2), | 41 | MOUSE_BTN3 = MOUSE_BTN_MASK(2), |
41 | MOUSE_BTN4 = (1 << 3), | 42 | MOUSE_BTN4 = MOUSE_BTN_MASK(3), |
42 | MOUSE_BTN5 = (1 << 4), | 43 | MOUSE_BTN5 = MOUSE_BTN_MASK(4), |
43 | MOUSE_BTN6 = (1 << 5), | 44 | MOUSE_BTN6 = MOUSE_BTN_MASK(5), |
44 | MOUSE_BTN7 = (1 << 6), | 45 | MOUSE_BTN7 = MOUSE_BTN_MASK(6), |
45 | MOUSE_BTN8 = (1 << 7) | 46 | MOUSE_BTN8 = MOUSE_BTN_MASK(7) |
46 | }; | 47 | }; |
47 | 48 | ||
48 | /* Consumer Page (0x0C) | 49 | /* Consumer Page (0x0C) |