2010-06-05 10:30:08 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Gilles Roux
|
|
|
|
* 2003 Garrett Derner
|
|
|
|
* 2010 Yoshihisa Uchida
|
|
|
|
*
|
|
|
|
* 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"
|
2010-08-24 14:30:46 +00:00
|
|
|
#include "lib/pluginlib_exit.h"
|
2010-06-05 10:30:08 +00:00
|
|
|
#include "tv_action.h"
|
|
|
|
#include "tv_button.h"
|
|
|
|
#include "tv_preferences.h"
|
|
|
|
|
2010-08-24 14:30:46 +00:00
|
|
|
|
2010-06-05 10:30:08 +00:00
|
|
|
|
|
|
|
enum plugin_status plugin_start(const void* file)
|
|
|
|
{
|
|
|
|
int button;
|
2011-05-01 14:44:20 +00:00
|
|
|
#if defined(TV_AUTOSCROLL_PRE)
|
2010-06-05 10:30:08 +00:00
|
|
|
int lastbutton = BUTTON_NONE;
|
2011-05-01 14:44:20 +00:00
|
|
|
#endif
|
2010-06-05 10:30:08 +00:00
|
|
|
bool autoscroll = false;
|
|
|
|
long old_tick;
|
|
|
|
bool done = false;
|
|
|
|
bool display_update = true;
|
2010-07-02 12:16:47 +00:00
|
|
|
size_t size;
|
|
|
|
unsigned char *plugin_buf;
|
2010-06-05 10:30:08 +00:00
|
|
|
|
|
|
|
old_tick = *rb->current_tick;
|
|
|
|
|
|
|
|
if (!file)
|
|
|
|
return PLUGIN_ERROR;
|
|
|
|
|
2010-07-02 12:16:47 +00:00
|
|
|
/* get the plugin buffer */
|
|
|
|
plugin_buf = rb->plugin_get_buffer(&size);
|
|
|
|
|
|
|
|
if (!tv_init_action(&plugin_buf, &size)) {
|
|
|
|
rb->splash(HZ, "Error initialize");
|
|
|
|
return PLUGIN_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tv_load_file(file)) {
|
2010-06-05 10:30:08 +00:00
|
|
|
rb->splash(HZ, "Error opening file");
|
|
|
|
return PLUGIN_ERROR;
|
|
|
|
}
|
|
|
|
|
2010-08-24 14:30:46 +00:00
|
|
|
atexit(tv_exit);
|
2010-06-05 10:30:08 +00:00
|
|
|
while (!done) {
|
2010-10-06 12:35:37 +00:00
|
|
|
if (preferences->statusbar)
|
2010-07-08 13:54:28 +00:00
|
|
|
rb->send_event(GUI_EVENT_ACTIONUPDATE, NULL);
|
2010-06-30 11:49:36 +00:00
|
|
|
|
2010-06-05 10:30:08 +00:00
|
|
|
if (display_update)
|
|
|
|
tv_draw();
|
|
|
|
|
|
|
|
display_update = true;
|
|
|
|
|
|
|
|
button = rb->button_get_w_tmo(HZ/10);
|
|
|
|
|
|
|
|
switch (button) {
|
|
|
|
case TV_MENU:
|
|
|
|
#ifdef TV_MENU2
|
|
|
|
case TV_MENU2:
|
|
|
|
#endif
|
|
|
|
{
|
2010-06-20 21:53:47 +00:00
|
|
|
unsigned res = tv_menu();
|
2010-06-05 10:30:08 +00:00
|
|
|
|
|
|
|
if (res != TV_MENU_RESULT_EXIT_MENU)
|
|
|
|
{
|
|
|
|
if (res == TV_MENU_RESULT_ATTACHED_USB)
|
|
|
|
return PLUGIN_USB_CONNECTED;
|
2010-06-29 11:05:36 +00:00
|
|
|
else if (res == TV_MENU_RESULT_ERROR)
|
|
|
|
return PLUGIN_ERROR;
|
2010-08-24 14:30:46 +00:00
|
|
|
else
|
|
|
|
done = true;
|
2010-06-05 10:30:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TV_AUTOSCROLL:
|
|
|
|
#ifdef TV_AUTOSCROLL_PRE
|
|
|
|
if (lastbutton != TV_AUTOSCROLL_PRE)
|
|
|
|
break;
|
2015-07-19 23:50:26 +00:00
|
|
|
#endif
|
|
|
|
#ifdef TV_AUTOSCROLL2
|
|
|
|
/* fallthrough */
|
|
|
|
case TV_AUTOSCROLL2:
|
2010-06-05 10:30:08 +00:00
|
|
|
#endif
|
|
|
|
autoscroll = !autoscroll;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TV_SCROLL_UP:
|
|
|
|
case TV_SCROLL_UP | BUTTON_REPEAT:
|
|
|
|
#ifdef TV_SCROLL_UP2
|
|
|
|
case TV_SCROLL_UP2:
|
|
|
|
case TV_SCROLL_UP2 | BUTTON_REPEAT:
|
|
|
|
#endif
|
|
|
|
tv_scroll_up(TV_VERTICAL_SCROLL_PREFS);
|
|
|
|
old_tick = *rb->current_tick;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TV_SCROLL_DOWN:
|
|
|
|
case TV_SCROLL_DOWN | BUTTON_REPEAT:
|
|
|
|
#ifdef TV_PAGE_DOWN2
|
|
|
|
case TV_SCROLL_DOWN2:
|
|
|
|
case TV_SCROLL_DOWN2 | BUTTON_REPEAT:
|
|
|
|
#endif
|
|
|
|
tv_scroll_down(TV_VERTICAL_SCROLL_PREFS);
|
|
|
|
old_tick = *rb->current_tick;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TV_SCREEN_LEFT:
|
|
|
|
case TV_SCREEN_LEFT | BUTTON_REPEAT:
|
2010-06-20 21:53:47 +00:00
|
|
|
if (preferences->windows > 1)
|
2010-06-05 10:30:08 +00:00
|
|
|
{
|
|
|
|
/* Screen left */
|
2010-06-07 11:04:09 +00:00
|
|
|
tv_scroll_left(TV_HORIZONTAL_SCROLL_PREFS);
|
2010-06-05 10:30:08 +00:00
|
|
|
}
|
2010-06-06 08:44:27 +00:00
|
|
|
else { /* prefs->windows == 1 */
|
2010-06-20 21:53:47 +00:00
|
|
|
if (preferences->narrow_mode == NM_PAGE)
|
2010-06-09 11:28:43 +00:00
|
|
|
{
|
|
|
|
/* scroll to previous page */
|
|
|
|
tv_scroll_up(TV_VERTICAL_SCROLL_PAGE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Top of file */
|
|
|
|
tv_top();
|
|
|
|
}
|
2010-06-05 10:30:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TV_SCREEN_RIGHT:
|
|
|
|
case TV_SCREEN_RIGHT | BUTTON_REPEAT:
|
2010-06-20 21:53:47 +00:00
|
|
|
if (preferences->windows > 1)
|
2010-06-05 10:30:08 +00:00
|
|
|
{
|
|
|
|
/* Screen right */
|
2010-06-07 11:04:09 +00:00
|
|
|
tv_scroll_right(TV_HORIZONTAL_SCROLL_PREFS);
|
2010-06-05 10:30:08 +00:00
|
|
|
}
|
2010-06-06 08:44:27 +00:00
|
|
|
else { /* prefs->windows == 1 */
|
2010-06-20 21:53:47 +00:00
|
|
|
if (preferences->narrow_mode == NM_PAGE)
|
2010-06-09 11:28:43 +00:00
|
|
|
{
|
|
|
|
/* scroll to next page */
|
|
|
|
tv_scroll_down(TV_VERTICAL_SCROLL_PAGE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Bottom of file */
|
|
|
|
tv_bottom();
|
|
|
|
}
|
2010-06-05 10:30:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef TV_LINE_UP
|
|
|
|
case TV_LINE_UP:
|
|
|
|
case TV_LINE_UP | BUTTON_REPEAT:
|
|
|
|
/* Scroll up one line */
|
|
|
|
tv_scroll_up(TV_VERTICAL_SCROLL_LINE);
|
|
|
|
old_tick = *rb->current_tick;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TV_LINE_DOWN:
|
|
|
|
case TV_LINE_DOWN | BUTTON_REPEAT:
|
|
|
|
/* Scroll down one line */
|
|
|
|
tv_scroll_down(TV_VERTICAL_SCROLL_LINE);
|
|
|
|
old_tick = *rb->current_tick;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef TV_COLUMN_LEFT
|
|
|
|
case TV_COLUMN_LEFT:
|
|
|
|
case TV_COLUMN_LEFT | BUTTON_REPEAT:
|
|
|
|
/* Scroll left one column */
|
|
|
|
tv_scroll_left(TV_HORIZONTAL_SCROLL_COLUMN);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TV_COLUMN_RIGHT:
|
|
|
|
case TV_COLUMN_RIGHT | BUTTON_REPEAT:
|
|
|
|
/* Scroll right one column */
|
|
|
|
tv_scroll_right(TV_HORIZONTAL_SCROLL_COLUMN);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TV_RC_QUIT
|
|
|
|
case TV_RC_QUIT:
|
|
|
|
#endif
|
|
|
|
case TV_QUIT:
|
|
|
|
#ifdef TV_QUIT2
|
|
|
|
case TV_QUIT2:
|
|
|
|
#endif
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TV_BOOKMARK:
|
|
|
|
tv_add_or_remove_bookmark();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-08-24 14:30:46 +00:00
|
|
|
exit_on_usb(button);
|
2010-06-05 10:30:08 +00:00
|
|
|
display_update = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (button != BUTTON_NONE)
|
|
|
|
{
|
2011-05-01 14:44:20 +00:00
|
|
|
#if defined(TV_AUTOSCROLL_PRE)
|
2010-06-05 10:30:08 +00:00
|
|
|
lastbutton = button;
|
2011-05-01 14:44:20 +00:00
|
|
|
#endif
|
2010-06-05 10:30:08 +00:00
|
|
|
rb->yield();
|
|
|
|
}
|
|
|
|
if (autoscroll)
|
|
|
|
{
|
2010-06-20 21:53:47 +00:00
|
|
|
if(old_tick <= *rb->current_tick - (110 - preferences->autoscroll_speed * 10))
|
2010-06-05 10:30:08 +00:00
|
|
|
{
|
|
|
|
tv_scroll_down(TV_VERTICAL_SCROLL_PREFS);
|
|
|
|
old_tick = *rb->current_tick;
|
|
|
|
display_update = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|