diff options
-rw-r--r-- | apps/plugin.c | 6 | ||||
-rw-r--r-- | apps/plugin.h | 8 | ||||
-rw-r--r-- | apps/plugins/CATEGORIES | 1 | ||||
-rw-r--r-- | apps/plugins/test_touchpad.c | 141 |
4 files changed, 155 insertions, 1 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index fd495bdc87..6c6be901f3 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -584,6 +584,12 @@ static const struct plugin_api rockbox_api = { | |||
584 | #ifdef HAVE_LCD_INVERT | 584 | #ifdef HAVE_LCD_INVERT |
585 | lcd_set_invert_display, | 585 | lcd_set_invert_display, |
586 | #endif /* HAVE_LCD_INVERT */ | 586 | #endif /* HAVE_LCD_INVERT */ |
587 | #ifdef HAVE_BUTTON_DATA | ||
588 | button_get_data, | ||
589 | #endif /* HAVE_BUTTON_DATA */ | ||
590 | #ifdef HAVE_TOUCHPAD | ||
591 | touchpad_set_mode, | ||
592 | #endif /* HAVE_TOUCHPAD */ | ||
587 | }; | 593 | }; |
588 | 594 | ||
589 | int plugin_load(const char* plugin, void* parameter) | 595 | int plugin_load(const char* plugin, void* parameter) |
diff --git a/apps/plugin.h b/apps/plugin.h index c9d118e873..8839271f43 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -120,7 +120,7 @@ | |||
120 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 120 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
121 | 121 | ||
122 | /* increase this every time the api struct changes */ | 122 | /* increase this every time the api struct changes */ |
123 | #define PLUGIN_API_VERSION 109 | 123 | #define PLUGIN_API_VERSION 110 |
124 | 124 | ||
125 | /* update this to latest version if a change to the api struct breaks | 125 | /* update this to latest version if a change to the api struct breaks |
126 | backwards compatibility (and please take the opportunity to sort in any | 126 | backwards compatibility (and please take the opportunity to sort in any |
@@ -731,6 +731,12 @@ struct plugin_api { | |||
731 | #ifdef HAVE_LCD_INVERT | 731 | #ifdef HAVE_LCD_INVERT |
732 | void (*lcd_set_invert_display)(bool yesno); | 732 | void (*lcd_set_invert_display)(bool yesno); |
733 | #endif /* HAVE_LCD_INVERT */ | 733 | #endif /* HAVE_LCD_INVERT */ |
734 | #ifdef HAVE_BUTTON_DATA | ||
735 | intptr_t (*button_get_data)(void); | ||
736 | #endif /* HAVE_BUTTON_DATA */ | ||
737 | #ifdef HAVE_TOUCHPAD | ||
738 | void (*touchpad_set_mode)(enum touchpad_mode); | ||
739 | #endif /* HAVE_TOUCHPAD */ | ||
734 | }; | 740 | }; |
735 | 741 | ||
736 | /* plugin header */ | 742 | /* plugin header */ |
diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES index 607dcbc544..65394a7ab9 100644 --- a/apps/plugins/CATEGORIES +++ b/apps/plugins/CATEGORIES | |||
@@ -84,6 +84,7 @@ test_fps,apps | |||
84 | test_grey,apps | 84 | test_grey,apps |
85 | test_sampr,apps | 85 | test_sampr,apps |
86 | test_scanrate,apps | 86 | test_scanrate,apps |
87 | test_touchpad,apps | ||
87 | test_viewports,apps | 88 | test_viewports,apps |
88 | text_editor,apps | 89 | text_editor,apps |
89 | vbrfix,viewers | 90 | vbrfix,viewers |
diff --git a/apps/plugins/test_touchpad.c b/apps/plugins/test_touchpad.c new file mode 100644 index 0000000000..7778ec6cbe --- /dev/null +++ b/apps/plugins/test_touchpad.c | |||
@@ -0,0 +1,141 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 Rob Purchase | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "plugin.h" | ||
20 | #include "helper.h" | ||
21 | #include "grey.h" | ||
22 | |||
23 | PLUGIN_HEADER | ||
24 | |||
25 | #if (CONFIG_KEYPAD == COWOND2_PAD) | ||
26 | #define TOUCHPAD_QUIT BUTTON_POWER | ||
27 | #define TOUCHPAD_TOGGLE BUTTON_MENU | ||
28 | #elif (CONFIG_KEYPAD == MROBE500_PAD) | ||
29 | #define TOUCHPAD_QUIT BUTTON_POWER | ||
30 | #define TOUCHPAD_TOGGLE BUTTON_RC_MODE | ||
31 | #endif | ||
32 | |||
33 | static struct plugin_api* rb; | ||
34 | |||
35 | /* plugin entry point */ | ||
36 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | ||
37 | { | ||
38 | int button = 0; | ||
39 | enum touchpad_mode mode = TOUCHPAD_BUTTON; | ||
40 | |||
41 | /* standard stuff */ | ||
42 | (void)parameter; | ||
43 | rb = api; | ||
44 | |||
45 | rb->touchpad_set_mode(mode); | ||
46 | |||
47 | /* wait until user closes plugin */ | ||
48 | do | ||
49 | { | ||
50 | short x = 0; | ||
51 | short y = 0; | ||
52 | bool draw_rect = false; | ||
53 | |||
54 | button = rb->button_get(true); | ||
55 | |||
56 | if (button & BUTTON_TOPLEFT) | ||
57 | { | ||
58 | draw_rect = true; | ||
59 | x = 0; y = 0; | ||
60 | } | ||
61 | else if (button & BUTTON_TOPMIDDLE) | ||
62 | { | ||
63 | draw_rect = true; | ||
64 | x = LCD_WIDTH/3; y = 0; | ||
65 | } | ||
66 | else if (button & BUTTON_TOPRIGHT) | ||
67 | { | ||
68 | draw_rect = true; | ||
69 | x = 2*(LCD_WIDTH/3); y = 0; | ||
70 | } | ||
71 | else if (button & BUTTON_MIDLEFT) | ||
72 | { | ||
73 | draw_rect = true; | ||
74 | x = 0; y = LCD_HEIGHT/3; | ||
75 | } | ||
76 | else if (button & BUTTON_CENTER) | ||
77 | { | ||
78 | draw_rect = true; | ||
79 | x = LCD_WIDTH/3; y = LCD_HEIGHT/3; | ||
80 | } | ||
81 | else if (button & BUTTON_MIDRIGHT) | ||
82 | { | ||
83 | draw_rect = true; | ||
84 | x = 2*(LCD_WIDTH/3); y = LCD_HEIGHT/3; | ||
85 | } | ||
86 | else if (button & BUTTON_BOTTOMLEFT) | ||
87 | { | ||
88 | draw_rect = true; | ||
89 | x = 0; y = 2*(LCD_HEIGHT/3); | ||
90 | } | ||
91 | else if (button & BUTTON_BOTTOMMIDDLE) | ||
92 | { | ||
93 | draw_rect = true; | ||
94 | x = LCD_WIDTH/3; y = 2*(LCD_HEIGHT/3); | ||
95 | } | ||
96 | else if (button & BUTTON_BOTTOMRIGHT) | ||
97 | { | ||
98 | draw_rect = true; | ||
99 | x = 2*(LCD_WIDTH/3); y = 2*(LCD_HEIGHT/3); | ||
100 | } | ||
101 | |||
102 | if (button & TOUCHPAD_TOGGLE && (button & BUTTON_REL)) | ||
103 | { | ||
104 | mode = (mode == TOUCHPAD_POINT) ? TOUCHPAD_BUTTON : TOUCHPAD_POINT; | ||
105 | rb->touchpad_set_mode(mode); | ||
106 | } | ||
107 | |||
108 | if (button & BUTTON_REL) draw_rect = false; | ||
109 | |||
110 | rb->lcd_clear_display(); | ||
111 | |||
112 | if (draw_rect) | ||
113 | { | ||
114 | rb->lcd_set_foreground(LCD_RGBPACK(0xc0, 0, 0)); | ||
115 | rb->lcd_fillrect(x, y, LCD_WIDTH/3, LCD_HEIGHT/3); | ||
116 | } | ||
117 | |||
118 | if (draw_rect || button & BUTTON_TOUCHPAD) | ||
119 | { | ||
120 | intptr_t button_data = rb->button_get_data(); | ||
121 | x = button_data >> 16; | ||
122 | y = button_data & 0xffff; | ||
123 | |||
124 | rb->lcd_set_foreground(LCD_RGBPACK(0, 0, 0xc0)); | ||
125 | rb->lcd_fillrect(x-7, y-7, 14, 14); | ||
126 | |||
127 | /* in stylus mode, show REL position in black */ | ||
128 | if (mode == TOUCHPAD_POINT && (button & BUTTON_REL)) | ||
129 | rb->lcd_set_foreground(LCD_BLACK); | ||
130 | else | ||
131 | rb->lcd_set_foreground(LCD_WHITE); | ||
132 | |||
133 | rb->lcd_hline(x-5, x+5, y); | ||
134 | rb->lcd_vline(x, y-5, y+5); | ||
135 | } | ||
136 | rb->lcd_update(); | ||
137 | |||
138 | } while (button != TOUCHPAD_QUIT); | ||
139 | |||
140 | return PLUGIN_OK; | ||
141 | } | ||