- /* TODO implement page flipping */
- if(pixels) {
- /*wait_vsync();*/
- memcpy(vmem_front, pixels, fbsize);
+ switch(ev->type) {
+ case SBALL_EV_MOTION:
+ if(RX(ev) | RY(ev) | RZ(ev)) {
+ float rx = (float)RX(ev);
+ float ry = (float)RY(ev);
+ float rz = (float)RZ(ev);
+ float axis_len = sqrt(rx * rx + ry * ry + rz * rz);
+ if(axis_len > 0.0) {
+ rot = quat_rotate(rot, axis_len * 0.001, -rx / axis_len,
+ -ry / axis_len, -rz / axis_len);
+ }
+ }
+
+ pos.x += TX(ev) * 0.001;
+ pos.y += TY(ev) * 0.001;
+ pos.z += TZ(ev) * 0.001;
+ break;
+
+ case SBALL_EV_BUTTON:
+ if(ev->button.pressed) {
+ pos = v3_cons(0, 0, 0);
+ rot = quat_cons(1, 0, 0, 0);
+ }
+ break;