diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/CATEGORIES | 1 | ||||
-rw-r--r-- | apps/plugins/SOURCES | 3 | ||||
-rw-r--r-- | apps/plugins/remote_control.c | 231 |
3 files changed, 235 insertions, 0 deletions
diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES index ab441f53a7..5d6570a9a4 100644 --- a/apps/plugins/CATEGORIES +++ b/apps/plugins/CATEGORIES | |||
@@ -63,6 +63,7 @@ pong,games | |||
63 | ppmviewer,viewers | 63 | ppmviewer,viewers |
64 | properties,viewers | 64 | properties,viewers |
65 | random_folder_advance_config,apps | 65 | random_folder_advance_config,apps |
66 | remote_control,apps | ||
66 | reversi,games | 67 | reversi,games |
67 | robotfindskitten,games | 68 | robotfindskitten,games |
68 | rockblox,games | 69 | rockblox,games |
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 92d1ae6ef6..95ffb1c9de 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES | |||
@@ -165,3 +165,6 @@ md5sum.c | |||
165 | lua.c | 165 | lua.c |
166 | #endif | 166 | #endif |
167 | 167 | ||
168 | #if defined(HAVE_USBSTACK) && defined(USB_ENABLE_HID) | ||
169 | remote_control.c | ||
170 | #endif | ||
diff --git a/apps/plugins/remote_control.c b/apps/plugins/remote_control.c new file mode 100644 index 0000000000..8e05c67283 --- /dev/null +++ b/apps/plugins/remote_control.c | |||
@@ -0,0 +1,231 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 Tomer Shalev | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "plugin.h" | ||
23 | |||
24 | #include "lib/pluginlib_actions.h" | ||
25 | |||
26 | PLUGIN_HEADER | ||
27 | |||
28 | static void remote_control_setcolors(void); | ||
29 | |||
30 | /***************************************************************************** | ||
31 | * remote_control_setcolors() set the foreground and background colors. | ||
32 | ******************************************************************************/ | ||
33 | static inline void remote_control_setcolors(void) | ||
34 | { | ||
35 | #ifdef HAVE_LCD_COLOR | ||
36 | rb->lcd_set_background(LCD_RGBPACK(181, 181, 222)); | ||
37 | rb->lcd_set_foreground(LCD_BLACK); | ||
38 | #endif | ||
39 | } | ||
40 | |||
41 | static int menu_desktop(void) | ||
42 | { | ||
43 | int selection = 0; | ||
44 | |||
45 | MENUITEM_STRINGLIST(menu, "Desktop", NULL, "Escape", "Windows", "F10", | ||
46 | "Page Up", "Page Down"); | ||
47 | while(1) | ||
48 | { | ||
49 | int id = HID_GENERIC_DESKTOP_UNDEFINED; | ||
50 | |||
51 | selection = rb->do_menu(&menu, &selection, NULL, false); | ||
52 | |||
53 | switch (selection) | ||
54 | { | ||
55 | case 0: /* Escape */ | ||
56 | id = HID_KEYBOARD_ESCAPE; | ||
57 | break; | ||
58 | case 1: /* Windows */ | ||
59 | /* Not sure whether this is the right key */ | ||
60 | id = HID_KEYBOARD_LEFT_GUI; | ||
61 | break; | ||
62 | case 2: /* F10 */ | ||
63 | id = HID_KEYBOARD_F10; | ||
64 | break; | ||
65 | case 3: /* Page Up */ | ||
66 | id = HID_KEYBOARD_PAGE_UP; | ||
67 | break; | ||
68 | case 4: /* Page Down */ | ||
69 | id = HID_KEYBOARD_PAGE_DOWN; | ||
70 | break; | ||
71 | case MENU_ATTACHED_USB: | ||
72 | return PLUGIN_USB_CONNECTED; | ||
73 | case GO_TO_PREVIOUS: | ||
74 | return 0; | ||
75 | default: | ||
76 | break; | ||
77 | } | ||
78 | |||
79 | if (id != HID_GENERIC_DESKTOP_UNDEFINED) | ||
80 | rb->usb_hid_send(HID_USAGE_PAGE_KEYBOARD_KEYPAD, id); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | static int menu_presentation(void) | ||
85 | { | ||
86 | int selection = 0; | ||
87 | |||
88 | MENUITEM_STRINGLIST(menu, "Presentation", NULL, "Next Slide", "Prev Slide", | ||
89 | "Start Slideshow", "Leave Slideshow", "Black Screen", | ||
90 | "White Screen"); | ||
91 | while(1) | ||
92 | { | ||
93 | int id = HID_GENERIC_DESKTOP_UNDEFINED; | ||
94 | |||
95 | selection = rb->do_menu(&menu, &selection, NULL, false); | ||
96 | |||
97 | switch (selection) | ||
98 | { | ||
99 | case 0: /* Next Slide */ | ||
100 | id = HID_KEYBOARD_N; | ||
101 | break; | ||
102 | case 1: /* Prev Slide */ | ||
103 | id = HID_KEYBOARD_P; | ||
104 | break; | ||
105 | case 2: /* Start Slideshow */ | ||
106 | id = HID_KEYBOARD_F5; | ||
107 | break; | ||
108 | case 3: /* Leave Slideshow */ | ||
109 | id = HID_KEYBOARD_ESCAPE; | ||
110 | break; | ||
111 | case 4: /* Black Screen */ | ||
112 | id = HID_KEYBOARD_DOT; | ||
113 | break; | ||
114 | case 5: /* White Screen */ | ||
115 | id = HID_KEYBOARD_COMMA; | ||
116 | break; | ||
117 | case MENU_ATTACHED_USB: | ||
118 | return PLUGIN_USB_CONNECTED; | ||
119 | case GO_TO_PREVIOUS: | ||
120 | return 0; | ||
121 | default: | ||
122 | break; | ||
123 | } | ||
124 | |||
125 | if (id != HID_GENERIC_DESKTOP_UNDEFINED) | ||
126 | rb->usb_hid_send(HID_USAGE_PAGE_KEYBOARD_KEYPAD, id); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | static int menu_media_player(void) | ||
131 | { | ||
132 | int selection = 0; | ||
133 | |||
134 | MENUITEM_STRINGLIST(menu, "Media Player", NULL, "Play", "Stop", "Next", | ||
135 | "Previous", "Volume Up", "Volume Down", "Mute"); | ||
136 | while(1) | ||
137 | { | ||
138 | int id = HID_CONSUMER_USAGE_UNASSIGNED; | ||
139 | |||
140 | selection = rb->do_menu(&menu, &selection, NULL, false); | ||
141 | |||
142 | switch (selection) | ||
143 | { | ||
144 | case 0: /* Play */ | ||
145 | id = HID_CONSUMER_USAGE_PLAY_PAUSE; | ||
146 | break; | ||
147 | case 1: /* Stop */ | ||
148 | id = HID_CONSUMER_USAGE_STOP; | ||
149 | break; | ||
150 | case 2: /* Next */ | ||
151 | id = HID_CONSUMER_USAGE_SCAN_NEXT_TRACK; | ||
152 | break; | ||
153 | case 3: /* Previous */ | ||
154 | id = HID_CONSUMER_USAGE_SCAN_PREVIOUS_TRACK; | ||
155 | break; | ||
156 | case 4: /* Volume Up */ | ||
157 | id = HID_CONSUMER_USAGE_VOLUME_INCREMENT; | ||
158 | break; | ||
159 | case 5: /* Volume Down */ | ||
160 | id = HID_CONSUMER_USAGE_VOLUME_DECREMENT; | ||
161 | break; | ||
162 | case 6: /* Mute */ | ||
163 | id = HID_CONSUMER_USAGE_MUTE; | ||
164 | break; | ||
165 | case MENU_ATTACHED_USB: | ||
166 | return PLUGIN_USB_CONNECTED; | ||
167 | case GO_TO_PREVIOUS: | ||
168 | return 0; | ||
169 | default: | ||
170 | break; | ||
171 | } | ||
172 | |||
173 | if (id != HID_CONSUMER_USAGE_UNASSIGNED) | ||
174 | rb->usb_hid_send(HID_USAGE_PAGE_CONSUMER, id); | ||
175 | } | ||
176 | } | ||
177 | |||
178 | /***************************************************************************** | ||
179 | * plugin entry point. | ||
180 | ******************************************************************************/ | ||
181 | enum plugin_status plugin_start(const void* parameter) | ||
182 | { | ||
183 | enum plugin_status rc = PLUGIN_USB_CONNECTED; | ||
184 | int selection = 0; | ||
185 | |||
186 | (void)parameter; | ||
187 | |||
188 | rb->lcd_clear_display(); | ||
189 | |||
190 | #if LCD_DEPTH > 1 | ||
191 | rb->lcd_set_backdrop(NULL); | ||
192 | #endif | ||
193 | rb->lcd_setfont(FONT_SYSFIXED); | ||
194 | |||
195 | remote_control_setcolors(); | ||
196 | |||
197 | MENUITEM_STRINGLIST(menu, "Remote Control", NULL, "Desktop", "Presentation", | ||
198 | "Media Player", "Quit"); | ||
199 | while(1) | ||
200 | { | ||
201 | selection = rb->do_menu(&menu, &selection, NULL, false); | ||
202 | switch (selection) | ||
203 | { | ||
204 | case 0: /* Desktop */ | ||
205 | if (menu_desktop() == PLUGIN_USB_CONNECTED) | ||
206 | goto Exit; | ||
207 | break; | ||
208 | case 1: /* Presentation */ | ||
209 | if (menu_presentation() == PLUGIN_USB_CONNECTED) | ||
210 | goto Exit; | ||
211 | break; | ||
212 | case 2: /* Media Player */ | ||
213 | if (menu_media_player() == PLUGIN_USB_CONNECTED) | ||
214 | goto Exit; | ||
215 | break; | ||
216 | case 3: /* Quit */ | ||
217 | case GO_TO_PREVIOUS: | ||
218 | rc = PLUGIN_OK; | ||
219 | goto Exit; | ||
220 | case MENU_ATTACHED_USB: | ||
221 | goto Exit; | ||
222 | default: | ||
223 | break; | ||
224 | } | ||
225 | } | ||
226 | Exit: | ||
227 | rb->lcd_setfont(FONT_UI); | ||
228 | |||
229 | return rc; | ||
230 | } | ||
231 | |||