tmk_core/common/action.c: refactor for code size; merge multiple cases 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.
This commit is contained in:
Liyang HU
2021-02-20 19:53:53 +00:00
committed by GitHub
parent 2e4f087615
commit c4bd6af837
2 changed files with 21 additions and 72 deletions

View File

@ -34,15 +34,16 @@ enum hid_report_ids {
};
/* Mouse buttons */
#define MOUSE_BTN_MASK(n) (1 << (n))
enum mouse_buttons {
MOUSE_BTN1 = (1 << 0),
MOUSE_BTN2 = (1 << 1),
MOUSE_BTN3 = (1 << 2),
MOUSE_BTN4 = (1 << 3),
MOUSE_BTN5 = (1 << 4),
MOUSE_BTN6 = (1 << 5),
MOUSE_BTN7 = (1 << 6),
MOUSE_BTN8 = (1 << 7)
MOUSE_BTN1 = MOUSE_BTN_MASK(0),
MOUSE_BTN2 = MOUSE_BTN_MASK(1),
MOUSE_BTN3 = MOUSE_BTN_MASK(2),
MOUSE_BTN4 = MOUSE_BTN_MASK(3),
MOUSE_BTN5 = MOUSE_BTN_MASK(4),
MOUSE_BTN6 = MOUSE_BTN_MASK(5),
MOUSE_BTN7 = MOUSE_BTN_MASK(6),
MOUSE_BTN8 = MOUSE_BTN_MASK(7)
};
/* Consumer Page (0x0C)