mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-18 17:42:36 -05:00
mr-500 button driver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14766 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6c9cbfb803
commit
376429dc9d
2 changed files with 72 additions and 73 deletions
|
|
@ -27,22 +27,11 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "backlight-target.h"
|
#include "backlight-target.h"
|
||||||
|
|
||||||
static int const remote_buttons[] =
|
#define BUTTON_TIMEOUT 50
|
||||||
{
|
|
||||||
BUTTON_NONE, /* Headphones connected - remote disconnected */
|
|
||||||
BUTTON_RC_PLAY,
|
|
||||||
BUTTON_RC_DSP,
|
|
||||||
BUTTON_RC_REW,
|
|
||||||
BUTTON_RC_FF,
|
|
||||||
BUTTON_RC_VOL_UP,
|
|
||||||
BUTTON_RC_VOL_DOWN,
|
|
||||||
BUTTON_NONE, /* Remote control attached - no buttons pressed */
|
|
||||||
BUTTON_NONE, /* Nothing in the headphone socket */
|
|
||||||
};
|
|
||||||
|
|
||||||
void button_init_device(void)
|
void button_init_device(void)
|
||||||
{
|
{
|
||||||
/* Power, Remote Play & Hold switch */
|
/* GIO is the power button, set as input */
|
||||||
|
outw(inw(IO_GIO_DIR0)|0x01, IO_GIO_DIR0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool button_hold(void)
|
inline bool button_hold(void)
|
||||||
|
|
@ -52,5 +41,51 @@ inline bool button_hold(void)
|
||||||
|
|
||||||
int button_read_device(void)
|
int button_read_device(void)
|
||||||
{
|
{
|
||||||
return 0;
|
char data[5], c;
|
||||||
|
int i = 0;
|
||||||
|
int btn = BUTTON_NONE, timeout = BUTTON_TIMEOUT;
|
||||||
|
|
||||||
|
if ((inw(IO_GIO_BITSET0)&0x01) == 0)
|
||||||
|
btn |= BUTTON_POWER;
|
||||||
|
|
||||||
|
uartHeartbeat();
|
||||||
|
while (timeout > 0)
|
||||||
|
{
|
||||||
|
c = uartPollch(BUTTON_TIMEOUT*100);
|
||||||
|
if (c > -1)
|
||||||
|
{
|
||||||
|
if (i && data[0] == 0xf4)
|
||||||
|
{
|
||||||
|
data[i++] = c;
|
||||||
|
}
|
||||||
|
else if (c == 0xf4)
|
||||||
|
{
|
||||||
|
data[0] = c;
|
||||||
|
i = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 5)
|
||||||
|
{
|
||||||
|
if (data[1]& (1<<7))
|
||||||
|
btn |= BUTTON_RC_HEART;
|
||||||
|
if (data[1]& (1<<6))
|
||||||
|
btn |= BUTTON_RC_MODE;
|
||||||
|
if (data[1]& (1<<5))
|
||||||
|
btn |= BUTTON_RC_VOL_DOWN;
|
||||||
|
if (data[1]& (1<<4))
|
||||||
|
btn |= BUTTON_RC_VOL_UP;
|
||||||
|
if (data[1]& (1<<3))
|
||||||
|
btn |= BUTTON_RC_REW;
|
||||||
|
if (data[1]& (1<<2))
|
||||||
|
btn |= BUTTON_RC_FF;
|
||||||
|
if (data[1]& (1<<1))
|
||||||
|
btn |= BUTTON_RC_DOWN;
|
||||||
|
if (data[1]& (1<<0))
|
||||||
|
btn |= BUTTON_RC_PLAY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
timeout--;
|
||||||
|
}
|
||||||
|
return btn;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: $
|
* $Id: $
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 by Karl Kurbjun
|
* Copyright (C) 2007 by Jonathan Gordon
|
||||||
*
|
*
|
||||||
* All files in this archive are subject to the GNU General Public License.
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
* See the file COPYING in the source tree root for full license agreement.
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
|
@ -29,71 +29,35 @@ bool button_hold(void);
|
||||||
void button_init_device(void);
|
void button_init_device(void);
|
||||||
int button_read_device(void);
|
int button_read_device(void);
|
||||||
|
|
||||||
/* Toshiba Gigabeat specific button codes */
|
/* m:robe 500 specific button codes */
|
||||||
|
|
||||||
#define BUTTON_POWER 0x00000001
|
#define BUTTON_POWER 0x00000001
|
||||||
#define BUTTON_MENU 0x00000002
|
|
||||||
|
|
||||||
#define BUTTON_LEFT 0x00000004
|
|
||||||
#define BUTTON_RIGHT 0x00000008
|
|
||||||
#define BUTTON_UP 0x00000010
|
|
||||||
#define BUTTON_DOWN 0x00000020
|
|
||||||
|
|
||||||
#define BUTTON_VOL_UP 0x00000040
|
|
||||||
#define BUTTON_VOL_DOWN 0x00000080
|
|
||||||
|
|
||||||
#define BUTTON_SELECT 0x00000100
|
|
||||||
#define BUTTON_A 0x00000200
|
|
||||||
|
|
||||||
/* Remote control buttons */
|
/* Remote control buttons */
|
||||||
|
|
||||||
#define BUTTON_RC_VOL_UP 0x00000400
|
#define BUTTON_RC_HEART 0x00000002
|
||||||
#define BUTTON_RC_VOL_DOWN 0x00000800
|
#define BUTTON_RC_MODE 0x00000004
|
||||||
#define BUTTON_RC_FF 0x00001000
|
#define BUTTON_RC_VOL_DOWN 0x00000008
|
||||||
#define BUTTON_RC_REW 0x00002000
|
#define BUTTON_RC_VOL_UP 0x00000010
|
||||||
|
|
||||||
#define BUTTON_RC_PLAY 0x00004000
|
|
||||||
#define BUTTON_RC_DSP 0x00008000
|
|
||||||
|
|
||||||
/* Toshiba Gigabeat specific remote button ADC values */
|
|
||||||
/* The remote control uses ADC 1 to emulate button pushes
|
|
||||||
Reading (approx) Button HP plugged in? Remote plugged in?
|
|
||||||
0 N/A Yes No
|
|
||||||
125 Play/Pause Cant tell Yes
|
|
||||||
241 Speaker+ Cant tell Yes
|
|
||||||
369 Rewind Cant tell Yes
|
|
||||||
492 Fast Fwd Cant tell Yes
|
|
||||||
616 Vol + Cant tell Yes
|
|
||||||
742 Vol - Cant tell Yes
|
|
||||||
864 None Cant tell Yes
|
|
||||||
1023 N/A No No
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Notes:
|
|
||||||
|
|
||||||
Buttons on the remote are translated into equivalent button presses just
|
|
||||||
as if you were pressing them on the Gigabeat itself.
|
|
||||||
|
|
||||||
We cannot tell if the hold is asserted on the remote. The Hold function on
|
|
||||||
the remote is to block the output of the buttons changing.
|
|
||||||
|
|
||||||
Only one button can be sensed at a time. If another is pressed, the button
|
|
||||||
with the lowest reading is dominant. So, if Rewind and Vol + are pressed
|
|
||||||
at the same time, Rewind value is the one that is read.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define BUTTON_RC_PLAY 0x00000020
|
||||||
|
#define BUTTON_RC_REW 0x00000040
|
||||||
|
#define BUTTON_RC_FF 0x00000080
|
||||||
|
#define BUTTON_RC_DOWN 0x00000100
|
||||||
|
#define BUTTON_TOUCH 0x00000200
|
||||||
|
|
||||||
#define BUTTON_MAIN (BUTTON_POWER|BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT\
|
/* compatibility hacks */
|
||||||
|BUTTON_UP|BUTTON_DOWN|BUTTON_VOL_UP|BUTTON_VOL_DOWN\
|
#define BUTTON_LEFT BUTTON_RC_REW
|
||||||
|BUTTON_SELECT|BUTTON_A)
|
#define BUTTON_RIGHT BUTTON_RC_FF
|
||||||
|
|
||||||
#define BUTTON_REMOTE (BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN|BUTTON_RC_FF\
|
|
||||||
|BUTTON_RC_REW|BUTTON_RC_PLAY|BUTTON_RC_DSP)
|
|
||||||
|
|
||||||
#define POWEROFF_BUTTON BUTTON_POWER
|
#define POWEROFF_BUTTON BUTTON_POWER
|
||||||
#define POWEROFF_COUNT 10
|
#define POWEROFF_COUNT 40
|
||||||
|
|
||||||
|
#define BUTTON_MAIN BUTTON_POWER
|
||||||
|
|
||||||
|
#define BUTTON_REMOTE (BUTTON_RC_HEART|BUTTON_RC_MODE| \
|
||||||
|
BUTTON_RC_VOL_DOWN|BUTTON_RC_VOL_UP| \
|
||||||
|
BUTTON_RC_PLAY|BUTTON_RC_DOWN| \
|
||||||
|
BUTTON_RC_REW|BUTTON_RC_FF)
|
||||||
|
|
||||||
#endif /* _BUTTON_TARGET_H_ */
|
#endif /* _BUTTON_TARGET_H_ */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue