Commits

rmtew committed dcca47d

JNI support functions for Android OS gestures (swipe and long tap). Swipe is not yet used, and long tap maps to a mouse click at the given screen position.

Comments (0)

Files changed (1)

PlatformCode/jni_glue.c

 	currentEntryType = -1;
 }
 
+void broguex_send_lmouse_click(int screen_x, int screen_y) {
+	int font_w, font_h;
+	TCOD_sys_get_char_size(&font_w, &font_h);
+	SDL_Window* window = (SDL_Window*)TCOD_sys_get_SDL_window();
+	SDL_WarpMouseInWindow(window, screen_x+font_w/2, screen_y+font_h/2);
+	SDL_SendMouseButton(window, SDL_PRESSED, SDL_BUTTON_LEFT);
+	SDL_SendMouseButton(window, SDL_RELEASED, SDL_BUTTON_LEFT);
+}
+
 /* Functions called from JNI to make calls on the SDL API. */
 
 void PACKAGE_FNAME(PKGNAME_FUNCTION,nativeFakeMouseClick)(JNIEnv *env, jclass cls, jint cx, jint cy) {
 	int screen_x, screen_y;
-	int font_w, font_h;
-	TCOD_sys_get_char_size(&font_w, &font_h);
 	TCOD_sys_convert_console_to_screen_coords(cx, cy, &screen_x, &screen_y);
 	/* __android_log_print(ANDROID_LOG_INFO, LOG_TAG, "nativeFakeMouseClick(%d, %d) => (%d, %d)", cx, cy, screen_x, screen_y); */
-
-	SDL_Window* window = (SDL_Window*)TCOD_sys_get_SDL_window();
-	SDL_WarpMouseInWindow(window, screen_x+font_w/2, screen_y+font_h/2);
-	SDL_SendMouseButton(window, SDL_PRESSED, SDL_BUTTON_LEFT);
-	SDL_SendMouseButton(window, SDL_RELEASED, SDL_BUTTON_LEFT);
+	broguex_send_lmouse_click(screen_x, screen_y);
 }
 
 /* Functions called from JNI to make calls on the TCOD API. */
 	else
 		SDL_ShowScreenKeyboard(window);
 }
+
+void PACKAGE_FNAME(PKGNAME_FUNCTION,nativeGestureFling)(JNIEnv *env, jclass cls, jint touch_device_id_in, jfloat x0, jfloat y0, jfloat x1, jfloat y1) {
+	printf("nativeGestureFling dev %d start %0.2f %0.2f end %0.2f %0.2f\n", x0, y0, x1, y1);
+}
+
+void PACKAGE_FNAME(PKGNAME_FUNCTION,nativeGestureLongTouch)(JNIEnv *env, jclass cls, jint touch_device_id_in, jfloat xf, jfloat yf) {
+	int w, h, screen_x, screen_y;
+	TCOD_sys_get_current_resolution(&w, &h);
+	screen_x = w * xf;
+	screen_y = h * yf;
+	printf("nativeGestureLongTouch %d %d\n", screen_x, screen_y);
+	broguex_send_lmouse_click(screen_x, screen_y);
+}