Button driver for iAudio X5

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8828 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2006-02-24 15:06:25 +00:00
parent f16c1f341a
commit 568ac3eb21
32 changed files with 98 additions and 56 deletions

View file

@ -44,7 +44,7 @@
#define BOOKMARK_DOWN BUTTON_DOWN
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
#define BOOKMARK_SELECT BUTTON_MENU
#define BOOKMARK_SELECT BUTTON_SELECT
#define BOOKMARK_DELETE BUTTON_REC | BUTTON_REPEAT
#define BOOKMARK_DOWN BUTTON_DOWN

View file

@ -74,7 +74,7 @@
#define EQ_BTN_NEXT_BAND BUTTON_DOWN
#define EQ_BTN_PREV_BAND BUTTON_UP
#define EQ_BTN_CHANGE_MODE BUTTON_REC
#define EQ_BTN_EXIT BUTTON_MENU
#define EQ_BTN_EXIT BUTTON_SELECT
#elif (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD)

View file

@ -228,10 +228,10 @@
#define WPS_DECVOL BUTTON_DOWN
#define WPS_PAUSE BUTTON_PLAY
/* #define WPS_MENU iAudioX5 can't have both main menu and context menu in wps (unless we use BUTTON_REC?) */
#define WPS_BROWSE (BUTTON_MENU | BUTTON_REL)
#define WPS_BROWSE_PRE BUTTON_MENU
#define WPS_BROWSE (BUTTON_SELECT | BUTTON_REL)
#define WPS_BROWSE_PRE BUTTON_SELECT
#define WPS_EXIT (BUTTON_PLAY | BUTTON_REPEAT)
#define WPS_CONTEXT (BUTTON_MENU | BUTTON_REPEAT)
#define WPS_CONTEXT (BUTTON_SELECT | BUTTON_REPEAT)
#endif

View file

@ -88,7 +88,7 @@
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
#define SELECT_INC BUTTON_UP
#define SELECT_DEC BUTTON_DOWN
#define SELECT_OK BUTTON_MENU
#define SELECT_OK BUTTON_SELECT
#define SELECT_OK2 BUTTON_LEFT
#define SELECT_CANCEL BUTTON_PLAY
#define SELECT_CANCEL2 BUTTON_POWER

View file

@ -92,7 +92,7 @@
#define MENU_NEXT BUTTON_DOWN
#define MENU_PREV BUTTON_UP
#define MENU_EXIT BUTTON_LEFT
#define MENU_EXIT_MENU BUTTON_MENU
#define MENU_EXIT_MENU BUTTON_REC
#define MENU_ENTER BUTTON_RIGHT
#endif

View file

@ -148,8 +148,8 @@ PLUGIN_HEADER
#define CALCULATOR_UP BUTTON_UP
#define CALCULATOR_DOWN BUTTON_DOWN
#define CALCULATOR_QUIT BUTTON_POWER
#define CALCULATOR_INPUT_CALC_PRE BUTTON_MENU
#define CALCULATOR_INPUT (BUTTON_MENU | BUTTON_REL)
#define CALCULATOR_INPUT_CALC_PRE BUTTON_SELECT
#define CALCULATOR_INPUT (BUTTON_SELECT | BUTTON_REL)
#define CALCULATOR_CALC BUTTON_PLAY
#define CALCULATOR_CLEAR BUTTON_REC

View file

@ -90,10 +90,10 @@ PLUGIN_HEADER
#define CHC_QUIT BUTTON_REC
#define CHC_STARTSTOP BUTTON_PLAY
#define CHC_RESET BUTTON_POWER
#define CHC_MENU BUTTON_MENU
#define CHC_MENU BUTTON_SELECT
#define CHC_SETTINGS_INC BUTTON_RIGHT
#define CHC_SETTINGS_DEC BUTTON_LEFT
#define CHC_SETTINGS_OK BUTTON_MENU
#define CHC_SETTINGS_OK BUTTON_SELECT
#define CHC_SETTINGS_CANCEL BUTTON_REC
#endif

View file

@ -988,7 +988,7 @@ STATIC void chip8 (void)
#define CHIP8_OFF BUTTON_POWER
#define CHIP8_KEY2 BUTTON_UP
#define CHIP8_KEY4 BUTTON_LEFT
#define CHIP8_KEY5 BUTTON_MENU
#define CHIP8_KEY5 BUTTON_SELECT
#define CHIP8_KEY6 BUTTON_RIGHT
#define CHIP8_KEY8 BUTTON_DOWN

View file

@ -115,7 +115,7 @@ PLUGIN_HEADER
#define CUBE_Y_DEC BUTTON_DOWN
#define CUBE_Z_INC (BUTTON_PLAY | BUTTON_UP)
#define CUBE_Z_DEC (BUTTON_PLAY | BUTTON_DOWN)
#define CUBE_MODE BUTTON_MENU
#define CUBE_MODE BUTTON_SELECT
#define CUBE_PAUSE_PRE BUTTON_PLAY
#define CUBE_PAUSE (BUTTON_PLAY | BUTTON_REL)
#define CUBE_HIGHSPEED (BUTTON_REC | BUTTON_REL)

View file

@ -41,7 +41,7 @@ PLUGIN_HEADER
#define DBX_SELECT BUTTON_SELECT
#define DBX_STOP BUTTON_PLAY
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
#define DBX_SELECT BUTTON_MENU
#define DBX_SELECT BUTTON_SELECT
#define DBX_STOP BUTTON_PLAY
#endif

View file

@ -71,8 +71,8 @@ PLUGIN_HEADER
#define FLIPIT_SHUFFLE (BUTTON_PLAY | BUTTON_LEFT)
#define FLIPIT_SOLVE (BUTTON_PLAY | BUTTON_RIGHT)
#define FLIPIT_STEP_BY_STEP (BUTTON_PLAY | BUTTON_UP)
#define FLIPIT_TOGGLE_PRE BUTTON_MENU
#define FLIPIT_TOGGLE (BUTTON_MENU | BUTTON_REL)
#define FLIPIT_TOGGLE_PRE BUTTON_SELECT
#define FLIPIT_TOGGLE (BUTTON_SELECT | BUTTON_REL)
#endif

View file

@ -73,7 +73,7 @@ PLUGIN_HEADER
#define BEJEWELED_DOWN BUTTON_DOWN
#define BEJEWELED_LEFT BUTTON_LEFT
#define BEJEWELED_RIGHT BUTTON_RIGHT
#define BEJEWELED_SELECT BUTTON_MENU
#define BEJEWELED_SELECT BUTTON_SELECT
#define BEJEWELED_CANCEL BUTTON_PLAY
#else

View file

@ -86,9 +86,9 @@ PLUGIN_HEADER
#define JPEG_PREVIOUS (BUTTON_SELECT |BUTTON_LEFT)
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
#define JPEG_ZOOM_IN_PRE BUTTON_MENU
#define JPEG_ZOOM_IN (BUTTON_MENU | BUTTON_REL)
#define JPEG_ZOOM_OUT (BUTTON_MENU | BUTTON_REPEAT)
#define JPEG_ZOOM_IN_PRE BUTTON_SELECT
#define JPEG_ZOOM_IN (BUTTON_SELECT | BUTTON_REL)
#define JPEG_ZOOM_OUT (BUTTON_SELECT | BUTTON_REPEAT)
#define JPEG_UP BUTTON_UP
#define JPEG_DOWN BUTTON_DOWN
#define JPEG_LEFT BUTTON_LEFT

View file

@ -196,13 +196,7 @@ const unsigned char rockbox16x7[] = {
#define LP_DEC_Y BUTTON_DOWN
#define LP_INC_Y BUTTON_UP
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
#define LP_QUIT BUTTON_MENU
#define LP_DEC_X BUTTON_LEFT
#define LP_INC_X BUTTON_RIGHT
#define LP_DEC_Y BUTTON_DOWN
#define LP_INC_Y BUTTON_UP
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
#define LP_QUIT BUTTON_MENU
#define LP_QUIT BUTTON_SELECT
#define LP_DEC_X BUTTON_LEFT
#define LP_INC_X BUTTON_RIGHT
#define LP_DEC_Y BUTTON_DOWN

View file

@ -84,9 +84,9 @@ PLUGIN_HEADER
#define MANDELBROT_DOWN BUTTON_DOWN
#define MANDELBROT_LEFT BUTTON_LEFT
#define MANDELBROT_RIGHT BUTTON_RIGHT
#define MANDELBROT_ZOOM_IN_PRE BUTTON_MENU
#define MANDELBROT_ZOOM_IN (BUTTON_MENU | BUTTON_REL)
#define MANDELBROT_ZOOM_OUT (BUTTON_MENU | BUTTON_REPEAT)
#define MANDELBROT_ZOOM_IN_PRE BUTTON_SELECT
#define MANDELBROT_ZOOM_IN (BUTTON_SELECT | BUTTON_REL)
#define MANDELBROT_ZOOM_OUT (BUTTON_SELECT | BUTTON_REPEAT)
#define MANDELBROT_MAXITER_INC (BUTTON_PLAY | BUTTON_RIGHT)
#define MANDELBROT_MAXITER_DEC (BUTTON_PLAY | BUTTON_LEFT)
#define MANDELBROT_RESET BUTTON_REC

View file

@ -86,7 +86,7 @@ PLUGIN_HEADER
#define MINESWP_QUIT BUTTON_POWER
#define MINESWP_START BUTTON_REC
#define MINESWP_TOGGLE BUTTON_PLAY
#define MINESWP_DISCOVER BUTTON_MENU
#define MINESWP_DISCOVER BUTTON_SELECT
#define MINESWP_INFO (BUTTON_REC | BUTTON_PLAY)
#endif

View file

@ -65,7 +65,7 @@ PLUGIN_HEADER
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
#define MOSAIQUE_QUIT BUTTON_POWER
#define MOSAIQUE_SPEED BUTTON_MENU
#define MOSAIQUE_SPEED BUTTON_SELECT
#define MOSAIQUE_RESTART BUTTON_PLAY
#endif

View file

@ -1889,7 +1889,7 @@ char *get_mp3_filename(char *wav_name)
#define MP3ENC_PREV BUTTON_UP
#define MP3ENC_NEXT BUTTON_DOWN
#define MP3ENC_DONE BUTTON_POWER
#define MP3ENC_SELECT BUTTON_MENU
#define MP3ENC_SELECT BUTTON_SELECT
#endif
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)

View file

@ -55,6 +55,10 @@ static int plasma_frequency;
#define PLASMA_QUIT BUTTON_MENU
#define PLASMA_INCREASE_FREQUENCY BUTTON_SCROLL_FWD
#define PLASMA_DECREASE_FREQUENCY BUTTON_SCROLL_BACK
#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
#define PLASMA_QUIT BUTTON_REC
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
#else
#define PLASMA_QUIT BUTTON_OFF
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP

View file

@ -111,7 +111,7 @@ PLUGIN_HEADER
#define SNAKE2_LEVEL_DOWN BUTTON_PLAY
#define SNAKE2_SELECT_MAZE BUTTON_LEFT
#define SNAKE2_SELECT_TYPE BUTTON_RIGHT
#define SNAKE2_PLAYPAUSE BUTTON_MENU
#define SNAKE2_PLAYPAUSE BUTTON_SELECT
#else
#error "lacks keymapping"

View file

@ -80,8 +80,8 @@ PLUGIN_HEADER
#define SOKOBAN_UP BUTTON_UP
#define SOKOBAN_DOWN BUTTON_DOWN
#define SOKOBAN_QUIT BUTTON_POWER
#define SOKOBAN_UNDO_PRE BUTTON_MENU
#define SOKOBAN_UNDO (BUTTON_MENU | BUTTON_REL)
#define SOKOBAN_UNDO_PRE BUTTON_SELECT
#define SOKOBAN_UNDO (BUTTON_SELECT | BUTTON_REL)
#define SOKOBAN_LEVEL_UP (BUTTON_PLAY | BUTTON_UP)
#define SOKOBAN_LEVEL_DOWN (BUTTON_PLAY | BUTTON_DOWN)
#define SOKOBAN_LEVEL_REPEAT BUTTON_REC

View file

@ -129,12 +129,12 @@ static struct plugin_api* rb;
#define SOL_DOWN BUTTON_DOWN
#define SOL_LEFT BUTTON_LEFT
#define SOL_RIGHT BUTTON_RIGHT
#define SOL_MOVE BUTTON_MENU
#define SOL_MOVE BUTTON_SELECT
#define SOL_DRAW BUTTON_PLAY
#define SOL_REM2CUR (BUTTON_REC | BUTTON_LEFT)
#define SOL_CUR2STACK (BUTTON_REC | BUTTON_UP)
#define SOL_REM2STACK (BUTTON_REC | BUTTON_DOWN)
#define SOL_MENU_RUN BUTTON_MENU
#define SOL_MENU_RUN BUTTON_SELECT
#define SOL_MENU_INFO BUTTON_PLAY
#endif

View file

@ -115,8 +115,8 @@ PLUGIN_HEADER
#define STAR_QUIT BUTTON_POWER
#define STAR_UP BUTTON_UP
#define STAR_DOWN BUTTON_DOWN
#define STAR_TOGGLE_CONTROL_PRE BUTTON_MENU
#define STAR_TOGGLE_CONTROL (BUTTON_MENU | BUTTON_REL)
#define STAR_TOGGLE_CONTROL_PRE BUTTON_SELECT
#define STAR_TOGGLE_CONTROL (BUTTON_SELECT | BUTTON_REL)
#define STAR_LEVEL_UP (BUTTON_PLAY | BUTTON_UP)
#define STAR_LEVEL_DOWN (BUTTON_PLAY | BUTTON_DOWN)
#define STAR_LEVEL_REPEAT (BUTTON_PLAY | BUTTON_RIGHT)

View file

@ -81,7 +81,7 @@ PLUGIN_HEADER
#define STOPWATCH_QUIT BUTTON_POWER
#define STOPWATCH_START_STOP BUTTON_PLAY
#define STOPWATCH_RESET_TIMER BUTTON_REC
#define STOPWATCH_LAP_TIMER BUTTON_MENU
#define STOPWATCH_LAP_TIMER BUTTON_SELECT
#define STOPWATCH_SCROLL_UP BUTTON_UP
#define STOPWATCH_SCROLL_DOWN BUTTON_DOWN
#endif

View file

@ -107,7 +107,7 @@ PLUGIN_HEADER
#define SUDOKU_BUTTON_QUIT BUTTON_POWER
#define SUDOKU_BUTTON_UP BUTTON_UP
#define SUDOKU_BUTTON_DOWN BUTTON_DOWN
#define SUDOKU_BUTTON_TOGGLE BUTTON_MENU
#define SUDOKU_BUTTON_TOGGLE BUTTON_SELECT
#define SUDOKU_BUTTON_MENU BUTTON_PLAY
#define SUDOKU_BUTTON_POSSIBLE BUTTON_REC

View file

@ -150,7 +150,7 @@ PLUGIN_HEADER
#define VIEWER_SCREEN_RIGHT BUTTON_RIGHT
#define VIEWER_MODE_WRAP (BUTTON_PLAY | BUTTON_REL)
#define VIEWER_MODE_LINE (BUTTON_PLAY | BUTTON_REPEAT)
#define VIEWER_MODE_WIDTH BUTTON_MENU
#define VIEWER_MODE_WIDTH BUTTON_SELECT
#endif

View file

@ -133,8 +133,8 @@
/* TODO: Check keyboard mappings */
#define KBD_MODES /* iAudio X5 uses 2 modes, picker and line edit */
#define KBD_SELECT (BUTTON_MENU | BUTTON_REL) /* backspace in line edit */
#define KBD_SELECT_PRE BUTTON_MENU
#define KBD_SELECT (BUTTON_SELECT | BUTTON_REL) /* backspace in line edit */
#define KBD_SELECT_PRE BUTTON_SELECT
#define KBD_DONE BUTTON_PLAY
#define KBD_ABORT BUTTON_REC
#define KBD_LEFT BUTTON_LEFT

View file

@ -113,7 +113,7 @@
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
#define SETTINGS_INC BUTTON_UP
#define SETTINGS_DEC BUTTON_DOWN
#define SETTINGS_OK BUTTON_MENU
#define SETTINGS_OK BUTTON_SELECT
#define SETTINGS_CANCEL BUTTON_REC
#define SETTINGS_PREV BUTTON_LEFT
#define SETTINGS_NEXT BUTTON_RIGHT

View file

@ -149,11 +149,11 @@
#define TREE_ABORT BUTTON_PLAY
#define TREE_RUN (BUTTON_RIGHT | BUTTON_REL)
#define TREE_RUN_PRE BUTTON_RIGHT
#define TREE_MENU (BUTTON_MENU | BUTTON_REPEAT)
#define TREE_MENU_PRE BUTTON_MENU
#define TREE_WPS (BUTTON_MENU | BUTTON_REL)
#define TREE_WPS_PRE BUTTON_MENU
#define TREE_CONTEXT (BUTTON_RIGHT | BUTTON_REPEAT)
#define TREE_MENU (BUTTON_REC | BUTTON_REPEAT)
#define TREE_MENU_PRE BUTTON_REC
#define TREE_WPS (BUTTON_REC | BUTTON_REL)
#define TREE_WPS_PRE BUTTON_REC
#define TREE_CONTEXT (BUTTON_SELECT | BUTTON_REPEAT)
#define TREE_POWER_BTN (BUTTON_PLAY | BUTTON_REPEAT)
#endif

View file

@ -70,6 +70,9 @@ static bool flipped; /* buttons can be flipped to match the LCD flip */
(CONFIG_KEYPAD == IRIVER_IFP7XX_PAD)
#define POWEROFF_BUTTON BUTTON_PLAY
#define POWEROFF_COUNT 40
#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
#define POWEROFF_BUTTON BUTTON_POWER
#define POWEROFF_COUNT 10
#else
#define POWEROFF_BUTTON BUTTON_OFF
#define POWEROFF_COUNT 10
@ -530,6 +533,11 @@ void button_init(void)
/* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */
GPIO1_ENABLE &= ~0x00100060;
GPIO1_FUNCTION |= 0x00100062;
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
/* Hold switch */
GPIO_FUNCTION |= 0x08000000;
GPIO_ENABLE &= ~0x08000000;
#elif CONFIG_KEYPAD == RECORDER_PAD
/* Set PB4 and PB8 as input pins */
PBCR1 &= 0xfffc; /* PB8MD = 00 */
@ -698,6 +706,7 @@ void button_set_flip(bool flip)
#endif /* CONFIG_KEYPAD */
int counter;
/*
* Get button pressed from hardware
*/
@ -1039,6 +1048,40 @@ static int button_read(void)
(void)data;
/* The int_btn variable is set in the button interrupt handler */
btn = int_btn;
#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
static bool hold_button = false;
static bool remote_hold_button = false;
counter ++;
hold_button = button_hold();
remote_hold_button = remote_button_hold();
/* normal buttons */
if (!hold_button)
{
data = adc_scan(ADC_BUTTONS);
if(data < 0x7c)
if(data < 0x42)
btn = BUTTON_LEFT;
else
if(data < 0x62)
btn = BUTTON_RIGHT;
else
btn = BUTTON_SELECT;
else
if(data < 0xb6)
if(data < 0x98)
btn = BUTTON_PLAY;
else
btn = BUTTON_REC;
else
if(data < 0xd3)
btn = BUTTON_DOWN;
else
if(data < 0xf0)
btn = BUTTON_UP;
}
#endif /* CONFIG_KEYPAD */
@ -1100,7 +1143,7 @@ bool button_hold(void)
#if (CONFIG_KEYPAD == IAUDIO_X5_PAD)
bool button_hold(void)
{
return (GPIO_READ & 0x08000000)?true:false;
return (GPIO_READ & 0x08000000)?false:true;
}
bool remote_button_hold(void)

View file

@ -92,7 +92,8 @@
unsigned short adc_read(int channel);
void adc_init(void);
#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)\
|| defined(IAUDIO_X5)
unsigned char adc_scan(int channel);
#endif

View file

@ -23,7 +23,8 @@
#include <stdbool.h>
#include "config.h"
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
(CONFIG_KEYPAD == IRIVER_H300_PAD)
(CONFIG_KEYPAD == IRIVER_H300_PAD) || \
(CONFIG_KEYPAD == IAUDIO_X5_PAD)
#define HAS_BUTTON_HOLD
#define HAS_REMOTE_BUTTON_HOLD
#elif (CONFIG_KEYPAD == IPOD_4G_PAD)
@ -192,8 +193,7 @@ bool button_hold(void);
#define BUTTON_POWER 0x0004
#define BUTTON_UP 0x0008
#define BUTTON_DOWN 0x0010
#define BUTTON_MENU 0x0020
#define BUTTON_OFF 0x0040 /* DOES NOT EXIST!!! */
#define BUTTON_SELECT 0x0020
#define BUTTON_RC_REC (BUTTON_REMOTE | 0x00400000)