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.

report.h 6.1KB

Squashed 'tmk_core/' changes from 57d27a8..08ce4c3 08ce4c3 Add update for chibios in README 30cac1d Merge remote-tracking branch 'flabbergast-tmk_keyboard/chibios' f218a38 core: Remove unused warning. Fix tmk_keyboard/#293 3e68807 Chibios: add more guards for transmitting (fix a deadlock bug). cecc807 core: Speed up compilation d01d959 Merge remote-tracking branch 'upstream/master' into chibios 8ff12ae Merge pull request #230 from jerryen/master 3afb83d core: Add note about sudo and git 2525d5d Chibios: Update to new USB API. 2fc5cd6 Merge branch 'master' into chibios 6f5511a core: Fix variable initialize 02a15fa core: Fix variable init and header include 1833ca1 Merge pull request #292 from obones/command_warning bc9dc6f Merge pull request #294 from shayneholmes/fix-debug-message c1b891b Merge pull request #295 from doopai/master 1da837c core: Add macro commands SM(), RM() and CM() d9d5a93 Add support for storing, restoring and clearing modifiers in macros 4f371c0 core: Add dfu-programmer example to doc/build.md ba3792e core: Fix doc/build.md 4b99fed remove SERIAL_SOFT_DEBUG macro 984accb Fix typo in bootmagic debug message 67a7ea1 usb_usb: Fix for keymap editor 2fc9ae4 host_driver is only used if KEYBOARD_LOCK_ENABLE is defined a35cdea Chibios: add 'core/protocol' to the makefiles' search path. 5ed2fd6 Merge remote-tracking branch 'upstream/master' into chibios bbc4851 Do timeout when writing to CONSOLE EP queue. 2450559 Remove an errant comma trailing the KC_ERAS macro alias 8465747 Merge pull request #270 from jeffgran/single-tap-toggle a37339a Merge pull request #271 from jeffgran/default-layer-toggle 8e732f7 core: Update doc/build.md and remove other_projects.md e47dc15 Workaround for compiler warnings when console disabled. 4184c52 Add maple mini code. b555238 core: Fix rules.mk for dfu target 26dacf4 add ACTION_DEFAULT_LAYER_TOGGLE to toggle a default layer on/off 83607d9 enable TAPPING_TOGGLE=1 to work correctly bef3089 Merge branch 'master' into chibios f7a55fd core: Fix debug print of usb_hid 1402f7d core: Add keycode KC_JPY for JIS 8e3a460 Chibios: Remove the wait in the main loop. 7d41746 ChibiOS: prettify/document sleep_led code. 235cdee ChibiOS: Update infinity bootloader code to match updated ChibiOS. 807bf1e Chibios: Add breathing sleep LED on Kinetis MCUs. ba3bf7c ChibiOS: make reset request more CMSISy. bf2ffd4 Add correct chibios/bootloader_jump for infinity KB. f5e03fd Chibios/usb_main: rename a variable for clarity. 63a330c Fix drop key stroke d8f5b06 Fix report size of boot protocol. 38abb50 ChibiOS/STM32: send remote wakeup. 6725650 ChibiOS/kinetis: sending remote wakeup. 69f6e54 Chibios: use WFI in idle. WIP suspend stuff. 02f044b Move chibios/cortex selection to local Makefiles. fa59dfa Rename chibios example keyboard. 5c060de Add eeprom support for chibios/kinetis. efd0044 Move declaration of keymap_config. 7196b24 Make bootmagic.c code portable (_delay_ms -> wait_ms). 37b15b2 Add missing #include to keymap.c. 31316e3 Merge branch 'master' into chibios 166f312 Fix chibios/usb_main GET_REPORT handing. 57ac6c2 Add ARM Teensies bootloader code. 1758086 Move STM32 bootloader address config to separate .h file. 03bb026 Rename some Makefile defines. 76ba6ac NKRO fixes. 06498f8 Update chibios README. db0a4f5 Add basic sleep_led for chibios. c3f930e Move AVR specific sleep_led.c into avr. 4069494 Fix bootloader-jump compiling. 9117f7b Small updates. 269cb85 Implement jump-to-bootloader. 7e81b34 Move chibios to tool. 923a892 Make usb_main more USB_DRIVER #define independent. aa054f0 Add ChibiOS support (USB stack + support files). 1e3e282 Modularity and gcc warnings fixes. 2f60ce0 Add KEYBOARD_LOCK_ENABLE to makefile git-subtree-dir: tmk_core git-subtree-split: 08ce4c3021d2ecd446c5b9a137aded65423d241e
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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_STOP_EJECT 0x00CC
  38. #define TRANSPORT_PLAY_PAUSE 0x00CD
  39. /* application launch */
  40. #define AL_CC_CONFIG 0x0183
  41. #define AL_EMAIL 0x018A
  42. #define AL_CALCULATOR 0x0192
  43. #define AL_LOCAL_BROWSER 0x0194
  44. /* application control */
  45. #define AC_SEARCH 0x0221
  46. #define AC_HOME 0x0223
  47. #define AC_BACK 0x0224
  48. #define AC_FORWARD 0x0225
  49. #define AC_STOP 0x0226
  50. #define AC_REFRESH 0x0227
  51. #define AC_BOOKMARKS 0x022A
  52. /* supplement for Bluegiga iWRAP HID(not supported by Windows?) */
  53. #define AL_LOCK 0x019E
  54. #define TRANSPORT_RECORD 0x00B2
  55. #define TRANSPORT_FAST_FORWARD 0x00B3
  56. #define TRANSPORT_REWIND 0x00B4
  57. #define TRANSPORT_EJECT 0x00B8
  58. #define AC_MINIMIZE 0x0206
  59. /* Generic Desktop Page(0x01) - system power control */
  60. #define SYSTEM_POWER_DOWN 0x0081
  61. #define SYSTEM_SLEEP 0x0082
  62. #define SYSTEM_WAKE_UP 0x0083
  63. /* key report size(NKRO or boot mode) */
  64. #if defined(PROTOCOL_PJRC) && defined(NKRO_ENABLE)
  65. # include "usb.h"
  66. # define KEYBOARD_REPORT_SIZE KBD2_SIZE
  67. # define KEYBOARD_REPORT_KEYS (KBD2_SIZE - 2)
  68. # define KEYBOARD_REPORT_BITS (KBD2_SIZE - 1)
  69. #elif defined(PROTOCOL_LUFA) && defined(NKRO_ENABLE)
  70. # include "protocol/lufa/descriptor.h"
  71. # define KEYBOARD_REPORT_SIZE NKRO_EPSIZE
  72. # define KEYBOARD_REPORT_KEYS (NKRO_EPSIZE - 2)
  73. # define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1)
  74. #elif defined(PROTOCOL_CHIBIOS) && defined(NKRO_ENABLE)
  75. # include "protocol/chibios/usb_main.h"
  76. # define KEYBOARD_REPORT_SIZE NKRO_EPSIZE
  77. # define KEYBOARD_REPORT_KEYS (NKRO_EPSIZE - 2)
  78. # define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1)
  79. #else
  80. # define KEYBOARD_REPORT_SIZE 8
  81. # define KEYBOARD_REPORT_KEYS 6
  82. #endif
  83. #ifdef __cplusplus
  84. extern "C" {
  85. #endif
  86. /*
  87. * keyboard report is 8-byte array retains state of 8 modifiers and 6 keys.
  88. *
  89. * byte |0 |1 |2 |3 |4 |5 |6 |7
  90. * -----+--------+--------+--------+--------+--------+--------+--------+--------
  91. * desc |mods |reserved|keys[0] |keys[1] |keys[2] |keys[3] |keys[4] |keys[5]
  92. *
  93. * It is exended to 16 bytes to retain 120keys+8mods when NKRO mode.
  94. *
  95. * byte |0 |1 |2 |3 |4 |5 |6 |7 ... |15
  96. * -----+--------+--------+--------+--------+--------+--------+--------+-------- +--------
  97. * desc |mods |bits[0] |bits[1] |bits[2] |bits[3] |bits[4] |bits[5] |bits[6] ... |bit[14]
  98. *
  99. * mods retains state of 8 modifiers.
  100. *
  101. * bit |0 |1 |2 |3 |4 |5 |6 |7
  102. * -----+--------+--------+--------+--------+--------+--------+--------+--------
  103. * desc |Lcontrol|Lshift |Lalt |Lgui |Rcontrol|Rshift |Ralt |Rgui
  104. *
  105. */
  106. typedef union {
  107. uint8_t raw[KEYBOARD_REPORT_SIZE];
  108. struct {
  109. uint8_t mods;
  110. uint8_t reserved;
  111. uint8_t keys[KEYBOARD_REPORT_KEYS];
  112. };
  113. #ifdef NKRO_ENABLE
  114. struct {
  115. uint8_t mods;
  116. uint8_t bits[KEYBOARD_REPORT_BITS];
  117. } nkro;
  118. #endif
  119. } __attribute__ ((packed)) report_keyboard_t;
  120. /*
  121. typedef struct {
  122. uint8_t mods;
  123. uint8_t reserved;
  124. uint8_t keys[REPORT_KEYS];
  125. } __attribute__ ((packed)) report_keyboard_t;
  126. */
  127. typedef struct {
  128. uint8_t buttons;
  129. int8_t x;
  130. int8_t y;
  131. int8_t v;
  132. int8_t h;
  133. } __attribute__ ((packed)) report_mouse_t;
  134. /* keycode to system usage */
  135. #define KEYCODE2SYSTEM(key) \
  136. (key == KC_SYSTEM_POWER ? SYSTEM_POWER_DOWN : \
  137. (key == KC_SYSTEM_SLEEP ? SYSTEM_SLEEP : \
  138. (key == KC_SYSTEM_WAKE ? SYSTEM_WAKE_UP : 0)))
  139. /* keycode to consumer usage */
  140. #define KEYCODE2CONSUMER(key) \
  141. (key == KC_AUDIO_MUTE ? AUDIO_MUTE : \
  142. (key == KC_AUDIO_VOL_UP ? AUDIO_VOL_UP : \
  143. (key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \
  144. (key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \
  145. (key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \
  146. (key == KC_MEDIA_FAST_FORWARD ? TRANSPORT_FAST_FORWARD : \
  147. (key == KC_MEDIA_REWIND ? TRANSPORT_REWIND : \
  148. (key == KC_MEDIA_STOP ? TRANSPORT_STOP : \
  149. (key == KC_MEDIA_EJECT ? TRANSPORT_STOP_EJECT : \
  150. (key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \
  151. (key == KC_MEDIA_SELECT ? AL_CC_CONFIG : \
  152. (key == KC_MAIL ? AL_EMAIL : \
  153. (key == KC_CALCULATOR ? AL_CALCULATOR : \
  154. (key == KC_MY_COMPUTER ? AL_LOCAL_BROWSER : \
  155. (key == KC_WWW_SEARCH ? AC_SEARCH : \
  156. (key == KC_WWW_HOME ? AC_HOME : \
  157. (key == KC_WWW_BACK ? AC_BACK : \
  158. (key == KC_WWW_FORWARD ? AC_FORWARD : \
  159. (key == KC_WWW_STOP ? AC_STOP : \
  160. (key == KC_WWW_REFRESH ? AC_REFRESH : \
  161. (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0)))))))))))))))))))))
  162. #ifdef __cplusplus
  163. }
  164. #endif
  165. #endif