Index: tools/configure =================================================================== --- tools/configure (revision 14233) +++ tools/configure (working copy) @@ -963,6 +963,7 @@ t_cpu="arm" t_manufacturer="ipod" t_model="video" + extradefines="$extradefines -DACCEPT_DOUBLE_CLICK" ;; 23|ipod3g) @@ -1334,14 +1335,14 @@ output=$bootoutput fi fi - extradefines="-DBOOTLOADER -ffunction-sections -fdata-sections" + extradefines="$extradefines -DBOOTLOADER -ffunction-sections -fdata-sections" bootloader="1" echo "Bootloader build selected" ;; [Ss]) debug="-DDEBUG" simulator="yes" - extradefines="-DSIMULATOR" + extradefines="$extradefines -DSIMULATOR" echo "Simulator build selected" ;; [Aa]) @@ -1349,7 +1350,7 @@ whichadvanced ;; [Gg]) - extradefines="-DSTUB" # for target makefile symbol EXTRA_DEFINES + extradefines="$extradefines -DSTUB" # for target makefile symbol EXTRA_DEFINES appsdir='\$(ROOTDIR)/gdb' apps="stub" case $archos in Index: firmware/export/button.h =================================================================== --- firmware/export/button.h (revision 14233) +++ firmware/export/button.h (working copy) @@ -59,5 +59,8 @@ /* Button modifiers */ #define BUTTON_REL 0x02000000 #define BUTTON_REPEAT 0x04000000 +#ifdef ACCEPT_DOUBLE_CLICK +#define BUTTON_DBL 0x08000000 +#endif #endif /* _BUTTON_H_ */ Index: firmware/drivers/button.c =================================================================== --- firmware/drivers/button.c (revision 14233) +++ firmware/drivers/button.c (working copy) @@ -63,6 +63,11 @@ bool phones_present = false; #endif +#ifdef ACCEPT_DOUBLE_CLICK +#define DOUBLE_CLICK_START 17 +#define DOUBLE_CLICK_INTERVAL 20 +#endif + /* how long until repeat kicks in, in ticks */ #define REPEAT_START 30 @@ -81,6 +86,10 @@ static int repeat_count = 0; static bool repeat = false; static bool post = false; +#ifdef ACCEPT_DOUBLE_CLICK + static int double_click = DOUBLE_CLICK_INTERVAL; + static int lastbtn_pushed = 0; +#endif #ifdef HAVE_BACKLIGHT static bool skip_release = false; #ifdef HAVE_REMOTE_LCD @@ -89,7 +98,8 @@ #endif int diff; int btn; - + int post_orig = 0; + #ifdef HAS_SERIAL_REMOTE /* Post events for the remote control */ btn = remote_control_rx(); @@ -132,23 +142,61 @@ else #endif if(!skip_release) +#ifdef ACCEPT_DOUBLE_CLICK + { + /* if double_click is < start then a double click was + * detected and queued, now we must queue the release + */ + if (lastbtn_pushed > 0 && double_click < DOUBLE_CLICK_START) + { + queue_post(&button_queue, BUTTON_REL | lastbtn_pushed, 0); + double_click = DOUBLE_CLICK_INTERVAL; + } + } +#else /* !ACCEPT_DOUBLE_CLICK */ queue_post(&button_queue, BUTTON_REL | diff, 0); +#endif else skip_release = false; -#else +#else /* !HAVE_REMOTE_LCD */ +#ifdef ACCEPT_DOUBLE_CLICK + /* see above section comment */ + if (lastbtn_pushed > 0 && double_click < DOUBLE_CLICK_START) + { + queue_post(&button_queue, BUTTON_REL | lastbtn_pushed, 0); + double_click = DOUBLE_CLICK_INTERVAL; + } +#else /* !ACCEPT_DOUBLE_CLICK */ queue_post(&button_queue, BUTTON_REL | diff, 0); #endif +#endif } else { if ( btn ) { +#ifdef ACCEPT_DOUBLE_CLICK + /* check for double click */ + /* double clicked if lastbtn == 0, and we've waited long enough */ + if (lastbtn == 0 && btn == lastbtn_pushed && double_click < DOUBLE_CLICK_START) + { + /* now post and wait for button to be released */ + post = true; + double_click = 0; + } + else +#endif /* normal keypress */ if ( btn != lastbtn ) { post = true; repeat = false; repeat_speed = REPEAT_INTERVAL_START; +#ifdef ACCEPT_DOUBLE_CLICK + /* diff btn - reset double click, no post */ + post = false; + double_click = DOUBLE_CLICK_INTERVAL; +#endif } else /* repeat? */ { @@ -165,6 +213,10 @@ repeat_count++; +#ifdef ACCEPT_DOUBLE_CLICK + /* reset double click stuff */ + double_click = DOUBLE_CLICK_INTERVAL; +#endif /* Send a SYS_POWEROFF event if we have a device which doesn't shut down easily with the OFF key */ @@ -200,6 +252,13 @@ repeat_count = 0; /* initial repeat */ count = REPEAT_INTERVAL_START; +#ifdef ACCEPT_DOUBLE_CLICK + /* post original button press */ + post_orig = btn; + /* reset double click stuff */ + double_click = DOUBLE_CLICK_INTERVAL; + lastbtn_pushed = 0; +#endif } } } @@ -211,6 +270,14 @@ * to avoid afterscroll effects. */ if (queue_empty(&button_queue)) { +#ifdef ACCEPT_DOUBLE_CLICK + if (post_orig != 0) + { + /* queue the original button press */ + queue_post(&button_queue, post_orig, 0); + post_orig = 0; + } +#endif queue_post(&button_queue, BUTTON_REPEAT | btn, 0); #ifdef HAVE_BACKLIGHT #ifdef HAVE_REMOTE_LCD @@ -242,12 +309,24 @@ || (btn&BUTTON_REMOTE) #endif ) + { +#ifdef ACCEPT_DOUBLE_CLICK + queue_post(&button_queue, + double_click < DOUBLE_CLICK_START ? (BUTTON_DBL | btn) : btn, 0); +#else queue_post(&button_queue, btn, 0); +#endif + } else skip_release = true; #else /* no backlight, nothing to skip */ +#ifdef ACCEPT_DOUBLE_CLICK + queue_post(&button_queue, + double_click < DOUBLE_CLICK_START ? (BUTTON_DBL | btn) : btn, 0); +#else queue_post(&button_queue, btn, 0); #endif +#endif post = false; } #ifdef HAVE_REMOTE_LCD @@ -264,9 +343,29 @@ { repeat = false; count = 0; +#ifdef ACCEPT_DOUBLE_CLICK + /* if we've waited longer than DOUBLE_CLICK_INTERVAL + * then it isn't a double click, so queue the button + */ + if (lastbtn_pushed && --double_click <= 0) + { + /* queue both the original press, and the release */ + queue_post(&button_queue, lastbtn_pushed, 0); + queue_post(&button_queue, BUTTON_REL | lastbtn_pushed, 0); + double_click = DOUBLE_CLICK_INTERVAL; + lastbtn_pushed = 0; + } +#endif } } + +#ifdef ACCEPT_DOUBLE_CLICK + lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT | BUTTON_DBL); + if (lastbtn) + lastbtn_pushed = lastbtn; +#else lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT); +#endif } #ifdef HAVE_ADJUSTABLE_CPU_FREQ