From 8c1d94fb235d69c5a61798b9f62d6b6663e738bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Stenberg?= Date: Sat, 20 Apr 2002 14:42:49 +0000 Subject: [PATCH] Added player button scanning git-svn-id: svn://svn.rockbox.org/rockbox/trunk@154 a1c6a512-1295-4272-9138-f99709370657 --- firmware/button.c | 50 ++++++++++++++++++++++++++++++++++++++++++----- firmware/button.h | 31 +++++++++++++++++------------ 2 files changed, 64 insertions(+), 17 deletions(-) diff --git a/firmware/button.c b/firmware/button.c index bedd294606..a1abccd32a 100644 --- a/firmware/button.c +++ b/firmware/button.c @@ -21,13 +21,11 @@ */ #include "config.h" - -#ifdef HAVE_RECORDER_KEYPAD - -#include "types.h" #include "sh7034.h" #include "button.h" +#ifdef HAVE_RECORDER_KEYPAD + /* AJBR buttons are connected to the CPU as follows: * * ON and OFF are connected to separate port B input pins. @@ -148,7 +146,49 @@ int button_get(void) return ret; } -#endif /* HAVE_RECORDER_KEYPAD */ +#elif HAVE_PLAYER_KEYPAD + +/* The player has all buttons on port pins: + + LEFT: PC0 + RIGHT: PC2 + PLAY: PC3 + STOP: PA11 + ON: PA5 + MENU: PC1 +*/ + +void button_init(void) +{ + /* set port pins as input */ + PAIOR &= ~0x820; +} + +int button_get(void) +{ + int porta = PADR; + int portc = PCDR; + int btn = 0; + + if ( portc & 1 ) + btn |= BUTTON_LEFT; + if ( portc & 2 ) + btn |= BUTTON_MENU; + if ( portc & 4 ) + btn |= BUTTON_RIGHT; + if ( portc & 8 ) + btn |= BUTTON_PLAY | BUTTON_UP; + if ( porta & 0x20 ) + btn |= BUTTON_ON; + if ( porta & 0x800 ) + btn |= BUTTON_STOP | BUTTON_DOWN; + + return btn; +} + +#endif + + /* ----------------------------------------------------------------- * local variables: diff --git a/firmware/button.h b/firmware/button.h index a09c7a25dc..a8cc71b875 100644 --- a/firmware/button.h +++ b/firmware/button.h @@ -19,29 +19,36 @@ #include "config.h" -#ifdef HAVE_RECORDER_KEYPAD -/* - * Archos Jukebox Recorder button functions - */ +void button_init (void); +int button_get (void); -/* Button codes */ +/* Shared button codes */ #define BUTTON_NONE 0x0000 #define BUTTON_ON 0x0001 -#define BUTTON_OFF 0x0002 -#define BUTTON_PLAY 0x0004 #define BUTTON_UP 0x0010 #define BUTTON_DOWN 0x0020 #define BUTTON_LEFT 0x0040 #define BUTTON_RIGHT 0x0080 -#define BUTTON_F1 0x0100 -#define BUTTON_F2 0x0200 -#define BUTTON_F3 0x0400 /* Button modifiers */ #define BUTTON_HELD 0x4000 #define BUTTON_REL 0x8000 -void button_init (void); -int button_get (void); + +#ifdef HAVE_RECORDER_KEYPAD + +/* Recorder specific button codes */ +#define BUTTON_OFF 0x0002 +#define BUTTON_PLAY 0x0004 +#define BUTTON_F1 0x0100 +#define BUTTON_F2 0x0200 +#define BUTTON_F3 0x0400 + +#elif HAVE_PLAYER_KEYPAD + +/* Jukebox 6000 and Studio specific button codes */ +#define BUTTON_MENU 0x0002 +#define BUTTON_PLAY BUTTON_UP +#define BUTTON_STOP BUTTON_DOWN #endif