1. rmtew
  2. brogue

Commits

rmtew  committed f3c30f6

- Faked mouse events for cursor coordinates are into the center of the first character, using the TCOD API sourced character width and height.

  • Participants
  • Parent commits 9fc82fb
  • Branches unofficial-SDL2
  • Tags broguex-1.7.1.15

Comments (0)

Files changed (1)

File PlatformCode/jni_glue.c

View file
 /* 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 = 0, screen_y = 0;
+	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+1, screen_y+1);
+	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);
 }