summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-09-26 19:25:52 +0000
committerDave Chapman <dave@dchapman.com>2006-09-26 19:25:52 +0000
commit491458e418ba443b42167b6fc4c4933d72883f47 (patch)
treeb02968aa4860bf3011ae0f6baa378fdc21af0a70
parent181dab41379e743a87319a975385f6caa3521230 (diff)
Add wheel_status() function to the ipod "4g" button driver (i.e. all ipods excluding the 3G and 1st gen mini) to read the absolute position the wheel is being touched (0..95 - clockwise from top, or -1 for untouched), plus the wheel_send_events(bool) function to disable/enable sending normal scrolling events - based on patch #4721 from Mikael Magnusson.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11068 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.c4
-rw-r--r--apps/plugin.h7
-rw-r--r--firmware/drivers/button.c32
-rw-r--r--firmware/export/button.h5
-rw-r--r--firmware/export/config-ipod4g.h3
-rw-r--r--firmware/export/config-ipodcolor.h3
-rwxr-xr-xfirmware/export/config-ipodmini2g.h3
-rw-r--r--firmware/export/config-ipodnano.h3
-rw-r--r--firmware/export/config-ipodvideo.h3
9 files changed, 58 insertions, 5 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 04a4d1c735..a908016703 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -468,6 +468,10 @@ static const struct plugin_api rockbox_api = {
the API gets incompatible */
strtok_r,
+#ifdef HAVE_WHEEL_POSITION
+ wheel_status,
+ wheel_send_events,
+#endif
};
int plugin_load(const char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index b0221c489d..25bbeb2324 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -105,7 +105,7 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 31
+#define PLUGIN_API_VERSION 32
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
@@ -547,6 +547,11 @@ struct plugin_api {
the API gets incompatible */
char* (*strtok_r)(char *ptr, const char *sep, char **end);
+
+#ifdef HAVE_WHEEL_POSITION
+ int (*wheel_status)(void);
+ void (*wheel_send_events)(bool send);
+#endif
};
/* plugin header */
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 20b725c3d4..599c22bc80 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -90,6 +90,10 @@ 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;
+#ifdef HAVE_WHEEL_POSITION
+static int wheel_position = -1;
+static bool send_events = true;
+#endif
#endif
#ifdef HAVE_HEADPHONE_DETECTION
@@ -131,6 +135,8 @@ static void opto_i2c_init(void)
static inline 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);*/
@@ -160,6 +166,7 @@ static inline int ipod_4g_button_read(void)
if (status & 0x40000000) {
/* NB: highest wheel = 0x5F, clockwise increases */
int new_wheel_value = (status << 9) >> 25;
+ whl = new_wheel_value;
backlight_on();
/* The queue should have no other events when scrolling */
if (queue_empty(&button_queue) && old_wheel_value >= 0) {
@@ -180,9 +187,14 @@ static inline int ipod_4g_button_read(void)
wheel_keycode = BUTTON_SCROLL_BACK;
} else goto wheel_end;
- data = (wheel_delta << 16) | new_wheel_value;
- queue_post(&button_queue, wheel_keycode | wheel_repeat,
- (void *)data);
+#ifdef HAVE_WHEEL_POSITION
+ if (send_events)
+#endif
+ {
+ data = (wheel_delta << 16) | new_wheel_value;
+ queue_post(&button_queue, wheel_keycode | wheel_repeat,
+ (void *)data);
+ }
if (!wheel_repeat) wheel_repeat = BUTTON_REPEAT;
}
@@ -205,6 +217,8 @@ wheel_end:
outl(0xffffffff, 0x7000c120);
outl(0xffffffff, 0x7000c124);
}
+ /* Save the new absolute wheel position */
+ wheel_position = whl;
return btn;
}
@@ -1343,6 +1357,18 @@ int button_status(void)
return lastbtn;
}
+#ifdef HAVE_WHEEL_POSITION
+int wheel_status(void)
+{
+ return wheel_position;
+}
+
+void wheel_send_events(bool send)
+{
+ send_events = send;
+}
+#endif
+
void button_clear_queue(void)
{
queue_clear(&button_queue);
diff --git a/firmware/export/button.h b/firmware/export/button.h
index 39dfbff6fa..4ff04202d5 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -57,7 +57,10 @@ bool remote_button_hold(void);
#ifdef HAVE_HEADPHONE_DETECTION
bool headphones_inserted(void);
#endif
-
+#ifdef HAVE_WHEEL_POSITION
+int wheel_status(void);
+void wheel_send_events(bool send);
+#endif
#define BUTTON_NONE 0x00000000
diff --git a/firmware/export/config-ipod4g.h b/firmware/export/config-ipod4g.h
index 2e8c4dcc33..2b603987f4 100644
--- a/firmware/export/config-ipod4g.h
+++ b/firmware/export/config-ipod4g.h
@@ -112,6 +112,9 @@
/* Define this if you can detect headphones */
#define HAVE_HEADPHONE_DETECTION
+/* Define this if you can read an absolute wheel position */
+#define HAVE_WHEEL_POSITION
+
#define BOOTFILE_EXT "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT
diff --git a/firmware/export/config-ipodcolor.h b/firmware/export/config-ipodcolor.h
index 964f103214..0bcb25b56c 100644
--- a/firmware/export/config-ipodcolor.h
+++ b/firmware/export/config-ipodcolor.h
@@ -108,6 +108,9 @@
/* Define this if you can detect headphones */
#define HAVE_HEADPHONE_DETECTION
+/* Define this if you can read an absolute wheel position */
+#define HAVE_WHEEL_POSITION
+
#define BOOTFILE_EXT "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT
diff --git a/firmware/export/config-ipodmini2g.h b/firmware/export/config-ipodmini2g.h
index 342742ea43..bac60e3e72 100755
--- a/firmware/export/config-ipodmini2g.h
+++ b/firmware/export/config-ipodmini2g.h
@@ -115,6 +115,9 @@
/* Define this if you can detect headphones */
#define HAVE_HEADPHONE_DETECTION
+/* Define this if you can read an absolute wheel position */
+#define HAVE_WHEEL_POSITION
+
#define BOOTFILE_EXT "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT
diff --git a/firmware/export/config-ipodnano.h b/firmware/export/config-ipodnano.h
index 03f5b8c753..c24aa43e55 100644
--- a/firmware/export/config-ipodnano.h
+++ b/firmware/export/config-ipodnano.h
@@ -113,6 +113,9 @@
/* Define this if you can detect headphones */
#define HAVE_HEADPHONE_DETECTION
+/* Define this if you can read an absolute wheel position */
+#define HAVE_WHEEL_POSITION
+
#define BOOTFILE_EXT "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT
diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h
index 4781a2c887..cd8f1eea11 100644
--- a/firmware/export/config-ipodvideo.h
+++ b/firmware/export/config-ipodvideo.h
@@ -113,6 +113,9 @@
/* Define this if you can detect headphones */
#define HAVE_HEADPHONE_DETECTION
+/* Define this if you can read an absolute wheel position */
+#define HAVE_WHEEL_POSITION
+
#define BOOTFILE_EXT "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT