JNIEXPORT void JNICALL Java_com_jeffboody_GearsES1eclair_GearsES1eclair_NativeRotate(JNIEnv* env, jobject obj, jfloat dx, jfloat dy) { assert(env); LOGD("debug dx=%f, dy=%f", (float) dx, (float) dy); if(gears_renderer) { gears_renderer_rotate(gears_renderer, (float) dx, (float) dy); } }
static void axis_update(gears_renderer_t* self, int w, int h) { assert(self); LOGD("debug w=%i, h=%i", w, h); if((fabs(g_axis_x1) > 0.1f) || (fabs(g_axis_y1) > 0.1f)) { float dx = 0.01f*g_axis_x1*w; float dy = 0.01f*g_axis_y1*h; gears_renderer_rotate(self, dx, dy); } if(fabs(g_axis_y2) > 0.1f) { float s = 0.05f*g_axis_y2*h; gears_renderer_scale(gears_renderer, s); } }
static void touch_event(gears_renderer_t* self, loax_event_t* e) { assert(self); assert(e); LOGD("debug"); int type = e->type; int count = e->event_touch.count; if(type == LOAX_EVENT_TOUCHUP) { // do nothing g_touch_state = TOUCH_STATE_INIT; } else if(count == 1) { if(g_touch_state == TOUCH_STATE_ROTATE) { float dx = e->event_touch.coord[0].x - g_touch_x1; float dy = e->event_touch.coord[0].y - g_touch_y1; gears_renderer_rotate(self, dx, dy); g_touch_x1 = e->event_touch.coord[0].x; g_touch_y1 = e->event_touch.coord[0].y; } else { g_touch_x1 = e->event_touch.coord[0].x; g_touch_y1 = e->event_touch.coord[0].y; g_touch_state = TOUCH_STATE_ROTATE; } } else if(count == 2) { if(g_touch_state == TOUCH_STATE_ZOOM) { // some unknown device throws an exception here float x1 = e->event_touch.coord[0].x; float y1 = e->event_touch.coord[0].y; float x2 = e->event_touch.coord[1].x; float y2 = e->event_touch.coord[1].y; float dx = fabsf(x2 - x1); float dy = fabsf(y2 - y1); float s = sqrtf((dx * dx) + (dy * dy)); gears_renderer_scale(gears_renderer, g_touch_s - s); g_touch_x1 = x1; g_touch_y1 = y1; g_touch_x2 = x2; g_touch_y2 = y2; g_touch_s = s; } else { g_touch_x1 = e->event_touch.coord[0].x; g_touch_y1 = e->event_touch.coord[0].y; g_touch_x2 = e->event_touch.coord[1].x; g_touch_y2 = e->event_touch.coord[1].y; float dx = fabsf(g_touch_x2 - g_touch_x1); float dy = fabsf(g_touch_y2 - g_touch_y1); g_touch_s = sqrtf((dx * dx) + (dy * dy)); g_touch_state = TOUCH_STATE_ZOOM; } } }