Fix: action LAYER_BIT uses xor now instead of and/or.

example_keyboards
tmk 12 years ago
parent 10b9237fa6
commit 7e1093b70f

@ -452,9 +452,9 @@ static void process_action(keyrecord_t *record)
switch (action.layer.code) { switch (action.layer.code) {
case 0x00: case 0x00:
if (event.pressed) { if (event.pressed) {
layer_switch(current_layer | action.layer.opt); layer_switch(current_layer ^ action.layer.opt);
} else { } else {
layer_switch(current_layer & ~action.layer.opt); layer_switch(current_layer ^ action.layer.opt);
} }
break; break;
case 0xF0: case 0xF0:
@ -462,25 +462,22 @@ static void process_action(keyrecord_t *record)
if (event.pressed) { if (event.pressed) {
if (tap_count < TAPPING_TOGGLE) { if (tap_count < TAPPING_TOGGLE) {
debug("LAYER_BIT: tap toggle(press).\n"); debug("LAYER_BIT: tap toggle(press).\n");
layer_switch(current_layer | action.layer.opt); layer_switch(current_layer ^ action.layer.opt);
} }
} else { } else {
if (tap_count < TAPPING_TOGGLE) { if (tap_count <= TAPPING_TOGGLE) {
debug("LAYER_BIT: tap toggle(release).\n"); debug("LAYER_BIT: tap toggle(release).\n");
layer_switch(current_layer & ~action.layer.opt); layer_switch(current_layer ^ action.layer.opt);
} else {
debug("LAYER_BIT: tap toggle.\n");
layer_switch(current_layer | action.layer.opt);
} }
} }
break; break;
case 0xFF: case 0xFF:
// change default layer // change default layer
if (event.pressed) { if (event.pressed) {
default_layer = current_layer | action.layer.opt; default_layer = current_layer ^ action.layer.opt;
layer_switch(default_layer); layer_switch(default_layer);
} else { } else {
default_layer = current_layer & ~action.layer.opt; default_layer = current_layer ^ action.layer.opt;
layer_switch(default_layer); layer_switch(default_layer);
} }
break; break;
@ -492,7 +489,7 @@ static void process_action(keyrecord_t *record)
register_code(action.layer.code); register_code(action.layer.code);
} else { } else {
debug("LAYER_BIT: No tap: layer_switch(bit on)\n"); debug("LAYER_BIT: No tap: layer_switch(bit on)\n");
layer_switch(current_layer | action.layer.opt); layer_switch(current_layer ^ action.layer.opt);
} }
} else { } else {
if (IS_TAPPING_KEY(event.key) && tap_count > 0) { if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
@ -500,7 +497,7 @@ static void process_action(keyrecord_t *record)
unregister_code(action.layer.code); unregister_code(action.layer.code);
} else { } else {
debug("LAYER_BIT: No tap: layer_switch(bit off)\n"); debug("LAYER_BIT: No tap: layer_switch(bit off)\n");
layer_switch(current_layer & ~action.layer.opt); layer_switch(current_layer ^ action.layer.opt);
} }
} }
break; break;

@ -225,7 +225,6 @@ enum acion_param {
/* action_t utility */ /* action_t utility */
#define ACTION_NO 0 #define ACTION_NO 0
#define ACTION(kind, param) ((kind)<<12 | (param)) #define ACTION(kind, param) ((kind)<<12 | (param))
#define MOD_BITS(mods) (((mods)>>4 | (mods)) & 0x0F)
/* Key & Mods */ /* Key & Mods */
#define ACTION_KEY(key) ACTION(ACT_LMODS, key) #define ACTION_KEY(key) ACTION(ACT_LMODS, key)
@ -235,15 +234,16 @@ enum acion_param {
#define ACTION_RMODS_KEY(mods, key) ACTION(ACT_RMODS, (mods)<<8 | (key)) #define ACTION_RMODS_KEY(mods, key) ACTION(ACT_RMODS, (mods)<<8 | (key))
/* Mods + Tap key */ /* Mods + Tap key */
#define ACTION_LMODS_TAP(mods, key) ACTION(ACT_LMODS_TAP, MOD_BITS(mods)<<8 | (key)) #define MODS4(mods) (((mods)>>4 | (mods)) & 0x0F)
#define ACTION_LMODS_ONESHOT(mods) ACTION(ACT_LMODS_TAP, MOD_BITS(mods)<<8 | ONE_SHOT) #define ACTION_LMODS_TAP(mods, key) ACTION(ACT_LMODS_TAP, MODS4(mods)<<8 | (key))
#define ACTION_RMODS_TAP(mods, key) ACTION(ACT_RMODS_TAP, MOD_BITS(mods)<<8 | (key)) #define ACTION_LMODS_ONESHOT(mods) ACTION(ACT_LMODS_TAP, MODS4(mods)<<8 | ONE_SHOT)
#define ACTION_RMODS_ONESHOT(mods) ACTION(ACT_RMODS_TAP, MOD_BITS(mods)<<8 | ONE_SHOT) #define ACTION_RMODS_TAP(mods, key) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | (key))
#define ACTION_RMODS_ONESHOT(mods) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | ONE_SHOT)
/* Switch current layer */ /* Switch current layer */
#define ACTION_LAYER_SET_ON_PRESSED(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0x00) #define ACTION_LAYER_SET_ON_PRESSED(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0x00)
#define ACTION_LAYER_SET_ON_RELEASED(layer) ACTION(ACT_LAYER_RELEASED, (layer)<<8 | 0x00) #define ACTION_LAYER_SET_ON_RELEASED(layer) ACTION(ACT_LAYER_RELEASED, (layer)<<8 | 0x00)
#define ACTION_LAYER_BIT(bits) ACTION(ACT_LAYER_BIT, (layer)<<8 | 0x00) #define ACTION_LAYER_BIT(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | 0x00)
#define ACTION_LAYER_TO_DEFAULT_ON_PRESSED ACTION(ACT_LAYER_EXT, 0x0<<8 | 0x00) #define ACTION_LAYER_TO_DEFAULT_ON_PRESSED ACTION(ACT_LAYER_EXT, 0x0<<8 | 0x00)
#define ACTION_LAYER_TO_DEFAULT_ON_RELEASED ACTION(ACT_LAYER_EXT, 0x1<<8 | 0x00) #define ACTION_LAYER_TO_DEFAULT_ON_RELEASED ACTION(ACT_LAYER_EXT, 0x1<<8 | 0x00)
/* Switch default layer */ /* Switch default layer */
@ -254,7 +254,7 @@ enum acion_param {
#define ACTION_LAYER_DEFAULT_SET_CURRENT_ON_RELEASED ACTION(ACT_LAYER_EXT, 0x1<<8 | 0xFF) #define ACTION_LAYER_DEFAULT_SET_CURRENT_ON_RELEASED ACTION(ACT_LAYER_EXT, 0x1<<8 | 0xFF)
/* Layer switch with tap key */ /* Layer switch with tap key */
#define ACTION_LAYER_SET_TAP_KEY(layer, key) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | (key)) #define ACTION_LAYER_SET_TAP_KEY(layer, key) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | (key))
#define ACTION_LAYER_BIT_TAP_KEY(bits, key) ACTION(ACT_LAYER_BIT, (layer)<<8 | (key)) #define ACTION_LAYER_BIT_TAP_KEY(bits, key) ACTION(ACT_LAYER_BIT, (bits)<<8 | (key))
#define ACTION_LAYER_DEFAULT_SET_TAP_KEY(key) ACTION(ACT_LAYER_EXT, 0x0<<8 | (key)) #define ACTION_LAYER_DEFAULT_SET_TAP_KEY(key) ACTION(ACT_LAYER_EXT, 0x0<<8 | (key))
/* with tap toggle */ /* with tap toggle */
#define ACTION_LAYER_SET_ON_PRESSED_TAP_TOGGLE(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0xF0) #define ACTION_LAYER_SET_ON_PRESSED_TAP_TOGGLE(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0xF0)

Loading…
Cancel
Save