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_macro.h 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. Copyright 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. #ifndef ACTION_MACRO_H
  15. #define ACTION_MACRO_H
  16. #include <stdint.h>
  17. #include <avr/pgmspace.h>
  18. #define MACRO_NONE 0
  19. #define MACRO(...) ({ static prog_macro_t _m[] PROGMEM = { __VA_ARGS__ }; _m; })
  20. typedef uint8_t macro_t;
  21. typedef macro_t prog_macro_t PROGMEM;
  22. #ifndef NO_ACTION_MACRO
  23. void action_macro_play(const prog_macro_t *macro);
  24. #else
  25. #define action_macro_play(macro)
  26. #endif
  27. /* TODO: NOT FINISHED
  28. normal mode command:
  29. key(down): 0x04-7f/73(F24)
  30. key(up): 0x84-ff
  31. command: 0x00-03, 0x80-83(0x74-7f, 0xf4-ff)
  32. mods down 0x00
  33. mods up 0x01
  34. wait 0x02
  35. interval 0x03
  36. extkey down 0x80
  37. extkey up 0x81
  38. ext commad 0x82
  39. ext mode 0x83
  40. end 0xff
  41. extension mode command: NOT IMPLEMENTED
  42. key down 0x00
  43. key up 0x01
  44. key down + wait
  45. key up + wait
  46. mods push
  47. mods pop
  48. wait
  49. interval
  50. if
  51. loop
  52. push
  53. pop
  54. all up
  55. end
  56. */
  57. enum macro_command_id{
  58. /* 0x00 - 0x03 */
  59. END = 0x00,
  60. MODS_DOWN = 0x01,
  61. MODS_UP = 0x02,
  62. MODS_SET,
  63. MODS_PUSH,
  64. MODS_POP,
  65. WAIT = 0x74,
  66. INTERVAL,
  67. /* 0x74 - 0x7f */
  68. /* 0x80 - 0x84 */
  69. EXT_DOWN,
  70. EXT_UP,
  71. EXT_WAIT,
  72. EXT_INTERVAL,
  73. COMPRESSION_MODE,
  74. EXTENSION_MODE = 0xff,
  75. };
  76. /* normal mode */
  77. #define DOWN(key) (key)
  78. #define UP(key) ((key) | 0x80)
  79. #define TYPE(key) (key), (key | 0x80)
  80. #define MODS_DOWN(mods) MODS_DOWN, (mods)
  81. #define MODS_UP(mods) MODS_UP, (mods)
  82. #define WAIT(ms) WAIT, (ms)
  83. #define INTERVAL(ms) INTERVAL, (ms)
  84. #define D(key) DOWN(KC_##key)
  85. #define U(key) UP(KC_##key)
  86. #define T(key) TYPE(KC_##key)
  87. #define MD(key) MODS_DOWN(MOD_BIT(KC_##key))
  88. #define MU(key) MODS_UP(MOD_BIT(KC_##key))
  89. #define W(ms) WAIT(ms)
  90. #define I(ms) INTERVAL(ms)
  91. /* extension mode */
  92. #endif /* ACTION_MACRO_H */