summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/action.c3
-rw-r--r--apps/gui/bitmap/list.c49
-rw-r--r--uisimulator/sdl/button.c16
3 files changed, 54 insertions, 14 deletions
diff --git a/apps/action.c b/apps/action.c
index 89d6a7ae7a..5d0f994862 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -308,6 +308,9 @@ int action_get_touchpad_press(short *x, short *y)
308 return BUTTON_REPEAT; 308 return BUTTON_REPEAT;
309 if (short_press) 309 if (short_press)
310 return BUTTON_REL; 310 return BUTTON_REL;
311 /* this is to give a BUTTON_REL after a BUTTON_REPEAT */
312 if (last_button & BUTTON_REL)
313 return BUTTON_REL;
311 return BUTTON_TOUCHPAD; 314 return BUTTON_TOUCHPAD;
312} 315}
313#endif 316#endif
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index ed257155bd..fa41daeb01 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -278,6 +278,7 @@ void list_draw(struct screen *display, struct viewport *parent,
278 278
279 279
280#if defined(HAVE_TOUCHPAD) 280#if defined(HAVE_TOUCHPAD)
281static int prev_line=0;
281/* this needs to be fixed if we ever get more than 1 touchscreen on a target */ 282/* this needs to be fixed if we ever get more than 1 touchscreen on a target */
282/* this also assumes the whole screen is used, which is a bad asusmption but 283/* this also assumes the whole screen is used, which is a bad asusmption but
283 fine untill customizable lists comes in... */ 284 fine untill customizable lists comes in... */
@@ -309,15 +310,15 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor
309 nb_lines = viewport_get_nb_lines(&list_text[SCREEN_MAIN]); 310 nb_lines = viewport_get_nb_lines(&list_text[SCREEN_MAIN]);
310 if (nb_lines < gui_list->nb_items) 311 if (nb_lines < gui_list->nb_items)
311 { 312 {
312 height = nb_lines * display->char_height; 313 height = nb_lines * font_get(parent->font)->height;
313 size = height*nb_lines / gui_list->nb_items; 314 size = height*nb_lines / gui_list->nb_items;
314 new_selection = ((y-list_text[SCREEN_MAIN].y)*(gui_list->nb_items-nb_lines))/(height-size); 315 new_selection = ((y-list_text[SCREEN_MAIN].y)*(gui_list->nb_items-nb_lines))/(height-size);
315 gui_synclist_select_item(gui_list, new_selection);
316 nb_lines /= 2; 316 nb_lines /= 2;
317
317 if (new_selection - gui_list->start_item[SCREEN_MAIN] > nb_lines) 318 if (new_selection - gui_list->start_item[SCREEN_MAIN] > nb_lines)
318 {
319 new_selection = gui_list->start_item[SCREEN_MAIN]+nb_lines; 319 new_selection = gui_list->start_item[SCREEN_MAIN]+nb_lines;
320 } 320
321 gui_synclist_select_item(gui_list, new_selection);
321 gui_list->start_item[SCREEN_MAIN] = new_selection; 322 gui_list->start_item[SCREEN_MAIN] = new_selection;
322 return ACTION_REDRAW; 323 return ACTION_REDRAW;
323 } 324 }
@@ -329,32 +330,52 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor
329 pressing the selected item will "enter" it */ 330 pressing the selected item will "enter" it */
330 if (y > list_text[SCREEN_MAIN].y) 331 if (y > list_text[SCREEN_MAIN].y)
331 { 332 {
332 line = (y-list_text[SCREEN_MAIN].y) / display->char_height; 333 int i, line_height, actual_y;
333 if (button != BUTTON_REL && button != BUTTON_REPEAT) 334 actual_y = y - list_text[SCREEN_MAIN].y;
335 line_height = font_get(parent->font)->height;
336 line = -1;
337 for(i=0; i<gui_list->nb_items; i++)
334 { 338 {
335 if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN]) 339 if(actual_y > line_height*i && actual_y < line_height*(i+1))
336 gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line); 340 line = i;
337 return ACTION_REDRAW;
338 } 341 }
339 if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN]) 342 if(line == -1)
343 return ACTION_NONE;
344
345 /* BUTTON_TOUCHPAD represents a button press*/
346 if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN] && button == BUTTON_TOUCHPAD)
340 { 347 {
341 if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items) 348 if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items)
342 return ACTION_NONE; 349 return ACTION_NONE;
343 gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line); 350 gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line);
351 return ACTION_REDRAW;
344 } 352 }
345 353
346 if (button == BUTTON_REPEAT) 354 if (button == BUTTON_REPEAT)
347 return ACTION_STD_CONTEXT; 355 return ACTION_STD_CONTEXT;
356 else if(button == BUTTON_REL)
357 {
358 if(prev_line == line)
359 {
360 prev_line = 0;
361 return ACTION_STD_OK;
362 }
363 else
364 {
365 prev_line = line;
366 return ACTION_NONE;
367 }
368 }
348 else 369 else
349 return ACTION_STD_OK; 370 return ACTION_NONE;
350 } 371 }
351 /* title goes up one level */ 372 /* title goes up one level */
352 else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list)) 373 else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list) && button == BUTTON_REL)
353 { 374 {
354 return ACTION_STD_CANCEL; 375 return ACTION_STD_CANCEL;
355 } 376 }
356 /* title or statusbar is cancel */ 377 /* title or statusbar is cancel */
357 else if (global_settings.statusbar) 378 else if (global_settings.statusbar && button == BUTTON_REL)
358 { 379 {
359 return ACTION_STD_CANCEL; 380 return ACTION_STD_CANCEL;
360 } 381 }
diff --git a/uisimulator/sdl/button.c b/uisimulator/sdl/button.c
index 76a1f2f10c..ba19f30061 100644
--- a/uisimulator/sdl/button.c
+++ b/uisimulator/sdl/button.c
@@ -166,6 +166,13 @@ void button_event(int key, bool pressed)
166 case SDLK_KP3: 166 case SDLK_KP3:
167 new_btn = BUTTON_BOTTOMRIGHT; 167 new_btn = BUTTON_BOTTOMRIGHT;
168 break; 168 break;
169 case SDLK_F10:
170 if(pressed)
171 {
172 touchpad_mode = (touchpad_mode == TOUCHPAD_POINT ? TOUCHPAD_BUTTON : TOUCHPAD_POINT);
173 printf("Touchpad mode: %s\n", touchpad_mode == TOUCHPAD_POINT ? "TOUCHPAD_POINT" : "TOUCHPAD_BUTTON");
174 }
175 break;
169 176
170#endif 177#endif
171 case SDLK_u: 178 case SDLK_u:
@@ -1080,6 +1087,15 @@ void mouse_tick_task(void)
1080 last_check = current_tick; 1087 last_check = current_tick;
1081 if (SDL_GetMouseState(&x, &y) & SDL_BUTTON(SDL_BUTTON_LEFT)) 1088 if (SDL_GetMouseState(&x, &y) & SDL_BUTTON(SDL_BUTTON_LEFT))
1082 { 1089 {
1090 if(background)
1091 {
1092 x -= UI_LCD_POSX;
1093 y -= UI_LCD_POSY;
1094
1095 if(x<0 || y<0 || x>UI_LCD_WIDTH || y>UI_LCD_HEIGHT)
1096 return;
1097 }
1098
1083 mouse_coords = (x<<16)|y; 1099 mouse_coords = (x<<16)|y;
1084 button_event(BUTTON_TOUCHPAD, true); 1100 button_event(BUTTON_TOUCHPAD, true);
1085 if (debug_wps) 1101 if (debug_wps)