1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2009 Tomer Shalev
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 #include "lib/pluginlib_actions.h"
28 #define PLUGIN_CONTINUE 10
30 static inline void remote_control_setcolors(void);
32 /*****************************************************************************
33 * remote_control_setcolors() set the foreground and background colors.
34 ******************************************************************************/
35 static inline void remote_control_setcolors(void)
38 rb
->lcd_set_background(LCD_RGBPACK(181, 181, 222));
39 rb
->lcd_set_foreground(LCD_BLACK
);
43 static int menu_desktop(void)
47 MENUITEM_STRINGLIST(menu
, "Desktop", NULL
, "Escape", "Windows", "F10",
48 "Page Up", "Page Down");
51 int id
= HID_GENERIC_DESKTOP_UNDEFINED
;
53 switch (rb
->do_menu(&menu
, &selection
, NULL
, false))
56 id
= HID_KEYBOARD_ESCAPE
;
59 /* Not sure whether this is the right key */
60 id
= HID_KEYBOARD_LEFT_GUI
;
63 id
= HID_KEYBOARD_F10
;
66 id
= HID_KEYBOARD_PAGE_UP
;
68 case 4: /* Page Down */
69 id
= HID_KEYBOARD_PAGE_DOWN
;
71 case MENU_ATTACHED_USB
:
72 return PLUGIN_USB_CONNECTED
;
74 return PLUGIN_CONTINUE
;
79 if (id
!= HID_GENERIC_DESKTOP_UNDEFINED
)
80 rb
->usb_hid_send(HID_USAGE_PAGE_KEYBOARD_KEYPAD
, id
);
84 static int menu_presentation(void)
88 MENUITEM_STRINGLIST(menu
, "Presentation", NULL
, "Next Slide", "Prev Slide",
89 "Start Slideshow", "Leave Slideshow", "Black Screen",
93 int id
= HID_GENERIC_DESKTOP_UNDEFINED
;
95 switch (rb
->do_menu(&menu
, &selection
, NULL
, false))
97 case 0: /* Next Slide */
100 case 1: /* Prev Slide */
103 case 2: /* Start Slideshow */
104 id
= HID_KEYBOARD_F5
;
106 case 3: /* Leave Slideshow */
107 id
= HID_KEYBOARD_ESCAPE
;
109 case 4: /* Black Screen */
110 id
= HID_KEYBOARD_DOT
;
112 case 5: /* White Screen */
113 id
= HID_KEYBOARD_COMMA
;
115 case MENU_ATTACHED_USB
:
116 return PLUGIN_USB_CONNECTED
;
118 return PLUGIN_CONTINUE
;
123 if (id
!= HID_GENERIC_DESKTOP_UNDEFINED
)
124 rb
->usb_hid_send(HID_USAGE_PAGE_KEYBOARD_KEYPAD
, id
);
128 static int menu_media_player(void)
132 MENUITEM_STRINGLIST(menu
, "Media Player", NULL
, "Play", "Stop", "Next",
133 "Previous", "Volume Up", "Volume Down", "Mute");
136 int id
= HID_CONSUMER_USAGE_UNASSIGNED
;
138 switch (rb
->do_menu(&menu
, &selection
, NULL
, false))
141 id
= HID_CONSUMER_USAGE_PLAY_PAUSE
;
144 id
= HID_CONSUMER_USAGE_STOP
;
147 id
= HID_CONSUMER_USAGE_SCAN_NEXT_TRACK
;
149 case 3: /* Previous */
150 id
= HID_CONSUMER_USAGE_SCAN_PREVIOUS_TRACK
;
152 case 4: /* Volume Up */
153 id
= HID_CONSUMER_USAGE_VOLUME_INCREMENT
;
155 case 5: /* Volume Down */
156 id
= HID_CONSUMER_USAGE_VOLUME_DECREMENT
;
159 id
= HID_CONSUMER_USAGE_MUTE
;
161 case MENU_ATTACHED_USB
:
162 return PLUGIN_USB_CONNECTED
;
164 return PLUGIN_CONTINUE
;
169 if (id
!= HID_CONSUMER_USAGE_UNASSIGNED
)
170 rb
->usb_hid_send(HID_USAGE_PAGE_CONSUMER
, id
);
174 /*****************************************************************************
175 * plugin entry point.
176 ******************************************************************************/
177 enum plugin_status
plugin_start(const void* parameter
)
179 enum plugin_status rc
= PLUGIN_CONTINUE
;
184 rb
->lcd_clear_display();
187 rb
->lcd_set_backdrop(NULL
);
189 rb
->lcd_setfont(FONT_SYSFIXED
);
191 remote_control_setcolors();
193 MENUITEM_STRINGLIST(menu
, "Remote Control", NULL
, "Desktop", "Presentation",
194 "Media Player", "Quit");
195 while(rc
== PLUGIN_CONTINUE
)
197 switch (rb
->do_menu(&menu
, &selection
, NULL
, false))
199 case 0: /* Desktop */
202 case 1: /* Presentation */
203 rc
= menu_presentation();
205 case 2: /* Media Player */
206 rc
= menu_media_player();
212 case MENU_ATTACHED_USB
:
213 rc
= PLUGIN_USB_CONNECTED
;
219 rb
->lcd_setfont(FONT_UI
);