1
0
Fork 0
forked from len0rd/rockbox

Tatung Elio: a few more buttons identified

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23737 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Kukla 2009-11-24 15:42:54 +00:00
parent ed13fd6dca
commit 1511d75f9d
2 changed files with 30 additions and 65 deletions

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id$ * $Id$
* *
* Copyright (C) 2006 by Barry Wardell * Copyright (C) 2006 by Robert Kukla
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -22,34 +22,33 @@
#ifndef _BUTTON_TARGET_H_ #ifndef _BUTTON_TARGET_H_
#define _BUTTON_TARGET_H_ #define _BUTTON_TARGET_H_
#include <stdbool.h>
#include "config.h"
#define HAS_BUTTON_HOLD #define HAS_BUTTON_HOLD
#define button_init_device()
bool button_hold(void); bool button_hold(void);
void button_init_device(void);
int button_read_device(void); int button_read_device(void);
/* Tatung Elio TPJ-1022 button codes */
/* Main unit's buttons */ /* Main unit's buttons */
#define BUTTON_POWER 0x00000001
#define BUTTON_LEFT 0x00000002 #define BUTTON_VOL_DOWN 0x00000001
#define BUTTON_RIGHT 0x00000004
#define BUTTON_UP 0x00000008
#define BUTTON_DOWN 0x00000010
#define BUTTON_MENU 0x00000020 /* bit position in GPIOA */
#define BUTTON_FF 0x00000040 #define BUTTON_REW 0x00000002
#define BUTTON_REW 0x00000080 #define BUTTON_FF 0x00000004
#define BUTTON_REC 0x00000100 #define BUTTON_POWER 0x00000008
#define BUTTON_AB 0x00000200 #define BUTTON_UP 0x00000010
#define BUTTON_PLUS 0x00000400 #define BUTTON_DOWN 0x00000020
#define BUTTON_MINUS 0x00000800 #define BUTTON_AB 0x00000040
#define BUTTON_RIGHT 0x00000080
#define BUTTON_MAIN 0x00000fff /* still unknown */
#define BUTTON_MENU 0x00000100
#define BUTTON_REC 0x00000200
#define BUTTON_VOL_UP 0x00000400
#define BUTTON_LEFT 0x00000800
#define BUTTON_MAIN 0x00000FFF
/* No Remote control */ /* No Remote control */
#define BUTTON_REMOTE 0 #define BUTTON_REMOTE 0

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id$ * $Id$
* *
* Copyright (C) 2006 by Barry Wardell * Copyright (C) 2006 by Robert Kukla
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -19,64 +19,30 @@
* *
****************************************************************************/ ****************************************************************************/
/* Custom written for the TPJ-1022 based on analysis of the GPIO data */
#include <stdlib.h>
#include "config.h"
#include "cpu.h"
#include "system.h" #include "system.h"
#include "button.h" #include "button.h"
#include "kernel.h"
#include "backlight.h"
void button_init_device(void)
{
/* No hardware initialisation required as it is done by the bootloader */
}
bool button_hold(void) bool button_hold(void)
{ {
return false; return (GPIOK_INPUT_VAL & 0x40) ? true : false;
} }
/*
* Get button pressed from hardware
*/
int button_read_device(void) int button_read_device(void)
{ {
int btn = BUTTON_NONE; int btn = BUTTON_NONE;
unsigned char state;
static bool hold_button = false;
#if 0 if (!button_hold())
/* light handling */
if (hold_button && !button_hold())
{ {
backlight_on(); btn = (GPIOA_INPUT_VAL & 0xfe) ^ 0xfe;
}
#endif
hold_button = button_hold(); if ((GPIOK_INPUT_VAL & 0x20) == 0) btn |= BUTTON_VOL_DOWN;
if (!hold_button)
{
/* Read normal buttons */
state = GPIOA_INPUT_VAL;
if ((state & 0x2) == 0) btn |= BUTTON_REW;
if ((state & 0x4) == 0) btn |= BUTTON_FF;
if ((state & 0x80) == 0) btn |= BUTTON_RIGHT;
/* Buttons left to figure out: /* to be found
button_hold() if ((GPIO?_INPUT_VAL & 0x??) == 0) btn |= BUTTON_MENU;
BUTTON_POWER if ((GPIO?_INPUT_VAL & 0x??) == 0) btn |= BUTTON_REC;
BUTTON_LEFT if ((GPIO?_INPUT_VAL & 0x??) == 0) btn |= BUTTON_VOL_UP;
BUTTON_UP if ((GPIO?_INPUT_VAL & 0x??) == 0) btn |= BUTTON_LEFT;
BUTTON_DOWN */
BUTTON_MENU
BUTTON_REC
BUTTON_AB
BUTTON_PLUS
BUTTON_MINUS
*/
} }
return btn; return btn;