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.

75 lines
2.8 KiB

  1. /* Copyright 2016 Jack Humbert
  2. *
  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. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef _API_H_
  17. #define _API_H_
  18. #include "lufa.h"
  19. enum MESSAGE_TYPE {
  20. MT_GET_DATA = 0x10, // Get data from keyboard
  21. MT_GET_DATA_ACK = 0x11, // returned data to process (ACK)
  22. MT_SET_DATA = 0x20, // Set data on keyboard
  23. MT_SET_DATA_ACK = 0x21, // returned data to confirm (ACK)
  24. MT_SEND_DATA = 0x30, // Sending data/action from keyboard
  25. MT_SEND_DATA_ACK = 0x31, // returned data/action confirmation (ACK)
  26. MT_EXE_ACTION = 0x40, // executing actions on keyboard
  27. MT_EXE_ACTION_ACK =0x41, // return confirmation/value (ACK)
  28. MT_TYPE_ERROR = 0x80 // type not recofgnised (ACK)
  29. };
  30. enum DATA_TYPE {
  31. DT_NONE = 0x00,
  32. DT_HANDSHAKE,
  33. DT_DEFAULT_LAYER,
  34. DT_CURRENT_LAYER,
  35. DT_KEYMAP_OPTIONS,
  36. DT_BACKLIGHT,
  37. DT_RGBLIGHT,
  38. DT_UNICODE,
  39. DT_DEBUG,
  40. DT_AUDIO,
  41. DT_QUANTUM_ACTION,
  42. DT_KEYBOARD_ACTION,
  43. DT_USER_ACTION,
  44. DT_KEYMAP_SIZE,
  45. DT_KEYMAP
  46. };
  47. void dword_to_bytes(uint32_t dword, uint8_t * bytes);
  48. uint32_t bytes_to_dword(uint8_t * bytes, uint8_t index);
  49. #define MT_GET_DATA(data_type, data, length) SEND_BYTES(MT_GET_DATA, data_type, data, length)
  50. #define MT_GET_DATA_ACK(data_type, data, length) SEND_BYTES(MT_GET_DATA_ACK, data_type, data, length)
  51. #define MT_SET_DATA(data_type, data, length) SEND_BYTES(MT_SET_DATA, data_type, data, length)
  52. #define MT_SET_DATA_ACK(data_type, data, length) SEND_BYTES(MT_SET_DATA_ACK, data_type, data, length)
  53. #define MT_SEND_DATA(data_type, data, length) SEND_BYTES(MT_SEND_DATA, data_type, data, length)
  54. #define MT_SEND_DATA_ACK(data_type, data, length) SEND_BYTES(MT_SEND_DATA_ACK, data_type, data, length)
  55. #define MT_EXE_ACTION(data_type, data, length) SEND_BYTES(MT_EXE_ACTION, data_type, data, length)
  56. #define MT_EXE_ACTION_ACK(data_type, data, length) SEND_BYTES(MT_EXE_ACTION_ACK, data_type, data, length)
  57. void process_api(uint16_t length, uint8_t * data);
  58. __attribute__ ((weak))
  59. bool process_api_quantum(uint8_t length, uint8_t * data);
  60. __attribute__ ((weak))
  61. bool process_api_keyboard(uint8_t length, uint8_t * data);
  62. __attribute__ ((weak))
  63. bool process_api_user(uint8_t length, uint8_t * data);
  64. #endif