A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel Stenberg
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#ifndef _BUTTON_H_
22#define _BUTTON_H_
23
24#include <stdbool.h>
25#include <inttypes.h>
26#include "config.h"
27#if defined(CHECKWPS) || !defined(__PCTOOL__)
28#include "button-target.h"
29#endif
30
31#ifndef BUTTON_REMOTE
32# define BUTTON_REMOTE 0
33#endif
34
35void button_init_device(void);
36#ifdef HAVE_BUTTON_DATA
37int button_read_device(int *);
38#else
39int button_read_device(void);
40#endif
41
42#ifdef HAS_BUTTON_HOLD
43bool button_hold(void);
44#endif
45#ifdef HAS_REMOTE_BUTTON_HOLD
46bool remote_button_hold(void);
47#endif
48
49void button_init (void) INIT_ATTR;
50void button_close(void);
51
52int button_status(void);
53#ifdef HAVE_BUTTON_DATA
54int button_status_wdata(int *pdata);
55#endif
56
57void button_set_flip(bool flip); /* turn 180 degrees */
58#ifdef HAVE_BACKLIGHT
59void set_backlight_filter_keypress(bool value);
60#ifdef HAVE_REMOTE_LCD
61void set_remote_backlight_filter_keypress(bool value);
62#endif
63#endif
64
65/* button queue functions (in button_queue.c) */
66void button_queue_init(void);
67void button_queue_post(long id, intptr_t data);
68void button_queue_post_remove_head(long id, intptr_t data);
69bool button_queue_try_post(long button, int data);
70int button_queue_count(void);
71bool button_queue_empty(void);
72bool button_queue_full(void);
73void button_clear_queue(void);
74void button_clear_pressed(void);
75long button_get(bool block);
76long button_get_w_tmo(int ticks);
77intptr_t button_get_data(void);
78
79#ifdef HAVE_HEADPHONE_DETECTION
80bool headphones_inserted(void);
81#endif
82#ifdef HAVE_LINEOUT_DETECTION
83bool lineout_inserted(void);
84#endif
85#ifdef HAVE_WHEEL_POSITION
86int wheel_status(void);
87void wheel_send_events(bool send);
88#endif
89
90#ifdef HAVE_WHEEL_ACCELERATION
91int button_apply_acceleration(const unsigned int data);
92#endif
93
94#define BUTTON_NONE 0x00000000
95
96/* Button modifiers */
97#define BUTTON_REL 0x02000000
98#define BUTTON_REPEAT 0x04000000
99/* Special buttons */
100#define BUTTON_TOUCHSCREEN 0x08000000
101#define BUTTON_MULTIMEDIA 0x10000000
102#define BUTTON_REDRAW 0x20000000
103
104#define BUTTON_MULTIMEDIA_PLAYPAUSE (BUTTON_MULTIMEDIA|0x01)
105#define BUTTON_MULTIMEDIA_STOP (BUTTON_MULTIMEDIA|0x02)
106#define BUTTON_MULTIMEDIA_PREV (BUTTON_MULTIMEDIA|0x04)
107#define BUTTON_MULTIMEDIA_NEXT (BUTTON_MULTIMEDIA|0x08)
108#define BUTTON_MULTIMEDIA_REW (BUTTON_MULTIMEDIA|0x10)
109#define BUTTON_MULTIMEDIA_FFWD (BUTTON_MULTIMEDIA|0x20)
110
111#define BUTTON_MULTIMEDIA_ALL (BUTTON_MULTIMEDIA_PLAYPAUSE| \
112 BUTTON_MULTIMEDIA_STOP| \
113 BUTTON_MULTIMEDIA_PREV| \
114 BUTTON_MULTIMEDIA_NEXT| \
115 BUTTON_MULTIMEDIA_REW | \
116 BUTTON_MULTIMEDIA_FFWD)
117
118#ifdef HAVE_TOUCHSCREEN
119long touchscreen_last_touch(void);
120
121#if (!defined(BUTTON_TOPLEFT) || !defined(BUTTON_TOPMIDDLE) \
122 || !defined(BUTTON_TOPRIGHT) || !defined(BUTTON_MIDLEFT) \
123 || !defined(BUTTON_CENTER) || !defined(BUTTON_MIDRIGHT) \
124 || !defined(BUTTON_BOTTOMLEFT) || !defined(BUTTON_BOTTOMMIDDLE) \
125 || !defined(BUTTON_BOTTOMRIGHT)) && !defined(__PCTOOL__)
126#error Touchscreen button mode BUTTON_* defines not set up correctly
127#endif
128
129#include "touchscreen.h"
130#endif
131
132#ifdef HAVE_TOUCHPAD
133#include "touchpad.h"
134#endif
135
136#if (defined(HAVE_TOUCHPAD) || defined(HAVE_TOUCHSCREEN)) && !defined(HAS_BUTTON_HOLD)
137void button_enable_touch(bool en);
138#endif
139
140#ifdef HAVE_SW_POWEROFF
141void button_set_sw_poweroff_state(bool en);
142bool button_get_sw_poweroff_state(void);
143#endif
144
145#endif /* _BUTTON_H_ */