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.5KB

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