Plugin rework 2: (most) Compile-time keyboard configuration, for Ondio adaption. (all) Now using the default event handler, standard placement is now in switch() default case. (calendar, chip8) Fixed usb handling.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5295 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
7c2496d35a
commit
79afbafa66
7 changed files with 235 additions and 91 deletions
|
@ -1,4 +1,4 @@
|
|||
/* plugins common to both Player+Recorder model */
|
||||
/* plugins common to all models */
|
||||
battery_test.c
|
||||
favorites.c
|
||||
firmware_flash.c
|
||||
|
@ -11,20 +11,24 @@ stopwatch.c
|
|||
vbrfix.c
|
||||
viewer.c
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP /* recorder model only */
|
||||
#ifdef HAVE_LCD_BITMAP /* Recorder/Ondio models only */
|
||||
bounce.c
|
||||
calculator.c
|
||||
chip8.c
|
||||
cube.c
|
||||
grayscale.c
|
||||
jpeg.c
|
||||
rockblox.c
|
||||
snow.c
|
||||
video.c
|
||||
|
||||
#ifdef HAVE_RTC /* Recorder models only */
|
||||
calendar.c
|
||||
clock.c
|
||||
#endif
|
||||
|
||||
#if CONFIG_KEYPAD != ONDIO_PAD
|
||||
/* gradually bring in the ones not working yet */
|
||||
bounce.c
|
||||
calculator.c
|
||||
calendar.c
|
||||
chip8.c
|
||||
clock.c
|
||||
cube.c
|
||||
flipit.c
|
||||
mandelbrot.c
|
||||
minesweeper.c
|
||||
|
|
|
@ -30,6 +30,17 @@
|
|||
#define XSPEED 3
|
||||
#define YADD -4
|
||||
|
||||
/* variable button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
#define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
|
||||
#define BOUNCE_MODE (BUTTON_ON | BUTTON_REL)
|
||||
|
||||
#elif CONFIG_KEYPAD == ONDIO_PAD
|
||||
#define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
|
||||
#define BOUNCE_MODE (BUTTON_MENU | BUTTON_REL)
|
||||
|
||||
#endif
|
||||
|
||||
static struct plugin_api* rb;
|
||||
|
||||
static unsigned char table[]={
|
||||
|
@ -172,6 +183,7 @@ struct counter values[]={
|
|||
{"ydistt", -6},
|
||||
};
|
||||
|
||||
#ifdef HAVE_RTC
|
||||
static unsigned char yminute[]={
|
||||
53,53,52,52,51,50,49,47,46,44,42,40,38,36,34,32,29,27,25,23,21,19,17,16,14,13,12,11,11,10,10,10,11,11,12,13,14,16,17,19,21,23,25,27,29,31,34,36,38,40,42,44,46,47,49,50,51,52,52,53,
|
||||
};
|
||||
|
@ -218,6 +230,7 @@ static void addclock(void)
|
|||
yminute[(i+1)%60]);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_RTC */
|
||||
|
||||
static int scrollit(void)
|
||||
{
|
||||
|
@ -236,10 +249,10 @@ static int scrollit(void)
|
|||
while(1)
|
||||
{
|
||||
b = rb->button_get_w_tmo(HZ/10);
|
||||
if ( b == (BUTTON_OFF|BUTTON_REL) )
|
||||
if ( b == BOUNCE_QUIT )
|
||||
return 0;
|
||||
|
||||
if ( b == (BUTTON_ON|BUTTON_REL) )
|
||||
if ( b == BOUNCE_MODE )
|
||||
return 1;
|
||||
|
||||
if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
|
||||
|
@ -256,7 +269,9 @@ static int scrollit(void)
|
|||
yy += YADD;
|
||||
xx+= LCD_WIDTH/LETTERS_ON_SCREEN;
|
||||
}
|
||||
#ifdef HAVE_RTC
|
||||
addclock();
|
||||
#endif
|
||||
rb->lcd_update();
|
||||
|
||||
x-= XSPEED;
|
||||
|
@ -293,10 +308,10 @@ static int loopit(void)
|
|||
while(1)
|
||||
{
|
||||
b = rb->button_get_w_tmo(HZ/10);
|
||||
if ( b == (BUTTON_OFF|BUTTON_REL) )
|
||||
if ( b == BOUNCE_QUIT )
|
||||
return 0;
|
||||
|
||||
if ( b == (BUTTON_ON|BUTTON_REL) )
|
||||
if ( b == BOUNCE_MODE )
|
||||
return 1;
|
||||
|
||||
if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
|
||||
|
@ -309,7 +324,9 @@ static int loopit(void)
|
|||
x+= speed[xsanke&15] + values[NUM_XADD].num;
|
||||
|
||||
rb->lcd_clear_display();
|
||||
#ifdef HAVE_RTC
|
||||
addclock();
|
||||
#endif
|
||||
if(timeout) {
|
||||
switch(b) {
|
||||
case BUTTON_LEFT:
|
||||
|
@ -402,7 +419,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
|
||||
rb->lcd_setfont(FONT_UI);
|
||||
|
||||
return h = 0 ? PLUGIN_OK : PLUGIN_USB_CONNECTED;
|
||||
return (h == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -104,6 +104,22 @@ F3: equal to "="
|
|||
#define SIGN(x) ((x)<0?-1:1)
|
||||
#define ABS(x) ((x)<0?-(x):(x))
|
||||
|
||||
/* variable button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
#define CALCULATOR_QUIT BUTTON_OFF
|
||||
#define CALCULATOR_INPUT BUTTON_PLAY
|
||||
#define CALCULATOR_CALC BUTTON_F3
|
||||
#define CALCULATOR_OPERATORS BUTTON_F2
|
||||
#define CALCULATOR_CLEAR BUTTON_F1
|
||||
|
||||
#elif CONFIG_KEYPAD == ONDIO_PAD
|
||||
#define CALCULATOR_QUIT BUTTON_OFF
|
||||
#define CALCULATOR_INPUT_CALC_PRE BUTTON_MENU
|
||||
#define CALCULATOR_INPUT (BUTTON_MENU | BUTTON_REL)
|
||||
#define CALCULATOR_CALC (BUTTON_MENU | BUTTON_REPEAT)
|
||||
|
||||
#endif
|
||||
|
||||
static struct plugin_api* rb;
|
||||
|
||||
enum {
|
||||
|
@ -187,6 +203,7 @@ int m, n, prev_m, prev_n; /* position index for button */
|
|||
#define CAL_BUTTON (m*5+n)
|
||||
|
||||
int btn = BUTTON_NONE;
|
||||
int lastbtn = BUTTON_NONE;
|
||||
|
||||
/* Status of calculator */
|
||||
enum {cal_normal, /* 0, normal status, display result */
|
||||
|
@ -1090,7 +1107,7 @@ Handle buttons on basic screen
|
|||
----------------------------------------------------------------------- */
|
||||
void basicButtonsProcess(void){
|
||||
switch (btn) {
|
||||
case BUTTON_PLAY:
|
||||
case CALCULATOR_INPUT:
|
||||
if (calStatus == cal_error && (CAL_BUTTON != btn_C) ) break;
|
||||
flashButton(CAL_BUTTON);
|
||||
switch( CAL_BUTTON ){
|
||||
|
@ -1143,7 +1160,9 @@ void basicButtonsProcess(void){
|
|||
case btn_add:
|
||||
if(!operInputted) {twoOperands(); operInputted = true;}
|
||||
oper = buttonChar[basicButtons][m][n][0];
|
||||
case_BUTTON_F2: /* F2 shortkey entrance */
|
||||
#ifdef CALCULATOR_OPERATORS
|
||||
case_cycle_operators: /* F2 shortkey entrance */
|
||||
#endif
|
||||
calStatus = cal_normal;
|
||||
formatResult();
|
||||
operand = result;
|
||||
|
@ -1159,7 +1178,8 @@ void basicButtonsProcess(void){
|
|||
} /* switch (CAL_BUTTON) */
|
||||
break;
|
||||
|
||||
case BUTTON_F2:
|
||||
#ifdef CALCULATOR_OPERATORS
|
||||
case CALCULATOR_OPERATORS:
|
||||
if (calStatus == cal_error) break;
|
||||
if (!operInputted) {twoOperands(); operInputted = true;}
|
||||
switch (oper){
|
||||
|
@ -1169,9 +1189,11 @@ void basicButtonsProcess(void){
|
|||
case '-': oper = '*'; flashButton(btn_time); break;
|
||||
case '*': oper = '/'; flashButton(btn_div); break;
|
||||
}
|
||||
goto case_BUTTON_F2;
|
||||
goto case_cycle_operators;
|
||||
break;
|
||||
case BUTTON_F3:
|
||||
#endif
|
||||
|
||||
case CALCULATOR_CALC:
|
||||
if (calStatus == cal_error) break;
|
||||
flashButton(btn_equal);
|
||||
goto case_btn_equal;
|
||||
|
@ -1186,7 +1208,7 @@ Handle buttons on scientific screen
|
|||
----------------------------------------------------------------------- */
|
||||
void sciButtonsProcess(void){
|
||||
switch (btn) {
|
||||
case BUTTON_PLAY:
|
||||
case CALCULATOR_INPUT:
|
||||
if (calStatus == cal_error && (CAL_BUTTON != sci_sci) ) break;
|
||||
flashButton(CAL_BUTTON);
|
||||
switch( CAL_BUTTON ){
|
||||
|
@ -1225,7 +1247,8 @@ void sciButtonsProcess(void){
|
|||
} /* switch (CAL_BUTTON) */
|
||||
break;
|
||||
|
||||
case BUTTON_F2:
|
||||
#ifdef CALCULATOR_OPERATORS
|
||||
case CALCULATOR_OPERATORS:
|
||||
if (calStatus == cal_error) break;
|
||||
if (!operInputted) {twoOperands(); operInputted = true;}
|
||||
switch (oper){
|
||||
|
@ -1240,7 +1263,9 @@ void sciButtonsProcess(void){
|
|||
operand = result;
|
||||
operandPower = power;
|
||||
break;
|
||||
case BUTTON_F3:
|
||||
#endif
|
||||
|
||||
case CALCULATOR_CALC:
|
||||
if (calStatus == cal_error) break;
|
||||
formatResult();
|
||||
calStatus = cal_normal;
|
||||
|
@ -1268,9 +1293,16 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
while (calStatus != cal_exit ) {
|
||||
btn = rb->button_get_w_tmo(HZ/2);
|
||||
switch (btn) {
|
||||
case BUTTON_PLAY:
|
||||
case BUTTON_F2:
|
||||
case BUTTON_F3:
|
||||
case CALCULATOR_INPUT:
|
||||
case CALCULATOR_CALC:
|
||||
#ifdef CALCULATOR_INPUT_CALC_PRE
|
||||
if (lastbtn != CALCULATOR_INPUT_CALC_PRE)
|
||||
break;
|
||||
/* no unconditional break; here! */
|
||||
#endif
|
||||
#ifdef CALCULATOR_OPERATORS
|
||||
case CALCULATOR_OPERATORS:
|
||||
#endif
|
||||
switch(buttonGroup){
|
||||
case basicButtons:
|
||||
basicButtonsProcess();
|
||||
|
@ -1281,18 +1313,20 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
}
|
||||
break;
|
||||
|
||||
case BUTTON_F1:
|
||||
switch(calStatus){
|
||||
case cal_typing:
|
||||
case cal_dotted:
|
||||
doDelete();
|
||||
break;
|
||||
default: /* cal_normal, cal_error, cal_exit */
|
||||
clearMem();
|
||||
break;
|
||||
}
|
||||
printResult();
|
||||
break;
|
||||
#ifdef CALCULATOR_CLEAR
|
||||
case CALCULATOR_CLEAR:
|
||||
switch(calStatus){
|
||||
case cal_typing:
|
||||
case cal_dotted:
|
||||
doDelete();
|
||||
break;
|
||||
default: /* cal_normal, cal_error, cal_exit */
|
||||
clearMem();
|
||||
break;
|
||||
}
|
||||
printResult();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case BUTTON_LEFT:
|
||||
case BUTTON_LEFT | BUTTON_REPEAT:
|
||||
|
@ -1304,7 +1338,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
case BUTTON_DOWN | BUTTON_REPEAT:
|
||||
moveButton();
|
||||
break;
|
||||
case BUTTON_OFF:
|
||||
case CALCULATOR_QUIT:
|
||||
calStatus = cal_exit;
|
||||
printResult();
|
||||
break;
|
||||
|
@ -1313,6 +1347,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
return PLUGIN_USB_CONNECTED;
|
||||
break;
|
||||
} /* switch (btn) */
|
||||
if (btn != BUTTON_NONE)
|
||||
lastbtn = btn;
|
||||
} /* while (calStatus != cal_exit ) */
|
||||
|
||||
/* rb->splash(HZ*2, true, "Hello world!"); */
|
||||
|
|
|
@ -592,6 +592,7 @@ static bool any_events(struct shown *shown, bool force)
|
|||
if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
||||
been_in_usb_mode = true;
|
||||
show_lines(lines_displayed,shown);
|
||||
rb->lcd_update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -707,8 +708,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
break;
|
||||
|
||||
case BUTTON_PLAY:
|
||||
if (any_events(&shown, true))
|
||||
rb->usb_screen();
|
||||
any_events(&shown, true);
|
||||
draw_calendar(&shown);
|
||||
break;
|
||||
|
||||
|
|
|
@ -23,6 +23,27 @@
|
|||
#ifdef HAVE_LCD_BITMAP
|
||||
#ifndef SIMULATOR /* not unless lcd_blit() is implemented and mp3_xx stubbed */
|
||||
|
||||
/* variable button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD /* only 9 out of 16 chip8 buttons */
|
||||
#define CHIP8_KEY1 BUTTON_F1
|
||||
#define CHIP8_KEY2 BUTTON_UP
|
||||
#define CHIP8_KEY3 BUTTON_F3
|
||||
#define CHIP8_KEY4 BUTTON_LEFT
|
||||
#define CHIP8_KEY5 BUTTON_PLAY
|
||||
#define CHIP8_KEY6 BUTTON_RIGHT
|
||||
#define CHIP8_KEY7 BUTTON_F2
|
||||
#define CHIP8_KEY8 BUTTON_DOWN
|
||||
#define CHIP8_KEY9 BUTTON_ON
|
||||
|
||||
#elif CONFIG_KEYPAD == ONDIO_PAD /* even more limited */
|
||||
#define CHIP8_KEY2 BUTTON_UP
|
||||
#define CHIP8_KEY4 BUTTON_LEFT
|
||||
#define CHIP8_KEY5 BUTTON_MENU
|
||||
#define CHIP8_KEY6 BUTTON_RIGHT
|
||||
#define CHIP8_KEY8 BUTTON_DOWN
|
||||
|
||||
#endif
|
||||
|
||||
static struct plugin_api* rb; /* here is a global api struct pointer */
|
||||
unsigned char lcd_framebuf[8][64]; /* frame buffer in hardware fomat */
|
||||
|
||||
|
@ -407,33 +428,43 @@ static void chip8_update_display(void)
|
|||
|
||||
static void chip8_keyboard(void)
|
||||
{
|
||||
switch (rb->button_get(false))
|
||||
int button = rb->button_get(false);
|
||||
switch (button)
|
||||
{
|
||||
case BUTTON_OFF: /* Abort Emulator */
|
||||
chip8_running = false;
|
||||
chip8_running = 0;
|
||||
break;
|
||||
|
||||
case BUTTON_UP: chip8_keys[2] = 1; break;
|
||||
case BUTTON_UP | BUTTON_REL: chip8_keys[2] = 0; break;
|
||||
case BUTTON_LEFT: chip8_keys[4] = 1; break;
|
||||
case BUTTON_LEFT | BUTTON_REL: chip8_keys[4] = 0; break;
|
||||
case BUTTON_RIGHT: chip8_keys[6] = 1; break;
|
||||
case BUTTON_RIGHT | BUTTON_REL: chip8_keys[6] = 0; break;
|
||||
case BUTTON_DOWN: chip8_keys[8] = 1; break;
|
||||
case BUTTON_DOWN | BUTTON_REL: chip8_keys[8] = 0; break;
|
||||
case BUTTON_PLAY: chip8_keys[5] = 1; break;
|
||||
case BUTTON_PLAY | BUTTON_REL: chip8_keys[5] = 0; break;
|
||||
case BUTTON_F1: chip8_keys[1] = 1; break;
|
||||
case BUTTON_F1 | BUTTON_REL: chip8_keys[1] = 0; break;
|
||||
case BUTTON_F2: chip8_keys[7] = 1; break;
|
||||
case BUTTON_F2 | BUTTON_REL: chip8_keys[7] = 0; break;
|
||||
case BUTTON_F3: chip8_keys[3] = 1; break;
|
||||
case BUTTON_F3 | BUTTON_REL: chip8_keys[3] = 0; break;
|
||||
case BUTTON_ON: chip8_keys[9] = 1; break;
|
||||
case BUTTON_ON | BUTTON_REL: chip8_keys[9] = 0; break;
|
||||
case CHIP8_KEY2: chip8_keys[2] = 1; break;
|
||||
case CHIP8_KEY2 | BUTTON_REL: chip8_keys[2] = 0; break;
|
||||
case CHIP8_KEY4: chip8_keys[4] = 1; break;
|
||||
case CHIP8_KEY4 | BUTTON_REL: chip8_keys[4] = 0; break;
|
||||
case CHIP8_KEY6: chip8_keys[6] = 1; break;
|
||||
case CHIP8_KEY6 | BUTTON_REL: chip8_keys[6] = 0; break;
|
||||
case CHIP8_KEY8: chip8_keys[8] = 1; break;
|
||||
case CHIP8_KEY8 | BUTTON_REL: chip8_keys[8] = 0; break;
|
||||
case CHIP8_KEY5: chip8_keys[5] = 1; break;
|
||||
case CHIP8_KEY5 | BUTTON_REL: chip8_keys[5] = 0; break;
|
||||
#ifdef CHIP8_KEY1
|
||||
case CHIP8_KEY1: chip8_keys[1] = 1; break;
|
||||
case CHIP8_KEY1 | BUTTON_REL: chip8_keys[1] = 0; break;
|
||||
#endif
|
||||
#ifdef CHIP8_KEY3
|
||||
case CHIP8_KEY3: chip8_keys[3] = 1; break;
|
||||
case CHIP8_KEY3 | BUTTON_REL: chip8_keys[3] = 0; break;
|
||||
#endif
|
||||
#ifdef CHIP8_KEY7
|
||||
case CHIP8_KEY7: chip8_keys[7] = 1; break;
|
||||
case CHIP8_KEY7 | BUTTON_REL: chip8_keys[7] = 0; break;
|
||||
#endif
|
||||
#ifdef CHIP8_KEY9
|
||||
case CHIP8_KEY9: chip8_keys[9] = 1; break;
|
||||
case CHIP8_KEY9 | BUTTON_REL: chip8_keys[9] = 0; break;
|
||||
#endif
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
chip8_running = false;
|
||||
default:
|
||||
if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
||||
chip8_running = 2; /* indicates stopped because of USB */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -556,7 +587,7 @@ bool chip8_run(char* file)
|
|||
}
|
||||
|
||||
chip8_reset();
|
||||
while (chip8_running) chip8_execute();
|
||||
while (chip8_running == 1) chip8_execute();
|
||||
|
||||
if (!is_playing)
|
||||
{ /* stop it if we used audio */
|
||||
|
@ -592,7 +623,13 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
}
|
||||
|
||||
/* now go ahead and have fun! */
|
||||
return chip8_run(filename) ? PLUGIN_OK : PLUGIN_ERROR;
|
||||
if (chip8_run(filename))
|
||||
if (chip8_running == 0)
|
||||
return PLUGIN_OK;
|
||||
else
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
else
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
|
||||
#endif /* #ifndef SIMULATOR */
|
||||
|
|
|
@ -1276,11 +1276,27 @@ bool show_credits(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* Cleanup on plugin return
|
||||
**********************************************************************/
|
||||
|
||||
void cleanup(void *parameter)
|
||||
{
|
||||
(void)parameter; /* unused */
|
||||
|
||||
if(settings.save_mode == 1)
|
||||
save_settings(true);
|
||||
|
||||
/* restore set backlight timeout */
|
||||
rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
|
||||
}
|
||||
|
||||
/******************
|
||||
* F1 Screen - HELP
|
||||
*****************/
|
||||
bool f1_screen(void)
|
||||
{
|
||||
int button;
|
||||
int screen = 1;
|
||||
done = false;
|
||||
|
||||
|
@ -1401,7 +1417,8 @@ bool f1_screen(void)
|
|||
|
||||
rb->lcd_update();
|
||||
|
||||
switch(rb->button_get_w_tmo(HZ/4))
|
||||
button = rb->button_get_w_tmo(HZ/4);
|
||||
switch(button)
|
||||
{
|
||||
case BUTTON_F1: /* exit */
|
||||
case BUTTON_OFF:
|
||||
|
@ -1418,9 +1435,10 @@ bool f1_screen(void)
|
|||
screen++;
|
||||
break;
|
||||
|
||||
case SYS_USB_CONNECTED: /* leave for usb */
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
rb->usb_screen();
|
||||
default:
|
||||
if(rb->default_event_handler_ex(button, cleanup, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2546,6 +2564,8 @@ void counter_options(void)
|
|||
**********************************************************************/
|
||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||
{
|
||||
int button;
|
||||
|
||||
/* time ints */
|
||||
int i;
|
||||
int hour;
|
||||
|
@ -2802,16 +2822,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
/*************************
|
||||
* Scan for button presses
|
||||
************************/
|
||||
switch (rb->button_get_w_tmo(HZ/10))
|
||||
button = rb->button_get_w_tmo(HZ/10);
|
||||
switch (button)
|
||||
{
|
||||
case BUTTON_OFF: /* save and exit */
|
||||
if(settings.save_mode == 1)
|
||||
save_settings(true);
|
||||
|
||||
/* restore set backlight timeout */
|
||||
rb->backlight_set_timeout(
|
||||
rb->global_settings->backlight_timeout);
|
||||
|
||||
cleanup(NULL);
|
||||
return PLUGIN_OK;
|
||||
|
||||
case BUTTON_ON | BUTTON_REL: /* credit roll */
|
||||
|
@ -2889,9 +2904,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
select_mode();
|
||||
break;
|
||||
|
||||
case SYS_USB_CONNECTED: /* usb plugged? */
|
||||
rb->usb_screen();
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
default:
|
||||
if(rb->default_event_handler_ex(button, cleanup, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,30 @@
|
|||
/* Loops that the values are displayed */
|
||||
#define DISP_TIME 30
|
||||
|
||||
/* variable button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
#define CUBE_QUIT (BUTTON_OFF | BUTTON_REL)
|
||||
#define CUBE_X_INC BUTTON_RIGHT
|
||||
#define CUBE_X_DEC BUTTON_LEFT
|
||||
#define CUBE_Y_INC BUTTON_UP
|
||||
#define CUBE_Y_DEC BUTTON_DOWN
|
||||
#define CUBE_Z_INC BUTTON_F2
|
||||
#define CUBE_Z_DEC BUTTON_F1
|
||||
#define CUBE_HIGHSPEED BUTTON_PLAY
|
||||
|
||||
#elif CONFIG_KEYPAD == ONDIO_PAD
|
||||
#define CUBE_QUIT (BUTTON_OFF | BUTTON_REL)
|
||||
#define CUBE_X_INC BUTTON_RIGHT
|
||||
#define CUBE_X_DEC BUTTON_LEFT
|
||||
#define CUBE_Y_INC BUTTON_UP
|
||||
#define CUBE_Y_DEC BUTTON_DOWN
|
||||
#define CUBE_Z_INC (BUTTON_MENU | BUTTON_UP)
|
||||
#define CUBE_Z_DEC (BUTTON_MENU | BUTTON_DOWN)
|
||||
#define CUBE_HIGHSPEED_PRE BUTTON_MENU
|
||||
#define CUBE_HIGHSPEED (BUTTON_MENU | BUTTON_REL)
|
||||
|
||||
#endif
|
||||
|
||||
struct point_3D {
|
||||
long x, y, z;
|
||||
};
|
||||
|
@ -230,6 +254,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
int t_disp=0;
|
||||
char buffer[30];
|
||||
|
||||
int button;
|
||||
int lastbutton=0;
|
||||
int xa=0;
|
||||
int ya=0;
|
||||
int za=0;
|
||||
|
@ -282,56 +308,64 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
if (za<0)
|
||||
za+=360;
|
||||
|
||||
switch(rb->button_get(false))
|
||||
button = rb->button_get(false);
|
||||
switch(button)
|
||||
{
|
||||
case BUTTON_RIGHT:
|
||||
case CUBE_X_INC:
|
||||
xs+=1;
|
||||
if (xs>10)
|
||||
xs=10;
|
||||
t_disp=DISP_TIME;
|
||||
break;
|
||||
case BUTTON_LEFT:
|
||||
case CUBE_X_DEC:
|
||||
xs-=1;
|
||||
if (xs<-10)
|
||||
xs=-10;
|
||||
t_disp=DISP_TIME;
|
||||
break;
|
||||
case BUTTON_UP:
|
||||
case CUBE_Y_INC:
|
||||
ys+=1;
|
||||
if (ys>10)
|
||||
ys=10;
|
||||
t_disp=DISP_TIME;
|
||||
break;
|
||||
case BUTTON_DOWN:
|
||||
case CUBE_Y_DEC:
|
||||
ys-=1;
|
||||
if (ys<-10)
|
||||
ys=-10;
|
||||
t_disp=DISP_TIME;
|
||||
break;
|
||||
case BUTTON_F2:
|
||||
case CUBE_Z_INC:
|
||||
zs+=1;
|
||||
if (zs>10)
|
||||
zs=10;
|
||||
t_disp=DISP_TIME;
|
||||
break;
|
||||
case BUTTON_F1:
|
||||
case CUBE_Z_DEC:
|
||||
zs-=1;
|
||||
if (zs<-10)
|
||||
zs=-10;
|
||||
t_disp=DISP_TIME;
|
||||
break;
|
||||
case BUTTON_PLAY:
|
||||
case CUBE_HIGHSPEED:
|
||||
#ifdef CUBE_HIGHSPEED_PRE
|
||||
if (lastbutton!=CUBE_HIGHSPEED_PRE)
|
||||
break;
|
||||
#endif
|
||||
highspeed=!highspeed;
|
||||
t_disp=DISP_TIME;
|
||||
break;
|
||||
case BUTTON_OFF|BUTTON_REL:
|
||||
case CUBE_QUIT:
|
||||
exit=1;
|
||||
break;
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
rb->usb_screen();
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
default:
|
||||
if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
break;
|
||||
}
|
||||
if (button!=BUTTON_NONE)
|
||||
lastbutton=button;
|
||||
}
|
||||
|
||||
return PLUGIN_OK;
|
||||
|
|
Loading…
Reference in a new issue