Index: apps/plugin.c
===================================================================
RCS file: /cvsroot/rockbox/apps/plugin.c,v
retrieving revision 1.158
diff -p -u -d -r1.158 plugin.c
--- apps/plugin.c	11 Mar 2006 15:44:35 -0000	1.158
+++ apps/plugin.c	17 Mar 2006 01:48:07 -0000
@@ -178,8 +179,12 @@ static const struct plugin_api rockbox_a
     button_get,
     button_get_w_tmo,
     button_status,
+#if CONFIG_KEYPAD == IPOD_4G_PAD && ! defined(SIMULATOR)
+    wheel_status,
+    wheel_send_events,
+#endif
     button_clear_queue,
-#if CONFIG_KEYPAD == IRIVER_H100_PAD
+#if CONFIG_KEYPAD == IRIVER_H100_PAD
     button_hold,
 #endif
 
@@ -531,6 +538,11 @@ int plugin_load(const char* plugin, void
     rc = hdr->entry_point((struct plugin_api*) &rockbox_api, parameter);
     /* explicitly casting the pointer here to avoid touching every plugin. */
 
+#if (CONFIG_KEYPAD == IPOD_4G_PAD)
+    /* using the menu probably isn't fun without wheel events, make sure 
+       a plugin doesn't leave us without events */
+    wheel_send_events(true);
+#endif
     button_clear_queue();
 
 #ifdef HAVE_LCD_BITMAP
Index: apps/plugin.h
===================================================================
RCS file: /cvsroot/rockbox/apps/plugin.h,v
retrieving revision 1.165
diff -p -u -d -r1.165 plugin.h
--- apps/plugin.h	16 Mar 2006 17:06:20 -0000	1.165
+++ apps/plugin.h	17 Mar 2006 01:48:07 -0000
@@ -228,8 +229,12 @@ struct plugin_api {
     long (*button_get)(bool block);
     long (*button_get_w_tmo)(int ticks);
     int (*button_status)(void);
+#if CONFIG_KEYPAD == IPOD_4G_PAD && ! defined(SIMULATOR)
+    int (*wheel_status)(void);
+    void (*wheel_send_events)(bool send);
+#endif
     void (*button_clear_queue)(void);
-#if CONFIG_KEYPAD == IRIVER_H100_PAD
+#if CONFIG_KEYPAD == IRIVER_H100_PAD
     bool (*button_hold)(void);
 #endif
 
Index: firmware/drivers/button.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/drivers/button.c,v
retrieving revision 1.128
diff -p -u -d -r1.128 button.c
--- firmware/drivers/button.c	10 Mar 2006 12:55:13 -0000	1.128
+++ firmware/drivers/button.c	17 Mar 2006 01:48:07 -0000
@@ -87,6 +87,8 @@ static bool remote_button_hold_only(void
 #if CONFIG_KEYPAD == IPOD_4G_PAD
 /* Variable to use for setting button status in interrupt handler */
 int int_btn = BUTTON_NONE;
+int int_wheel = -1;
+int send_events = 1;
 #endif
 
 #if (CONFIG_KEYPAD == IPOD_4G_PAD) && (!defined(APPLE_IPODMINI))
@@ -124,6 +126,8 @@ static void opto_i2c_init(void)
 
 static int ipod_4g_button_read(void)
 {
+    int whl = -1;
+    
     /* The ipodlinux source had a udelay(250) here, but testing has shown that
        it is not needed - tested on Nano, Color/Photo and Video. */
     /* udelay(250);*/
@@ -153,6 +157,7 @@ static int ipod_4g_button_read(void)
             if (status & 0x40000000) {
                 /* NB: highest wheel = 0x5F, clockwise increases */
                 int new_wheel_value = ((status << 9) >> 25) & 0xff;
+                whl = new_wheel_value;
 
                 /* scroll wheel down */
                 clickwheel_down = 1;
@@ -190,7 +195,7 @@ static int ipod_4g_button_read(void)
                            Can also implement queue_peek() to do this in a
                            cleaner way.
                          */
-                        if (queue_empty(&button_queue))
+                        if (send_events && queue_empty(&button_queue))
                             queue_post(&button_queue, wheel_keycode, NULL);
                     }
                 }
@@ -219,6 +224,7 @@ static int ipod_4g_button_read(void)
         outl(0xffffffff, 0x7000c120);
         outl(0xffffffff, 0x7000c124);
     }
+    int_wheel = whl;
     return btn;
 }
 
@@ -1281,6 +1287,18 @@ int button_status(void)
     return lastbtn;
 }
 
+#if (CONFIG_KEYPAD == IPOD_4G_PAD)
+int wheel_status(void)
+{
+    return int_wheel;
+}
+
+void wheel_send_events(bool send)
+{
+    send_events = send;
+}
+#endif
+
 void button_clear_queue(void)
 {
     queue_clear(&button_queue);
Index: firmware/export/button.h
===================================================================
RCS file: /cvsroot/rockbox/firmware/export/button.h,v
retrieving revision 1.44
diff -p -u -d -r1.44 button.h
--- firmware/export/button.h	9 Mar 2006 07:23:07 -0000	1.44
+++ firmware/export/button.h	17 Mar 2006 01:48:07 -0000
@@ -37,6 +37,10 @@ void button_init (void);
 long button_get (bool block);
 long button_get_w_tmo(int ticks);
 int button_status(void);
+#if (CONFIG_KEYPAD == IPOD_4G_PAD)
+int wheel_status(void);
+void wheel_send_events(bool send);
+#endif
 void button_clear_queue(void);
 #ifdef HAVE_LCD_BITMAP
 void button_set_flip(bool flip); /* turn 180 degrees */
