Add handling for "camera actions" 3rd checkbox state

This commit is contained in:
Ingvar Stepanyan
2021-07-26 15:00:35 +00:00
parent 36ed35192c
commit 8f30a60c2e
2 changed files with 24 additions and 6 deletions

15
api.cpp
View File

@@ -86,6 +86,9 @@ class Context {
if (event_type == GP_EVENT_TIMEOUT) {
break;
}
if (event_type == GP_EVENT_UNKNOWN) {
EM_ASM({ console.log(UTF8ToString($0)); }, event_data.get());
}
had_events = true;
}
return had_events;
@@ -240,7 +243,17 @@ class Context {
}
case GP_WIDGET_TOGGLE: {
result.set("type", "toggle");
result.set("value", GPP_CALL(int, gp_widget_get_value(widget, _)) != 0);
int value = GPP_CALL(int, gp_widget_get_value(widget, _));
// Note: explicitly not adding `value` for any other values
// (e.g. camera actions often would return 2 here...)
switch (value) {
case 0:
result.set("value", false);
break;
case 1:
result.set("value", true);
break;
}
break;
}