20 "title" :
"UI Interaction",
21 "description" :
"Stores information about a UI device's input.",
22 "keywords" : [
"gui" ],
26 "VuoList_VuoInteraction",
56 if (json_object_object_get_ex(js,
"uuid", &o))
59 if (json_object_object_get_ex(js,
"position", &o))
62 if (json_object_object_get_ex(js,
"isPressed", &o))
63 interaction.isPressed = json_object_get_boolean(o);
65 if (json_object_object_get_ex(js,
"type", &o))
68 if( json_object_object_get_ex(js,
"origin", &o))
71 if( json_object_object_get_ex(js,
"timestamp", &o))
72 interaction.timestamp = json_object_get_double(o);
74 if( json_object_object_get_ex(js,
"clickCount", &o))
92 json_object_object_add(js,
"isPressed", json_object_new_boolean(value.isPressed));
95 json_object_object_add(js,
"timestamp", json_object_new_double(value.timestamp));
111 char* sum =
VuoText_format(
"<div>Type: %s</div><div>Position: %.2f, %.2f</div><div>Is Pressed: %s</div><div>Click Count: %lli</div>",
115 (value.isPressed ?
"Yes" :
"No"),
144 return (
int)&a < (int)&b;
147 #define MAX_CLICK_DELTA .2
149 #define MIN_DRAG_DISTANCE .08
159 if(!isPressed || !previous.isPressed)
163 if(previous.type == VuoInteractionType_Drag || previous.type == VuoInteractionType_DragStart)
190 bool changed =
false;
192 interaction->type = VuoInteractionType_None;
203 interaction->type = (prev.type == VuoInteractionType_Drag || prev.type == VuoInteractionType_DragStart) ? VuoInteractionType_Drag : VuoInteractionType_DragStart;
205 interaction->type = VuoInteractionType_Move;
207 interaction->position = position;
208 interaction->clickCount = 0;
211 if( interaction->isPressed != isPressed )
217 interaction->type = VuoInteractionType_Press;
218 interaction->origin = position;
223 interaction->clickCount = prev.clickCount + 1;
227 interaction->clickCount = 1;
235 if( prev.type == VuoInteractionType_DragStart || prev.type == VuoInteractionType_Drag )
237 interaction->clickCount = 0;
238 interaction->type = VuoInteractionType_DragFinish;
242 interaction->clickCount = prev.clickCount;
243 interaction->type = VuoInteractionType_Click;
247 interaction->clickCount = prev.clickCount;
248 interaction->type = VuoInteractionType_Release;
252 interaction->isPressed = isPressed;