Keyboard firmwares for Atmel AVR and Cortex-M
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.

action.c 19KB

Squashed 'tmk_core/' changes from ee8c5ba..d5c5ac6 d5c5ac6 Merge branch 'develop' 5957682 Merge branch 'hotfix-mediakey' a478c62 Merge branch 'hotfix-vusb' cccebfe Merge branch 'njbair-docfix' 0aaab57 Clean up wording in keymap example dc8bbc3 Clarify layer precedence 9e0b4c1 clarify layer documentation 915eb48 core: Fix media/consumer keys 88f90f3 Fix for VUSB configuration 3e290cd Fix including board.mk in chibios.mk 32c69e0 Merge branch 'newapi' into develop c9a56f9 Merge remote-tracking branch 'flabbergast/chibios' into develop 01e33ea Fix chibios and mbed common.mk for hook.c bea79d9 hook: Change func name of usb events 3e97536 hook: Change file and func names(*_hook -> hook_*) c286d8c Merge pull request #10 from fredizzimo/chibios-contrib2 062d74e Update ChibiOS instructions d47150f Add support for new version of ChibiOS and Contrib 62b5401 Chibios: disable LTO (link-time optimisation). c64e9aa hooks: Fix for LUFA 54e68b0 hooks: Remove led_restore_hook 325c09d Chibios: make the default bootloader_jump redefinable (weak). 078c722 Chibios: fix STM32_BOOTLOADER_ADDRESS name. e73cfe5 hooks: Fix for keyboard LED update e6120c5 Implement basic hooks. 7c370e9 Chibios: Update the main chibios README. 7f0198d Chibios: implement sleep LED for STM32. afef9b4 Fix hard-coded path of CHIBIOS 95c5b19 Merge pull request #7 from fredizzimo/sysvsize 27128a8 Sysv format for ChibiOS arm-none-eabi-size d4b8e68 core: Fix chibios user compile options b85d462 Merge branch 'chibios' of https://github.com/flabbergast/tmk_keyboard into flabbergast_chibios de41aa1 core: Fix ps2_mouse.c debug print d79d925 Removed duplicate debug message code and surrounded it with IFDEF as needed 8f28589 Chibios: Revert common.mk change (fix AVR linking problem). ec9eff2 Chibios: cleanup usb_main code. 28c4665 Chibios: Fix a HardFault bug (wait after start). git-subtree-dir: tmk_core git-subtree-split: d5c5ac63e60dfc6da6661a21bd968b4d577a27d5
8 years ago
Squashed 'tmk_core/' changes from 8da1898..e5f9940 e5f9940 Merge commit '1bc3dd200b023cecf063a0cb3ba347f77f6d759d' into core_update da03c50 Add note for L/R side bit being ignored e80f3c1 Add in basic documentation for Macro system 35e8a76 core: Swap position of PEQL and PENT in unimap 00751f1 Merge pull request #406 from 39aldo39/patch-1 e50d7de V-USB remote wakeup 4340997 core: Fix typo in definition AC_g 958144d core: Debug print for system and consumer keys e7e1030 core: Fix sleep_led 0866323 core: Change matrix_init and matrix_print 0dbf73d core: Add matrix_clear() and default impl. 3202ca3 core: Add suspend mode options 4cda3aa core: Fix suspend/wake for converters #386 4e15247 core: LUFA_DEBUG_SUART for serial debug b9cf8e7 core: Fix mechanical locking supoort #390 12aa0fd Merge branch 'nemith-master' fccb3fa core: Fix OPT_DEFS for mbed build 2e2d2c8 Merge branch 'master' of github.com:leizzer/tmk_keyboard f1d3634 Change .gitignore for ChibiOS 3aab802 core: Fix build config in protocol.mk 5e43da0 core: Add short names in unimap 7a56998 core: Fix dfu wait in rules.mk 6d9c500 Merge branch 'mediakey-fix' 08382ac core: Fix 'make dfu' message 78cb04e Fix OS X Recognizing keyboard as Mouse/Tablet a114714 core: 'make dfu' waits for bootloader to start d0a8f13 core: Fix unimap UNIMAP_NO case e17abef core: Change lufa NKRO report size 16 to 32 bytes 375b20f core: Fix common.mk for build options 394fdff core: Fix unimap layout comment 912326c core: Add unimap support 00f4011 core: Fix doc/keymap.md for new keymap framework ddbd7b4 core: Add default implemenation of keymap read 671cacc core: action codes are action_t struct now b4fdb27 core: Change chibios repo directory names 7daed10 core: Fix keycode.txt 90399d7 core: Fix USB remote wakeup on ATmega32U2 #361 3677e84 usb_usb: Add multiple keyboard support 54d5b26 core: Fix Logical Maximum in report descriptor bd0d372 core: Fix LUFA report descriptor 95327b5 Merge pull request #355 from papodaca/XT 62bf548 core: change API of adb.c to accept device address 3097c9e Fix function name in host.h 836e209 Merge branch 'core_split_160522' 3918ea2 Merge commit '20b787fc1284176834cbe7ca2134e4b36bec5828' 7f87b11 core: Add comment of register 3 of ADB ef6478a core: Add adb_host_talk() 5c665b4 update macro names in bluefruit 4f2c5bf Merge commit '71381457fa1311dfa0b58ba882a96db740640871' 53a9c08 Merge pull request #321 from njbair/master f08a656 core: Fix media/consumer keys d526de8 Clean up wording in keymap example 0bb3dbb Clarify layer precedence d915c75 clarify layer documentation 72070d4 ps2_usb: Fix for VUSB configuration 170e2dc Mostly working. Is unstable, will emit bad codes after a while. c8e45b5 core: Actionmap support aabaa24 Codes appear to be detected correctly, the break codes are broken. git-subtree-dir: tmk_core git-subtree-split: e5f994033cbc8700745ac0c6d12772820492eed0
7 years ago
Squashed 'tmk_core/' changes from ee8c5ba..d5c5ac6 d5c5ac6 Merge branch 'develop' 5957682 Merge branch 'hotfix-mediakey' a478c62 Merge branch 'hotfix-vusb' cccebfe Merge branch 'njbair-docfix' 0aaab57 Clean up wording in keymap example dc8bbc3 Clarify layer precedence 9e0b4c1 clarify layer documentation 915eb48 core: Fix media/consumer keys 88f90f3 Fix for VUSB configuration 3e290cd Fix including board.mk in chibios.mk 32c69e0 Merge branch 'newapi' into develop c9a56f9 Merge remote-tracking branch 'flabbergast/chibios' into develop 01e33ea Fix chibios and mbed common.mk for hook.c bea79d9 hook: Change func name of usb events 3e97536 hook: Change file and func names(*_hook -> hook_*) c286d8c Merge pull request #10 from fredizzimo/chibios-contrib2 062d74e Update ChibiOS instructions d47150f Add support for new version of ChibiOS and Contrib 62b5401 Chibios: disable LTO (link-time optimisation). c64e9aa hooks: Fix for LUFA 54e68b0 hooks: Remove led_restore_hook 325c09d Chibios: make the default bootloader_jump redefinable (weak). 078c722 Chibios: fix STM32_BOOTLOADER_ADDRESS name. e73cfe5 hooks: Fix for keyboard LED update e6120c5 Implement basic hooks. 7c370e9 Chibios: Update the main chibios README. 7f0198d Chibios: implement sleep LED for STM32. afef9b4 Fix hard-coded path of CHIBIOS 95c5b19 Merge pull request #7 from fredizzimo/sysvsize 27128a8 Sysv format for ChibiOS arm-none-eabi-size d4b8e68 core: Fix chibios user compile options b85d462 Merge branch 'chibios' of https://github.com/flabbergast/tmk_keyboard into flabbergast_chibios de41aa1 core: Fix ps2_mouse.c debug print d79d925 Removed duplicate debug message code and surrounded it with IFDEF as needed 8f28589 Chibios: Revert common.mk change (fix AVR linking problem). ec9eff2 Chibios: cleanup usb_main code. 28c4665 Chibios: Fix a HardFault bug (wait after start). git-subtree-dir: tmk_core git-subtree-split: d5c5ac63e60dfc6da6661a21bd968b4d577a27d5
8 years ago
Squashed 'tmk_core/' changes from 57d27a8..08ce4c3 08ce4c3 Add update for chibios in README 30cac1d Merge remote-tracking branch 'flabbergast-tmk_keyboard/chibios' f218a38 core: Remove unused warning. Fix tmk_keyboard/#293 3e68807 Chibios: add more guards for transmitting (fix a deadlock bug). cecc807 core: Speed up compilation d01d959 Merge remote-tracking branch 'upstream/master' into chibios 8ff12ae Merge pull request #230 from jerryen/master 3afb83d core: Add note about sudo and git 2525d5d Chibios: Update to new USB API. 2fc5cd6 Merge branch 'master' into chibios 6f5511a core: Fix variable initialize 02a15fa core: Fix variable init and header include 1833ca1 Merge pull request #292 from obones/command_warning bc9dc6f Merge pull request #294 from shayneholmes/fix-debug-message c1b891b Merge pull request #295 from doopai/master 1da837c core: Add macro commands SM(), RM() and CM() d9d5a93 Add support for storing, restoring and clearing modifiers in macros 4f371c0 core: Add dfu-programmer example to doc/build.md ba3792e core: Fix doc/build.md 4b99fed remove SERIAL_SOFT_DEBUG macro 984accb Fix typo in bootmagic debug message 67a7ea1 usb_usb: Fix for keymap editor 2fc9ae4 host_driver is only used if KEYBOARD_LOCK_ENABLE is defined a35cdea Chibios: add 'core/protocol' to the makefiles' search path. 5ed2fd6 Merge remote-tracking branch 'upstream/master' into chibios bbc4851 Do timeout when writing to CONSOLE EP queue. 2450559 Remove an errant comma trailing the KC_ERAS macro alias 8465747 Merge pull request #270 from jeffgran/single-tap-toggle a37339a Merge pull request #271 from jeffgran/default-layer-toggle 8e732f7 core: Update doc/build.md and remove other_projects.md e47dc15 Workaround for compiler warnings when console disabled. 4184c52 Add maple mini code. b555238 core: Fix rules.mk for dfu target 26dacf4 add ACTION_DEFAULT_LAYER_TOGGLE to toggle a default layer on/off 83607d9 enable TAPPING_TOGGLE=1 to work correctly bef3089 Merge branch 'master' into chibios f7a55fd core: Fix debug print of usb_hid 1402f7d core: Add keycode KC_JPY for JIS 8e3a460 Chibios: Remove the wait in the main loop. 7d41746 ChibiOS: prettify/document sleep_led code. 235cdee ChibiOS: Update infinity bootloader code to match updated ChibiOS. 807bf1e Chibios: Add breathing sleep LED on Kinetis MCUs. ba3bf7c ChibiOS: make reset request more CMSISy. bf2ffd4 Add correct chibios/bootloader_jump for infinity KB. f5e03fd Chibios/usb_main: rename a variable for clarity. 63a330c Fix drop key stroke d8f5b06 Fix report size of boot protocol. 38abb50 ChibiOS/STM32: send remote wakeup. 6725650 ChibiOS/kinetis: sending remote wakeup. 69f6e54 Chibios: use WFI in idle. WIP suspend stuff. 02f044b Move chibios/cortex selection to local Makefiles. fa59dfa Rename chibios example keyboard. 5c060de Add eeprom support for chibios/kinetis. efd0044 Move declaration of keymap_config. 7196b24 Make bootmagic.c code portable (_delay_ms -> wait_ms). 37b15b2 Add missing #include to keymap.c. 31316e3 Merge branch 'master' into chibios 166f312 Fix chibios/usb_main GET_REPORT handing. 57ac6c2 Add ARM Teensies bootloader code. 1758086 Move STM32 bootloader address config to separate .h file. 03bb026 Rename some Makefile defines. 76ba6ac NKRO fixes. 06498f8 Update chibios README. db0a4f5 Add basic sleep_led for chibios. c3f930e Move AVR specific sleep_led.c into avr. 4069494 Fix bootloader-jump compiling. 9117f7b Small updates. 269cb85 Implement jump-to-bootloader. 7e81b34 Move chibios to tool. 923a892 Make usb_main more USB_DRIVER #define independent. aa054f0 Add ChibiOS support (USB stack + support files). 1e3e282 Modularity and gcc warnings fixes. 2f60ce0 Add KEYBOARD_LOCK_ENABLE to makefile git-subtree-dir: tmk_core git-subtree-split: 08ce4c3021d2ecd446c5b9a137aded65423d241e
8 years ago
Squashed 'tmk_core/' changes from 57d27a8..08ce4c3 08ce4c3 Add update for chibios in README 30cac1d Merge remote-tracking branch 'flabbergast-tmk_keyboard/chibios' f218a38 core: Remove unused warning. Fix tmk_keyboard/#293 3e68807 Chibios: add more guards for transmitting (fix a deadlock bug). cecc807 core: Speed up compilation d01d959 Merge remote-tracking branch 'upstream/master' into chibios 8ff12ae Merge pull request #230 from jerryen/master 3afb83d core: Add note about sudo and git 2525d5d Chibios: Update to new USB API. 2fc5cd6 Merge branch 'master' into chibios 6f5511a core: Fix variable initialize 02a15fa core: Fix variable init and header include 1833ca1 Merge pull request #292 from obones/command_warning bc9dc6f Merge pull request #294 from shayneholmes/fix-debug-message c1b891b Merge pull request #295 from doopai/master 1da837c core: Add macro commands SM(), RM() and CM() d9d5a93 Add support for storing, restoring and clearing modifiers in macros 4f371c0 core: Add dfu-programmer example to doc/build.md ba3792e core: Fix doc/build.md 4b99fed remove SERIAL_SOFT_DEBUG macro 984accb Fix typo in bootmagic debug message 67a7ea1 usb_usb: Fix for keymap editor 2fc9ae4 host_driver is only used if KEYBOARD_LOCK_ENABLE is defined a35cdea Chibios: add 'core/protocol' to the makefiles' search path. 5ed2fd6 Merge remote-tracking branch 'upstream/master' into chibios bbc4851 Do timeout when writing to CONSOLE EP queue. 2450559 Remove an errant comma trailing the KC_ERAS macro alias 8465747 Merge pull request #270 from jeffgran/single-tap-toggle a37339a Merge pull request #271 from jeffgran/default-layer-toggle 8e732f7 core: Update doc/build.md and remove other_projects.md e47dc15 Workaround for compiler warnings when console disabled. 4184c52 Add maple mini code. b555238 core: Fix rules.mk for dfu target 26dacf4 add ACTION_DEFAULT_LAYER_TOGGLE to toggle a default layer on/off 83607d9 enable TAPPING_TOGGLE=1 to work correctly bef3089 Merge branch 'master' into chibios f7a55fd core: Fix debug print of usb_hid 1402f7d core: Add keycode KC_JPY for JIS 8e3a460 Chibios: Remove the wait in the main loop. 7d41746 ChibiOS: prettify/document sleep_led code. 235cdee ChibiOS: Update infinity bootloader code to match updated ChibiOS. 807bf1e Chibios: Add breathing sleep LED on Kinetis MCUs. ba3bf7c ChibiOS: make reset request more CMSISy. bf2ffd4 Add correct chibios/bootloader_jump for infinity KB. f5e03fd Chibios/usb_main: rename a variable for clarity. 63a330c Fix drop key stroke d8f5b06 Fix report size of boot protocol. 38abb50 ChibiOS/STM32: send remote wakeup. 6725650 ChibiOS/kinetis: sending remote wakeup. 69f6e54 Chibios: use WFI in idle. WIP suspend stuff. 02f044b Move chibios/cortex selection to local Makefiles. fa59dfa Rename chibios example keyboard. 5c060de Add eeprom support for chibios/kinetis. efd0044 Move declaration of keymap_config. 7196b24 Make bootmagic.c code portable (_delay_ms -> wait_ms). 37b15b2 Add missing #include to keymap.c. 31316e3 Merge branch 'master' into chibios 166f312 Fix chibios/usb_main GET_REPORT handing. 57ac6c2 Add ARM Teensies bootloader code. 1758086 Move STM32 bootloader address config to separate .h file. 03bb026 Rename some Makefile defines. 76ba6ac NKRO fixes. 06498f8 Update chibios README. db0a4f5 Add basic sleep_led for chibios. c3f930e Move AVR specific sleep_led.c into avr. 4069494 Fix bootloader-jump compiling. 9117f7b Small updates. 269cb85 Implement jump-to-bootloader. 7e81b34 Move chibios to tool. 923a892 Make usb_main more USB_DRIVER #define independent. aa054f0 Add ChibiOS support (USB stack + support files). 1e3e282 Modularity and gcc warnings fixes. 2f60ce0 Add KEYBOARD_LOCK_ENABLE to makefile git-subtree-dir: tmk_core git-subtree-split: 08ce4c3021d2ecd446c5b9a137aded65423d241e
8 years ago
Squashed 'tmk_core/' changes from 8da1898..e5f9940 e5f9940 Merge commit '1bc3dd200b023cecf063a0cb3ba347f77f6d759d' into core_update da03c50 Add note for L/R side bit being ignored e80f3c1 Add in basic documentation for Macro system 35e8a76 core: Swap position of PEQL and PENT in unimap 00751f1 Merge pull request #406 from 39aldo39/patch-1 e50d7de V-USB remote wakeup 4340997 core: Fix typo in definition AC_g 958144d core: Debug print for system and consumer keys e7e1030 core: Fix sleep_led 0866323 core: Change matrix_init and matrix_print 0dbf73d core: Add matrix_clear() and default impl. 3202ca3 core: Add suspend mode options 4cda3aa core: Fix suspend/wake for converters #386 4e15247 core: LUFA_DEBUG_SUART for serial debug b9cf8e7 core: Fix mechanical locking supoort #390 12aa0fd Merge branch 'nemith-master' fccb3fa core: Fix OPT_DEFS for mbed build 2e2d2c8 Merge branch 'master' of github.com:leizzer/tmk_keyboard f1d3634 Change .gitignore for ChibiOS 3aab802 core: Fix build config in protocol.mk 5e43da0 core: Add short names in unimap 7a56998 core: Fix dfu wait in rules.mk 6d9c500 Merge branch 'mediakey-fix' 08382ac core: Fix 'make dfu' message 78cb04e Fix OS X Recognizing keyboard as Mouse/Tablet a114714 core: 'make dfu' waits for bootloader to start d0a8f13 core: Fix unimap UNIMAP_NO case e17abef core: Change lufa NKRO report size 16 to 32 bytes 375b20f core: Fix common.mk for build options 394fdff core: Fix unimap layout comment 912326c core: Add unimap support 00f4011 core: Fix doc/keymap.md for new keymap framework ddbd7b4 core: Add default implemenation of keymap read 671cacc core: action codes are action_t struct now b4fdb27 core: Change chibios repo directory names 7daed10 core: Fix keycode.txt 90399d7 core: Fix USB remote wakeup on ATmega32U2 #361 3677e84 usb_usb: Add multiple keyboard support 54d5b26 core: Fix Logical Maximum in report descriptor bd0d372 core: Fix LUFA report descriptor 95327b5 Merge pull request #355 from papodaca/XT 62bf548 core: change API of adb.c to accept device address 3097c9e Fix function name in host.h 836e209 Merge branch 'core_split_160522' 3918ea2 Merge commit '20b787fc1284176834cbe7ca2134e4b36bec5828' 7f87b11 core: Add comment of register 3 of ADB ef6478a core: Add adb_host_talk() 5c665b4 update macro names in bluefruit 4f2c5bf Merge commit '71381457fa1311dfa0b58ba882a96db740640871' 53a9c08 Merge pull request #321 from njbair/master f08a656 core: Fix media/consumer keys d526de8 Clean up wording in keymap example 0bb3dbb Clarify layer precedence d915c75 clarify layer documentation 72070d4 ps2_usb: Fix for VUSB configuration 170e2dc Mostly working. Is unstable, will emit bad codes after a while. c8e45b5 core: Actionmap support aabaa24 Codes appear to be detected correctly, the break codes are broken. git-subtree-dir: tmk_core git-subtree-split: e5f994033cbc8700745ac0c6d12772820492eed0
7 years ago
Squashed 'tmk_core/' changes from 8da1898..e5f9940 e5f9940 Merge commit '1bc3dd200b023cecf063a0cb3ba347f77f6d759d' into core_update da03c50 Add note for L/R side bit being ignored e80f3c1 Add in basic documentation for Macro system 35e8a76 core: Swap position of PEQL and PENT in unimap 00751f1 Merge pull request #406 from 39aldo39/patch-1 e50d7de V-USB remote wakeup 4340997 core: Fix typo in definition AC_g 958144d core: Debug print for system and consumer keys e7e1030 core: Fix sleep_led 0866323 core: Change matrix_init and matrix_print 0dbf73d core: Add matrix_clear() and default impl. 3202ca3 core: Add suspend mode options 4cda3aa core: Fix suspend/wake for converters #386 4e15247 core: LUFA_DEBUG_SUART for serial debug b9cf8e7 core: Fix mechanical locking supoort #390 12aa0fd Merge branch 'nemith-master' fccb3fa core: Fix OPT_DEFS for mbed build 2e2d2c8 Merge branch 'master' of github.com:leizzer/tmk_keyboard f1d3634 Change .gitignore for ChibiOS 3aab802 core: Fix build config in protocol.mk 5e43da0 core: Add short names in unimap 7a56998 core: Fix dfu wait in rules.mk 6d9c500 Merge branch 'mediakey-fix' 08382ac core: Fix 'make dfu' message 78cb04e Fix OS X Recognizing keyboard as Mouse/Tablet a114714 core: 'make dfu' waits for bootloader to start d0a8f13 core: Fix unimap UNIMAP_NO case e17abef core: Change lufa NKRO report size 16 to 32 bytes 375b20f core: Fix common.mk for build options 394fdff core: Fix unimap layout comment 912326c core: Add unimap support 00f4011 core: Fix doc/keymap.md for new keymap framework ddbd7b4 core: Add default implemenation of keymap read 671cacc core: action codes are action_t struct now b4fdb27 core: Change chibios repo directory names 7daed10 core: Fix keycode.txt 90399d7 core: Fix USB remote wakeup on ATmega32U2 #361 3677e84 usb_usb: Add multiple keyboard support 54d5b26 core: Fix Logical Maximum in report descriptor bd0d372 core: Fix LUFA report descriptor 95327b5 Merge pull request #355 from papodaca/XT 62bf548 core: change API of adb.c to accept device address 3097c9e Fix function name in host.h 836e209 Merge branch 'core_split_160522' 3918ea2 Merge commit '20b787fc1284176834cbe7ca2134e4b36bec5828' 7f87b11 core: Add comment of register 3 of ADB ef6478a core: Add adb_host_talk() 5c665b4 update macro names in bluefruit 4f2c5bf Merge commit '71381457fa1311dfa0b58ba882a96db740640871' 53a9c08 Merge pull request #321 from njbair/master f08a656 core: Fix media/consumer keys d526de8 Clean up wording in keymap example 0bb3dbb Clarify layer precedence d915c75 clarify layer documentation 72070d4 ps2_usb: Fix for VUSB configuration 170e2dc Mostly working. Is unstable, will emit bad codes after a while. c8e45b5 core: Actionmap support aabaa24 Codes appear to be detected correctly, the break codes are broken. git-subtree-dir: tmk_core git-subtree-split: e5f994033cbc8700745ac0c6d12772820492eed0
7 years ago
Squashed 'tmk_core/' changes from 8da1898..e5f9940 e5f9940 Merge commit '1bc3dd200b023cecf063a0cb3ba347f77f6d759d' into core_update da03c50 Add note for L/R side bit being ignored e80f3c1 Add in basic documentation for Macro system 35e8a76 core: Swap position of PEQL and PENT in unimap 00751f1 Merge pull request #406 from 39aldo39/patch-1 e50d7de V-USB remote wakeup 4340997 core: Fix typo in definition AC_g 958144d core: Debug print for system and consumer keys e7e1030 core: Fix sleep_led 0866323 core: Change matrix_init and matrix_print 0dbf73d core: Add matrix_clear() and default impl. 3202ca3 core: Add suspend mode options 4cda3aa core: Fix suspend/wake for converters #386 4e15247 core: LUFA_DEBUG_SUART for serial debug b9cf8e7 core: Fix mechanical locking supoort #390 12aa0fd Merge branch 'nemith-master' fccb3fa core: Fix OPT_DEFS for mbed build 2e2d2c8 Merge branch 'master' of github.com:leizzer/tmk_keyboard f1d3634 Change .gitignore for ChibiOS 3aab802 core: Fix build config in protocol.mk 5e43da0 core: Add short names in unimap 7a56998 core: Fix dfu wait in rules.mk 6d9c500 Merge branch 'mediakey-fix' 08382ac core: Fix 'make dfu' message 78cb04e Fix OS X Recognizing keyboard as Mouse/Tablet a114714 core: 'make dfu' waits for bootloader to start d0a8f13 core: Fix unimap UNIMAP_NO case e17abef core: Change lufa NKRO report size 16 to 32 bytes 375b20f core: Fix common.mk for build options 394fdff core: Fix unimap layout comment 912326c core: Add unimap support 00f4011 core: Fix doc/keymap.md for new keymap framework ddbd7b4 core: Add default implemenation of keymap read 671cacc core: action codes are action_t struct now b4fdb27 core: Change chibios repo directory names 7daed10 core: Fix keycode.txt 90399d7 core: Fix USB remote wakeup on ATmega32U2 #361 3677e84 usb_usb: Add multiple keyboard support 54d5b26 core: Fix Logical Maximum in report descriptor bd0d372 core: Fix LUFA report descriptor 95327b5 Merge pull request #355 from papodaca/XT 62bf548 core: change API of adb.c to accept device address 3097c9e Fix function name in host.h 836e209 Merge branch 'core_split_160522' 3918ea2 Merge commit '20b787fc1284176834cbe7ca2134e4b36bec5828' 7f87b11 core: Add comment of register 3 of ADB ef6478a core: Add adb_host_talk() 5c665b4 update macro names in bluefruit 4f2c5bf Merge commit '71381457fa1311dfa0b58ba882a96db740640871' 53a9c08 Merge pull request #321 from njbair/master f08a656 core: Fix media/consumer keys d526de8 Clean up wording in keymap example 0bb3dbb Clarify layer precedence d915c75 clarify layer documentation 72070d4 ps2_usb: Fix for VUSB configuration 170e2dc Mostly working. Is unstable, will emit bad codes after a while. c8e45b5 core: Actionmap support aabaa24 Codes appear to be detected correctly, the break codes are broken. git-subtree-dir: tmk_core git-subtree-split: e5f994033cbc8700745ac0c6d12772820492eed0
7 years ago
Squashed 'tmk_core/' changes from 8da1898..e5f9940 e5f9940 Merge commit '1bc3dd200b023cecf063a0cb3ba347f77f6d759d' into core_update da03c50 Add note for L/R side bit being ignored e80f3c1 Add in basic documentation for Macro system 35e8a76 core: Swap position of PEQL and PENT in unimap 00751f1 Merge pull request #406 from 39aldo39/patch-1 e50d7de V-USB remote wakeup 4340997 core: Fix typo in definition AC_g 958144d core: Debug print for system and consumer keys e7e1030 core: Fix sleep_led 0866323 core: Change matrix_init and matrix_print 0dbf73d core: Add matrix_clear() and default impl. 3202ca3 core: Add suspend mode options 4cda3aa core: Fix suspend/wake for converters #386 4e15247 core: LUFA_DEBUG_SUART for serial debug b9cf8e7 core: Fix mechanical locking supoort #390 12aa0fd Merge branch 'nemith-master' fccb3fa core: Fix OPT_DEFS for mbed build 2e2d2c8 Merge branch 'master' of github.com:leizzer/tmk_keyboard f1d3634 Change .gitignore for ChibiOS 3aab802 core: Fix build config in protocol.mk 5e43da0 core: Add short names in unimap 7a56998 core: Fix dfu wait in rules.mk 6d9c500 Merge branch 'mediakey-fix' 08382ac core: Fix 'make dfu' message 78cb04e Fix OS X Recognizing keyboard as Mouse/Tablet a114714 core: 'make dfu' waits for bootloader to start d0a8f13 core: Fix unimap UNIMAP_NO case e17abef core: Change lufa NKRO report size 16 to 32 bytes 375b20f core: Fix common.mk for build options 394fdff core: Fix unimap layout comment 912326c core: Add unimap support 00f4011 core: Fix doc/keymap.md for new keymap framework ddbd7b4 core: Add default implemenation of keymap read 671cacc core: action codes are action_t struct now b4fdb27 core: Change chibios repo directory names 7daed10 core: Fix keycode.txt 90399d7 core: Fix USB remote wakeup on ATmega32U2 #361 3677e84 usb_usb: Add multiple keyboard support 54d5b26 core: Fix Logical Maximum in report descriptor bd0d372 core: Fix LUFA report descriptor 95327b5 Merge pull request #355 from papodaca/XT 62bf548 core: change API of adb.c to accept device address 3097c9e Fix function name in host.h 836e209 Merge branch 'core_split_160522' 3918ea2 Merge commit '20b787fc1284176834cbe7ca2134e4b36bec5828' 7f87b11 core: Add comment of register 3 of ADB ef6478a core: Add adb_host_talk() 5c665b4 update macro names in bluefruit 4f2c5bf Merge commit '71381457fa1311dfa0b58ba882a96db740640871' 53a9c08 Merge pull request #321 from njbair/master f08a656 core: Fix media/consumer keys d526de8 Clean up wording in keymap example 0bb3dbb Clarify layer precedence d915c75 clarify layer documentation 72070d4 ps2_usb: Fix for VUSB configuration 170e2dc Mostly working. Is unstable, will emit bad codes after a while. c8e45b5 core: Actionmap support aabaa24 Codes appear to be detected correctly, the break codes are broken. git-subtree-dir: tmk_core git-subtree-split: e5f994033cbc8700745ac0c6d12772820492eed0
7 years ago
Squashed 'tmk_core/' changes from 8da1898..e5f9940 e5f9940 Merge commit '1bc3dd200b023cecf063a0cb3ba347f77f6d759d' into core_update da03c50 Add note for L/R side bit being ignored e80f3c1 Add in basic documentation for Macro system 35e8a76 core: Swap position of PEQL and PENT in unimap 00751f1 Merge pull request #406 from 39aldo39/patch-1 e50d7de V-USB remote wakeup 4340997 core: Fix typo in definition AC_g 958144d core: Debug print for system and consumer keys e7e1030 core: Fix sleep_led 0866323 core: Change matrix_init and matrix_print 0dbf73d core: Add matrix_clear() and default impl. 3202ca3 core: Add suspend mode options 4cda3aa core: Fix suspend/wake for converters #386 4e15247 core: LUFA_DEBUG_SUART for serial debug b9cf8e7 core: Fix mechanical locking supoort #390 12aa0fd Merge branch 'nemith-master' fccb3fa core: Fix OPT_DEFS for mbed build 2e2d2c8 Merge branch 'master' of github.com:leizzer/tmk_keyboard f1d3634 Change .gitignore for ChibiOS 3aab802 core: Fix build config in protocol.mk 5e43da0 core: Add short names in unimap 7a56998 core: Fix dfu wait in rules.mk 6d9c500 Merge branch 'mediakey-fix' 08382ac core: Fix 'make dfu' message 78cb04e Fix OS X Recognizing keyboard as Mouse/Tablet a114714 core: 'make dfu' waits for bootloader to start d0a8f13 core: Fix unimap UNIMAP_NO case e17abef core: Change lufa NKRO report size 16 to 32 bytes 375b20f core: Fix common.mk for build options 394fdff core: Fix unimap layout comment 912326c core: Add unimap support 00f4011 core: Fix doc/keymap.md for new keymap framework ddbd7b4 core: Add default implemenation of keymap read 671cacc core: action codes are action_t struct now b4fdb27 core: Change chibios repo directory names 7daed10 core: Fix keycode.txt 90399d7 core: Fix USB remote wakeup on ATmega32U2 #361 3677e84 usb_usb: Add multiple keyboard support 54d5b26 core: Fix Logical Maximum in report descriptor bd0d372 core: Fix LUFA report descriptor 95327b5 Merge pull request #355 from papodaca/XT 62bf548 core: change API of adb.c to accept device address 3097c9e Fix function name in host.h 836e209 Merge branch 'core_split_160522' 3918ea2 Merge commit '20b787fc1284176834cbe7ca2134e4b36bec5828' 7f87b11 core: Add comment of register 3 of ADB ef6478a core: Add adb_host_talk() 5c665b4 update macro names in bluefruit 4f2c5bf Merge commit '71381457fa1311dfa0b58ba882a96db740640871' 53a9c08 Merge pull request #321 from njbair/master f08a656 core: Fix media/consumer keys d526de8 Clean up wording in keymap example 0bb3dbb Clarify layer precedence d915c75 clarify layer documentation 72070d4 ps2_usb: Fix for VUSB configuration 170e2dc Mostly working. Is unstable, will emit bad codes after a while. c8e45b5 core: Actionmap support aabaa24 Codes appear to be detected correctly, the break codes are broken. git-subtree-dir: tmk_core git-subtree-split: e5f994033cbc8700745ac0c6d12772820492eed0
7 years ago
Squashed 'tmk_core/' changes from 8da1898..e5f9940 e5f9940 Merge commit '1bc3dd200b023cecf063a0cb3ba347f77f6d759d' into core_update da03c50 Add note for L/R side bit being ignored e80f3c1 Add in basic documentation for Macro system 35e8a76 core: Swap position of PEQL and PENT in unimap 00751f1 Merge pull request #406 from 39aldo39/patch-1 e50d7de V-USB remote wakeup 4340997 core: Fix typo in definition AC_g 958144d core: Debug print for system and consumer keys e7e1030 core: Fix sleep_led 0866323 core: Change matrix_init and matrix_print 0dbf73d core: Add matrix_clear() and default impl. 3202ca3 core: Add suspend mode options 4cda3aa core: Fix suspend/wake for converters #386 4e15247 core: LUFA_DEBUG_SUART for serial debug b9cf8e7 core: Fix mechanical locking supoort #390 12aa0fd Merge branch 'nemith-master' fccb3fa core: Fix OPT_DEFS for mbed build 2e2d2c8 Merge branch 'master' of github.com:leizzer/tmk_keyboard f1d3634 Change .gitignore for ChibiOS 3aab802 core: Fix build config in protocol.mk 5e43da0 core: Add short names in unimap 7a56998 core: Fix dfu wait in rules.mk 6d9c500 Merge branch 'mediakey-fix' 08382ac core: Fix 'make dfu' message 78cb04e Fix OS X Recognizing keyboard as Mouse/Tablet a114714 core: 'make dfu' waits for bootloader to start d0a8f13 core: Fix unimap UNIMAP_NO case e17abef core: Change lufa NKRO report size 16 to 32 bytes 375b20f core: Fix common.mk for build options 394fdff core: Fix unimap layout comment 912326c core: Add unimap support 00f4011 core: Fix doc/keymap.md for new keymap framework ddbd7b4 core: Add default implemenation of keymap read 671cacc core: action codes are action_t struct now b4fdb27 core: Change chibios repo directory names 7daed10 core: Fix keycode.txt 90399d7 core: Fix USB remote wakeup on ATmega32U2 #361 3677e84 usb_usb: Add multiple keyboard support 54d5b26 core: Fix Logical Maximum in report descriptor bd0d372 core: Fix LUFA report descriptor 95327b5 Merge pull request #355 from papodaca/XT 62bf548 core: change API of adb.c to accept device address 3097c9e Fix function name in host.h 836e209 Merge branch 'core_split_160522' 3918ea2 Merge commit '20b787fc1284176834cbe7ca2134e4b36bec5828' 7f87b11 core: Add comment of register 3 of ADB ef6478a core: Add adb_host_talk() 5c665b4 update macro names in bluefruit 4f2c5bf Merge commit '71381457fa1311dfa0b58ba882a96db740640871' 53a9c08 Merge pull request #321 from njbair/master f08a656 core: Fix media/consumer keys d526de8 Clean up wording in keymap example 0bb3dbb Clarify layer precedence d915c75 clarify layer documentation 72070d4 ps2_usb: Fix for VUSB configuration 170e2dc Mostly working. Is unstable, will emit bad codes after a while. c8e45b5 core: Actionmap support aabaa24 Codes appear to be detected correctly, the break codes are broken. git-subtree-dir: tmk_core git-subtree-split: e5f994033cbc8700745ac0c6d12772820492eed0
7 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. /*
  2. Copyright 2012,2013 Jun Wako <[email protected]>
  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. #include "host.h"
  15. #include "keycode.h"
  16. #include "keyboard.h"
  17. #include "mousekey.h"
  18. #include "command.h"
  19. #include "led.h"
  20. #include "backlight.h"
  21. #include "action_layer.h"
  22. #include "action_tapping.h"
  23. #include "action_macro.h"
  24. #include "action_util.h"
  25. #include "action.h"
  26. #include "hook.h"
  27. #include "wait.h"
  28. #ifdef DEBUG_ACTION
  29. #include "debug.h"
  30. #else
  31. #include "nodebug.h"
  32. #endif
  33. void action_exec(keyevent_t event)
  34. {
  35. if (!IS_NOEVENT(event)) {
  36. dprint("\n---- action_exec: start -----\n");
  37. dprint("EVENT: "); debug_event(event); dprintln();
  38. hook_matrix_change(event);
  39. }
  40. keyrecord_t record = { .event = event };
  41. #ifndef NO_ACTION_TAPPING
  42. action_tapping_process(record);
  43. #else
  44. process_action(&record);
  45. if (!IS_NOEVENT(record.event)) {
  46. dprint("processed: "); debug_record(record); dprintln();
  47. }
  48. #endif
  49. }
  50. void process_action(keyrecord_t *record)
  51. {
  52. keyevent_t event = record->event;
  53. #ifndef NO_ACTION_TAPPING
  54. uint8_t tap_count = record->tap.count;
  55. #endif
  56. if (IS_NOEVENT(event)) { return; }
  57. action_t action = layer_switch_get_action(event.key);
  58. dprint("ACTION: "); debug_action(action);
  59. #ifndef NO_ACTION_LAYER
  60. dprint(" layer_state: "); layer_debug();
  61. dprint(" default_layer_state: "); default_layer_debug();
  62. #endif
  63. dprintln();
  64. switch (action.kind.id) {
  65. /* Key and Mods */
  66. case ACT_LMODS:
  67. case ACT_RMODS:
  68. {
  69. uint8_t mods = (action.kind.id == ACT_LMODS) ? action.key.mods :
  70. action.key.mods<<4;
  71. if (event.pressed) {
  72. if (mods) {
  73. add_weak_mods(mods);
  74. send_keyboard_report();
  75. }
  76. register_code(action.key.code);
  77. } else {
  78. unregister_code(action.key.code);
  79. if (mods) {
  80. del_weak_mods(mods);
  81. send_keyboard_report();
  82. }
  83. }
  84. }
  85. break;
  86. #ifndef NO_ACTION_TAPPING
  87. case ACT_LMODS_TAP:
  88. case ACT_RMODS_TAP:
  89. {
  90. uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods :
  91. action.key.mods<<4;
  92. switch (action.layer_tap.code) {
  93. #ifndef NO_ACTION_ONESHOT
  94. case MODS_ONESHOT:
  95. // Oneshot modifier
  96. if (event.pressed) {
  97. if (tap_count == 0) {
  98. register_mods(mods);
  99. }
  100. else if (tap_count == 1) {
  101. dprint("MODS_TAP: Oneshot: start\n");
  102. set_oneshot_mods(mods);
  103. }
  104. else {
  105. register_mods(mods);
  106. }
  107. } else {
  108. if (tap_count == 0) {
  109. clear_oneshot_mods();
  110. unregister_mods(mods);
  111. }
  112. else if (tap_count == 1) {
  113. // Retain Oneshot mods
  114. }
  115. else {
  116. clear_oneshot_mods();
  117. unregister_mods(mods);
  118. }
  119. }
  120. break;
  121. #endif
  122. case MODS_TAP_TOGGLE:
  123. if (event.pressed) {
  124. if (tap_count <= TAPPING_TOGGLE) {
  125. if (mods & get_mods()) {
  126. dprint("MODS_TAP_TOGGLE: toggle mods off\n");
  127. unregister_mods(mods);
  128. } else {
  129. dprint("MODS_TAP_TOGGLE: toggle mods on\n");
  130. register_mods(mods);
  131. }
  132. }
  133. } else {
  134. if (tap_count < TAPPING_TOGGLE) {
  135. dprint("MODS_TAP_TOGGLE: release : unregister_mods\n");
  136. unregister_mods(mods);
  137. }
  138. }
  139. break;
  140. default:
  141. if (event.pressed) {
  142. if (tap_count > 0) {
  143. if (record->tap.interrupted) {
  144. dprint("MODS_TAP: Tap: Cancel: add_mods\n");
  145. // ad hoc: set 0 to cancel tap
  146. record->tap.count = 0;
  147. register_mods(mods);
  148. } else {
  149. dprint("MODS_TAP: Tap: register_code\n");
  150. register_code(action.key.code);
  151. }
  152. } else {
  153. dprint("MODS_TAP: No tap: add_mods\n");
  154. register_mods(mods);
  155. }
  156. } else {
  157. if (tap_count > 0) {
  158. dprint("MODS_TAP: Tap: unregister_code\n");
  159. unregister_code(action.key.code);
  160. } else {
  161. dprint("MODS_TAP: No tap: add_mods\n");
  162. unregister_mods(mods);
  163. }
  164. }
  165. break;
  166. }
  167. }
  168. break;
  169. #endif
  170. #ifdef EXTRAKEY_ENABLE
  171. /* other HID usage */
  172. case ACT_USAGE:
  173. switch (action.usage.page) {
  174. case PAGE_SYSTEM:
  175. if (event.pressed) {
  176. host_system_send(action.usage.code);
  177. } else {
  178. host_system_send(0);
  179. }
  180. break;
  181. case PAGE_CONSUMER:
  182. if (event.pressed) {
  183. host_consumer_send(action.usage.code);
  184. } else {
  185. host_consumer_send(0);
  186. }
  187. break;
  188. }
  189. break;
  190. #endif
  191. #ifdef MOUSEKEY_ENABLE
  192. /* Mouse key */
  193. case ACT_MOUSEKEY:
  194. if (event.pressed) {
  195. mousekey_on(action.key.code);
  196. mousekey_send();
  197. } else {
  198. mousekey_off(action.key.code);
  199. mousekey_send();
  200. }
  201. break;
  202. #endif
  203. #ifndef NO_ACTION_LAYER
  204. case ACT_LAYER:
  205. if (action.layer_bitop.on == 0) {
  206. /* Default Layer Bitwise Operation */
  207. if (!event.pressed) {
  208. uint8_t shift = action.layer_bitop.part*4;
  209. uint32_t bits = ((uint32_t)action.layer_bitop.bits)<<shift;
  210. uint32_t mask = (action.layer_bitop.xbit) ? ~(((uint32_t)0xf)<<shift) : 0;
  211. switch (action.layer_bitop.op) {
  212. case OP_BIT_AND: default_layer_and(bits | mask); break;
  213. case OP_BIT_OR: default_layer_or(bits | mask); break;
  214. case OP_BIT_XOR: default_layer_xor(bits | mask); break;
  215. case OP_BIT_SET: default_layer_and(mask); default_layer_or(bits); break;
  216. }
  217. }
  218. } else {
  219. /* Layer Bitwise Operation */
  220. if (event.pressed ? (action.layer_bitop.on & ON_PRESS) :
  221. (action.layer_bitop.on & ON_RELEASE)) {
  222. uint8_t shift = action.layer_bitop.part*4;
  223. uint32_t bits = ((uint32_t)action.layer_bitop.bits)<<shift;
  224. uint32_t mask = (action.layer_bitop.xbit) ? ~(((uint32_t)0xf)<<shift) : 0;
  225. switch (action.layer_bitop.op) {
  226. case OP_BIT_AND: layer_and(bits | mask); break;
  227. case OP_BIT_OR: layer_or(bits | mask); break;
  228. case OP_BIT_XOR: layer_xor(bits | mask); break;
  229. case OP_BIT_SET: layer_and(mask); layer_or(bits); break;
  230. }
  231. }
  232. }
  233. break;
  234. #ifndef NO_ACTION_TAPPING
  235. case ACT_LAYER_TAP:
  236. case ACT_LAYER_TAP_EXT:
  237. switch (action.layer_tap.code) {
  238. case 0xe0 ... 0xef:
  239. /* layer On/Off with modifiers(left only) */
  240. if (event.pressed) {
  241. layer_on(action.layer_tap.val);
  242. register_mods(action.layer_tap.code & 0x0f);
  243. } else {
  244. layer_off(action.layer_tap.val);
  245. unregister_mods(action.layer_tap.code & 0x0f);
  246. }
  247. break;
  248. case OP_TAP_TOGGLE:
  249. /* tap toggle */
  250. if (event.pressed) {
  251. if (tap_count < TAPPING_TOGGLE) {
  252. layer_invert(action.layer_tap.val);
  253. }
  254. } else {
  255. if (tap_count <= TAPPING_TOGGLE) {
  256. layer_invert(action.layer_tap.val);
  257. }
  258. }
  259. break;
  260. case OP_ON_OFF:
  261. event.pressed ? layer_on(action.layer_tap.val) :
  262. layer_off(action.layer_tap.val);
  263. break;
  264. case OP_OFF_ON:
  265. event.pressed ? layer_off(action.layer_tap.val) :
  266. layer_on(action.layer_tap.val);
  267. break;
  268. case OP_SET_CLEAR:
  269. event.pressed ? layer_move(action.layer_tap.val) :
  270. layer_clear();
  271. break;
  272. default:
  273. /* tap key */
  274. if (event.pressed) {
  275. if (tap_count > 0) {
  276. dprint("KEYMAP_TAP_KEY: Tap: register_code\n");
  277. register_code(action.layer_tap.code);
  278. } else {
  279. dprint("KEYMAP_TAP_KEY: No tap: On on press\n");
  280. layer_on(action.layer_tap.val);
  281. }
  282. } else {
  283. if (tap_count > 0) {
  284. dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n");
  285. unregister_code(action.layer_tap.code);
  286. } else {
  287. dprint("KEYMAP_TAP_KEY: No tap: Off on release\n");
  288. layer_off(action.layer_tap.val);
  289. }
  290. }
  291. break;
  292. }
  293. break;
  294. #endif
  295. #endif
  296. /* Extentions */
  297. #ifndef NO_ACTION_MACRO
  298. case ACT_MACRO:
  299. action_macro_play(action_get_macro(record, action.func.id, action.func.opt));
  300. break;
  301. #endif
  302. #ifdef BACKLIGHT_ENABLE
  303. case ACT_BACKLIGHT:
  304. if (!event.pressed) {
  305. switch (action.backlight.opt) {
  306. case BACKLIGHT_INCREASE:
  307. backlight_increase();
  308. break;
  309. case BACKLIGHT_DECREASE:
  310. backlight_decrease();
  311. break;
  312. case BACKLIGHT_TOGGLE:
  313. backlight_toggle();
  314. break;
  315. case BACKLIGHT_STEP:
  316. backlight_step();
  317. break;
  318. case BACKLIGHT_LEVEL:
  319. backlight_level(action.backlight.level);
  320. break;
  321. }
  322. }
  323. break;
  324. #endif
  325. case ACT_COMMAND:
  326. break;
  327. #ifndef NO_ACTION_FUNCTION
  328. case ACT_FUNCTION:
  329. action_function(record, action.func.id, action.func.opt);
  330. break;
  331. #endif
  332. default:
  333. break;
  334. }
  335. }
  336. /*
  337. * Utilities for actions.
  338. */
  339. void register_code(uint8_t code)
  340. {
  341. if (code == KC_NO) {
  342. return;
  343. }
  344. #ifdef LOCKING_SUPPORT_ENABLE
  345. else if (KC_LOCKING_CAPS == code) {
  346. #ifdef LOCKING_RESYNC_ENABLE
  347. // Resync: ignore if caps lock already is on
  348. if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return;
  349. #endif
  350. add_key(KC_CAPSLOCK);
  351. send_keyboard_report();
  352. wait_ms(100);
  353. del_key(KC_CAPSLOCK);
  354. send_keyboard_report();
  355. }
  356. else if (KC_LOCKING_NUM == code) {
  357. #ifdef LOCKING_RESYNC_ENABLE
  358. if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) return;
  359. #endif
  360. add_key(KC_NUMLOCK);
  361. send_keyboard_report();
  362. wait_ms(100);
  363. del_key(KC_NUMLOCK);
  364. send_keyboard_report();
  365. }
  366. else if (KC_LOCKING_SCROLL == code) {
  367. #ifdef LOCKING_RESYNC_ENABLE
  368. if (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) return;
  369. #endif
  370. add_key(KC_SCROLLLOCK);
  371. send_keyboard_report();
  372. wait_ms(100);
  373. del_key(KC_SCROLLLOCK);
  374. send_keyboard_report();
  375. }
  376. #endif
  377. else if IS_KEY(code) {
  378. // TODO: should push command_proc out of this block?
  379. if (command_proc(code)) return;
  380. #ifndef NO_ACTION_ONESHOT
  381. /* TODO: remove
  382. if (oneshot_state.mods && !oneshot_state.disabled) {
  383. uint8_t tmp_mods = get_mods();
  384. add_mods(oneshot_state.mods);
  385. add_key(code);
  386. send_keyboard_report();
  387. set_mods(tmp_mods);
  388. send_keyboard_report();
  389. oneshot_cancel();
  390. } else
  391. */
  392. #endif
  393. {
  394. add_key(code);
  395. send_keyboard_report();
  396. }
  397. }
  398. else if IS_MOD(code) {
  399. add_mods(MOD_BIT(code));
  400. send_keyboard_report();
  401. }
  402. else if IS_SYSTEM(code) {
  403. host_system_send(KEYCODE2SYSTEM(code));
  404. }
  405. else if IS_CONSUMER(code) {
  406. host_consumer_send(KEYCODE2CONSUMER(code));
  407. }
  408. }
  409. void unregister_code(uint8_t code)
  410. {
  411. if (code == KC_NO) {
  412. return;
  413. }
  414. #ifdef LOCKING_SUPPORT_ENABLE
  415. else if (KC_LOCKING_CAPS == code) {
  416. #ifdef LOCKING_RESYNC_ENABLE
  417. // Resync: ignore if caps lock already is off
  418. if (!(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) return;
  419. #endif
  420. add_key(KC_CAPSLOCK);
  421. send_keyboard_report();
  422. wait_ms(100);
  423. del_key(KC_CAPSLOCK);
  424. send_keyboard_report();
  425. }
  426. else if (KC_LOCKING_NUM == code) {
  427. #ifdef LOCKING_RESYNC_ENABLE
  428. if (!(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))) return;
  429. #endif
  430. add_key(KC_NUMLOCK);
  431. send_keyboard_report();
  432. wait_ms(100);
  433. del_key(KC_NUMLOCK);
  434. send_keyboard_report();
  435. }
  436. else if (KC_LOCKING_SCROLL == code) {
  437. #ifdef LOCKING_RESYNC_ENABLE
  438. if (!(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK))) return;
  439. #endif
  440. add_key(KC_SCROLLLOCK);
  441. send_keyboard_report();
  442. wait_ms(100);
  443. del_key(KC_SCROLLLOCK);
  444. send_keyboard_report();
  445. }
  446. #endif
  447. else if IS_KEY(code) {
  448. del_key(code);
  449. send_keyboard_report();
  450. }
  451. else if IS_MOD(code) {
  452. del_mods(MOD_BIT(code));
  453. send_keyboard_report();
  454. }
  455. else if IS_SYSTEM(code) {
  456. host_system_send(0);
  457. }
  458. else if IS_CONSUMER(code) {
  459. host_consumer_send(0);
  460. }
  461. }
  462. void register_mods(uint8_t mods)
  463. {
  464. if (mods) {
  465. add_mods(mods);
  466. send_keyboard_report();
  467. }
  468. }
  469. void unregister_mods(uint8_t mods)
  470. {
  471. if (mods) {
  472. del_mods(mods);
  473. send_keyboard_report();
  474. }
  475. }
  476. void clear_keyboard(void)
  477. {
  478. clear_mods();
  479. clear_keyboard_but_mods();
  480. }
  481. void clear_keyboard_but_mods(void)
  482. {
  483. clear_weak_mods();
  484. clear_keys();
  485. send_keyboard_report();
  486. #ifdef MOUSEKEY_ENABLE
  487. mousekey_clear();
  488. mousekey_send();
  489. #endif
  490. #ifdef EXTRAKEY_ENABLE
  491. host_system_send(0);
  492. host_consumer_send(0);
  493. #endif
  494. }
  495. bool is_tap_key(keypos_t key)
  496. {
  497. action_t action = layer_switch_get_action(key);
  498. switch (action.kind.id) {
  499. case ACT_LMODS_TAP:
  500. case ACT_RMODS_TAP:
  501. case ACT_LAYER_TAP:
  502. case ACT_LAYER_TAP_EXT:
  503. switch (action.layer_tap.code) {
  504. case 0x00 ... 0xdf:
  505. case OP_TAP_TOGGLE:
  506. return true;
  507. }
  508. return false;
  509. case ACT_MACRO:
  510. case ACT_FUNCTION:
  511. if (action.func.opt & FUNC_TAP) { return true; }
  512. return false;
  513. }
  514. return false;
  515. }
  516. /*
  517. * debug print
  518. */
  519. void debug_event(keyevent_t event)
  520. {
  521. dprintf("%04X%c(%u)", (event.key.row<<8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
  522. }
  523. void debug_record(keyrecord_t record)
  524. {
  525. debug_event(record.event);
  526. #ifndef NO_ACTION_TAPPING
  527. dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' '));
  528. #endif
  529. }
  530. void debug_action(action_t action)
  531. {
  532. switch (action.kind.id) {
  533. case ACT_LMODS: dprint("ACT_LMODS"); break;
  534. case ACT_RMODS: dprint("ACT_RMODS"); break;
  535. case ACT_LMODS_TAP: dprint("ACT_LMODS_TAP"); break;
  536. case ACT_RMODS_TAP: dprint("ACT_RMODS_TAP"); break;
  537. case ACT_USAGE: dprint("ACT_USAGE"); break;
  538. case ACT_MOUSEKEY: dprint("ACT_MOUSEKEY"); break;
  539. case ACT_LAYER: dprint("ACT_LAYER"); break;
  540. case ACT_LAYER_TAP: dprint("ACT_LAYER_TAP"); break;
  541. case ACT_LAYER_TAP_EXT: dprint("ACT_LAYER_TAP_EXT"); break;
  542. case ACT_MACRO: dprint("ACT_MACRO"); break;
  543. case ACT_COMMAND: dprint("ACT_COMMAND"); break;
  544. case ACT_FUNCTION: dprint("ACT_FUNCTION"); break;
  545. default: dprint("UNKNOWN"); break;
  546. }
  547. dprintf("[%X:%02X]", action.kind.param>>8, action.kind.param&0xff);
  548. }