summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/sansa-fuze/button-fuze.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuze/button-fuze.c')
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/button-fuze.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c
new file mode 100644
index 0000000000..fc2715216c
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c
@@ -0,0 +1,98 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22/* Taken from button-h10.c by Barry Wardell and reverse engineering by MrH. */
23
24#include "system.h"
25#include "button.h"
26#include "backlight.h"
27#include "powermgmt.h"
28
29#define WHEEL_REPEAT_INTERVAL 300000
30#define WHEEL_FAST_ON_INTERVAL 20000
31#define WHEEL_FAST_OFF_INTERVAL 60000
32#define WHEELCLICKS_PER_ROTATION 48 /* wheelclicks per full rotation */
33
34/* Clickwheel */
35#ifndef BOOTLOADER
36static unsigned int old_wheel_value = 0;
37static unsigned int wheel_repeat = BUTTON_NONE;
38static unsigned int wheel_click_count = 0;
39static unsigned int wheel_delta = 0;
40static int wheel_fast_mode = 0;
41static unsigned long last_wheel_usec = 0;
42static unsigned long wheel_velocity = 0;
43static long last_wheel_post = 0;
44static long next_backlight_on = 0;
45/* Buttons */
46static bool hold_button = false;
47static bool hold_button_old = false;
48#define _button_hold() hold_button
49#else
50#define _button_hold() false /* FIXME */
51#endif /* BOOTLOADER */
52static int int_btn = BUTTON_NONE;
53
54void button_init_device(void)
55{
56}
57
58bool button_hold(void)
59{
60 return _button_hold();
61}
62
63/* clickwheel */
64#ifndef BOOTLOADER
65void clickwheel_int(void)
66{
67}
68#endif /* BOOTLOADER */
69
70/* device buttons */
71void button_int(void)
72{
73 unsigned char state;
74
75 int_btn = BUTTON_NONE;
76
77}
78
79/*
80 * Get button pressed from hardware
81 */
82int button_read_device(void)
83{
84#ifdef BOOTLOADER
85 /* Read buttons directly in the bootloader */
86 button_int();
87#else
88 /* light handling */
89 if (hold_button != hold_button_old)
90 {
91 hold_button_old = hold_button;
92 backlight_hold_changed(hold_button);
93 }
94#endif /* BOOTLOADER */
95
96 /* The int_btn variable is set in the button interrupt handler */
97 return int_btn;
98}