From c044117c5f72af93d680780c60fc93b8776449b0 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Fri, 5 Nov 2010 21:50:23 +0000 Subject: Make --zoom option of the sdl port correctly work with mouse clicks. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28500 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/hosted/sdl/button-sdl.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'firmware') diff --git a/firmware/target/hosted/sdl/button-sdl.c b/firmware/target/hosted/sdl/button-sdl.c index 519ac8d7c5..3321a01bc6 100644 --- a/firmware/target/hosted/sdl/button-sdl.c +++ b/firmware/target/hosted/sdl/button-sdl.c @@ -96,7 +96,7 @@ static void touchscreen_event(int x, int y) mouse_coords = (x << 16) | y; button_event(BUTTON_TOUCHSCREEN, true); if (debug_wps) - printf("Mouse at: (%d, %d)\n", x, y); + printf("Mouse at 1: (%d, %d)\n", x, y); } } #endif @@ -193,15 +193,15 @@ static void mouse_event(SDL_MouseButtonEvent *event, bool button_up) } else { - m_x = event->x / display_zoom; - m_y = event->y / display_zoom; + m_x = event->x; + m_y = event->y; #ifdef HAVE_REMOTE if ( m_y >= LCD_HEIGHT ) /* Remote Screen */ m_y -= LCD_HEIGHT; #endif } - printf("Mouse at: (%d, %d)\n", m_x, m_y); + printf("Mouse at 2: (%d, %d)\n", m_x, m_y); } } #undef SQUARE @@ -218,15 +218,23 @@ static bool event_handler(SDL_Event *event) #ifdef HAVE_TOUCHSCREEN case SDL_MOUSEMOTION: if (event->motion.state & SDL_BUTTON(1)) - touchscreen_event(event->motion.x, event->motion.y); + { + int x = event->motion.x / display_zoom; + int y = event->motion.y / display_zoom; + touchscreen_event(x, y); + } break; #endif case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: - mouse_event(&event->button, event->type == SDL_MOUSEBUTTONUP); + { + SDL_MouseButtonEvent *mev = &event->button; + mev->x /= display_zoom; + mev->y /= display_zoom; + mouse_event(mev, event->type == SDL_MOUSEBUTTONUP); break; - + } case SDL_QUIT: return true; } -- cgit v1.2.3