Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
11 роки тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. /* Macro commands
  27. * code(0x04-73) // key down(1byte)
  28. * code(0x04-73) | 0x80 // key up(1byte)
  29. * { KEY_DOWN, code(0x04-0xff) } // key down(2bytes)
  30. * { KEY_UP, code(0x04-0xff) } // key up(2bytes)
  31. * WAIT // wait milli-seconds
  32. * INTERVAL // set interval between macro commands
  33. * END // stop macro execution
  34. *
  35. * Ideas(Not implemented):
  36. * modifiers
  37. * system usage
  38. * consumer usage
  39. * unicode usage
  40. * function call
  41. * conditionals
  42. * loop
  43. */
  44. enum macro_command_id{
  45. /* 0x00 - 0x03 */
  46. END = 0x00,
  47. KEY_DOWN,
  48. KEY_UP,
  49. /* 0x04 - 0x73 (reserved for keycode down) */
  50. /* 0x74 - 0x83 */
  51. WAIT = 0x74,
  52. INTERVAL,
  53. /* 0x84 - 0xf3 (reserved for keycode up) */
  54. /* 0xf4 - 0xff */
  55. };
  56. /* TODO: keycode:0x04-0x73 can be handled by 1byte command else 2bytes are needed
  57. * if keycode between 0x04 and 0x73
  58. * keycode / (keycode|0x80)
  59. * else
  60. * {KEY_DOWN, keycode} / {KEY_UP, keycode}
  61. */
  62. #define DOWN(key) KEY_DOWN, (key)
  63. #define UP(key) KEY_UP, (key)
  64. #define TYPE(key) DOWN(key), UP(key)
  65. #define WAIT(ms) WAIT, (ms)
  66. #define INTERVAL(ms) INTERVAL, (ms)
  67. /* key down */
  68. #define D(key) DOWN(KC_##key)
  69. /* key up */
  70. #define U(key) UP(KC_##key)
  71. /* key type */
  72. #define T(key) TYPE(KC_##key)
  73. /* wait */
  74. #define W(ms) WAIT(ms)
  75. /* interval */
  76. #define I(ms) INTERVAL(ms)
  77. /* for backward comaptibility */
  78. #define MD(key) DOWN(KC_##key)
  79. #define MU(key) UP(KC_##key)
  80. #endif /* ACTION_MACRO_H */