1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Gilles Roux
12 * 2010 Yoshihisa Uchida
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
24 #include "tv_action.h"
25 #include "tv_button.h"
26 #include "tv_preferences.h"
30 enum plugin_status
plugin_start(const void* file
)
33 int lastbutton
= BUTTON_NONE
;
34 bool autoscroll
= false;
37 bool display_update
= true;
38 const struct tv_preferences
*prefs
= tv_get_preferences();
40 old_tick
= *rb
->current_tick
;
46 rb
->splash(HZ
, "Error opening file");
51 rb
->lcd_set_backdrop(NULL
);
59 display_update
= true;
61 button
= rb
->button_get_w_tmo(HZ
/10);
69 enum tv_menu_result res
= tv_menu();
71 if (res
!= TV_MENU_RESULT_EXIT_MENU
)
75 if (res
== TV_MENU_RESULT_ATTACHED_USB
)
76 return PLUGIN_USB_CONNECTED
;
82 #ifdef TV_AUTOSCROLL_PRE
83 if (lastbutton
!= TV_AUTOSCROLL_PRE
)
86 autoscroll
= !autoscroll
;
90 case TV_SCROLL_UP
| BUTTON_REPEAT
:
93 case TV_SCROLL_UP2
| BUTTON_REPEAT
:
95 tv_scroll_up(TV_VERTICAL_SCROLL_PREFS
);
96 old_tick
= *rb
->current_tick
;
100 case TV_SCROLL_DOWN
| BUTTON_REPEAT
:
102 case TV_SCROLL_DOWN2
:
103 case TV_SCROLL_DOWN2
| BUTTON_REPEAT
:
105 tv_scroll_down(TV_VERTICAL_SCROLL_PREFS
);
106 old_tick
= *rb
->current_tick
;
110 case TV_SCREEN_LEFT
| BUTTON_REPEAT
:
111 if (prefs
->windows
> 1)
114 tv_scroll_left(TV_HORIZONTAL_SCROLL_PREFS
);
116 else { /* prefs->windows == 1 */
117 if (prefs
->narrow_mode
== NM_PAGE
)
119 /* scroll to previous page */
120 tv_scroll_up(TV_VERTICAL_SCROLL_PAGE
);
130 case TV_SCREEN_RIGHT
:
131 case TV_SCREEN_RIGHT
| BUTTON_REPEAT
:
132 if (prefs
->windows
> 1)
135 tv_scroll_right(TV_HORIZONTAL_SCROLL_PREFS
);
137 else { /* prefs->windows == 1 */
138 if (prefs
->narrow_mode
== NM_PAGE
)
140 /* scroll to next page */
141 tv_scroll_down(TV_VERTICAL_SCROLL_PAGE
);
153 case TV_LINE_UP
| BUTTON_REPEAT
:
154 /* Scroll up one line */
155 tv_scroll_up(TV_VERTICAL_SCROLL_LINE
);
156 old_tick
= *rb
->current_tick
;
160 case TV_LINE_DOWN
| BUTTON_REPEAT
:
161 /* Scroll down one line */
162 tv_scroll_down(TV_VERTICAL_SCROLL_LINE
);
163 old_tick
= *rb
->current_tick
;
166 #ifdef TV_COLUMN_LEFT
168 case TV_COLUMN_LEFT
| BUTTON_REPEAT
:
169 /* Scroll left one column */
170 tv_scroll_left(TV_HORIZONTAL_SCROLL_COLUMN
);
173 case TV_COLUMN_RIGHT
:
174 case TV_COLUMN_RIGHT
| BUTTON_REPEAT
:
175 /* Scroll right one column */
176 tv_scroll_right(TV_HORIZONTAL_SCROLL_COLUMN
);
192 tv_add_or_remove_bookmark();
196 if (rb
->default_event_handler_ex(button
, tv_exit
, NULL
)
197 == SYS_USB_CONNECTED
)
198 return PLUGIN_USB_CONNECTED
;
199 display_update
= false;
202 if (button
!= BUTTON_NONE
)
209 if(old_tick
<= *rb
->current_tick
- (110 - prefs
->autoscroll_speed
* 10))
211 tv_scroll_down(TV_VERTICAL_SCROLL_PREFS
);
212 old_tick
= *rb
->current_tick
;
213 display_update
= true;