diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/debug_menu.c | 60 | ||||
-rw-r--r-- | apps/plugin.c | 8 | ||||
-rw-r--r-- | apps/plugin.h | 10 | ||||
-rw-r--r-- | apps/plugins/CATEGORIES | 1 | ||||
-rw-r--r-- | apps/plugins/SOURCES | 3 | ||||
-rw-r--r-- | apps/plugins/remote_control.c | 231 | ||||
-rw-r--r-- | apps/screens.c | 20 |
7 files changed, 262 insertions, 71 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 648a7e6cae..6a40d4b54a 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -112,13 +112,6 @@ | |||
112 | #include "as3514.h" | 112 | #include "as3514.h" |
113 | #endif | 113 | #endif |
114 | 114 | ||
115 | #ifdef HAVE_USBSTACK | ||
116 | #include "usb_core.h" | ||
117 | #ifdef USB_ENABLE_HID | ||
118 | #include "usbstack/usb_hid.h" | ||
119 | #endif | ||
120 | #endif | ||
121 | |||
122 | /*---------------------------------------------------*/ | 115 | /*---------------------------------------------------*/ |
123 | /* SPECIAL DEBUG STUFF */ | 116 | /* SPECIAL DEBUG STUFF */ |
124 | /*---------------------------------------------------*/ | 117 | /*---------------------------------------------------*/ |
@@ -2635,50 +2628,6 @@ static bool toggle_usb_serial(void) | |||
2635 | } | 2628 | } |
2636 | #endif | 2629 | #endif |
2637 | 2630 | ||
2638 | #ifdef USB_ENABLE_HID | ||
2639 | static bool hid_send_cmd(consumer_usage_page_t cmd, char *msg) | ||
2640 | { | ||
2641 | (void)msg; | ||
2642 | |||
2643 | if (!usb_core_driver_enabled(USB_DRIVER_HID)) { | ||
2644 | splashf(HZ, "Send failed. Driver is disabled"); | ||
2645 | return false; | ||
2646 | } | ||
2647 | |||
2648 | usb_hid_send_consumer_usage(cmd); | ||
2649 | logf("Sent %s command", msg); | ||
2650 | |||
2651 | return false; | ||
2652 | } | ||
2653 | static bool usb_hid_send_play_pause(void) | ||
2654 | { | ||
2655 | return hid_send_cmd(PLAY_PAUSE, "Play/Pause"); | ||
2656 | } | ||
2657 | static bool usb_hid_send_stop(void) | ||
2658 | { | ||
2659 | return hid_send_cmd(STOP, "Stop"); | ||
2660 | } | ||
2661 | static bool usb_hid_send_scan_previous_track(void) | ||
2662 | { | ||
2663 | return hid_send_cmd(SCAN_PREVIOUS_TRACK, "Scan previous track"); | ||
2664 | } | ||
2665 | static bool usb_hid_send_scan_next_track(void) | ||
2666 | { | ||
2667 | return hid_send_cmd(SCAN_NEXT_TRACK, "Scan next track"); | ||
2668 | } | ||
2669 | static bool usb_hid_send_mute(void) | ||
2670 | { | ||
2671 | return hid_send_cmd(MUTE, "Mute"); | ||
2672 | } | ||
2673 | static bool usb_hid_send_volume_decrement(void) | ||
2674 | { | ||
2675 | return hid_send_cmd(VOLUME_DECREMENT, "Vol Down"); | ||
2676 | } | ||
2677 | static bool usb_hid_send_volume_increment(void) | ||
2678 | { | ||
2679 | return hid_send_cmd(VOLUME_INCREMENT, "Vol Up"); | ||
2680 | } | ||
2681 | #endif | ||
2682 | #endif | 2631 | #endif |
2683 | 2632 | ||
2684 | #if CONFIG_USBOTG == USBOTG_ISP1583 | 2633 | #if CONFIG_USBOTG == USBOTG_ISP1583 |
@@ -2819,15 +2768,6 @@ static const struct the_menu_item menuitems[] = { | |||
2819 | #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL) | 2768 | #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL) |
2820 | {"USB Serial driver (logf)", toggle_usb_serial }, | 2769 | {"USB Serial driver (logf)", toggle_usb_serial }, |
2821 | #endif | 2770 | #endif |
2822 | #if defined(USB_ENABLE_HID) | ||
2823 | {"USB HID play/pause", usb_hid_send_play_pause }, | ||
2824 | {"USB HID stop", usb_hid_send_stop }, | ||
2825 | {"USB HID prev track", usb_hid_send_scan_previous_track }, | ||
2826 | {"USB HID next track", usb_hid_send_scan_next_track }, | ||
2827 | {"USB HID mute", usb_hid_send_mute }, | ||
2828 | {"USB HID vol down", usb_hid_send_volume_decrement }, | ||
2829 | {"USB HID vol up", usb_hid_send_volume_increment }, | ||
2830 | #endif | ||
2831 | #endif /* HAVE_USBSTACK */ | 2771 | #endif /* HAVE_USBSTACK */ |
2832 | #ifdef CPU_BOOST_LOGGING | 2772 | #ifdef CPU_BOOST_LOGGING |
2833 | {"cpu_boost log",cpu_boost_log}, | 2773 | {"cpu_boost log",cpu_boost_log}, |
diff --git a/apps/plugin.c b/apps/plugin.c index 84200bbf05..35b4179949 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -51,6 +51,10 @@ | |||
51 | #include "bidi.h" | 51 | #include "bidi.h" |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #if defined(HAVE_USBSTACK) && defined(USB_ENABLE_HID) | ||
55 | #include "usbstack/usb_hid.h" | ||
56 | #endif | ||
57 | |||
54 | #ifdef SIMULATOR | 58 | #ifdef SIMULATOR |
55 | #define PREFIX(_x_) sim_ ## _x_ | 59 | #define PREFIX(_x_) sim_ ## _x_ |
56 | #else | 60 | #else |
@@ -660,6 +664,10 @@ static const struct plugin_api rockbox_api = { | |||
660 | appsversion, | 664 | appsversion, |
661 | /* new stuff at the end, sort into place next time | 665 | /* new stuff at the end, sort into place next time |
662 | the API gets incompatible */ | 666 | the API gets incompatible */ |
667 | |||
668 | #if defined(HAVE_USBSTACK) && defined(USB_ENABLE_HID) | ||
669 | usb_hid_send, | ||
670 | #endif | ||
663 | }; | 671 | }; |
664 | 672 | ||
665 | int plugin_load(const char* plugin, const void* parameter) | 673 | int plugin_load(const char* plugin, const void* parameter) |
diff --git a/apps/plugin.h b/apps/plugin.h index a946f42a14..3809486d0a 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -105,6 +105,10 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
105 | 105 | ||
106 | #include "yesno.h" | 106 | #include "yesno.h" |
107 | 107 | ||
108 | #if defined(HAVE_USBSTACK) && defined(USB_ENABLE_HID) | ||
109 | #include "usbstack/usb_hid_usage_tables.h" | ||
110 | #endif | ||
111 | |||
108 | #ifdef PLUGIN | 112 | #ifdef PLUGIN |
109 | 113 | ||
110 | #if defined(DEBUG) || defined(SIMULATOR) | 114 | #if defined(DEBUG) || defined(SIMULATOR) |
@@ -129,7 +133,7 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
129 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 133 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
130 | 134 | ||
131 | /* increase this every time the api struct changes */ | 135 | /* increase this every time the api struct changes */ |
132 | #define PLUGIN_API_VERSION 164 | 136 | #define PLUGIN_API_VERSION 165 |
133 | 137 | ||
134 | /* update this to latest version if a change to the api struct breaks | 138 | /* update this to latest version if a change to the api struct breaks |
135 | backwards compatibility (and please take the opportunity to sort in any | 139 | backwards compatibility (and please take the opportunity to sort in any |
@@ -828,6 +832,10 @@ struct plugin_api { | |||
828 | const char *appsversion; | 832 | const char *appsversion; |
829 | /* new stuff at the end, sort into place next time | 833 | /* new stuff at the end, sort into place next time |
830 | the API gets incompatible */ | 834 | the API gets incompatible */ |
835 | |||
836 | #if defined(HAVE_USBSTACK) && defined(USB_ENABLE_HID) | ||
837 | void (*usb_hid_send)(usage_page_t usage_page, int id); | ||
838 | #endif | ||
831 | }; | 839 | }; |
832 | 840 | ||
833 | /* plugin header */ | 841 | /* plugin header */ |
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 | |||
diff --git a/apps/screens.c b/apps/screens.c index 829aa191e1..a19614dcd9 100644 --- a/apps/screens.c +++ b/apps/screens.c | |||
@@ -116,36 +116,36 @@ static int handle_usb_events(void) | |||
116 | 116 | ||
117 | if (hid_enabled) | 117 | if (hid_enabled) |
118 | { | 118 | { |
119 | consumer_usage_page_t cmd = UNASSIGNED; | 119 | int id = HID_CONSUMER_USAGE_UNASSIGNED; |
120 | button = get_action(CONTEXT_USB_HID, HZ/4); | 120 | button = get_action(CONTEXT_USB_HID, HZ/4); |
121 | 121 | ||
122 | switch (button) | 122 | switch (button) |
123 | { | 123 | { |
124 | case ACTION_USB_HID_PLAY: | 124 | case ACTION_USB_HID_PLAY: |
125 | cmd = PLAY_PAUSE; | 125 | id = HID_CONSUMER_USAGE_PLAY_PAUSE; |
126 | break; | 126 | break; |
127 | case ACTION_USB_HID_STOP: | 127 | case ACTION_USB_HID_STOP: |
128 | cmd = STOP; | 128 | id = HID_CONSUMER_USAGE_STOP; |
129 | break; | 129 | break; |
130 | case ACTION_USB_HID_SKIPPREV: | 130 | case ACTION_USB_HID_SKIPPREV: |
131 | cmd = SCAN_PREVIOUS_TRACK; | 131 | id = HID_CONSUMER_USAGE_SCAN_PREVIOUS_TRACK; |
132 | break; | 132 | break; |
133 | case ACTION_USB_HID_SKIPNEXT: | 133 | case ACTION_USB_HID_SKIPNEXT: |
134 | cmd = SCAN_NEXT_TRACK; | 134 | id = HID_CONSUMER_USAGE_SCAN_NEXT_TRACK; |
135 | break; | 135 | break; |
136 | case ACTION_USB_HID_VOLDOWN: | 136 | case ACTION_USB_HID_VOLDOWN: |
137 | cmd = VOLUME_DECREMENT; | 137 | id = HID_CONSUMER_USAGE_VOLUME_DECREMENT; |
138 | break; | 138 | break; |
139 | case ACTION_USB_HID_VOLUP: | 139 | case ACTION_USB_HID_VOLUP: |
140 | cmd = VOLUME_INCREMENT; | 140 | id = HID_CONSUMER_USAGE_VOLUME_INCREMENT; |
141 | break; | 141 | break; |
142 | case ACTION_USB_HID_MUTE: | 142 | case ACTION_USB_HID_MUTE: |
143 | cmd = MUTE; | 143 | id = HID_CONSUMER_USAGE_MUTE; |
144 | break; | 144 | break; |
145 | } | 145 | } |
146 | 146 | ||
147 | if (cmd != UNASSIGNED) | 147 | if (id != HID_CONSUMER_USAGE_UNASSIGNED) |
148 | usb_hid_send_consumer_usage(cmd); | 148 | usb_hid_send(HID_USAGE_PAGE_CONSUMER, id); |
149 | } | 149 | } |
150 | else | 150 | else |
151 | #endif | 151 | #endif |