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.

преди 11 години
преди 10 години
преди 11 години
преди 11 години
преди 10 години
преди 10 години
преди 11 години
преди 10 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #include <stdint.h>
  15. //#include <avr/interrupt.h>
  16. #include "keycode.h"
  17. #include "host.h"
  18. #include "util.h"
  19. #include "debug.h"
  20. #ifdef NKRO_ENABLE
  21. bool keyboard_nkro = true;
  22. #endif
  23. static host_driver_t *driver;
  24. static uint16_t last_system_report = 0;
  25. static uint16_t last_consumer_report = 0;
  26. void host_set_driver(host_driver_t *d)
  27. {
  28. driver = d;
  29. }
  30. host_driver_t *host_get_driver(void)
  31. {
  32. return driver;
  33. }
  34. uint8_t host_keyboard_leds(void)
  35. {
  36. if (!driver) return 0;
  37. return (*driver->keyboard_leds)();
  38. }
  39. /* send report */
  40. void host_keyboard_send(report_keyboard_t *report)
  41. {
  42. if (!driver) return;
  43. (*driver->send_keyboard)(report);
  44. if (debug_keyboard) {
  45. dprint("keyboard_report: ");
  46. for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) {
  47. dprintf("%02X ", report->raw[i]);
  48. }
  49. dprint("\n");
  50. }
  51. }
  52. void host_mouse_send(report_mouse_t *report)
  53. {
  54. if (!driver) return;
  55. (*driver->send_mouse)(report);
  56. }
  57. void host_system_send(uint16_t report)
  58. {
  59. if (report == last_system_report) return;
  60. last_system_report = report;
  61. if (!driver) return;
  62. (*driver->send_system)(report);
  63. }
  64. void host_consumer_send(uint16_t report)
  65. {
  66. if (report == last_consumer_report) return;
  67. last_consumer_report = report;
  68. if (!driver) return;
  69. (*driver->send_consumer)(report);
  70. }
  71. uint16_t host_last_sysytem_report(void)
  72. {
  73. return last_system_report;
  74. }
  75. uint16_t host_last_consumer_report(void)
  76. {
  77. return last_consumer_report;
  78. }