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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. Copyright 2011,2012 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 REPORT_H
  15. #define REPORT_H
  16. #include <stdint.h>
  17. #include "keycode.h"
  18. /* report id */
  19. #define REPORT_ID_MOUSE 1
  20. #define REPORT_ID_SYSTEM 2
  21. #define REPORT_ID_CONSUMER 3
  22. /* mouse buttons */
  23. #define MOUSE_BTN1 (1<<0)
  24. #define MOUSE_BTN2 (1<<1)
  25. #define MOUSE_BTN3 (1<<2)
  26. #define MOUSE_BTN4 (1<<3)
  27. #define MOUSE_BTN5 (1<<4)
  28. /* Consumer Page(0x0C)
  29. * following are supported by Windows: http://msdn.microsoft.com/en-us/windows/hardware/gg463372.aspx
  30. */
  31. #define AUDIO_MUTE 0x00E2
  32. #define AUDIO_VOL_UP 0x00E9
  33. #define AUDIO_VOL_DOWN 0x00EA
  34. #define TRANSPORT_NEXT_TRACK 0x00B5
  35. #define TRANSPORT_PREV_TRACK 0x00B6
  36. #define TRANSPORT_STOP 0x00B7
  37. #define TRANSPORT_PLAY_PAUSE 0x00CD
  38. /* application launch */
  39. #define AL_CC_CONFIG 0x0183
  40. #define AL_EMAIL 0x018A
  41. #define AL_CALCULATOR 0x0192
  42. #define AL_LOCAL_BROWSER 0x0194
  43. /* application control */
  44. #define AC_SEARCH 0x0221
  45. #define AC_HOME 0x0223
  46. #define AC_BACK 0x0224
  47. #define AC_FORWARD 0x0225
  48. #define AC_STOP 0x0226
  49. #define AC_REFRESH 0x0227
  50. #define AC_BOOKMARKS 0x022A
  51. /* supplement for Bluegiga iWRAP HID(not supported by Windows?) */
  52. #define AL_LOCK 0x019E
  53. #define TRANSPORT_RECORD 0x00B2
  54. #define TRANSPORT_REWIND 0x00B4
  55. #define TRANSPORT_EJECT 0x00B8
  56. #define AC_MINIMIZE 0x0206
  57. /* Generic Desktop Page(0x01) - system power control */
  58. #define SYSTEM_POWER_DOWN 0x0081
  59. #define SYSTEM_SLEEP 0x0082
  60. #define SYSTEM_WAKE_UP 0x0083
  61. /* key report size(NKRO or boot mode) */
  62. #if defined(HOST_PJRC)
  63. # include "usb.h"
  64. # if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
  65. # define REPORT_KEYS KBD2_REPORT_KEYS
  66. # else
  67. # define REPORT_KEYS KBD_REPORT_KEYS
  68. # endif
  69. #else
  70. # define REPORT_KEYS 6
  71. #endif
  72. #ifdef __cplusplus
  73. extern "C" {
  74. #endif
  75. typedef struct {
  76. uint8_t mods;
  77. uint8_t rserved;
  78. uint8_t keys[REPORT_KEYS];
  79. } __attribute__ ((packed)) report_keyboard_t;
  80. typedef struct {
  81. uint8_t buttons;
  82. int8_t x;
  83. int8_t y;
  84. int8_t v;
  85. int8_t h;
  86. } __attribute__ ((packed)) report_mouse_t;
  87. /* keycode to system usage */
  88. #define KEYCODE2SYSTEM(key) \
  89. (key == KC_SYSTEM_POWER ? SYSTEM_POWER_DOWN : \
  90. (key == KC_SYSTEM_SLEEP ? SYSTEM_SLEEP : \
  91. (key == KC_SYSTEM_WAKE ? SYSTEM_WAKE_UP : 0)))
  92. /* keycode to consumer usage */
  93. #define KEYCODE2CONSUMER(key) \
  94. (key == KC_AUDIO_MUTE ? AUDIO_MUTE : \
  95. (key == KC_AUDIO_VOL_UP ? AUDIO_VOL_UP : \
  96. (key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \
  97. (key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \
  98. (key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \
  99. (key == KC_MEDIA_STOP ? TRANSPORT_STOP : \
  100. (key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \
  101. (key == KC_MEDIA_SELECT ? AL_CC_CONFIG : \
  102. (key == KC_MAIL ? AL_EMAIL : \
  103. (key == KC_CALCULATOR ? AL_CALCULATOR : \
  104. (key == KC_MY_COMPUTER ? AL_LOCAL_BROWSER : \
  105. (key == KC_WWW_SEARCH ? AC_SEARCH : \
  106. (key == KC_WWW_HOME ? AC_HOME : \
  107. (key == KC_WWW_BACK ? AC_BACK : \
  108. (key == KC_WWW_FORWARD ? AC_FORWARD : \
  109. (key == KC_WWW_STOP ? AC_STOP : \
  110. (key == KC_WWW_REFRESH ? AC_REFRESH : \
  111. (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))
  112. #ifdef __cplusplus
  113. }
  114. #endif
  115. #endif