Audio plugin host https://kx.studio/carla
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.

194 lines
5.1KB

  1. /*
  2. * travesty, pure C VST3-compatible interface
  3. * Copyright (C) 2021-2023 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #pragma once
  17. #include "base.h"
  18. /**
  19. * base view stuff
  20. */
  21. struct v3_view_rect {
  22. int32_t left;
  23. int32_t top;
  24. int32_t right;
  25. int32_t bottom;
  26. };
  27. #define V3_VIEW_PLATFORM_TYPE_HWND "HWND"
  28. #define V3_VIEW_PLATFORM_TYPE_NSVIEW "NSView"
  29. #define V3_VIEW_PLATFORM_TYPE_X11 "X11EmbedWindowID"
  30. #if defined(__APPLE__)
  31. # define V3_VIEW_PLATFORM_TYPE_NATIVE V3_VIEW_PLATFORM_TYPE_NSVIEW
  32. #elif defined(_WIN32)
  33. # define V3_VIEW_PLATFORM_TYPE_NATIVE V3_VIEW_PLATFORM_TYPE_HWND
  34. #elif !defined(__EMSCRIPTEN__)
  35. # define V3_VIEW_PLATFORM_TYPE_NATIVE V3_VIEW_PLATFORM_TYPE_X11
  36. #endif
  37. /**
  38. * plugin view
  39. */
  40. struct v3_plugin_frame;
  41. struct v3_plugin_view {
  42. #ifndef __cplusplus
  43. struct v3_funknown;
  44. #endif
  45. v3_result (V3_API* is_platform_type_supported)(void* self, const char* platform_type);
  46. v3_result (V3_API* attached)(void* self, void* parent, const char* platform_type);
  47. v3_result (V3_API* removed)(void* self);
  48. v3_result (V3_API* on_wheel)(void* self, float distance);
  49. v3_result (V3_API* on_key_down)(void* self, int16_t key_char, int16_t key_code, int16_t modifiers);
  50. v3_result (V3_API* on_key_up)(void* self, int16_t key_char, int16_t key_code, int16_t modifiers);
  51. v3_result (V3_API* get_size)(void* self, struct v3_view_rect*);
  52. v3_result (V3_API* on_size)(void* self, struct v3_view_rect*);
  53. v3_result (V3_API* on_focus)(void* self, v3_bool state);
  54. v3_result (V3_API* set_frame)(void* self, struct v3_plugin_frame**);
  55. v3_result (V3_API* can_resize)(void* self);
  56. v3_result (V3_API* check_size_constraint)(void* self, struct v3_view_rect*);
  57. };
  58. static constexpr const v3_tuid v3_plugin_view_iid =
  59. V3_ID(0x5BC32507, 0xD06049EA, 0xA6151B52, 0x2B755B29);
  60. /**
  61. * plugin frame
  62. */
  63. struct v3_plugin_frame {
  64. #ifndef __cplusplus
  65. struct v3_funknown;
  66. #endif
  67. v3_result (V3_API* resize_view)(void* self, struct v3_plugin_view**, struct v3_view_rect*);
  68. };
  69. static constexpr const v3_tuid v3_plugin_frame_iid =
  70. V3_ID(0x367FAF01, 0xAFA94693, 0x8D4DA2A0, 0xED0882A3);
  71. /**
  72. * steinberg content scaling support
  73. * (same IID/iface as presonus view scaling)
  74. */
  75. struct v3_plugin_view_content_scale {
  76. #ifndef __cplusplus
  77. struct v3_funknown;
  78. #endif
  79. v3_result (V3_API* set_content_scale_factor)(void* self, float factor);
  80. };
  81. static constexpr const v3_tuid v3_plugin_view_content_scale_iid =
  82. V3_ID(0x65ED9690, 0x8AC44525, 0x8AADEF7A, 0x72EA703F);
  83. /**
  84. * support for querying the view to find what control is underneath the mouse
  85. */
  86. struct v3_plugin_view_parameter_finder {
  87. #ifndef __cplusplus
  88. struct v3_funknown;
  89. #endif
  90. v3_result (V3_API* find_parameter)(void* self, int32_t x, int32_t y, v3_param_id *);
  91. };
  92. static constexpr const v3_tuid v3_plugin_view_parameter_finder_iid =
  93. V3_ID(0x0F618302, 0x215D4587, 0xA512073C, 0x77B9D383);
  94. /**
  95. * linux event handler
  96. */
  97. struct v3_event_handler {
  98. #ifndef __cplusplus
  99. struct v3_funknown;
  100. #endif
  101. void (V3_API* on_fd_is_set)(void* self, int fd);
  102. };
  103. static constexpr const v3_tuid v3_event_handler_iid =
  104. V3_ID(0x561E65C9, 0x13A0496F, 0x813A2C35, 0x654D7983);
  105. /**
  106. * linux timer handler
  107. */
  108. struct v3_timer_handler {
  109. #ifndef __cplusplus
  110. struct v3_funknown;
  111. #endif
  112. void (V3_API* on_timer)(void* self);
  113. };
  114. static constexpr const v3_tuid v3_timer_handler_iid =
  115. V3_ID(0x10BDD94F, 0x41424774, 0x821FAD8F, 0xECA72CA9);
  116. /**
  117. * linux host run loop
  118. */
  119. struct v3_run_loop {
  120. #ifndef __cplusplus
  121. struct v3_funknown;
  122. #endif
  123. v3_result (V3_API* register_event_handler)(void* self, v3_event_handler** handler, int fd);
  124. v3_result (V3_API* unregister_event_handler)(void* self, v3_event_handler** handler);
  125. v3_result (V3_API* register_timer)(void* self, v3_timer_handler** handler, uint64_t ms);
  126. v3_result (V3_API* unregister_timer)(void* self, v3_timer_handler** handler);
  127. };
  128. static constexpr const v3_tuid v3_run_loop_iid =
  129. V3_ID(0x18C35366, 0x97764F1A, 0x9C5B8385, 0x7A871389);
  130. #ifdef __cplusplus
  131. /**
  132. * C++ variants
  133. */
  134. struct v3_plugin_view_cpp : v3_funknown {
  135. v3_plugin_view view;
  136. };
  137. struct v3_plugin_frame_cpp : v3_funknown {
  138. v3_plugin_frame frame;
  139. };
  140. struct v3_plugin_view_content_scale_cpp : v3_funknown {
  141. v3_plugin_view_content_scale scale;
  142. };
  143. struct v3_plugin_view_parameter_finder_cpp : v3_funknown {
  144. v3_plugin_view_parameter_finder finder;
  145. };
  146. struct v3_event_handler_cpp : v3_funknown {
  147. v3_event_handler handler;
  148. };
  149. struct v3_timer_handler_cpp : v3_funknown {
  150. v3_timer_handler timer;
  151. };
  152. struct v3_run_loop_cpp : v3_funknown {
  153. v3_run_loop loop;
  154. };
  155. #endif