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.

host.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 HOST_H
  15. #define HOST_H
  16. #include <stdint.h>
  17. /* report id */
  18. #define REPORT_ID_MOUSE 1
  19. #define REPORT_ID_SYSTEM 2
  20. #define REPORT_ID_CONSUMER 3
  21. /* keyboard Modifiers in boot protocol report */
  22. #define BIT_LCTRL (1<<0)
  23. #define BIT_LSHIFT (1<<1)
  24. #define BIT_LALT (1<<2)
  25. #define BIT_LGUI (1<<3)
  26. #define BIT_RCTRL (1<<4)
  27. #define BIT_RSHIFT (1<<5)
  28. #define BIT_RALT (1<<6)
  29. #define BIT_RGUI (1<<7)
  30. #define BIT_LCTL BIT_LCTRL
  31. #define BIT_RCTL BIT_RCTRL
  32. #define BIT_LSFT BIT_LSHIFT
  33. #define BIT_RSFT BIT_RSHIFT
  34. /* mouse buttons */
  35. #define MOUSE_BTN1 (1<<0)
  36. #define MOUSE_BTN2 (1<<1)
  37. #define MOUSE_BTN3 (1<<2)
  38. #define MOUSE_BTN4 (1<<3)
  39. #define MOUSE_BTN5 (1<<4)
  40. // Consumer Page(0x0C)
  41. #define AUDIO_MUTE 0x00E2
  42. #define AUDIO_VOL_UP 0x00E9
  43. #define AUDIO_VOL_DOWN 0x00EA
  44. #define TRANSPORT_NEXT_TRACK 0x00B5
  45. #define TRANSPORT_PREV_TRACK 0x00B6
  46. #define TRANSPORT_STOP 0x00B7
  47. #define TRANSPORT_PLAY_PAUSE 0x00CD
  48. #define AL_CC_CONFIG 0x0183
  49. #define AL_EMAIL 0x018A
  50. #define AL_CALCULATOR 0x0192
  51. #define AL_LOCAL_BROWSER 0x0194
  52. #define AC_SEARCH 0x0221
  53. #define AC_HOME 0x0223
  54. #define AC_BACK 0x0224
  55. #define AC_FORWARD 0x0225
  56. #define AC_STOP 0x0226
  57. #define AC_REFRESH 0x0227
  58. #define AC_BOOKMARKS 0x022A
  59. // Generic Desktop Page(0x01)
  60. #define SYSTEM_POWER_DOWN 0x0081
  61. #define SYSTEM_SLEEP 0x0082
  62. #define SYSTEM_WAKE_UP 0x0083
  63. #if defined(HOST_PJRC)
  64. # include "usb.h"
  65. # if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
  66. # define REPORT_KEYS KBD2_REPORT_KEYS
  67. # else
  68. # define REPORT_KEYS KBD_REPORT_KEYS
  69. # endif
  70. #elif defined(HOST_VUSB)
  71. # define REPORT_KEYS 6
  72. #endif
  73. typedef struct {
  74. uint8_t mods;
  75. uint8_t rserved;
  76. uint8_t keys[REPORT_KEYS];
  77. } report_keyboard_t;
  78. typedef struct {
  79. uint8_t report_id;
  80. uint8_t buttons;
  81. int8_t x;
  82. int8_t y;
  83. int8_t v;
  84. int8_t h;
  85. } report_mouse_t;
  86. #ifdef USB_NKRO_ENABLE
  87. extern bool keyboard_nkro;
  88. #endif
  89. extern report_keyboard_t *keyboard_report;
  90. extern report_keyboard_t *keyboard_report_prev;
  91. uint8_t host_keyboard_leds(void);
  92. /* keyboard report operations */
  93. void host_add_key(uint8_t key);
  94. void host_add_mod_bit(uint8_t mod);
  95. void host_set_mods(uint8_t mods);
  96. void host_add_code(uint8_t code);
  97. void host_swap_keyboard_report(void);
  98. void host_clear_keyboard_report(void);
  99. uint8_t host_has_anykey(void);
  100. uint8_t host_get_first_key(void);
  101. void host_send_keyboard_report(void);
  102. #if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE)
  103. void host_mouse_send(report_mouse_t *report);
  104. #endif
  105. #ifdef USB_EXTRA_ENABLE
  106. void host_system_send(uint16_t data);
  107. void host_consumer_send(uint16_t data);
  108. #endif
  109. #endif