hey all,
So I got my m:robe 500 today which is a touchscreen player and I
started working in the sim to get the mouse going, and it worked
nicely, but the changes I had to make weren't very clean.

So, can anyone see a problem with the attached patch?
What it does is change gui_synclist_do_button() to return true if the
action is handled by that function or false otherwise (instead of
returning the action code of the handled action), and it also changes
the action param to unsigned * so the function can modify it (required
by I think 3 calls in total).

The reason this is needed is because the list is used in most of the
UI the touchscreen code would need to get called once for every button
event in a list, and this call can either be in the list code itself,
or in every list loop in the code...

I tested the tree, menu and settings, and the other ones should work,
but not tested (one of the reasons ive written this up...)

imho its a bit cleaner anyway, so unless there are any objections I'll
probably commit it.

last thing, I just realised their is non-latin letters being fudged
which I'll obviously fix before committing, and plugin API version
will need bumping.

Jonathan

P.S incase anyone asks, using the mouse in the sim is, well..
different :) only the lists are working, but it does work great and
makes it feel more like a possible stand alone app instead of just a
sim.
Index: apps/screens.c
===================================================================
--- apps/screens.c	(revision 14726)
+++ apps/screens.c	(working copy)
@@ -7,7 +7,7 @@
  *                     \/            \/     \/    \/            \/
  * $Id$
  *
- * Copyright (C) 2002 Björn Stenberg
+ * Copyright (C) 2002 Bj�rn Stenberg
  *
  * All files in this archive are subject to the GNU General Public License.
  * See the file COPYING in the source tree root for full license agreement.
@@ -1282,7 +1282,7 @@
         gui_syncstatusbar_draw(&statusbars, false);
         key = get_action(CONTEXT_LIST,HZ/2);
         if(key!=ACTION_NONE && key!=ACTION_UNKNOWN
-        && !gui_synclist_do_button(&id3_lists, key,LIST_WRAP_UNLESS_HELD))
+        && !gui_synclist_do_button(&id3_lists, &key,LIST_WRAP_UNLESS_HELD))
         {
             return(default_event_handler(key) == SYS_USB_CONNECTED);
         }
@@ -1342,7 +1342,7 @@
         gui_synclist_draw(&lists);
         gui_syncstatusbar_draw(&statusbars, true);
         action = get_action(CONTEXT_STD, HZ);
-        gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD);
+        gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD);
         if(action == ACTION_STD_CANCEL)
             break;
         if(action == ACTION_STD_OK) {
Index: apps/cuesheet.c
===================================================================
--- apps/cuesheet.c	(revision 14726)
+++ apps/cuesheet.c	(working copy)
@@ -296,7 +296,7 @@
     {
         gui_synclist_draw(&lists);
         action = get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
-        if (gui_synclist_do_button(&lists,action,LIST_WRAP_UNLESS_HELD))
+        if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
             continue;
         switch (action)
         {
Index: apps/recorder/radio.c
===================================================================
--- apps/recorder/radio.c	(revision 14726)
+++ apps/recorder/radio.c	(working copy)
@@ -1266,7 +1266,7 @@
         gui_syncstatusbar_draw(&statusbars, true);
         action = get_action(CONTEXT_STD, HZ);
 
-        gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD);
+        gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD);
         switch (action)
         {
             case ACTION_STD_MENU:
Index: apps/tree.c
===================================================================
--- apps/tree.c	(revision 14726)
+++ apps/tree.c	(working copy)
@@ -552,7 +552,7 @@
     int numentries=0;
     char buf[MAX_PATH];
     int lasti = -1;
-    unsigned button, returned_button;
+    unsigned button, oldbutton;
     bool reload_root = false;
     int lastfilter = *tc.dirfilter;
     bool lastsortcase = global_settings.sort_case;
@@ -605,12 +605,8 @@
         }
 #endif
         button = get_action(CONTEXT_TREE,HZ/5);
-        returned_button = gui_synclist_do_button(&tree_lists, button,LIST_WRAP_UNLESS_HELD);
-        if (returned_button)
-            need_update = true;
-        if (returned_button == ACTION_STD_CANCEL)
-            button = ACTION_STD_CANCEL;
-
+        oldbutton = button;
+        need_update = gui_synclist_do_button(&tree_lists, &button,LIST_WRAP_UNLESS_HELD);
         tc.selected_item = gui_synclist_get_sel_pos(&tree_lists);
         switch ( button ) {
             case ACTION_STD_OK:
@@ -640,9 +636,11 @@
                 if ((*tc.dirfilter == SHOW_ID3DB && tc.dirlevel == 0) ||
                     ((*tc.dirfilter != SHOW_ID3DB && !strcmp(currdir,"/"))))
                 {
-                    if (returned_button == ACTION_STD_CANCEL)
+#ifdef HAVE_LCD_BITMAP
+                    if (oldbutton == ACTION_TREE_PGLEFT)
                         break;
                     else
+#endif
                         return GO_TO_ROOT;
                 }
                 
Index: apps/plugins/random_folder_advance_config.c
===================================================================
--- apps/plugins/random_folder_advance_config.c	(revision 14726)
+++ apps/plugins/random_folder_advance_config.c	(working copy)
@@ -288,7 +288,7 @@
     {
         rb->gui_synclist_draw(&lists);
         button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
-        if (rb->gui_synclist_do_button(&lists,button,LIST_WRAP_UNLESS_HELD))
+        if (rb->gui_synclist_do_button(&lists,&button,LIST_WRAP_UNLESS_HELD))
             continue;
         selection = rb->gui_synclist_get_sel_pos(&lists);
         switch (button)
Index: apps/plugins/chessbox/chessbox_pgn.c
===================================================================
--- apps/plugins/chessbox/chessbox_pgn.c	(revision 14726)
+++ apps/plugins/chessbox/chessbox_pgn.c	(working copy)
@@ -808,7 +808,7 @@
         rb->gui_synclist_draw(&games_list);
         curr_selection = rb->gui_synclist_get_sel_pos(&games_list);
         button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
-        if (rb->gui_synclist_do_button(&games_list,button,LIST_WRAP_OFF)){
+        if (rb->gui_synclist_do_button(&games_list,&button,LIST_WRAP_OFF)){
             continue;
         }
         switch (button) {
Index: apps/plugins/shortcuts/shortcuts_view.c
===================================================================
--- apps/plugins/shortcuts/shortcuts_view.c	(revision 14726)
+++ apps/plugins/shortcuts/shortcuts_view.c	(working copy)
@@ -59,7 +59,7 @@
         rb->gui_syncstatusbar_draw(rb->statusbars, true);
         /* user input */
         button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK);
-        if (rb->gui_synclist_do_button(&gui_sc, button,
+        if (rb->gui_synclist_do_button(&gui_sc, &button,
                                             LIST_WRAP_UNLESS_HELD)) {
             /* automatic handling of user input.
             * _UNLESS_HELD can be _ON or _OFF also
Index: apps/plugins/lib/oldmenuapi.c
===================================================================
--- apps/plugins/lib/oldmenuapi.c	(revision 14726)
+++ apps/plugins/lib/oldmenuapi.c	(working copy)
@@ -107,7 +107,7 @@
          */
         if( menus[m].callback != NULL )
             key = menus[m].callback(key, m);
-        rb->gui_synclist_do_button(&(menus[m].synclist), key,LIST_WRAP_UNLESS_HELD);
+        rb->gui_synclist_do_button(&(menus[m].synclist), &key,LIST_WRAP_UNLESS_HELD);
         switch( key ) {
             case ACTION_STD_OK:
                 return rb->gui_synclist_get_sel_pos(&(menus[m].synclist));
Index: apps/plugins/text_editor.c
===================================================================
--- apps/plugins/text_editor.c	(revision 14726)
+++ apps/plugins/text_editor.c	(working copy)
@@ -374,7 +374,7 @@
         rb->gui_synclist_draw(&lists);
         cur_sel = rb->gui_synclist_get_sel_pos(&lists);
         button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
-        if (rb->gui_synclist_do_button(&lists,button,LIST_WRAP_UNLESS_HELD))
+        if (rb->gui_synclist_do_button(&lists,&button,LIST_WRAP_UNLESS_HELD))
             continue;
         switch (button)
         {
Index: apps/plugins/properties.c
===================================================================
--- apps/plugins/properties.c	(revision 14726)
+++ apps/plugins/properties.c	(working copy)
@@ -318,7 +318,7 @@
     while(!quit)
     {
         button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
-        if (rb->gui_synclist_do_button(&properties_lists,button,LIST_WRAP_ON))
+        if (rb->gui_synclist_do_button(&properties_lists,&button,LIST_WRAP_ON))
             continue;
         switch(button)
         {
Index: apps/gui/option_select.c
===================================================================
--- apps/gui/option_select.c	(revision 14726)
+++ apps/gui/option_select.c	(working copy)
@@ -381,7 +381,7 @@
         action = get_action(CONTEXT_LIST, TIMEOUT_BLOCK);
         if (action == ACTION_NONE)
             continue;
-        if (gui_synclist_do_button(&lists,action,
+        if (gui_synclist_do_button(&lists, &action,
             allow_wrap? LIST_WRAP_UNLESS_HELD: LIST_WRAP_OFF))
         {
             selected = gui_synclist_get_sel_pos(&lists);
Index: apps/gui/list.c
===================================================================
--- apps/gui/list.c	(revision 14726)
+++ apps/gui/list.c	(working copy)
@@ -889,8 +889,8 @@
 
 extern intptr_t get_action_data(void);
 
-unsigned gui_synclist_do_button(struct gui_synclist * lists,
-                                unsigned button,enum list_wrap wrap)
+bool gui_synclist_do_button(struct gui_synclist * lists,
+                            unsigned *action, enum list_wrap wrap)
 {
 #ifdef HAVE_LCD_BITMAP
     static bool scrolling_left = false;
@@ -937,16 +937,16 @@
             gui_synclist_limit_scroll(lists, true);
         break;
         case LIST_WRAP_UNLESS_HELD:
-            if (button == ACTION_STD_PREVREPEAT ||
-                button == ACTION_STD_NEXTREPEAT ||
-                button == ACTION_LISTTREE_PGUP  ||
-                button == ACTION_LISTTREE_PGDOWN)
+            if (*action == ACTION_STD_PREVREPEAT ||
+                *action == ACTION_STD_NEXTREPEAT ||
+                *action == ACTION_LISTTREE_PGUP  ||
+                *action == ACTION_LISTTREE_PGDOWN)
                 gui_synclist_limit_scroll(lists, true);
             else gui_synclist_limit_scroll(lists, false);
         break;
     };
 
-    switch(button)
+    switch (*action)
     {
 #ifdef HAVE_VOLUME_IN_LIST
         case ACTION_LIST_VOLUP:
@@ -955,7 +955,7 @@
         case ACTION_LIST_VOLDOWN:
             global_settings.volume--;
             setvol();
-            return button;
+            return true;
 #endif
         case ACTION_STD_PREV:
         case ACTION_STD_PREVREPEAT:
@@ -968,7 +968,8 @@
                 gui_synclist_draw(lists);
             }
             yield();
-            return ACTION_STD_PREV;
+            *action = ACTION_STD_PREV;
+            return true;
 
         case ACTION_STD_NEXT:
         case ACTION_STD_NEXTREPEAT:
@@ -981,13 +982,14 @@
                 gui_synclist_draw(lists);
             }
             yield();
-            return ACTION_STD_NEXT;
+            *action = ACTION_STD_NEXT;
+            return true;
 
 #ifdef HAVE_LCD_BITMAP
         case ACTION_TREE_PGRIGHT:
             gui_synclist_scroll_right(lists);
             gui_synclist_draw(lists);
-            return ACTION_TREE_PGRIGHT;
+            return true;
         case ACTION_TREE_ROOT_INIT:
          /* After this button press ACTION_TREE_PGLEFT is allowed
             to skip to root. ACTION_TREE_ROOT_INIT must be defined in the
@@ -997,16 +999,21 @@
             if (lists->gui_list[0].offset_position == 0)
             {
                 scrolling_left = false;
-                return ACTION_STD_CANCEL;
+                *action = ACTION_STD_CANCEL;
+                return true;
             }
+            *action = ACTION_TREE_PGLEFT;
         case ACTION_TREE_PGLEFT:
             if(!scrolling_left && (lists->gui_list[0].offset_position == 0))
-                return ACTION_STD_CANCEL;
+            {
+                *action = ACTION_STD_CANCEL;
+                return false;
+            }
             gui_synclist_scroll_left(lists);
             gui_synclist_draw(lists);
             scrolling_left = true; /* stop ACTION_TREE_PAGE_LEFT
                                       skipping to root */
-            return ACTION_TREE_PGLEFT;
+            return true;
 #endif
 
 /* for pgup / pgdown, we are obliged to have a different behaviour depending
@@ -1023,8 +1030,9 @@
             gui_synclist_select_previous_page(lists, screen);
             gui_synclist_draw(lists);
             yield();
+            *action = ACTION_STD_NEXT;
         }
-        return ACTION_STD_NEXT;
+        return true;
 
         case ACTION_LISTTREE_PGDOWN:
         {
@@ -1037,8 +1045,9 @@
             gui_synclist_select_next_page(lists, screen);
             gui_synclist_draw(lists);
             yield();
+            *action = ACTION_STD_PREV;
         }
-        return ACTION_STD_PREV;
+        return true;
     }
-    return 0;
+    return false;
 }
Index: apps/gui/list.h
===================================================================
--- apps/gui/list.h	(revision 14726)
+++ apps/gui/list.h	(working copy)
@@ -218,16 +218,11 @@
                                                 bool hide);
 /*
  * Do the action implied by the given button,
- * returns the action taken if any, 0 else
- *  - lists : the synchronized lists
- *  - button : the keycode of a pressed button
- *  - specifies weather to allow the list to wrap or not, values at top of page
- * returned value :
- *  - ACTION_STD_NEXT when moving forward (next item or pgup)
- *  - ACTION_STD_PREV when moving backward (previous item or pgdown)
+ * returns true if the action was handled.
+ * NOTE: *action may be changed regardless of return value
  */
-extern unsigned gui_synclist_do_button(struct gui_synclist * lists,
-                                       unsigned button,
+extern bool gui_synclist_do_button(struct gui_synclist * lists,
+                                       unsigned *action,
                                        enum list_wrap);
 
 #endif /* _GUI_LIST_H_ */
Index: apps/menu.c
===================================================================
--- apps/menu.c	(revision 14726)
+++ apps/menu.c	(working copy)
@@ -345,7 +345,7 @@
             }
         }
 
-        if (gui_synclist_do_button(&lists,action,LIST_WRAP_UNLESS_HELD))
+        if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
         {
             talk_menu_item(menu, &lists);
             continue;
Index: apps/menus/settings_menu.c
===================================================================
--- apps/menus/settings_menu.c	(revision 14726)
+++ apps/menus/settings_menu.c	(working copy)
@@ -491,7 +491,7 @@
     {
         gui_syncstatusbar_draw(&statusbars, true);
         action = get_action(CONTEXT_STD, HZ/5); 
-        if (gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD))
+        if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
             continue;
         if (action == ACTION_STD_CANCEL)
         {
Index: apps/playlist_viewer.c
===================================================================
--- apps/playlist_viewer.c	(revision 14726)
+++ apps/playlist_viewer.c	(working copy)
@@ -605,14 +605,13 @@
 
         /* Timeout so we can determine if play status has changed */
         button = get_action(CONTEXT_TREE,HZ/2);
-        int list_action;
-        if( (list_action=gui_synclist_do_button(&playlist_lists, button,LIST_WRAP_UNLESS_HELD))!=0 )
+        if( (gui_synclist_do_button(&playlist_lists, &button,LIST_WRAP_UNLESS_HELD)) )
         {
             viewer.selected_track=gui_synclist_get_sel_pos(&playlist_lists);
             if(playlist_buffer_needs_reload(&viewer.buffer,
                 viewer.selected_track))
                 playlist_buffer_load_entries_screen(&viewer.buffer,
-                    list_action==ACTION_STD_NEXT?
+                    button==ACTION_STD_NEXT?
                         FORWARD
                         :
                         BACKWARD
@@ -778,7 +777,7 @@
     while (!exit)
     {
         button = get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
-        if (gui_synclist_do_button(&playlist_lists, button,LIST_WRAP_UNLESS_HELD))
+        if (gui_synclist_do_button(&playlist_lists, &button, LIST_WRAP_UNLESS_HELD))
             continue;
         switch (button)
         {
Index: apps/plugin.h
===================================================================
--- apps/plugin.h	(revision 14726)
+++ apps/plugin.h	(working copy)
@@ -7,7 +7,7 @@
  *                     \/            \/     \/    \/            \/
  * $Id$
  *
- * Copyright (C) 2002 Björn Stenberg
+ * Copyright (C) 2002 Bj�rn Stenberg
  *
  * All files in this archive are subject to the GNU General Public License.
  * See the file COPYING in the source tree root for full license agreement.
@@ -280,8 +280,8 @@
     void (*gui_synclist_del_item)(struct gui_synclist * lists);
     void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
     void (*gui_synclist_flash)(struct gui_synclist * lists);
-    unsigned (*gui_synclist_do_button)(struct gui_synclist * lists,
-                                         unsigned button,enum list_wrap wrap);
+    bool (*gui_synclist_do_button)(struct gui_synclist * lists,
+                                         unsigned *action, enum list_wrap wrap);
     void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, int icon);
 
     /* button */
Index: apps/filetypes.c
===================================================================
--- apps/filetypes.c	(revision 14726)
+++ apps/filetypes.c	(working copy)
@@ -476,7 +476,7 @@
         gui_syncstatusbar_draw(&statusbars, true);
         action = get_action(CONTEXT_MAINMENU,HZ);
         if ((action == ACTION_NONE) ||
-            gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD))
+            gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
             continue;
         else if (action == ACTION_STD_OK)
         {
Index: apps/bookmark.c
===================================================================
--- apps/bookmark.c	(revision 14726)
+++ apps/bookmark.c	(working copy)
@@ -659,7 +659,7 @@
         }
 
         action = get_action(CONTEXT_BOOKMARKSCREEN, HZ / 2);
-        gui_synclist_do_button(&list, action, LIST_WRAP_UNLESS_HELD);
+        gui_synclist_do_button(&list, &action, LIST_WRAP_UNLESS_HELD);
         item = gui_synclist_get_sel_pos(&list) / 2;
 
         if (bookmarks->show_dont_resume)
Index: apps/debug_menu.c
===================================================================
--- apps/debug_menu.c	(revision 14726)
+++ apps/debug_menu.c	(working copy)
@@ -162,7 +162,7 @@
     {
         gui_syncstatusbar_draw(&statusbars, true);
         action = get_action(CONTEXT_STD, HZ/5); 
-        if (gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD))
+        if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
             continue;
         if (info->action_callback)
             action = info->action_callback(action, info);
@@ -1676,7 +1676,7 @@
     static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
     static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
     static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
-    static const unsigned char *nsec_units[] = { "ns", "µs", "ms" };
+    static const unsigned char *nsec_units[] = { "ns", "�s", "ms" };
     static const char *spec_vers[] = { "1.0-1.2", "1.4", "2.0-2.2",
         "3.1-3.31", "4.0" };
     if ((btn == ACTION_STD_OK) || (btn == SYS_FS_CHANGED) || (btn == ACTION_REDRAW))
Index: apps/playlist_catalog.c
===================================================================
--- apps/playlist_catalog.c	(revision 14726)
+++ apps/playlist_catalog.c	(working copy)
@@ -249,7 +249,7 @@
         int button = get_action(CONTEXT_LIST,HZ/2);
         char* sel_file;
 
-        gui_synclist_do_button(&playlist_lists, button,LIST_WRAP_UNLESS_HELD);
+        gui_synclist_do_button(&playlist_lists, &button,LIST_WRAP_UNLESS_HELD);
 
         sel_file = playlists[gui_synclist_get_sel_pos(&playlist_lists)];
 

Reply via email to