2008-05-05 21:31:34 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Rob Purchase
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* 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.
|
2008-05-05 21:31:34 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2008-05-05 21:31:34 +00:00
|
|
|
|
2009-12-15 20:51:41 +00:00
|
|
|
#if (CONFIG_KEYPAD == COWON_D2_PAD)
|
2008-08-23 09:46:38 +00:00
|
|
|
#define TOUCHSCREEN_QUIT BUTTON_POWER
|
|
|
|
#define TOUCHSCREEN_TOGGLE BUTTON_MENU
|
2008-05-05 21:31:34 +00:00
|
|
|
#elif (CONFIG_KEYPAD == MROBE500_PAD)
|
2008-08-23 09:46:38 +00:00
|
|
|
#define TOUCHSCREEN_QUIT BUTTON_POWER
|
|
|
|
#define TOUCHSCREEN_TOGGLE BUTTON_RC_MODE
|
2009-04-07 23:41:44 +00:00
|
|
|
#elif (CONFIG_KEYPAD == ONDAVX747_PAD)
|
|
|
|
#define TOUCHSCREEN_QUIT BUTTON_POWER
|
|
|
|
#define TOUCHSCREEN_TOGGLE BUTTON_MENU
|
2013-07-29 17:03:22 +00:00
|
|
|
#elif (CONFIG_KEYPAD == ONDAVX777_PAD)
|
|
|
|
#define TOUCHSCREEN_QUIT BUTTON_POWER
|
|
|
|
#define TOUCHSCREEN_TOGGLE BUTTON_MENU
|
2012-01-26 23:14:53 +00:00
|
|
|
#elif (CONFIG_KEYPAD == ANDROID_PAD)
|
|
|
|
#define TOUCHSCREEN_QUIT BUTTON_BACK
|
|
|
|
#define TOUCHSCREEN_TOGGLE BUTTON_MENU
|
|
|
|
#elif (CONFIG_KEYPAD == SDL_PAD)
|
|
|
|
#define TOUCHSCREEN_QUIT BUTTON_MIDLEFT
|
|
|
|
#define TOUCHSCREEN_TOGGLE BUTTON_CENTER
|
2008-05-05 21:31:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* plugin entry point */
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2008-05-05 21:31:34 +00:00
|
|
|
{
|
|
|
|
int button = 0;
|
2008-08-23 09:46:38 +00:00
|
|
|
enum touchscreen_mode mode = TOUCHSCREEN_BUTTON;
|
2008-05-05 21:31:34 +00:00
|
|
|
|
|
|
|
/* standard stuff */
|
|
|
|
(void)parameter;
|
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
rb->touchscreen_set_mode(mode);
|
2008-05-05 21:31:34 +00:00
|
|
|
|
|
|
|
/* wait until user closes plugin */
|
|
|
|
do
|
|
|
|
{
|
|
|
|
short x = 0;
|
|
|
|
short y = 0;
|
|
|
|
bool draw_rect = false;
|
|
|
|
|
|
|
|
button = rb->button_get(true);
|
|
|
|
|
|
|
|
if (button & BUTTON_TOPLEFT)
|
|
|
|
{
|
|
|
|
draw_rect = true;
|
|
|
|
x = 0; y = 0;
|
|
|
|
}
|
|
|
|
else if (button & BUTTON_TOPMIDDLE)
|
|
|
|
{
|
|
|
|
draw_rect = true;
|
|
|
|
x = LCD_WIDTH/3; y = 0;
|
|
|
|
}
|
|
|
|
else if (button & BUTTON_TOPRIGHT)
|
|
|
|
{
|
|
|
|
draw_rect = true;
|
|
|
|
x = 2*(LCD_WIDTH/3); y = 0;
|
|
|
|
}
|
|
|
|
else if (button & BUTTON_MIDLEFT)
|
|
|
|
{
|
|
|
|
draw_rect = true;
|
|
|
|
x = 0; y = LCD_HEIGHT/3;
|
|
|
|
}
|
|
|
|
else if (button & BUTTON_CENTER)
|
|
|
|
{
|
|
|
|
draw_rect = true;
|
|
|
|
x = LCD_WIDTH/3; y = LCD_HEIGHT/3;
|
|
|
|
}
|
|
|
|
else if (button & BUTTON_MIDRIGHT)
|
|
|
|
{
|
|
|
|
draw_rect = true;
|
|
|
|
x = 2*(LCD_WIDTH/3); y = LCD_HEIGHT/3;
|
|
|
|
}
|
|
|
|
else if (button & BUTTON_BOTTOMLEFT)
|
|
|
|
{
|
|
|
|
draw_rect = true;
|
|
|
|
x = 0; y = 2*(LCD_HEIGHT/3);
|
|
|
|
}
|
|
|
|
else if (button & BUTTON_BOTTOMMIDDLE)
|
|
|
|
{
|
|
|
|
draw_rect = true;
|
|
|
|
x = LCD_WIDTH/3; y = 2*(LCD_HEIGHT/3);
|
|
|
|
}
|
|
|
|
else if (button & BUTTON_BOTTOMRIGHT)
|
|
|
|
{
|
|
|
|
draw_rect = true;
|
|
|
|
x = 2*(LCD_WIDTH/3); y = 2*(LCD_HEIGHT/3);
|
|
|
|
}
|
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
if (button & TOUCHSCREEN_TOGGLE && (button & BUTTON_REL))
|
2008-05-05 21:31:34 +00:00
|
|
|
{
|
2008-08-23 09:46:38 +00:00
|
|
|
mode = (mode == TOUCHSCREEN_POINT) ? TOUCHSCREEN_BUTTON : TOUCHSCREEN_POINT;
|
|
|
|
rb->touchscreen_set_mode(mode);
|
2008-05-05 21:31:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (button & BUTTON_REL) draw_rect = false;
|
|
|
|
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
|
|
|
|
if (draw_rect)
|
|
|
|
{
|
|
|
|
rb->lcd_set_foreground(LCD_RGBPACK(0xc0, 0, 0));
|
|
|
|
rb->lcd_fillrect(x, y, LCD_WIDTH/3, LCD_HEIGHT/3);
|
|
|
|
}
|
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
if (draw_rect || button & BUTTON_TOUCHSCREEN)
|
2008-05-05 21:31:34 +00:00
|
|
|
{
|
|
|
|
intptr_t button_data = rb->button_get_data();
|
|
|
|
x = button_data >> 16;
|
|
|
|
y = button_data & 0xffff;
|
|
|
|
|
|
|
|
rb->lcd_set_foreground(LCD_RGBPACK(0, 0, 0xc0));
|
|
|
|
rb->lcd_fillrect(x-7, y-7, 14, 14);
|
|
|
|
|
|
|
|
/* in stylus mode, show REL position in black */
|
2008-08-23 09:46:38 +00:00
|
|
|
if (mode == TOUCHSCREEN_POINT && (button & BUTTON_REL))
|
2008-05-05 21:31:34 +00:00
|
|
|
rb->lcd_set_foreground(LCD_BLACK);
|
|
|
|
else
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
|
|
|
|
rb->lcd_hline(x-5, x+5, y);
|
|
|
|
rb->lcd_vline(x, y-5, y+5);
|
|
|
|
}
|
|
|
|
rb->lcd_update();
|
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
} while (button != TOUCHSCREEN_QUIT);
|
2008-05-05 21:31:34 +00:00
|
|
|
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|