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 static void remote_control_setcolors(void);
30 /*****************************************************************************
31 * remote_control_setcolors() set the foreground and background colors.
32 ******************************************************************************/
33 static inline void remote_control_setcolors(void)
36 rb
->lcd_set_background(LCD_RGBPACK(181, 181, 222));
37 rb
->lcd_set_foreground(LCD_BLACK
);
41 static int menu_desktop(void)
45 MENUITEM_STRINGLIST(menu
, "Desktop", NULL
, "Escape", "Windows", "F10",
46 "Page Up", "Page Down");
49 int id
= HID_GENERIC_DESKTOP_UNDEFINED
;
51 selection
= 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
;
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 selection
= rb
->do_menu(&menu
, &selection
, NULL
, false);
99 case 0: /* Next Slide */
102 case 1: /* Prev Slide */
105 case 2: /* Start Slideshow */
106 id
= HID_KEYBOARD_F5
;
108 case 3: /* Leave Slideshow */
109 id
= HID_KEYBOARD_ESCAPE
;
111 case 4: /* Black Screen */
112 id
= HID_KEYBOARD_DOT
;
114 case 5: /* White Screen */
115 id
= HID_KEYBOARD_COMMA
;
117 case MENU_ATTACHED_USB
:
118 return PLUGIN_USB_CONNECTED
;
125 if (id
!= HID_GENERIC_DESKTOP_UNDEFINED
)
126 rb
->usb_hid_send(HID_USAGE_PAGE_KEYBOARD_KEYPAD
, id
);
130 static int menu_media_player(void)
134 MENUITEM_STRINGLIST(menu
, "Media Player", NULL
, "Play", "Stop", "Next",
135 "Previous", "Volume Up", "Volume Down", "Mute");
138 int id
= HID_CONSUMER_USAGE_UNASSIGNED
;
140 selection
= rb
->do_menu(&menu
, &selection
, NULL
, false);
145 id
= HID_CONSUMER_USAGE_PLAY_PAUSE
;
148 id
= HID_CONSUMER_USAGE_STOP
;
151 id
= HID_CONSUMER_USAGE_SCAN_NEXT_TRACK
;
153 case 3: /* Previous */
154 id
= HID_CONSUMER_USAGE_SCAN_PREVIOUS_TRACK
;
156 case 4: /* Volume Up */
157 id
= HID_CONSUMER_USAGE_VOLUME_INCREMENT
;
159 case 5: /* Volume Down */
160 id
= HID_CONSUMER_USAGE_VOLUME_DECREMENT
;
163 id
= HID_CONSUMER_USAGE_MUTE
;
165 case MENU_ATTACHED_USB
:
166 return PLUGIN_USB_CONNECTED
;
173 if (id
!= HID_CONSUMER_USAGE_UNASSIGNED
)
174 rb
->usb_hid_send(HID_USAGE_PAGE_CONSUMER
, id
);
178 /*****************************************************************************
179 * plugin entry point.
180 ******************************************************************************/
181 enum plugin_status
plugin_start(const void* parameter
)
183 enum plugin_status rc
= PLUGIN_USB_CONNECTED
;
188 rb
->lcd_clear_display();
191 rb
->lcd_set_backdrop(NULL
);
193 rb
->lcd_setfont(FONT_SYSFIXED
);
195 remote_control_setcolors();
197 MENUITEM_STRINGLIST(menu
, "Remote Control", NULL
, "Desktop", "Presentation",
198 "Media Player", "Quit");
201 selection
= rb
->do_menu(&menu
, &selection
, NULL
, false);
204 case 0: /* Desktop */
205 if (menu_desktop() == PLUGIN_USB_CONNECTED
)
208 case 1: /* Presentation */
209 if (menu_presentation() == PLUGIN_USB_CONNECTED
)
212 case 2: /* Media Player */
213 if (menu_media_player() == PLUGIN_USB_CONNECTED
)
220 case MENU_ATTACHED_USB
:
227 rb
->lcd_setfont(FONT_UI
);