Skip to content

Commit

Permalink
Add missing parentheses to some important macros (#4775)
Browse files Browse the repository at this point in the history
* Add missing parentheses to quantum_keycodes macros

* Add missing parentheses to progmem macros
  • Loading branch information
vomindoraan authored and drashna committed Jan 8, 2019
1 parent 9eb7b79 commit 64c957d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
21 changes: 10 additions & 11 deletions quantum/quantum_keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,8 @@ enum quantum_keycodes {
#define SWIN(kc) SGUI(kc)
#define LCA(kc) (QK_LCTL | QK_LALT | (kc))

#define MOD_HYPR 0xf
#define MOD_MEH 0x7

#define MOD_HYPR 0xF
#define MOD_MEH 0x7

// Aliases for shifted symbols
// Each key has a 4-letter code, and some have longer aliases too.
Expand Down Expand Up @@ -601,7 +600,7 @@ enum quantum_keycodes {
#define RGB_M_T RGB_MODE_RGBTEST

// L-ayer, T-ap - 256 keycode max, 16 layer max
#define LT(layer, kc) (QK_LAYER_TAP | ((layer & 0xF) << 8) | ((kc) & 0xFF))
#define LT(layer, kc) (QK_LAYER_TAP | (((layer) & 0xF) << 8) | ((kc) & 0xFF))

#define AG_SWAP MAGIC_SWAP_ALT_GUI
#define AG_NORM MAGIC_UNSWAP_ALT_GUI
Expand All @@ -615,28 +614,28 @@ enum quantum_keycodes {
// In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own
// keycode modeled after the old version, kept below for this.
/* #define TO(layer, when) (QK_TO | (when << 0x4) | (layer & 0xFF)) */
#define TO(layer) (QK_TO | (ON_PRESS << 0x4) | (layer & 0xFF))
#define TO(layer) (QK_TO | (ON_PRESS << 0x4) | ((layer) & 0xFF))

// Momentary switch layer - 256 layer max
#define MO(layer) (QK_MOMENTARY | (layer & 0xFF))
#define MO(layer) (QK_MOMENTARY | ((layer) & 0xFF))

// Set default layer - 256 layer max
#define DF(layer) (QK_DEF_LAYER | (layer & 0xFF))
#define DF(layer) (QK_DEF_LAYER | ((layer) & 0xFF))

// Toggle to layer - 256 layer max
#define TG(layer) (QK_TOGGLE_LAYER | (layer & 0xFF))
#define TG(layer) (QK_TOGGLE_LAYER | ((layer) & 0xFF))

// One-shot layer - 256 layer max
#define OSL(layer) (QK_ONE_SHOT_LAYER | (layer & 0xFF))
#define OSL(layer) (QK_ONE_SHOT_LAYER | ((layer) & 0xFF))

// L-ayer M-od: Momentary switch layer with modifiers active - 16 layer max, left mods only
#define LM(layer, mod) (QK_LAYER_MOD | ((layer & 0xF) << 4) | ((mod) & 0xF))
#define LM(layer, mod) (QK_LAYER_MOD | (((layer) & 0xF) << 4) | ((mod) & 0xF))

// One-shot mod
#define OSM(mod) (QK_ONE_SHOT_MOD | ((mod) & 0xFF))

// Layer tap-toggle
#define TT(layer) (QK_LAYER_TAP_TOGGLE | (layer & 0xFF))
#define TT(layer) (QK_LAYER_TAP_TOGGLE | ((layer) & 0xFF))

// M-od, T-ap - 256 keycode max
#define MT(mod, kc) (QK_MOD_TAP | (((mod) & 0x1F) << 8) | ((kc) & 0xFF))
Expand Down
6 changes: 3 additions & 3 deletions tmk_core/common/progmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# include <avr/pgmspace.h>
#else
# define PROGMEM
# define pgm_read_byte(p) *((unsigned char*)p)
# define pgm_read_word(p) *((uint16_t*)p)
# define pgm_read_dword(p) *((uint32_t*)p)
# define pgm_read_byte(p) *((unsigned char*)(p))
# define pgm_read_word(p) *((uint16_t*)(p))
# define pgm_read_dword(p) *((uint32_t*)(p))
#endif

#endif

0 comments on commit 64c957d

Please sign in to comment.