X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=quantum%2Fkeymap_common.c;h=9d2d331ce549b4400dbb38b83883af56ea23e9f5;hb=c080a3e7c4aa565c696224588b16d4e883f60a7b;hp=002eabd85e6e68edb7de9f7337fb7d5e57ffce8f;hpb=e51001efcc3ff8b64f8264e8bd4c2dbea15f3364;p=qmk_firmware.git diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 002eabd85..9d2d331ce 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -1,5 +1,5 @@ /* -Copyright 2012,2013 Jun Wako +Copyright 2012-2017 Jun Wako This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,10 @@ along with this program. If not, see . #include "backlight.h" #include "quantum.h" +#ifdef SPLIT_KEYBOARD + #include "split_flags.h" +#endif + #ifdef MIDI_ENABLE #include "process_midi.h" #endif @@ -60,7 +64,7 @@ action_t action_for_key(uint8_t layer, keypos_t key) case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); break; - case KC_AUDIO_MUTE ... KC_MEDIA_REWIND: + case KC_AUDIO_MUTE ... KC_BRIGHTNESS_DOWN: action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); break; case KC_MS_UP ... KC_MS_ACCEL2: @@ -116,32 +120,65 @@ action_t action_for_key(uint8_t layer, keypos_t key) break; case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: ; // OSM(mod) - One-shot mod - mod = keycode & 0xFF; + mod = mod_config(keycode & 0xFF); action.code = ACTION_MODS_ONESHOT(mod); break; case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: action.code = ACTION_LAYER_TAP_TOGGLE(keycode & 0xFF); break; + case QK_LAYER_MOD ... QK_LAYER_MOD_MAX: + mod = mod_config(keycode & 0xF); + action_layer = (keycode >> 4) & 0xF; + action.code = ACTION_LAYER_MODS(action_layer, mod); + break; case QK_MOD_TAP ... QK_MOD_TAP_MAX: - action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0x1F, keycode & 0xFF); + mod = mod_config((keycode >> 0x8) & 0x1F); + action.code = ACTION_MODS_TAP_KEY(mod, keycode & 0xFF); break; #ifdef BACKLIGHT_ENABLE - case BL_0 ... BL_15: - action.code = ACTION_BACKLIGHT_LEVEL(keycode - BL_0); + case BL_ON: + action.code = ACTION_BACKLIGHT_ON(); + #ifdef SPLIT_KEYBOARD + BACKLIT_DIRTY = true; + #endif + break; + case BL_OFF: + action.code = ACTION_BACKLIGHT_OFF(); + #ifdef SPLIT_KEYBOARD + BACKLIT_DIRTY = true; + #endif break; case BL_DEC: action.code = ACTION_BACKLIGHT_DECREASE(); + #ifdef SPLIT_KEYBOARD + BACKLIT_DIRTY = true; + #endif break; case BL_INC: action.code = ACTION_BACKLIGHT_INCREASE(); + #ifdef SPLIT_KEYBOARD + BACKLIT_DIRTY = true; + #endif break; case BL_TOGG: action.code = ACTION_BACKLIGHT_TOGGLE(); + #ifdef SPLIT_KEYBOARD + BACKLIT_DIRTY = true; + #endif break; case BL_STEP: action.code = ACTION_BACKLIGHT_STEP(); + #ifdef SPLIT_KEYBOARD + BACKLIT_DIRTY = true; + #endif break; #endif + #ifdef SWAP_HANDS_ENABLE + case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: + action.code = ACTION(ACT_SWAP_HANDS, keycode & 0xff); + break; + #endif + default: action.code = ACTION_NO; break; @@ -179,5 +216,12 @@ uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) __attribute__ ((weak)) uint16_t keymap_function_id_to_action( uint16_t function_id ) { + // The compiler sees the empty (weak) fn_actions and generates a warning + // This function should not be called in that case, so the warning is too strict + // If this function is called however, the keymap should have overridden fn_actions, and then the compile + // is comparing against the wrong array + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Warray-bounds" return pgm_read_word(&fn_actions[function_id]); + #pragma GCC diagnostic pop }