Keyboard firmwares for Atmel AVR and Cortex-M
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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