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

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