logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

connection.h (2506B)


  1. // Copyright 2025 QMK
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <stdint.h>
  5. #include "compiler_support.h"
  6. #include "util.h"
  7. /**
  8. * \enum connection_host_t
  9. *
  10. * An enumeration of the possible hosts.
  11. */
  12. typedef enum connection_host_t {
  13. CONNECTION_HOST_AUTO,
  14. CONNECTION_HOST_NONE,
  15. CONNECTION_HOST_USB,
  16. CONNECTION_HOST_BLUETOOTH,
  17. CONNECTION_HOST_2P4GHZ
  18. } connection_host_t;
  19. /**
  20. * \union connection_config_t
  21. *
  22. * Configuration structure for the connection subsystem.
  23. */
  24. typedef union connection_config_t {
  25. uint8_t raw;
  26. connection_host_t desired_host : 8;
  27. } PACKED connection_config_t;
  28. STATIC_ASSERT(sizeof(connection_config_t) == sizeof(uint8_t), "Connection EECONFIG out of spec.");
  29. /**
  30. * \brief Initialize the subsystem.
  31. *
  32. * This function must be called only once, before any of the below functions can be called.
  33. */
  34. void connection_init(void);
  35. /**
  36. * \brief Get currently configured host. Does not resolve 'CONNECTION_HOST_AUTO'.
  37. *
  38. * \return 'connection_host_t' of the configured host.
  39. */
  40. connection_host_t connection_get_host_raw(void);
  41. /**
  42. * \brief Get current active host.
  43. *
  44. * \return 'connection_host_t' of the configured host.
  45. */
  46. connection_host_t connection_auto_detect_host(void);
  47. /**
  48. * \brief Get currently configured host. Resolves 'CONNECTION_HOST_AUTO' using 'connection_auto_detect_host()'.
  49. *
  50. * \return 'connection_host_t' of the configured host.
  51. */
  52. connection_host_t connection_get_host(void);
  53. /**
  54. * \brief Get current host. New state is not written to EEPROM.
  55. *
  56. * \param host The host to configure.
  57. */
  58. void connection_set_host_noeeprom(connection_host_t host);
  59. /**
  60. * \brief Get current host.
  61. *
  62. * \param host The host to configure.
  63. */
  64. void connection_set_host(connection_host_t host);
  65. /**
  66. * \brief Move to the next potential host. New state is not written to EEPROM.
  67. *
  68. */
  69. void connection_next_host_noeeprom(void);
  70. /**
  71. * \brief Move to the next potential host.
  72. *
  73. */
  74. void connection_next_host(void);
  75. /**
  76. * \brief Move to the previous potential host. New state is not written to EEPROM.
  77. *
  78. */
  79. void connection_prev_host_noeeprom(void);
  80. /**
  81. * \brief Move to the previous potential host.
  82. *
  83. */
  84. void connection_prev_host(void);
  85. /**
  86. * \brief user hook called when changing configured host
  87. *
  88. */
  89. void connection_host_changed_user(connection_host_t host);
  90. /**
  91. * \brief keyboard hook called when changing configured host
  92. *
  93. */
  94. void connection_host_changed_kb(connection_host_t host);