summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Purchase <shotofadds@rockbox.org>2008-05-05 21:31:34 +0000
committerRob Purchase <shotofadds@rockbox.org>2008-05-05 21:31:34 +0000
commit81803eba1b267f3150cc176c744e8f9fbc5eb9c4 (patch)
tree94dda50cf07ca7ae88f683d9cc17fb56d776a88d
parentab40aa94770c49fa6d0e19e2d407b8c8335a6307 (diff)
downloadrockbox-81803eba1b267f3150cc176c744e8f9fbc5eb9c4.zip
rockbox-81803eba1b267f3150cc176c744e8f9fbc5eb9c4.tar.gz
rockbox-81803eba1b267f3150cc176c744e8f9fbc5eb9c4.tar.bz2
rockbox-81803eba1b267f3150cc176c744e8f9fbc5eb9c4.tar.xz
Simple test_touchpad plugin for D2 and m:robe500 (not built by default).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17392 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.c6
-rw-r--r--apps/plugin.h8
-rw-r--r--apps/plugins/CATEGORIES1
-rw-r--r--apps/plugins/test_touchpad.c141
4 files changed, 155 insertions, 1 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index fd495bd..6c6be90 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -584,6 +584,12 @@ static const struct plugin_api rockbox_api = {
#ifdef HAVE_LCD_INVERT
lcd_set_invert_display,
#endif /* HAVE_LCD_INVERT */
+#ifdef HAVE_BUTTON_DATA
+ button_get_data,
+#endif /* HAVE_BUTTON_DATA */
+#ifdef HAVE_TOUCHPAD
+ touchpad_set_mode,
+#endif /* HAVE_TOUCHPAD */
};
int plugin_load(const char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index c9d118e..8839271 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -120,7 +120,7 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 109
+#define PLUGIN_API_VERSION 110
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
@@ -731,6 +731,12 @@ struct plugin_api {
#ifdef HAVE_LCD_INVERT
void (*lcd_set_invert_display)(bool yesno);
#endif /* HAVE_LCD_INVERT */
+#ifdef HAVE_BUTTON_DATA
+ intptr_t (*button_get_data)(void);
+#endif /* HAVE_BUTTON_DATA */
+#ifdef HAVE_TOUCHPAD
+ void (*touchpad_set_mode)(enum touchpad_mode);
+#endif /* HAVE_TOUCHPAD */
};
/* plugin header */
diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES
index 607dcbc..65394a7 100644
--- a/apps/plugins/CATEGORIES
+++ b/apps/plugins/CATEGORIES
@@ -84,6 +84,7 @@ test_fps,apps
test_grey,apps
test_sampr,apps
test_scanrate,apps
+test_touchpad,apps
test_viewports,apps
text_editor,apps
vbrfix,viewers
diff --git a/apps/plugins/test_touchpad.c b/apps/plugins/test_touchpad.c
new file mode 100644
index 0000000..7778ec6
--- /dev/null
+++ b/apps/plugins/test_touchpad.c
@@ -0,0 +1,141 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 Rob Purchase
+ *
+ * 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.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "plugin.h"
+#include "helper.h"
+#include "grey.h"
+
+PLUGIN_HEADER
+
+#if (CONFIG_KEYPAD == COWOND2_PAD)
+#define TOUCHPAD_QUIT BUTTON_POWER
+#define TOUCHPAD_TOGGLE BUTTON_MENU
+#elif (CONFIG_KEYPAD == MROBE500_PAD)
+#define TOUCHPAD_QUIT BUTTON_POWER
+#define TOUCHPAD_TOGGLE BUTTON_RC_MODE
+#endif
+
+static struct plugin_api* rb;
+
+/* plugin entry point */
+enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
+{
+ int button = 0;
+ enum touchpad_mode mode = TOUCHPAD_BUTTON;
+
+ /* standard stuff */
+ (void)parameter;
+ rb = api;
+
+ rb->touchpad_set_mode(mode);
+
+ /* wait until user closes plugin */
+ do
+ {
+ short x = 0;
+ short y = 0;
+ bool draw_rect = false;
+
+ button = rb->button_get(true);
+
+ if (button & BUTTON_TOPLEFT)
+ {
+ draw_rect = true;
+ x = 0; y = 0;
+ }
+ else if (button & BUTTON_TOPMIDDLE)
+ {
+ draw_rect = true;
+ x = LCD_WIDTH/3; y = 0;
+ }
+ else if (button & BUTTON_TOPRIGHT)
+ {
+ draw_rect = true;
+ x = 2*(LCD_WIDTH/3); y = 0;
+ }
+ else if (button & BUTTON_MIDLEFT)
+ {
+ draw_rect = true;
+ x = 0; y = LCD_HEIGHT/3;
+ }
+ else if (button & BUTTON_CENTER)
+ {
+ draw_rect = true;
+ x = LCD_WIDTH/3; y = LCD_HEIGHT/3;
+ }
+ else if (button & BUTTON_MIDRIGHT)
+ {
+ draw_rect = true;
+ x = 2*(LCD_WIDTH/3); y = LCD_HEIGHT/3;
+ }
+ else if (button & BUTTON_BOTTOMLEFT)
+ {
+ draw_rect = true;
+ x = 0; y = 2*(LCD_HEIGHT/3);
+ }
+ else if (button & BUTTON_BOTTOMMIDDLE)
+ {
+ draw_rect = true;
+ x = LCD_WIDTH/3; y = 2*(LCD_HEIGHT/3);
+ }
+ else if (button & BUTTON_BOTTOMRIGHT)
+ {
+ draw_rect = true;
+ x = 2*(LCD_WIDTH/3); y = 2*(LCD_HEIGHT/3);
+ }
+
+ if (button & TOUCHPAD_TOGGLE && (button & BUTTON_REL))
+ {
+ mode = (mode == TOUCHPAD_POINT) ? TOUCHPAD_BUTTON : TOUCHPAD_POINT;
+ rb->touchpad_set_mode(mode);
+ }
+
+ if (button & BUTTON_REL) draw_rect = false;
+
+ rb->lcd_clear_display();
+
+ if (draw_rect)
+ {
+ rb->lcd_set_foreground(LCD_RGBPACK(0xc0, 0, 0));
+ rb->lcd_fillrect(x, y, LCD_WIDTH/3, LCD_HEIGHT/3);
+ }
+
+ if (draw_rect || button & BUTTON_TOUCHPAD)
+ {
+ intptr_t button_data = rb->button_get_data();
+ x = button_data >> 16;
+ y = button_data & 0xffff;
+
+ rb->lcd_set_foreground(LCD_RGBPACK(0, 0, 0xc0));
+ rb->lcd_fillrect(x-7, y-7, 14, 14);
+
+ /* in stylus mode, show REL position in black */
+ if (mode == TOUCHPAD_POINT && (button & BUTTON_REL))
+ rb->lcd_set_foreground(LCD_BLACK);
+ else
+ rb->lcd_set_foreground(LCD_WHITE);
+
+ rb->lcd_hline(x-5, x+5, y);
+ rb->lcd_vline(x, y-5, y+5);
+ }
+ rb->lcd_update();
+
+ } while (button != TOUCHPAD_QUIT);
+
+ return PLUGIN_OK;
+}