Keyboard firmwares for Atmel AVR and Cortex-M
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_AUDIO 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) Consumer Control(0x01)
  28. #define AUDIO_VOL_UP (1<<0)
  29. #define AUDIO_VOL_DOWN (1<<1)
  30. #define AUDIO_MUTE (1<<2)
  31. // Generic Desktop Page(0x01) System Control(0x80)
  32. #define SYSTEM_POWER_DOWN (1<<0)
  33. #define SYSTEM_SLEEP (1<<1)
  34. #define SYSTEM_WAKE_UP (1<<2)
  35. #if defined(HOST_PJRC)
  36. # include "usb.h"
  37. # if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
  38. # define REPORT_KEYS KBD2_REPORT_KEYS
  39. # else
  40. # define REPORT_KEYS KBD_REPORT_KEYS
  41. # endif
  42. #elif defined(HOST_VUSB)
  43. # define REPORT_KEYS 6
  44. #endif
  45. typedef struct {
  46. uint8_t mods;
  47. uint8_t rserved;
  48. uint8_t keys[REPORT_KEYS];
  49. } report_keyboard_t;
  50. typedef struct {
  51. uint8_t report_id;
  52. uint8_t buttons;
  53. int8_t x;
  54. int8_t y;
  55. int8_t v;
  56. int8_t h;
  57. } report_mouse_t;
  58. #ifdef USB_NKRO_ENABLE
  59. extern bool keyboard_nkro;
  60. #endif
  61. extern report_keyboard_t *keyboard_report;
  62. extern report_keyboard_t *keyboard_report_prev;
  63. uint8_t host_keyboard_leds(void);
  64. /* keyboard report operations */
  65. void host_add_key(uint8_t key);
  66. void host_add_mod_bit(uint8_t mod);
  67. void host_set_mods(uint8_t mods);
  68. void host_add_code(uint8_t code);
  69. void host_swap_keyboard_report(void);
  70. void host_clear_keyboard_report(void);
  71. uint8_t host_has_anykey(void);
  72. uint8_t host_get_first_key(void);
  73. void host_send_keyboard_report(void);
  74. #if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE)
  75. void host_mouse_send(report_mouse_t *report);
  76. #endif
  77. #ifdef USB_EXTRA_ENABLE
  78. void host_system_send(uint8_t data);
  79. void host_audio_send(uint8_t data);
  80. #endif
  81. #endif