implemented lv2 ui:touch

This commit is contained in:
Stefano D'Angelo 2024-07-17 11:17:21 +02:00
parent 12650980b0
commit 78bb6c54f7
2 changed files with 26 additions and 17 deletions

View File

@ -125,15 +125,11 @@
{{=it.tibia.lv2.ttlURI(it.lv2.ui.uri)}} {{=it.tibia.lv2.ttlURI(it.lv2.ui.uri)}}
a ui:@UI_TYPE@ ; a ui:@UI_TYPE@ ;
ui:binary <{{=it.product.bundleName}}@DLL_SUFFIX@> ; ui:binary <{{=it.product.bundleName}}@DLL_SUFFIX@> ;
lv2:extensionData ui:resize ;
{{?!it.product.ui.userResizable}} {{?!it.product.ui.userResizable}}
lv2:optionalFeature ui:noUserResize ; # doesn't work as lv2:requiredFeature, don't ask me why lv2:optionalFeature ui:noUserResize ; # doesn't work as lv2:requiredFeature, don't ask me why
{{?!it.product.ui.selfResizable}} {{?!it.product.ui.selfResizable}}
lv2:optionalFeature ui:fixedSize ; lv2:optionalFeature ui:fixedSize ;
{{?}} {{?}}
{{?}}
{{?it.product.ui.selfResizable}}
lv2:optionalFeature ui:resize ;
{{?}} {{?}}
lv2:requiredFeature ui:idleInterface ; lv2:requiredFeature ui:idleInterface ;
lv2:extensionData ui:idleInterface . lv2:extensionData ui:idleInterface .

View File

@ -346,6 +346,8 @@ typedef struct {
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0 # if DATA_PRODUCT_CONTROL_INPUTS_N > 0
LV2UI_Write_Function write; LV2UI_Write_Function write;
LV2UI_Controller controller; LV2UI_Controller controller;
char has_touch;
LV2UI_Touch touch;
# endif # endif
} ui_instance; } ui_instance;
@ -363,8 +365,11 @@ static const char * ui_get_bundle_path_cb(void *handle) {
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0 # if DATA_PRODUCT_CONTROL_INPUTS_N > 0
static void ui_set_parameter_begin_cb(void *handle, size_t index) { static void ui_set_parameter_begin_cb(void *handle, size_t index) {
(void)handle; ui_instance *instance = (ui_instance *)handle;
(void)index; if (instance->has_touch) {
index = index_to_param[index];
instance->touch.touch(instance->touch.handle, index, true);
}
} }
static void ui_set_parameter_cb(void *handle, size_t index, float value) { static void ui_set_parameter_cb(void *handle, size_t index, float value) {
@ -375,23 +380,17 @@ static void ui_set_parameter_cb(void *handle, size_t index, float value) {
} }
static void ui_set_parameter_end_cb(void *handle, size_t index) { static void ui_set_parameter_end_cb(void *handle, size_t index) {
(void)handle; ui_instance *instance = (ui_instance *)handle;
(void)index; if (instance->has_touch) {
index = index_to_param[index];
instance->touch.touch(instance->touch.handle, index, false);
}
} }
# endif # endif
static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const char * plugin_uri, const char * bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget * widget, const LV2_Feature * const * features) { static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const char * plugin_uri, const char * bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget * widget, const LV2_Feature * const * features) {
(void)descriptor; (void)descriptor;
(void)plugin_uri; (void)plugin_uri;
(void)bundle_path;
char has_parent = 0;
void *parent = NULL;
for (size_t i = 0; features[i] != NULL; i++)
if (!strcmp(features[i]->URI, LV2_UI__parent)) {
has_parent = 1;
parent = features[i]->data;
}
ui_instance *instance = malloc(sizeof(ui_instance)); ui_instance *instance = malloc(sizeof(ui_instance));
if (instance == NULL) if (instance == NULL)
@ -401,6 +400,20 @@ static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const ch
if (instance->bundle_path == NULL) if (instance->bundle_path == NULL)
goto err_bundle_path; goto err_bundle_path;
char has_parent = 0;
void *parent = NULL;
instance->has_touch = 0;
for (size_t i = 0; features[i] != NULL; i++) {
if (!strcmp(features[i]->URI, LV2_UI__parent)) {
has_parent = 1;
parent = features[i]->data;
}
if (!strcmp(features[i]->URI, LV2_UI__touch)) {
instance->has_touch = 1;
instance->touch = *((LV2UI_Touch *)features[i]->data);
}
}
plugin_ui_callbacks cbs = { plugin_ui_callbacks cbs = {
/* .handle = */ (void *)instance, /* .handle = */ (void *)instance,
/* .format = */ "lv2", /* .format = */ "lv2",