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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

action_macro.h 2.6KB

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