You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

350 lines
9.0 KiB

Add ChibiOS support for QMK (#465) * Modularity and gcc warnings fixes. * Add ChibiOS support (USB stack + support files). * Make usb_main more USB_DRIVER #define independent. * Move chibios to tool. * Implement jump-to-bootloader. * Small updates. * Fix bootloader-jump compiling. * Move AVR specific sleep_led.c into avr. * Add basic sleep_led for chibios. * Update chibios README. * NKRO fixes. * Rename some Makefile defines. * Move STM32 bootloader address config to separate .h file. * Add ARM Teensies bootloader code. * Fix chibios/usb_main GET_REPORT handing. * Add missing #include to keymap.c. * Make bootmagic.c code portable (_delay_ms -> wait_ms). * Move declaration of keymap_config. Should really not declare variables in .h files - since it's included in different .c files, a proper linker then complains that the same variable is declared more than once (once for each .c file that the offending .h is included in). * Add eeprom support for chibios/kinetis. * Rename chibios example keyboard. * Move chibios/cortex selection to local Makefiles. * Chibios: use WFI in idle. WIP suspend stuff. * ChibiOS/kinetis: sending remote wakeup. * ChibiOS/STM32: send remote wakeup. * Fix report size of boot protocol. * Fix drop key stroke Keyboard report should be checked if its transfer finishs successfully. Otherwise key stroke can be missing when other key event occurs before the last report transfer is done. Boot protocol 10ms interval probably causes this problem in case it receives key events in a row within the period. NKRO protocol suffers less or nothing due to its interval 1ms. * Chibios/usb_main: rename a variable for clarity. * Add correct chibios/bootloader_jump for infinity KB. * ChibiOS: make reset request more CMSISy. * Chibios: Add breathing sleep LED on Kinetis MCUs. * ChibiOS: Update infinity bootloader code to match updated ChibiOS. * ChibiOS: prettify/document sleep_led code. * Chibios: Remove the wait in the main loop. * Add maple mini code. * Do timeout when writing to CONSOLE EP queue. Fixes TMK bug #266. * Chibios: add 'core/protocol' to the makefiles' search path. * Chibios: Update to new USB API. * Chibios: add more guards for transmitting (fix a deadlock bug). * Add update for chibios in README * Chibios: Fix a HardFault bug (wait after start). * Chibios: cleanup usb_main code. * Chibios: Revert common.mk change (fix AVR linking problem). * core: Fix chibios user compile options Compile options can be defined in project Makefile such as UDEFS, UADEFS, UINCDIR, ULIBDIR and ULIBS. * Sysv format for ChibiOS arm-none-eabi-size Some new patches to ChibiOS puts heap as it's own section. So the berkeley format is now useless, as the heap will be included in the BSS report. The sysv format displays the bss size correctly. * Fix hard-coded path of CHIBIOS * Add support for new version of ChibiOS and Contrib The Kinetis support has moved to a separate Contrib repository in the newest version of Chibios. There has also been some structure changes. So this adds support for those, while maintaining back- wards compability. * Update ChibiOS instructions * Chibios: implement sleep LED for STM32. * Chibios: Update the main chibios README. * Chibios: fix STM32_BOOTLOADER_ADDRESS name. * Chibios: make the default bootloader_jump redefinable (weak). * Chibios: disable LTO (link-time optimisation). With LTO enabled, sometimes things fail for mysterious reasons (e.g. bootloader jump on WF with LEDs enabled), just because the linker optimisation is too aggressive. * Chibios: add default location for chibios-contrib. * ChibiOS: update mk to match chibios/master. * ChibiOS: update instructions.md. * Add chibi_onekey example. * Add comments to chibi_onekey Makefile. * Rename some Makefile defines. * Move STM32 bootloader address config to separate .h file. * Rename chibios example keyboard. * Move chibios/cortex selection to local Makefiles. * Add Teensy LC onekey example. * Chibios: use WFI in idle. WIP suspend stuff. * Update chibi/teensy instructions. * Update chibios/Teensy instructions. * Add infinity_chibios * Add keymap_hasu.c * Infinity_chibios: select correct bootloader_jump. * Infinity_chibios: improve comments. * Add generic STM32F103C8T6 example. * Add maple mini code. * STM32F103x fixes. * Add maple mini pinout pic. * Chibios: updates for 3.0.4 git. * Chibios: rename example stm32_onekey -> stm32_f072_onekey. * Chibios: add makefiles for Teensy 3.x examples. * Chibios: update Teensy 3.x instructions. * Chibios: Tsy LC is cortex-m0plus. * Chibios: add more guards for transmitting (fix a deadlock bug). * Change README for chibios * Chibios: update examples to current chibios git. Match the changes in mainline chibios: - update chconf.h - update supplied ld scripts structure - update Teensy instructions (switch to official chibios and introduce contrib) * Add ChibiOS and ChibiOS-Contrib submodules Also fix the makefile path for them. * Moves chibios keyboards to keyboards folder * First version of ChibiOS compilation Only the stm32_f072_onkey keyboard is ported at the moment. It compiles, but still doesn't link. * More chibios fixes It now compiles without warnings and links * Move the teensy_lc_onekey to the keyboards folder * Clean up the make file rule structure * Remove keymap_fn_to_action * Update more ChibiOS keyboards to QMK Most of them does not compile at the moment though. * Use older version of Chibios libraries The newest ones have problems with compilation * Remove USB_UNCONFIGURED event It isn't present in the older version of ChibiOS * Fix the infinity_chibios compilation * Fix potentially uninitialized variable * Add missing include * Fix the ChibiOS makefile * Fix some Chibios keyboard compilation * Revert the rules.mk file back to master version * Combine the chibios and AVR makefiles With just the required overrides in the respective platform specific one. * Slight makefile restrucuring Platform specific compiler options * Move avr specific targets out of the main rules * Fix ChibiOS objcopy The ChibiOS objcopy needs different parameters, so the parameters are moved to the corresponding platform rule file * Fix the objcopy for real this time The comands were moved around, so chibios used avr and the ohter way around. Also change the objsize output format * Fix the thumb flags * Fix the infinity hasu keymap * Per platform cpp flags * Add gcc-arm-none-eabi package to travis * Add arm-none-eabi-newlib to travis * Fix the name of the libnewlib-arm-none-eabi lib * Fix the ChibiOS paths So that they are properly relative, and builds don't generate extra folders * Fix the board path of stm32_f103_onekey * Only consider folders with Makefiles as subproject
8 years ago
Add ChibiOS support for QMK (#465) * Modularity and gcc warnings fixes. * Add ChibiOS support (USB stack + support files). * Make usb_main more USB_DRIVER #define independent. * Move chibios to tool. * Implement jump-to-bootloader. * Small updates. * Fix bootloader-jump compiling. * Move AVR specific sleep_led.c into avr. * Add basic sleep_led for chibios. * Update chibios README. * NKRO fixes. * Rename some Makefile defines. * Move STM32 bootloader address config to separate .h file. * Add ARM Teensies bootloader code. * Fix chibios/usb_main GET_REPORT handing. * Add missing #include to keymap.c. * Make bootmagic.c code portable (_delay_ms -> wait_ms). * Move declaration of keymap_config. Should really not declare variables in .h files - since it's included in different .c files, a proper linker then complains that the same variable is declared more than once (once for each .c file that the offending .h is included in). * Add eeprom support for chibios/kinetis. * Rename chibios example keyboard. * Move chibios/cortex selection to local Makefiles. * Chibios: use WFI in idle. WIP suspend stuff. * ChibiOS/kinetis: sending remote wakeup. * ChibiOS/STM32: send remote wakeup. * Fix report size of boot protocol. * Fix drop key stroke Keyboard report should be checked if its transfer finishs successfully. Otherwise key stroke can be missing when other key event occurs before the last report transfer is done. Boot protocol 10ms interval probably causes this problem in case it receives key events in a row within the period. NKRO protocol suffers less or nothing due to its interval 1ms. * Chibios/usb_main: rename a variable for clarity. * Add correct chibios/bootloader_jump for infinity KB. * ChibiOS: make reset request more CMSISy. * Chibios: Add breathing sleep LED on Kinetis MCUs. * ChibiOS: Update infinity bootloader code to match updated ChibiOS. * ChibiOS: prettify/document sleep_led code. * Chibios: Remove the wait in the main loop. * Add maple mini code. * Do timeout when writing to CONSOLE EP queue. Fixes TMK bug #266. * Chibios: add 'core/protocol' to the makefiles' search path. * Chibios: Update to new USB API. * Chibios: add more guards for transmitting (fix a deadlock bug). * Add update for chibios in README * Chibios: Fix a HardFault bug (wait after start). * Chibios: cleanup usb_main code. * Chibios: Revert common.mk change (fix AVR linking problem). * core: Fix chibios user compile options Compile options can be defined in project Makefile such as UDEFS, UADEFS, UINCDIR, ULIBDIR and ULIBS. * Sysv format for ChibiOS arm-none-eabi-size Some new patches to ChibiOS puts heap as it's own section. So the berkeley format is now useless, as the heap will be included in the BSS report. The sysv format displays the bss size correctly. * Fix hard-coded path of CHIBIOS * Add support for new version of ChibiOS and Contrib The Kinetis support has moved to a separate Contrib repository in the newest version of Chibios. There has also been some structure changes. So this adds support for those, while maintaining back- wards compability. * Update ChibiOS instructions * Chibios: implement sleep LED for STM32. * Chibios: Update the main chibios README. * Chibios: fix STM32_BOOTLOADER_ADDRESS name. * Chibios: make the default bootloader_jump redefinable (weak). * Chibios: disable LTO (link-time optimisation). With LTO enabled, sometimes things fail for mysterious reasons (e.g. bootloader jump on WF with LEDs enabled), just because the linker optimisation is too aggressive. * Chibios: add default location for chibios-contrib. * ChibiOS: update mk to match chibios/master. * ChibiOS: update instructions.md. * Add chibi_onekey example. * Add comments to chibi_onekey Makefile. * Rename some Makefile defines. * Move STM32 bootloader address config to separate .h file. * Rename chibios example keyboard. * Move chibios/cortex selection to local Makefiles. * Add Teensy LC onekey example. * Chibios: use WFI in idle. WIP suspend stuff. * Update chibi/teensy instructions. * Update chibios/Teensy instructions. * Add infinity_chibios * Add keymap_hasu.c * Infinity_chibios: select correct bootloader_jump. * Infinity_chibios: improve comments. * Add generic STM32F103C8T6 example. * Add maple mini code. * STM32F103x fixes. * Add maple mini pinout pic. * Chibios: updates for 3.0.4 git. * Chibios: rename example stm32_onekey -> stm32_f072_onekey. * Chibios: add makefiles for Teensy 3.x examples. * Chibios: update Teensy 3.x instructions. * Chibios: Tsy LC is cortex-m0plus. * Chibios: add more guards for transmitting (fix a deadlock bug). * Change README for chibios * Chibios: update examples to current chibios git. Match the changes in mainline chibios: - update chconf.h - update supplied ld scripts structure - update Teensy instructions (switch to official chibios and introduce contrib) * Add ChibiOS and ChibiOS-Contrib submodules Also fix the makefile path for them. * Moves chibios keyboards to keyboards folder * First version of ChibiOS compilation Only the stm32_f072_onkey keyboard is ported at the moment. It compiles, but still doesn't link. * More chibios fixes It now compiles without warnings and links * Move the teensy_lc_onekey to the keyboards folder * Clean up the make file rule structure * Remove keymap_fn_to_action * Update more ChibiOS keyboards to QMK Most of them does not compile at the moment though. * Use older version of Chibios libraries The newest ones have problems with compilation * Remove USB_UNCONFIGURED event It isn't present in the older version of ChibiOS * Fix the infinity_chibios compilation * Fix potentially uninitialized variable * Add missing include * Fix the ChibiOS makefile * Fix some Chibios keyboard compilation * Revert the rules.mk file back to master version * Combine the chibios and AVR makefiles With just the required overrides in the respective platform specific one. * Slight makefile restrucuring Platform specific compiler options * Move avr specific targets out of the main rules * Fix ChibiOS objcopy The ChibiOS objcopy needs different parameters, so the parameters are moved to the corresponding platform rule file * Fix the objcopy for real this time The comands were moved around, so chibios used avr and the ohter way around. Also change the objsize output format * Fix the thumb flags * Fix the infinity hasu keymap * Per platform cpp flags * Add gcc-arm-none-eabi package to travis * Add arm-none-eabi-newlib to travis * Fix the name of the libnewlib-arm-none-eabi lib * Fix the ChibiOS paths So that they are properly relative, and builds don't generate extra folders * Fix the board path of stm32_f103_onekey * Only consider folders with Makefiles as subproject
8 years ago
Add ChibiOS support for QMK (#465) * Modularity and gcc warnings fixes. * Add ChibiOS support (USB stack + support files). * Make usb_main more USB_DRIVER #define independent. * Move chibios to tool. * Implement jump-to-bootloader. * Small updates. * Fix bootloader-jump compiling. * Move AVR specific sleep_led.c into avr. * Add basic sleep_led for chibios. * Update chibios README. * NKRO fixes. * Rename some Makefile defines. * Move STM32 bootloader address config to separate .h file. * Add ARM Teensies bootloader code. * Fix chibios/usb_main GET_REPORT handing. * Add missing #include to keymap.c. * Make bootmagic.c code portable (_delay_ms -> wait_ms). * Move declaration of keymap_config. Should really not declare variables in .h files - since it's included in different .c files, a proper linker then complains that the same variable is declared more than once (once for each .c file that the offending .h is included in). * Add eeprom support for chibios/kinetis. * Rename chibios example keyboard. * Move chibios/cortex selection to local Makefiles. * Chibios: use WFI in idle. WIP suspend stuff. * ChibiOS/kinetis: sending remote wakeup. * ChibiOS/STM32: send remote wakeup. * Fix report size of boot protocol. * Fix drop key stroke Keyboard report should be checked if its transfer finishs successfully. Otherwise key stroke can be missing when other key event occurs before the last report transfer is done. Boot protocol 10ms interval probably causes this problem in case it receives key events in a row within the period. NKRO protocol suffers less or nothing due to its interval 1ms. * Chibios/usb_main: rename a variable for clarity. * Add correct chibios/bootloader_jump for infinity KB. * ChibiOS: make reset request more CMSISy. * Chibios: Add breathing sleep LED on Kinetis MCUs. * ChibiOS: Update infinity bootloader code to match updated ChibiOS. * ChibiOS: prettify/document sleep_led code. * Chibios: Remove the wait in the main loop. * Add maple mini code. * Do timeout when writing to CONSOLE EP queue. Fixes TMK bug #266. * Chibios: add 'core/protocol' to the makefiles' search path. * Chibios: Update to new USB API. * Chibios: add more guards for transmitting (fix a deadlock bug). * Add update for chibios in README * Chibios: Fix a HardFault bug (wait after start). * Chibios: cleanup usb_main code. * Chibios: Revert common.mk change (fix AVR linking problem). * core: Fix chibios user compile options Compile options can be defined in project Makefile such as UDEFS, UADEFS, UINCDIR, ULIBDIR and ULIBS. * Sysv format for ChibiOS arm-none-eabi-size Some new patches to ChibiOS puts heap as it's own section. So the berkeley format is now useless, as the heap will be included in the BSS report. The sysv format displays the bss size correctly. * Fix hard-coded path of CHIBIOS * Add support for new version of ChibiOS and Contrib The Kinetis support has moved to a separate Contrib repository in the newest version of Chibios. There has also been some structure changes. So this adds support for those, while maintaining back- wards compability. * Update ChibiOS instructions * Chibios: implement sleep LED for STM32. * Chibios: Update the main chibios README. * Chibios: fix STM32_BOOTLOADER_ADDRESS name. * Chibios: make the default bootloader_jump redefinable (weak). * Chibios: disable LTO (link-time optimisation). With LTO enabled, sometimes things fail for mysterious reasons (e.g. bootloader jump on WF with LEDs enabled), just because the linker optimisation is too aggressive. * Chibios: add default location for chibios-contrib. * ChibiOS: update mk to match chibios/master. * ChibiOS: update instructions.md. * Add chibi_onekey example. * Add comments to chibi_onekey Makefile. * Rename some Makefile defines. * Move STM32 bootloader address config to separate .h file. * Rename chibios example keyboard. * Move chibios/cortex selection to local Makefiles. * Add Teensy LC onekey example. * Chibios: use WFI in idle. WIP suspend stuff. * Update chibi/teensy instructions. * Update chibios/Teensy instructions. * Add infinity_chibios * Add keymap_hasu.c * Infinity_chibios: select correct bootloader_jump. * Infinity_chibios: improve comments. * Add generic STM32F103C8T6 example. * Add maple mini code. * STM32F103x fixes. * Add maple mini pinout pic. * Chibios: updates for 3.0.4 git. * Chibios: rename example stm32_onekey -> stm32_f072_onekey. * Chibios: add makefiles for Teensy 3.x examples. * Chibios: update Teensy 3.x instructions. * Chibios: Tsy LC is cortex-m0plus. * Chibios: add more guards for transmitting (fix a deadlock bug). * Change README for chibios * Chibios: update examples to current chibios git. Match the changes in mainline chibios: - update chconf.h - update supplied ld scripts structure - update Teensy instructions (switch to official chibios and introduce contrib) * Add ChibiOS and ChibiOS-Contrib submodules Also fix the makefile path for them. * Moves chibios keyboards to keyboards folder * First version of ChibiOS compilation Only the stm32_f072_onkey keyboard is ported at the moment. It compiles, but still doesn't link. * More chibios fixes It now compiles without warnings and links * Move the teensy_lc_onekey to the keyboards folder * Clean up the make file rule structure * Remove keymap_fn_to_action * Update more ChibiOS keyboards to QMK Most of them does not compile at the moment though. * Use older version of Chibios libraries The newest ones have problems with compilation * Remove USB_UNCONFIGURED event It isn't present in the older version of ChibiOS * Fix the infinity_chibios compilation * Fix potentially uninitialized variable * Add missing include * Fix the ChibiOS makefile * Fix some Chibios keyboard compilation * Revert the rules.mk file back to master version * Combine the chibios and AVR makefiles With just the required overrides in the respective platform specific one. * Slight makefile restrucuring Platform specific compiler options * Move avr specific targets out of the main rules * Fix ChibiOS objcopy The ChibiOS objcopy needs different parameters, so the parameters are moved to the corresponding platform rule file * Fix the objcopy for real this time The comands were moved around, so chibios used avr and the ohter way around. Also change the objsize output format * Fix the thumb flags * Fix the infinity hasu keymap * Per platform cpp flags * Add gcc-arm-none-eabi package to travis * Add arm-none-eabi-newlib to travis * Fix the name of the libnewlib-arm-none-eabi lib * Fix the ChibiOS paths So that they are properly relative, and builds don't generate extra folders * Fix the board path of stm32_f103_onekey * Only consider folders with Makefiles as subproject
8 years ago
Moves features to their own files (process_*), adds tap dance feature (#460) * non-working commit * working * subprojects implemented for planck * pass a subproject variable through to c * consolidates clueboard revisions * thanks for letting me know about conflicts.. * turn off audio for yang's * corrects starting paths for subprojects * messing around with travis * semicolon * travis script * travis script * script for travis * correct directory (probably), amend files to commit * remove origin before adding * git pull, correct syntax * git checkout * git pull origin branch * where are we? * where are we? * merging * force things to happen * adds commit message, adds add * rebase, no commit message * rebase branch * idk! * try just pull * fetch - merge * specify repo branch * checkout * goddammit * merge? idk * pls * after all * don't split up keyboards * syntax * adds quick for all-keyboards * trying out new script * script update * lowercase * all keyboards * stop replacing compiled.hex automatically * adds if statement * skip automated build branches * forces push to automated build branch * throw an add in there * upstream? * adds AUTOGEN * ignore all .hex files again * testing out new repo * global ident * generate script, keyboard_keymap.hex * skip generation for now, print pandoc info, submodule update * try trusty * and sudo * try generate * updates subprojects to keyboards * no idea * updates to keyboards * cleans up clueboard stuff * setup to use local readme * updates cluepad, planck experimental * remove extra led.c [ci skip] * audio and midi moved over to separate files * chording, leader, unicode separated * consolidate each [skip ci] * correct include * quantum: Add a tap dance feature (#451) * quantum: Add a tap dance feature With this feature one can specify keys that behave differently, based on the amount of times they have been tapped, and when interrupted, they get handled before the interrupter. To make it clear how this is different from `ACTION_FUNCTION_TAP`, lets explore a certain setup! We want one key to send `Space` on single tap, but `Enter` on double-tap. With `ACTION_FUNCTION_TAP`, it is quite a rain-dance to set this up, and has the problem that when the sequence is interrupted, the interrupting key will be send first. Thus, `SPC a` will result in `a SPC` being sent, if they are typed within `TAPPING_TERM`. With the tap dance feature, that'll come out as `SPC a`, correctly. The implementation hooks into two parts of the system, to achieve this: into `process_record_quantum()`, and the matrix scan. We need the latter to be able to time out a tap sequence even when a key is not being pressed, so `SPC` alone will time out and register after `TAPPING_TERM` time. But lets start with how to use it, first! First, you will need `TAP_DANCE_ENABLE=yes` in your `Makefile`, because the feature is disabled by default. This adds a little less than 1k to the firmware size. Next, you will want to define some tap-dance keys, which is easiest to do with the `TD()` macro, that - similar to `F()`, takes a number, which will later be used as an index into the `tap_dance_actions` array. This array specifies what actions shall be taken when a tap-dance key is in action. Currently, there are two possible options: * `ACTION_TAP_DANCE_DOUBLE(kc1, kc2)`: Sends the `kc1` keycode when tapped once, `kc2` otherwise. * `ACTION_TAP_DANCE_FN(fn)`: Calls the specified function - defined in the user keymap - with the current state of the tap-dance action. The first option is enough for a lot of cases, that just want dual roles. For example, `ACTION_TAP_DANCE(KC_SPC, KC_ENT)` will result in `Space` being sent on single-tap, `Enter` otherwise. And that's the bulk of it! Do note, however, that this implementation does have some consequences: keys do not register until either they reach the tapping ceiling, or they time out. This means that if you hold the key, nothing happens, no repeat, no nothing. It is possible to detect held state, and register an action then too, but that's not implemented yet. Keys also unregister immediately after being registered, so you can't even hold the second tap. This is intentional, to be consistent. And now, on to the explanation of how it works! The main entry point is `process_tap_dance()`, called from `process_record_quantum()`, which is run for every keypress, and our handler gets to run early. This function checks whether the key pressed is a tap-dance key. If it is not, and a tap-dance was in action, we handle that first, and enqueue the newly pressed key. If it is a tap-dance key, then we check if it is the same as the already active one (if there's one active, that is). If it is not, we fire off the old one first, then register the new one. If it was the same, we increment the counter and the timer. This means that you have `TAPPING_TERM` time to tap the key again, you do not have to input all the taps within that timeframe. This allows for longer tap counts, with minimal impact on responsiveness. Our next stop is `matrix_scan_tap_dance()`. This handles the timeout of tap-dance keys. For the sake of flexibility, tap-dance actions can be either a pair of keycodes, or a user function. The latter allows one to handle higher tap counts, or do extra things, like blink the LEDs, fiddle with the backlighting, and so on. This is accomplished by using an union, and some clever macros. In the end, lets see a full example! ```c enum { CT_SE = 0, CT_CLN, CT_EGG }; /* Have the above three on the keymap, TD(CT_SE), etc... */ void dance_cln (qk_tap_dance_state_t *state) { if (state->count == 1) { register_code (KC_RSFT); register_code (KC_SCLN); unregister_code (KC_SCLN); unregister_code (KC_RSFT); } else { register_code (KC_SCLN); unregister_code (KC_SCLN); reset_tap_dance (state); } } void dance_egg (qk_tap_dance_state_t *state) { if (state->count >= 100) { SEND_STRING ("Safety dance!"); reset_tap_dance (state); } } const qk_tap_dance_action_t tap_dance_actions[] = { [CT_SE] = ACTION_TAP_DANCE_DOUBLE (KC_SPC, KC_ENT) ,[CT_CLN] = ACTION_TAP_DANCE_FN (dance_cln) ,[CT_EGG] = ACTION_TAP_DANCE_FN (dance_egg) }; ``` This addresses #426. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org> * hhkb: Fix the build with the new tap-dance feature Signed-off-by: Gergely Nagy <algernon@madhouse-project.org> * tap_dance: Move process_tap_dance further down Process the tap dance stuff after midi and audio, because those don't process keycodes, but row/col positions. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org> * tap_dance: Use conditionals instead of dummy functions To be consistent with how the rest of the quantum features are implemented, use ifdefs instead of dummy functions. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org> * Merge branch 'master' into quantum-keypress-process # Conflicts: # Makefile # keyboards/planck/rev3/config.h # keyboards/planck/rev4/config.h * update build script
8 years ago
7 years ago
7 years ago
  1. /*
  2. Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef KEYMAP_H
  15. #define KEYMAP_H
  16. #include <stdint.h>
  17. #include <stdbool.h>
  18. #include "action.h"
  19. #if defined(__AVR__)
  20. #include <avr/pgmspace.h>
  21. #endif
  22. #include "keycode.h"
  23. #include "action_macro.h"
  24. #include "report.h"
  25. #include "host.h"
  26. // #include "print.h"
  27. #include "debug.h"
  28. #include "keycode_config.h"
  29. // ChibiOS uses RESET in its FlagStatus enumeration
  30. // Therefore define it as QK_RESET here, to avoid name collision
  31. #if defined(PROTOCOL_CHIBIOS)
  32. #define RESET QK_RESET
  33. #endif
  34. /* translates key to keycode */
  35. uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
  36. extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
  37. extern const uint16_t fn_actions[];
  38. enum quantum_keycodes {
  39. // Ranges used in shortucuts - not to be used directly
  40. QK_TMK = 0x0000,
  41. QK_TMK_MAX = 0x00FF,
  42. QK_MODS = 0x0100,
  43. QK_LCTL = 0x0100,
  44. QK_LSFT = 0x0200,
  45. QK_LALT = 0x0400,
  46. QK_LGUI = 0x0800,
  47. QK_RCTL = 0x1100,
  48. QK_RSFT = 0x1200,
  49. QK_RALT = 0x1400,
  50. QK_RGUI = 0x1800,
  51. QK_MODS_MAX = 0x1FFF,
  52. QK_FUNCTION = 0x2000,
  53. QK_FUNCTION_MAX = 0x2FFF,
  54. QK_MACRO = 0x3000,
  55. QK_MACRO_MAX = 0x3FFF,
  56. QK_LAYER_TAP = 0x4000,
  57. QK_LAYER_TAP_MAX = 0x4FFF,
  58. QK_TO = 0x5000,
  59. QK_TO_MAX = 0x50FF,
  60. QK_MOMENTARY = 0x5100,
  61. QK_MOMENTARY_MAX = 0x51FF,
  62. QK_DEF_LAYER = 0x5200,
  63. QK_DEF_LAYER_MAX = 0x52FF,
  64. QK_TOGGLE_LAYER = 0x5300,
  65. QK_TOGGLE_LAYER_MAX = 0x53FF,
  66. QK_ONE_SHOT_LAYER = 0x5400,
  67. QK_ONE_SHOT_LAYER_MAX = 0x54FF,
  68. QK_ONE_SHOT_MOD = 0x5500,
  69. QK_ONE_SHOT_MOD_MAX = 0x55FF,
  70. #ifndef DISABLE_CHORDING
  71. QK_CHORDING = 0x5600,
  72. QK_CHORDING_MAX = 0x56FF,
  73. #endif
  74. QK_MOD_TAP = 0x6000,
  75. QK_MOD_TAP_MAX = 0x6FFF,
  76. QK_TAP_DANCE = 0x7100,
  77. QK_TAP_DANCE_MAX = 0x71FF,
  78. #ifdef UNICODEMAP_ENABLE
  79. QK_UNICODE_MAP = 0x7800,
  80. QK_UNICODE_MAP_MAX = 0x7FFF,
  81. #endif
  82. #ifdef UNICODE_ENABLE
  83. QK_UNICODE = 0x8000,
  84. QK_UNICODE_MAX = 0xFFFF,
  85. #endif
  86. // Loose keycodes - to be used directly
  87. RESET = 0x7000,
  88. DEBUG,
  89. MAGIC_SWAP_CONTROL_CAPSLOCK,
  90. MAGIC_CAPSLOCK_TO_CONTROL,
  91. MAGIC_SWAP_LALT_LGUI,
  92. MAGIC_SWAP_RALT_RGUI,
  93. MAGIC_NO_GUI,
  94. MAGIC_SWAP_GRAVE_ESC,
  95. MAGIC_SWAP_BACKSLASH_BACKSPACE,
  96. MAGIC_HOST_NKRO,
  97. MAGIC_SWAP_ALT_GUI,
  98. MAGIC_UNSWAP_CONTROL_CAPSLOCK,
  99. MAGIC_UNCAPSLOCK_TO_CONTROL,
  100. MAGIC_UNSWAP_LALT_LGUI,
  101. MAGIC_UNSWAP_RALT_RGUI,
  102. MAGIC_UNNO_GUI,
  103. MAGIC_UNSWAP_GRAVE_ESC,
  104. MAGIC_UNSWAP_BACKSLASH_BACKSPACE,
  105. MAGIC_UNHOST_NKRO,
  106. MAGIC_UNSWAP_ALT_GUI,
  107. MAGIC_TOGGLE_NKRO,
  108. // Leader key
  109. #ifndef DISABLE_LEADER
  110. KC_LEAD,
  111. #endif
  112. // Audio on/off/toggle
  113. AU_ON,
  114. AU_OFF,
  115. AU_TOG,
  116. // Music mode on/off/toggle
  117. MU_ON,
  118. MU_OFF,
  119. MU_TOG,
  120. // Music voice iterate
  121. MUV_IN,
  122. MUV_DE,
  123. // Midi mode on/off
  124. MIDI_ON,
  125. MIDI_OFF,
  126. // Backlight functionality
  127. BL_0,
  128. BL_1,
  129. BL_2,
  130. BL_3,
  131. BL_4,
  132. BL_5,
  133. BL_6,
  134. BL_7,
  135. BL_8,
  136. BL_9,
  137. BL_10,
  138. BL_11,
  139. BL_12,
  140. BL_13,
  141. BL_14,
  142. BL_15,
  143. BL_DEC,
  144. BL_INC,
  145. BL_TOGG,
  146. BL_STEP,
  147. // RGB functionality
  148. RGB_TOG,
  149. RGB_MOD,
  150. RGB_HUI,
  151. RGB_HUD,
  152. RGB_SAI,
  153. RGB_SAD,
  154. RGB_VAI,
  155. RGB_VAD,
  156. // Left shift, open paren
  157. KC_LSPO,
  158. // Right shift, close paren
  159. KC_RSPC,
  160. // always leave at the end
  161. SAFE_RANGE
  162. };
  163. // Ability to use mods in layouts
  164. #define LCTL(kc) (kc | QK_LCTL)
  165. #define LSFT(kc) (kc | QK_LSFT)
  166. #define LALT(kc) (kc | QK_LALT)
  167. #define LGUI(kc) (kc | QK_LGUI)
  168. #define RCTL(kc) (kc | QK_RCTL)
  169. #define RSFT(kc) (kc | QK_RSFT)
  170. #define RALT(kc) (kc | QK_RALT)
  171. #define RGUI(kc) (kc | QK_RGUI)
  172. #define HYPR(kc) (kc | QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI)
  173. #define MEH(kc) (kc | QK_LCTL | QK_LSFT | QK_LALT)
  174. #define LCAG(kc) (kc | QK_LCTL | QK_LALT | QK_LGUI)
  175. #define ALTG(kc) (kc | QK_RCTL | QK_RALT)
  176. #define MOD_HYPR 0xf
  177. #define MOD_MEH 0x7
  178. // Aliases for shifted symbols
  179. // Each key has a 4-letter code, and some have longer aliases too.
  180. // While the long aliases are descriptive, the 4-letter codes
  181. // make for nicer grid layouts (everything lines up), and are
  182. // the preferred style for Quantum.
  183. #define KC_TILD LSFT(KC_GRV) // ~
  184. #define KC_TILDE KC_TILD
  185. #define KC_EXLM LSFT(KC_1) // !
  186. #define KC_EXCLAIM KC_EXLM
  187. #define KC_AT LSFT(KC_2) // @
  188. #define KC_HASH LSFT(KC_3) // #
  189. #define KC_DLR LSFT(KC_4) // $
  190. #define KC_DOLLAR KC_DLR
  191. #define KC_PERC LSFT(KC_5) // %
  192. #define KC_PERCENT KC_PERC
  193. #define KC_CIRC LSFT(KC_6) // ^
  194. #define KC_CIRCUMFLEX KC_CIRC
  195. #define KC_AMPR LSFT(KC_7) // &
  196. #define KC_AMPERSAND KC_AMPR
  197. #define KC_ASTR LSFT(KC_8) // *
  198. #define KC_ASTERISK KC_ASTR
  199. #define KC_LPRN LSFT(KC_9) // (
  200. #define KC_LEFT_PAREN KC_LPRN
  201. #define KC_RPRN LSFT(KC_0) // )
  202. #define KC_RIGHT_PAREN KC_RPRN
  203. #define KC_UNDS LSFT(KC_MINS) // _
  204. #define KC_UNDERSCORE KC_UNDS
  205. #define KC_PLUS LSFT(KC_EQL) // +
  206. #define KC_LCBR LSFT(KC_LBRC) // {
  207. #define KC_LEFT_CURLY_BRACE KC_LCBR
  208. #define KC_RCBR LSFT(KC_RBRC) // }
  209. #define KC_RIGHT_CURLY_BRACE KC_RCBR
  210. #define KC_LABK LSFT(KC_COMM) // <
  211. #define KC_LEFT_ANGLE_BRACKET KC_LABK
  212. #define KC_RABK LSFT(KC_DOT) // >
  213. #define KC_RIGHT_ANGLE_BRACKET KC_RABK
  214. #define KC_COLN LSFT(KC_SCLN) // :
  215. #define KC_COLON KC_COLN
  216. #define KC_PIPE LSFT(KC_BSLS) // |
  217. #define KC_LT LSFT(KC_COMM) // <
  218. #define KC_GT LSFT(KC_DOT) // >
  219. #define KC_QUES LSFT(KC_SLSH) // ?
  220. #define KC_QUESTION KC_QUES
  221. #define KC_DQT LSFT(KC_QUOT) // "
  222. #define KC_DOUBLE_QUOTE KC_DQT
  223. #define KC_DQUO KC_DQT
  224. #define KC_DELT KC_DELETE // Del key (four letter code)
  225. // Alias for function layers than expand past FN31
  226. #define FUNC(kc) (kc | QK_FUNCTION)
  227. // Aliases
  228. #define S(kc) LSFT(kc)
  229. #define F(kc) FUNC(kc)
  230. #define M(kc) (kc | QK_MACRO)
  231. #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
  232. // L-ayer, T-ap - 256 keycode max, 16 layer max
  233. #define LT(layer, kc) (kc | QK_LAYER_TAP | ((layer & 0xF) << 8))
  234. #define AG_SWAP MAGIC_SWAP_ALT_GUI
  235. #define AG_NORM MAGIC_UNSWAP_ALT_GUI
  236. #define BL_ON BL_9
  237. #define BL_OFF BL_0
  238. #define MI_ON MIDI_ON
  239. #define MI_OFF MIDI_OFF
  240. // GOTO layer - 16 layers max
  241. // when:
  242. // ON_PRESS = 1
  243. // ON_RELEASE = 2
  244. // Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default.
  245. // In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own
  246. // keycode modeled after the old version, kept below for this.
  247. /* #define TO(layer, when) (layer | QK_TO | (when << 0x4)) */
  248. #define TO(layer) (layer | QK_TO | (ON_PRESS << 0x4))
  249. // Momentary switch layer - 256 layer max
  250. #define MO(layer) (layer | QK_MOMENTARY)
  251. // Set default layer - 256 layer max
  252. #define DF(layer) (layer | QK_DEF_LAYER)
  253. // Toggle to layer - 256 layer max
  254. #define TG(layer) (layer | QK_TOGGLE_LAYER)
  255. // One-shot layer - 256 layer max
  256. #define OSL(layer) (layer | QK_ONE_SHOT_LAYER)
  257. // One-shot mod
  258. #define OSM(mod) (mod | QK_ONE_SHOT_MOD)
  259. // M-od, T-ap - 256 keycode max
  260. #define MT(mod, kc) (kc | QK_MOD_TAP | ((mod & 0xF) << 8))
  261. #define CTL_T(kc) MT(MOD_LCTL, kc)
  262. #define SFT_T(kc) MT(MOD_LSFT, kc)
  263. #define ALT_T(kc) MT(MOD_LALT, kc)
  264. #define GUI_T(kc) MT(MOD_LGUI, kc)
  265. #define C_S_T(kc) MT((MOD_LCTL | MOD_LSFT), kc) // Control + Shift e.g. for gnome-terminal
  266. #define MEH_T(kc) MT((MOD_LCTL | MOD_LSFT | MOD_LALT), kc) // Meh is a less hyper version of the Hyper key -- doesn't include Win or Cmd, so just alt+shift+ctrl
  267. #define LCAG_T(kc) MT((MOD_LCTL | MOD_LALT | MOD_LGUI), kc) // Left control alt and gui
  268. #define ALL_T(kc) MT((MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI), kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/
  269. // Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap
  270. #define KC_HYPR HYPR(KC_NO)
  271. #define KC_MEH MEH(KC_NO)
  272. #ifdef UNICODE_ENABLE
  273. // For sending unicode codes.
  274. // You may not send codes over 7FFF -- this supports most of UTF8.
  275. // To have a key that sends out Œ, go UC(0x0152)
  276. #define UNICODE(n) (n | QK_UNICODE)
  277. #define UC(n) UNICODE(n)
  278. #endif
  279. #ifdef UNICODEMAP_ENABLE
  280. #define X(n) (n | QK_UNICODE_MAP)
  281. #endif
  282. #endif