Keyboard firmwares for Atmel AVR and Cortex-M
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

report.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. Copyright 2011 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. #define AUDIO_MUTE 0x00E2
  31. #define AUDIO_VOL_UP 0x00E9
  32. #define AUDIO_VOL_DOWN 0x00EA
  33. #define TRANSPORT_NEXT_TRACK 0x00B5
  34. #define TRANSPORT_PREV_TRACK 0x00B6
  35. #define TRANSPORT_STOP 0x00B7
  36. #define TRANSPORT_PLAY_PAUSE 0x00CD
  37. #define AL_CC_CONFIG 0x0183
  38. #define AL_EMAIL 0x018A
  39. #define AL_CALCULATOR 0x0192
  40. #define AL_LOCAL_BROWSER 0x0194
  41. #define AC_SEARCH 0x0221
  42. #define AC_HOME 0x0223
  43. #define AC_BACK 0x0224
  44. #define AC_FORWARD 0x0225
  45. #define AC_STOP 0x0226
  46. #define AC_REFRESH 0x0227
  47. #define AC_BOOKMARKS 0x022A
  48. // supplement for Bluegiga iWRAP HID(not supported by Windows?)
  49. #define AL_LOCK 0x019E
  50. #define TRANSPORT_RECORD 0x00B2
  51. #define TRANSPORT_REWIND 0x00B4
  52. #define TRANSPORT_EJECT 0x00B8
  53. #define AC_MINIMIZE 0x0206
  54. // Generic Desktop Page(0x01)
  55. #define SYSTEM_POWER_DOWN 0x0081
  56. #define SYSTEM_SLEEP 0x0082
  57. #define SYSTEM_WAKE_UP 0x0083
  58. // key report size(NKRO or boot mode)
  59. #if defined(HOST_PJRC)
  60. # include "usb.h"
  61. # if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
  62. # define REPORT_KEYS KBD2_REPORT_KEYS
  63. # else
  64. # define REPORT_KEYS KBD_REPORT_KEYS
  65. # endif
  66. #else
  67. # define REPORT_KEYS 6
  68. #endif
  69. #ifdef __cplusplus
  70. extern "C" {
  71. #endif
  72. typedef struct {
  73. uint8_t mods;
  74. uint8_t rserved;
  75. uint8_t keys[REPORT_KEYS];
  76. } __attribute__ ((packed)) report_keyboard_t;
  77. typedef struct {
  78. uint8_t buttons;
  79. int8_t x;
  80. int8_t y;
  81. int8_t v;
  82. int8_t h;
  83. } __attribute__ ((packed)) report_mouse_t;
  84. static uint16_t key2system(uint8_t key)
  85. {
  86. uint16_t usage = 0;
  87. switch (key) {
  88. case KC_SYSTEM_POWER:
  89. usage = SYSTEM_POWER_DOWN;
  90. break;
  91. case KC_SYSTEM_SLEEP:
  92. usage = SYSTEM_SLEEP;
  93. break;
  94. case KC_SYSTEM_WAKE:
  95. usage = SYSTEM_WAKE_UP;
  96. break;
  97. }
  98. return usage;
  99. }
  100. static uint16_t key2consumer(uint8_t key)
  101. {
  102. uint16_t usage = 0;
  103. switch (key) {
  104. case KC_AUDIO_MUTE:
  105. usage = AUDIO_MUTE;
  106. break;
  107. case KC_AUDIO_VOL_UP:
  108. usage = AUDIO_VOL_UP;
  109. break;
  110. case KC_AUDIO_VOL_DOWN:
  111. usage = AUDIO_VOL_DOWN;
  112. break;
  113. case KC_MEDIA_NEXT_TRACK:
  114. usage = TRANSPORT_NEXT_TRACK;
  115. break;
  116. case KC_MEDIA_PREV_TRACK:
  117. usage = TRANSPORT_PREV_TRACK;
  118. break;
  119. case KC_MEDIA_STOP:
  120. usage = TRANSPORT_STOP;
  121. break;
  122. case KC_MEDIA_PLAY_PAUSE:
  123. usage = TRANSPORT_PLAY_PAUSE;
  124. break;
  125. case KC_MEDIA_SELECT:
  126. usage = AL_CC_CONFIG;
  127. break;
  128. case KC_MAIL:
  129. usage = AL_EMAIL;
  130. break;
  131. case KC_CALCULATOR:
  132. usage = AL_CALCULATOR;
  133. break;
  134. case KC_MY_COMPUTER:
  135. usage = AL_LOCAL_BROWSER;
  136. break;
  137. case KC_WWW_SEARCH:
  138. usage = AC_SEARCH;
  139. break;
  140. case KC_WWW_HOME:
  141. usage = AC_HOME;
  142. break;
  143. case KC_WWW_BACK:
  144. usage = AC_BACK;
  145. break;
  146. case KC_WWW_FORWARD:
  147. usage = AC_FORWARD;
  148. break;
  149. case KC_WWW_STOP:
  150. usage = AC_STOP;
  151. break;
  152. case KC_WWW_REFRESH:
  153. usage = AC_REFRESH;
  154. break;
  155. case KC_WWW_FAVORITES:
  156. usage = AC_BOOKMARKS;
  157. break;
  158. }
  159. return usage;
  160. }
  161. #ifdef __cplusplus
  162. }
  163. #endif
  164. #endif