hid_protocol.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright 2021 foxx1337 at yahoo dot com
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #pragma once
  18. #include <color.h>
  19. #include <raw_hid.h>
  20. #define CTRL_HID_GREETING_VERSION "CTRLHID 1.0.0"
  21. enum ctrl_hid_codes {
  22. // Signals end of message. Not really that useful.
  23. CTRL_HID_EOM = 0x00,
  24. CTRL_HID_OK,
  25. CTRL_HID_NOK,
  26. /**
  27. * to hid: CTRL_HID_HELLO
  28. * from hid: CTRL_HID_HELLO, "CTRLHID 1.0.0", CTRL_HID_EOM
  29. **/
  30. CTRL_HID_HELLO,
  31. /**
  32. * to hid: CTRL_HID_LIGHTS_TOGGLE
  33. * from hid: CTRL_HID_LIGHTS_TOGGLE, CTRL_HID_OK, is_led_timeout, CTRL_HID_EOM
  34. *
  35. * Toggles all the leds on the keyboard. is_led_timeout will be 1 if the new
  36. * state is off, 0 if leds are on.
  37. **/
  38. CTRL_HID_LIGHTS_TOGGLE,
  39. /**
  40. * to hid: CTRL_HID_LED, led_id, r, g, b
  41. * from hid: CTRL_HID_LED, CTRL_HID_OK, CTRL_HID_EOM
  42. * on error: CTRL_HID_LED, CTRL_HID_NOK, num_leds, CTRL_HID_EOM
  43. *
  44. * Sets the specific led to r, g, b. It's only visible when the hid_effect mode is active.
  45. **/
  46. CTRL_HID_LED,
  47. /**
  48. * to hid: CTRL_HID_LEDS, start, count, r0, g0, b0, ..., r[count-1], g[count-1], b[count-1]
  49. * from hid: CTRL_HID_LEDS, CTRL_HID_OK, affected_leds, CTRL_HID_EOM
  50. *
  51. * Sets affected_leds leds following start to the corresponding r, g, b value.
  52. * It's only visible when the hid_effect mode is active.
  53. **/
  54. CTRL_HID_LEDS,
  55. /**
  56. * to hid: CTRL_HID_RGBMATRIX_MODE, mode
  57. * from hid: CTRL_HID_RGBMATRIX_MODE, CTRL_HID_OK, CTRL_HID_EOM
  58. * on error: CTRL_HID_RGBMATRIX_MODE, CTRL_HID_NOK, mode_max, CTRL_HID_EOM
  59. *
  60. * Changes light mode. mode_max is hid_effect for CTRL_HID_LED and CTRL_HID_LEDS.
  61. */
  62. CTRL_HID_RGBMATRIX_MODE
  63. };
  64. extern uint8_t raw_hid_buffer[RAW_EPSIZE];
  65. // Defined in rgb_matrix_user.inc
  66. // It's 119 for Massdrop CTRL, 0 - 118.
  67. extern RGB rgb_matrix_led_state[RGB_MATRIX_LED_COUNT];
  68. void raw_hid_perform_send(void);