| 59 | } |
| 60 | |
| 61 | bool mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { |
| 62 | printf("%s, screen: (%d,%d), client: (%d,%d),%s%s%s%s button: %hu, buttons: %hu, movement: (%d,%d), target: (%d, %d)\n", |
| 63 | emscripten_event_type_to_string(eventType), e->screenX, e->screenY, e->clientX, e->clientY, |
| 64 | e->ctrlKey ? " CTRL" : "", e->shiftKey ? " SHIFT" : "", e->altKey ? " ALT" : "", e->metaKey ? " META" : "", |
| 65 | e->button, e->buttons, e->movementX, e->movementY, e->targetX, e->targetY); |
| 66 | |
| 67 | if (e->screenX != 0 && e->screenY != 0 && e->clientX != 0 && e->clientY != 0 && e->targetX != 0 && e->targetY != 0) { |
| 68 | if (eventType == EMSCRIPTEN_EVENT_CLICK) gotClick = 1; |
| 69 | if (eventType == EMSCRIPTEN_EVENT_MOUSEDOWN && e->buttons != 0) gotMouseDown = 1; |
| 70 | if (eventType == EMSCRIPTEN_EVENT_DBLCLICK) gotDblClick = 1; |
| 71 | if (eventType == EMSCRIPTEN_EVENT_MOUSEUP) gotMouseUp = 1; |
| 72 | if (eventType == EMSCRIPTEN_EVENT_MOUSEMOVE && (e->movementX != 0 || e->movementY != 0)) gotMouseMove = 1; |
| 73 | } |
| 74 | |
| 75 | if (eventType == EMSCRIPTEN_EVENT_CLICK && e->screenX == -500000) { |
| 76 | printf("ERROR! Received an event to a callback that should have been unregistered!\n"); |
| 77 | gotClick = 0; |
| 78 | assert(false && "Received an event to a callback that should have been unregistered"); |
| 79 | } |
| 80 | |
| 81 | instruction(); |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | bool wheel_callback(int eventType, const EmscriptenWheelEvent *e, void *userData) { |
| 86 | printf("%s, screen: (%d,%d), client: (%d,%d),%s%s%s%s button: %hu, buttons: %hu, target: (%d, %d), delta:(%g,%g,%g), deltaMode:%u\n", |
nothing calls this directly
no test coverage detected