summaryrefslogtreecommitdiffstats
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/CATEGORIES1
-rw-r--r--apps/plugins/SOURCES3
-rw-r--r--apps/plugins/remote_control.c231
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
ppmviewer,viewers
properties,viewers
random_folder_advance_config,apps
+remote_control,apps
reversi,games
robotfindskitten,games
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
lua.c
#endif
+#if defined(HAVE_USBSTACK) && defined(USB_ENABLE_HID)
+remote_control.c
+#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 @@
+/***************************************************************************
+* __________ __ ___.
+* Open \______ \ ____ ____ | | _\_ |__ _______ ___
+* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+* \/ \/ \/ \/ \/
+* $Id$
+*
+* Copyright (C) 2009 Tomer Shalev
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+* KIND, either express or implied.
+*
+****************************************************************************/
+
+#include "plugin.h"
+
+#include "lib/pluginlib_actions.h"
+
+PLUGIN_HEADER
+
+static void remote_control_setcolors(void);
+
+/*****************************************************************************
+* remote_control_setcolors() set the foreground and background colors.
+******************************************************************************/
+static inline void remote_control_setcolors(void)
+{
+#ifdef HAVE_LCD_COLOR
+ rb->lcd_set_background(LCD_RGBPACK(181, 181, 222));
+ rb->lcd_set_foreground(LCD_BLACK);
+#endif
+}
+
+static int menu_desktop(void)
+{
+ int selection = 0;
+
+ MENUITEM_STRINGLIST(menu, "Desktop", NULL, "Escape", "Windows", "F10",
+ "Page Up", "Page Down");
+ while(1)
+ {
+ int id = HID_GENERIC_DESKTOP_UNDEFINED;
+
+ selection = rb->do_menu(&menu, &selection, NULL, false);
+
+ switch (selection)
+ {
+ case 0: /* Escape */
+ id = HID_KEYBOARD_ESCAPE;
+ break;
+ case 1: /* Windows */
+ /* Not sure whether this is the right key */
+ id = HID_KEYBOARD_LEFT_GUI;
+ break;
+ case 2: /* F10 */
+ id = HID_KEYBOARD_F10;
+ break;
+ case 3: /* Page Up */
+ id = HID_KEYBOARD_PAGE_UP;
+ break;
+ case 4: /* Page Down */
+ id = HID_KEYBOARD_PAGE_DOWN;
+ break;
+ case MENU_ATTACHED_USB:
+ return PLUGIN_USB_CONNECTED;
+ case GO_TO_PREVIOUS:
+ return 0;
+ default:
+ break;
+ }
+
+ if (id != HID_GENERIC_DESKTOP_UNDEFINED)
+ rb->usb_hid_send(HID_USAGE_PAGE_KEYBOARD_KEYPAD, id);
+ }
+}
+
+static int menu_presentation(void)
+{
+ int selection = 0;
+
+ MENUITEM_STRINGLIST(menu, "Presentation", NULL, "Next Slide", "Prev Slide",
+ "Start Slideshow", "Leave Slideshow", "Black Screen",
+ "White Screen");
+ while(1)
+ {
+ int id = HID_GENERIC_DESKTOP_UNDEFINED;
+
+ selection = rb->do_menu(&menu, &selection, NULL, false);
+
+ switch (selection)
+ {
+ case 0: /* Next Slide */
+ id = HID_KEYBOARD_N;
+ break;
+ case 1: /* Prev Slide */
+ id = HID_KEYBOARD_P;
+ break;
+ case 2: /* Start Slideshow */
+ id = HID_KEYBOARD_F5;
+ break;
+ case 3: /* Leave Slideshow */
+ id = HID_KEYBOARD_ESCAPE;
+ break;
+ case 4: /* Black Screen */
+ id = HID_KEYBOARD_DOT;
+ break;
+ case 5: /* White Screen */
+ id = HID_KEYBOARD_COMMA;
+ break;
+ case MENU_ATTACHED_USB:
+ return PLUGIN_USB_CONNECTED;
+ case GO_TO_PREVIOUS:
+ return 0;
+ default:
+ break;
+ }
+
+ if (id != HID_GENERIC_DESKTOP_UNDEFINED)
+ rb->usb_hid_send(HID_USAGE_PAGE_KEYBOARD_KEYPAD, id);
+ }
+}
+
+static int menu_media_player(void)
+{
+ int selection = 0;
+
+ MENUITEM_STRINGLIST(menu, "Media Player", NULL, "Play", "Stop", "Next",
+ "Previous", "Volume Up", "Volume Down", "Mute");
+ while(1)
+ {
+ int id = HID_CONSUMER_USAGE_UNASSIGNED;
+
+ selection = rb->do_menu(&menu, &selection, NULL, false);
+
+ switch (selection)
+ {
+ case 0: /* Play */
+ id = HID_CONSUMER_USAGE_PLAY_PAUSE;
+ break;
+ case 1: /* Stop */
+ id = HID_CONSUMER_USAGE_STOP;
+ break;
+ case 2: /* Next */
+ id = HID_CONSUMER_USAGE_SCAN_NEXT_TRACK;
+ break;
+ case 3: /* Previous */
+ id = HID_CONSUMER_USAGE_SCAN_PREVIOUS_TRACK;
+ break;
+ case 4: /* Volume Up */
+ id = HID_CONSUMER_USAGE_VOLUME_INCREMENT;
+ break;
+ case 5: /* Volume Down */
+ id = HID_CONSUMER_USAGE_VOLUME_DECREMENT;
+ break;
+ case 6: /* Mute */
+ id = HID_CONSUMER_USAGE_MUTE;
+ break;
+ case MENU_ATTACHED_USB:
+ return PLUGIN_USB_CONNECTED;
+ case GO_TO_PREVIOUS:
+ return 0;
+ default:
+ break;
+ }
+
+ if (id != HID_CONSUMER_USAGE_UNASSIGNED)
+ rb->usb_hid_send(HID_USAGE_PAGE_CONSUMER, id);
+ }
+}
+
+/*****************************************************************************
+* plugin entry point.
+******************************************************************************/
+enum plugin_status plugin_start(const void* parameter)
+{
+ enum plugin_status rc = PLUGIN_USB_CONNECTED;
+ int selection = 0;
+
+ (void)parameter;
+
+ rb->lcd_clear_display();
+
+#if LCD_DEPTH > 1
+ rb->lcd_set_backdrop(NULL);
+#endif
+ rb->lcd_setfont(FONT_SYSFIXED);
+
+ remote_control_setcolors();
+
+ MENUITEM_STRINGLIST(menu, "Remote Control", NULL, "Desktop", "Presentation",
+ "Media Player", "Quit");
+ while(1)
+ {
+ selection = rb->do_menu(&menu, &selection, NULL, false);
+ switch (selection)
+ {
+ case 0: /* Desktop */
+ if (menu_desktop() == PLUGIN_USB_CONNECTED)
+ goto Exit;
+ break;
+ case 1: /* Presentation */
+ if (menu_presentation() == PLUGIN_USB_CONNECTED)
+ goto Exit;
+ break;
+ case 2: /* Media Player */
+ if (menu_media_player() == PLUGIN_USB_CONNECTED)
+ goto Exit;
+ break;
+ case 3: /* Quit */
+ case GO_TO_PREVIOUS:
+ rc = PLUGIN_OK;
+ goto Exit;
+ case MENU_ATTACHED_USB:
+ goto Exit;
+ default:
+ break;
+ }
+ }
+Exit:
+ rb->lcd_setfont(FONT_UI);
+
+ return rc;
+}
+